|
1 | 1 | # Eliza In Forth
|
2 | 2 |
|
3 |
| -This version of the classic Lisp demonstration is a little less sophisticated than the original. A future version may allow programming the responses in Forth allowing for more interesting responses like "In what way is 'X' like 'Y'?" . These were part of the original Lisp version and make the chatbot seem more life-like. |
4 |
| - |
5 |
| -##Instructions |
6 |
| -the file ELIZADATA must be on your system on DSK2. |
7 |
| -To put convert the PC file to TI-99 you can use the TI-99 Edit program. |
8 |
| - |
9 |
| -1. Paste the file ELIZADATA.FTH into the Editor/Assembler Editor program. |
10 |
| -2. Save the file as DSK2.ELIZADATA |
11 |
| - |
12 |
| -##Overview |
13 |
| -This implementation creates simple string list syntax in Forth to help manage the replies. A simple string stack provides simple dynamic string creation but the program could have been written without it. |
14 |
| - |
15 |
| -By parsing the user text the program scans for keywords and key phrases. The matched text is converted into a Forth word by removing spaces and punctuation. Armed with a valid Forth word we simply pass it to EVALUATE to kick off Eliza's response. |
16 |
| - |
17 |
| -Lists of responses are created and then compiled as a Forth word with the word REPLY: <name> |
18 |
| - |
19 |
| -Using the list structure for keywords, phrases and conjugations coupled with directly executing Forth "REPLYs" makes modification quite simple. |
20 |
| - |
21 |
| -The file ELIZADATA.FTH contains the source code for the replies. They are separated from the program for ease of editing. |
| 3 | +This version of the classic Lisp demonstration in version 3 |
| 4 | +has been re-written to use the Forth colon definition rather |
| 5 | +than strings, as is commonly done in other languages. |
| 6 | +A small DSL (domain specific language) was created to allow |
| 7 | +the creation of key words and replies that was closer to the |
| 8 | +power of LISP. |
| 9 | + |
| 10 | +I was motivated to change the program after looking at the |
| 11 | +LISP version of Eliza where you can see LISP's powerful |
| 12 | +use of "code" as data. |
| 13 | + |
| 14 | +For example: |
| 15 | +``` |
| 16 | +(((?* ?x) dream about (?* ?y)) |
| 17 | + (How do you feel about ?y in reality?)) |
| 18 | +''' |
| 19 | +Here we see the ?y inserted into the reply text seamlessly. |
| 20 | +This creates a much more natural reply than simply appending |
| 21 | +the subject text to the end of a reply phrase. |
| 22 | +
|
| 23 | +The equivalent code in this DSL would be: |
| 24 | +``` |
| 25 | +KEY" DREAM ABOUT" |
| 26 | +{ :: CR ." How do you feel about " <rogerian> ." in reality?" ; |
| 27 | +} REPLY: DREAMABOUT |
| 28 | +``` |
| 29 | +
|
| 30 | +With a little effort this could be further simplfied. |
0 commit comments