HOW TO DISPLAY thing: FOR x IN thing: WRITE x/ HOW TO DISPLAY GRAMMAR g: FOR w IN keys g: WRITE w, ":" / FOR a IN g[w]: WRITE " " FOR e IN a: WRITE e, " " WRITE / HOW TO ELIZA: GREET LISTEN WHILE lower remark <> "bye": REPLY TO remark LISTEN WRITE "Thanks for talking to me. Bye." / GREET: WRITE "Hello, I'm Eliza. Tell me about yourself. " WRITE "(Type ""Bye"" to finish)" / LISTEN: WRITE "> " READ remark RAW HOW TO GENERATE thing FROM sentences: SELECT: thing in keys sentences: FOR word IN choice sentences[thing]: GENERATE word FROM sentences ELSE: WRITE thing, " " HOW TO INPUT grammar: PROMPT "Define: " FOR term WHILE term <> "": DEFINITION PROMPT "Define: " FOR term DEFINITION: PROMPT "Alternative: " FOR alt WHILE alt <> "": SAVE split alt IN grammar AT term PROMPT "Alternative: " FOR alt HOW TO PROMPT p FOR v: WRITE p READ v EG "" HOW TO REPLY TO remark: SHARE simple, keywords, answers, lesser, starters PUT split lower remark IN sentence SELECT: sentence in keys simple: WRITE choice simple[sentence] / SOME word IN sentence HAS word in keys keywords: WRITE choice keywords[word] / "?" in remark: WRITE choice answers / SOME word IN sentence HAS word in keys lesser: WRITE choice lesser[word] / ELSE: WRITE choice starters / HOW TO SAVE item IN table AT key: IF key not.in keys table: PUT {} IN table[key] INSERT item IN table[key] HOW TO SESSION patient: \patient = {} for self or a grammar SELECT: patient = {}: PUT "" IN r WHILE 1=1: PUT reply r IN r WRITE "> ", r/ PUT reply r IN r WRITE r/ ELSE: WHILE 1=1: PUT patient generated "<>" IN r WRITE "> ", r/ WRITE reply r/ HOW TO RETURN reply remark: SHARE simple, keywords, answers, lesser, starters PUT split lower remark IN sentence SELECT: sentence in keys simple: RETURN choice simple[sentence] SOME word IN sentence HAS word in keys keywords: RETURN choice keywords[word] "?" in remark: RETURN choice answers SOME word IN sentence HAS word in keys lesser: RETURN choice lesser[word] ELSE: RETURN choice starters HOW TO RETURN sentences generated thing: SELECT: thing in keys sentences: PUT "" IN result FOR word IN choice sentences[thing]: PUT result^" "^(sentences generated word) IN result RETURN stripped result ELSE: RETURN thing PUT {"Ask me another";"Do you really want to know?";"What a question!";"Why do you ask?";"You don't have to ask that!";"You know really."} IN answers PUT {["afraid"]:{"Tell me about fear"};["amsterdam"]:{"A lovely place I hear"};["boring"]:{"Boredom is only in the mind"; "Do I bore you?"};["boyfriend"]:{"Been together long?"; "How do you get on together?"};["cat"]:{"Cats are very cosy animals"; "Do you like animals"; "Tell me about pets"};["cats"]:{"Cats are very cosy animals"; "Do you like animals"; "Tell me about pets"};["computer"]:{"Let's change the subject."; "Oh computers! They're so stupid!"};["computers"]:{"Let's change the subject."; "Oh computers! They're so stupid!"};["family"]:{"Do you have any brothers and sisters?"; "Tell me about your father"; "Tell me about your mother"};["father"]:{"Are you like your father?"; "Tell me more about your family"};["fear"]:{"Tell me about fear"};["friend"]:{"Do you have many friends?"; "How do you get along with your friends?"};["friends"]:{"Do you have many friends?"; "How do you get along with your friends?"};["girlfriend"]:{"Been together long?"; "How do you get on together?"};["hate"]:{"Hate is a strong emotion"; "Is that fair?"};["husband"]:{"Been together long?"; "How do you get on together?"};["love"]:{"Have you ever been in love?"; "Love is a fine affair"};["mother"]:{"And your father?"; "Your mother?"};["nederlands"]:{"I don't speak Dutch, I'm afraid"; "Is that Dutch?"};["sex"]:{"I don't get involved myself"; "That sounds fun!"; "They tell me sex can be fun"};["stupid"]:{"Do you think stupidity is a good trait, or a bad one?"; "Some of my best friends are stupid."};["wife"]:{"Been together long?"; "How do you get on together?"}} IN keywords PUT {["don't"]:{"Not at all?";"Really not?";"Why not?"};["know"]:{"Knowledge is a useful resource"};["never"]:{"Never is putting it a bit strong, isn't it?";"Never?"};["no"]:{"Are you sure?";"Why not?"};["none"]:{"None at all?"};["not"]:{"Not at all?";"That sounds a bit negative";"Why not?"};["yes"]:{"Are you sure?";"You seem very sure of yourself"};["you"]:{"Let's not talk about me";"Let's talk about you";"Me?";"You don't mean it?"};["you're"]:{"Let's not talk about me";"Let's talk about you";"Me?";"You don't mean it?"}} IN lesser PUT {["<>"]:{{[1]:"";[2]:"";[3]:""}; {[1]:"";[2]:"";[3]:"";[4]:"with";[5]:""}; {[1]:"";[2]:"";[3]:""}; {[1]:"";[2]:"thinks";[3]:"I";[4]:"am";[5]:""}; {[1]:"I";[2]:"";[3]:""}; {[1]:"I";[2]:"";[3]:"";[4]:"with";[5]:""}; {[1]:"I";[2]:"";[3]:""}};[""]:{{[1]:"eating"}; {[1]:"going";[2]:"to";[3]:"the";[4]:"toilet"}; {[1]:"jogging"}; {[1]:"sex"}};[""]:{{[1]:""}; {[1]:"myself"}};[""]:{{[1]:""}; {[1]:"computers"}; {[1]:"everything"}; {[1]:"life"}; {[1]:"marriage"}; {[1]:"my";[2]:"body"}; {[1]:"my";[2]:"opinions"}; {[1]:"other";[2]:"people"}; {[1]:"people"}; {[1]:"sex"}};[""]:{{[1]:"adore"}; {[1]:"am";[2]:"jealous";[3]:"of"}; {[1]:"despise"}; {[1]:"dislike"}; {[1]:"hate"}; {[1]:"have";[2]:"no";[3]:"opinion";[4]:"about"}; {[1]:"like"}; {[1]:"love"}};[""]:{{[1]:"adores"}; {[1]:"despises"}; {[1]:"dislikes"}; {[1]:"has";[2]:"no";[3]:"opinion";[4]:"about"}; {[1]:"hates"}; {[1]:"is";[2]:"jealous";[3]:"of"}; {[1]:"likes"}; {[1]:"loves"}};[""]:{{[1]:"anybody"}; {[1]:"everybody"}; {[1]:"my";[2]:"brother"}; {[1]:"my";[2]:"father"}; {[1]:"my";[2]:"mother"}; {[1]:"my";[2]:"sister"}; {[1]:"the";[2]:"man";[3]:"next";[4]:"door"}};[""]:{{[1]:"clever"}; {[1]:"good-looking"}; {[1]:"paranoid"}; {[1]:"sexy"}; {[1]:"stupid"}; {[1]:"wise"}};[""]:{{[1]:""}; {[1]:"me"}}} IN paranoid PUT {[{}]:{"Do you want to change the subject?"; "Go on"; "I'm listening"; "Nothing to say?"};[{[1]:"no"}]:{"Couldn't you fill that answer out a bit?"; "Tell me more"};[{[1]:"yes"}]:{"Can't you be more specific?"; "Give me more details"; "That doesn't tell me much"}} IN simple PUT {"Are you married?"; "Do you enjoy life?"; "Do you enjoy this sort of interaction?"; "Do you have a sweetheart?"; "Let's talk about relationships"; "Tell me about your family"; "Tell me about your problems"; "Tell me about your relationships"; "Tell me more"; "What are your interests?"; "What do you think of computers?"; "What shall we talk about?"} IN starters