home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / winlisp.zip / LISPLIB.LZH / DOCTOR.DL < prev    next >
Text File  |  1989-09-22  |  44KB  |  1,452 lines

  1. ;; Psychological help for frustrated users.
  2. (print "wait a few seconds. The doctor program is loading ...")
  3. (setq #:winlisp:colon 'doctor)
  4.  
  5. (synonym 'slength 'slen)
  6. (dmd chrnth (n s) `(sref ,s ,n))
  7. (synonym 'assq 'assoc)
  8. (de cassq (s l) (cdr (assq s l)))
  9.  
  10. (defun random-range (top)
  11.   ;;"Return a random nonnegative integer less than TOP."
  12.   (modulo (random) top)) 
  13.  
  14. (defun // (x) x)
  15.  
  16. (defmacro $ (what)
  17.   ;;"quoted arg form of :$"
  18.   `(:$ ',what))
  19. ;;;  (list ':$ (list 'quote what)))
  20.  
  21. (defun :$ (what)
  22.   ;;"Return the car of a list, rotating the list each time"
  23.   (let* ((vv (symeval what))
  24.      (first (car vv)))
  25.     (set what (nconc (cdr vv) (list first)))
  26.     first))
  27.  
  28. (defun make-doctor-variables ()
  29.   (setq typos
  30.     (mapcar (lambda (x)
  31.           (putprop (car x) (cadr x) ':correction)
  32.           (putprop (cadr x) (caddr x) ':expansion)
  33.           (car x))
  34.         '((theyll |they'll| (they will))
  35.           (theyre |they're| (they are))
  36.           (hes |he's| (he is))
  37.           (he7s |he's| (he is))
  38.           (im |i'm| (you are))
  39.           (i7m |i'm| (you are))
  40.           (isa |is a| (is a))
  41.           (thier their (their))
  42.           (dont |don't| (do not))
  43.           (don7t |don't| (do not))
  44.           (you7re |you're| (i am))
  45.           (you7ve |you've| (i have))
  46.           (you7ll |you'll| (i will)))))
  47.   (setq found nil)
  48.   (setq owner nil)
  49.   (setq history nil)
  50.   (setq *debug* nil)
  51.   (setq inter
  52.     '("well,"
  53.       "hmmm ... so,"
  54.       "so"
  55.       "...and"
  56.       "then"))
  57.   (setq continue
  58.     '("continue"
  59.       "proceed"
  60.       "go on"
  61.       "keep going" ))
  62.   (setq relation
  63.     '("your relationship with"
  64.       "something you remember about"
  65.       "your feelings toward"
  66.       "some experiences you have had with"
  67.       "how you feel about"))
  68.   (setq fears '( (($ whysay) "you are" ($ afraidof) (// feared) |?|)
  69.          ("you seem terrified by" (// feared) |.|)
  70.          ("when did you first feel" ($ afraidof) (// feared) |?|) ))
  71.   (setq sure '("sure" "positive" "certain" "absolutely sure"))
  72.   (setq afraidof '("afraid of" "frightened by" "scared of" ))
  73.   (setq areyou '("are you" "have you been" "have you been" ))
  74.   (setq isrelated '( "has something to do with" "is related to"
  75.              "could be the reason for" "is caused by" "is because of"))
  76.   (setq arerelated '("have something to do with" "are related to"
  77.              "could have caused" "could be the reason for" 
  78.              "are caused by" "are because of"))
  79.   (setq moods '( (($ areyou)(// found) often |?|)
  80.          ("what causes you to be" (// found) |?|)
  81.          (($ whysay) "you are" (// found) |?|) ))
  82.   (setq maybe
  83.     '("maybe"
  84.       "perhaps"
  85.       "possibly"))
  86.   (setq whatwhen
  87.     '("what happened when"
  88.       "what would happen if"))
  89.   (setq hello
  90.     '("how do you do?" "hello." "howdy!" "hello." "hi." "hi there."))
  91.   (setq drnk
  92.     '(("do you drink a lot of" (// found) |?|)
  93.       ("do you get drunk often?")
  94.       (($ describe) "your drinking habits.") ))
  95.   (setq drugs '( ("do you use" (// found) "often?")
  96.          (($ areyou) "addicted to" (// found) |?|)
  97.          ("do you realize that drugs can be very harmful?")
  98.          (($ maybe) "you should try to quit using" (// found) |.|)))
  99.   (setq whywant '( (($ whysay) (// subj) might ($ want) (// obj) |?|)
  100.            ("how does it feel to want?")
  101.            ("why should" (// subj) get (// obj) |?|)
  102.            ("when did" (// subj) first ($ want) (// obj) |?|)
  103.            (($ areyou) "obsessed with" (// obj) |?|)
  104.            ("why should i give" (// obj) to (// subj) |?|)
  105.            ("have you ever gotten" (// obj) |?|) ))
  106.   (setq canyou '(("of course i can.")
  107.          ("why should i?")
  108.          ("what makes you think i would even want to?")
  109.          ("i am the doctor, i can do anything i damn please.")
  110.          ("not really, it's not up to me.")
  111.          ("depends, how important is it?")
  112.          ("i could, but i don't think it would be a wise thing to do.")
  113.          ("can you?")
  114.          ("maybe i can, maybe i can't ...")
  115.          ("i don't think i should do that.")))
  116.   (setq want '("want" "desire" "wish" "want" "hope"))
  117.   (setq shortlst
  118.     '(("can you elaborate on that?")
  119.       (($ please) "continue.")
  120.       ("go on, don't be afraid.")
  121.       ("i need a little more detail please.")
  122.       ("you're being a bit brief," ($ please) "go into detail.")
  123.       ("can you be more explicit?")
  124.       ("and?")
  125.       (($ please) "go into more detail?")
  126.       ("you aren't being very talkative today!")
  127.       ("is that all there is to it?")
  128.       ("why must you respond so briefly?")))
  129.  
  130.   (setq famlst
  131.     '(("tell me" ($ something) about (// owner) "family.")
  132.       ("you seem to dwell on" (// owner) "family.")
  133.       (($ areyou) "hung up on" (// owner) "family?")))
  134.   (setq huhlst
  135.     '((($ whysay) |"| (// sent) |"| |?|)
  136.       ("is it because of" ($ things) "that you say" (// sent) |?|) ))
  137.   (setq longhuhlst
  138.     '((($ whysay) that |?|)
  139.       ("i don't understand.")
  140.       (($ thlst))
  141.       (($ areyou) ($ afraidof) "that?")))
  142.   (setq feelings-about
  143.     '("feelings about"
  144.       "aprehensions toward"
  145.       "thoughts on"
  146.       "emotions toward"))
  147.   (setq random-adjective
  148.     '("vivid"
  149.       "emotionally stimulating"
  150.       "exciting"
  151.       "boring"
  152.       "interesting"
  153.       "recent"
  154.       "random"            ;How can we omit this?
  155.       "unusual"
  156.       "shocking"
  157.       "embarrassing"))
  158.   (setq whysay
  159.     '("why do you say"
  160.       "what makes you believe"
  161.       "are you sure that"
  162.       "do you really think"
  163.       "what makes you think" ))
  164.   (setq isee
  165.     '(("i see ...")
  166.       ("yes,")
  167.       ("i understand.")
  168.       ("oh.") ))
  169.   (setq please 
  170.     '("please,"
  171.       "i would appreciate it if you would"
  172.       "perhaps you could"
  173.       "please,"
  174.       "would you please"
  175.       "why don't you"
  176.       "could you"))
  177.   (setq bye
  178.     '("my secretary will send you a bill."
  179.       "bye bye."
  180.       "see ya."
  181.       "ok, talk to you some other time."
  182.       "talk to you later."
  183.       "ok, have fun."
  184.       "ciao."))
  185.   (setq something
  186.     '("something"
  187.       "more"
  188.       "how you feel"))
  189.   (setq things 
  190.     '(                ;"your interests in computers"   ;; let's make this less computer oriented
  191.                     ;"the machines you use"
  192.       "your plans"
  193.                     ;"your use of computers"
  194.       "your life"
  195.                     ;"other machines you use"
  196.       "the people you hang around with"
  197.                     ;"computers you like"
  198.       "problems at school"
  199.       "any hobbies you have"
  200.                     ;"other computers you use"
  201.       "your sex life"
  202.       "hangups you have"
  203.       "your inhibitions"
  204.       "some problems in your childhood"
  205.                     ;"knowledge of computers"
  206.       "some problems at home"))
  207.   (setq describe
  208.     '("describe"
  209.       "tell me about"
  210.       "talk about"
  211.       "discuss"
  212.       "tell me more about"
  213.       "elaborate on"))
  214.   (setq ibelieve 
  215.     '("i believe" "i think" "i have a feeling" "it seems to me that"
  216.       "it looks like"))
  217.   (setq problems '( "problems"
  218.             "inhibitions"
  219.             "hangups"
  220.             "difficulties"
  221.             "anxieties"
  222.             "frustrations" ))
  223.   (setq bother
  224.     '("does it bother you that"
  225.       "are you annoyed that"
  226.       "did you ever regret"
  227.       "are you sorry"
  228.       "are you satisfied with the fact that"))
  229.   (setq machlst 
  230.     '(("you have your mind on" (// found) ",it seems.")
  231.       ("you think too much about"  (// found) ".")
  232.       ("you should try taking your mind off of" (// found) ".")
  233.       "are you a computer hacker?"))
  234.   (setq qlist
  235.     '("what do you think?"
  236.       "i'll ask the questions, if you don't mind!"
  237.       "i could ask the same thing myself."
  238.       (($ please) "allow me to do the questioning.")
  239.       "i have asked myself that question many times."
  240.       (($ please) "try to answer that question yourself.")))
  241.   (setq elist
  242.     '((($ please) "try to calm yourself.")
  243.       ("you seem very excited. relax." ($ please) ($ describe) ($ things)
  244.        |.|)
  245.       ("you're being very emotional. calm down.")))
  246.   (setq foullst
  247.     '((($ please) "watch your tongue!")
  248.       (($ please) "avoid such unwholesome thoughts.")
  249.       (($ please) "get your mind out of the gutter.")
  250.       "such lewdness is not appreciated."))
  251.   (setq deathlst
  252.     '("this is not a healthy way of thinking."
  253.       (($ bother) "you, too, may die someday?")
  254.       "i am worried by your obssession with this topic!"
  255.       "did you watch a lot of crime and violence on television as a child?")
  256.     )
  257.   (setq sexlst 
  258.     '((($ areyou) ($ afraidof) "sex?")
  259.       (($ describe)($ something) "about your sexual history.")
  260.       (($ please)($ describe) "your sex life...")
  261.       (($ describe) your ($ feelings-about) "your sexual partner.")
  262.       (($ describe) "your most" ($ random-adjective) "sexual experience.")
  263.       (($ areyou) "satisfied with" (// lover) "...?")))
  264.   (setq neglst
  265.     '("why not?"
  266.       (($ bother) "i ask that?")
  267.       "what makes you answer negatively?"
  268.       "could you tell me why you feel that the answer is no?"
  269.       "how come?"
  270.       (($ bother) "to explain more precisely why?")))
  271.   (setq beclst '(
  272.          ("is it because" (// sent) "that you came to me?")
  273.          (($ bother)(// sent) |?|)
  274.          ("when did you first know that" (// sent) |?|)
  275.          ("is the fact that" (// sent) "the real reason?")
  276.          ("does the fact< that" (// sent) "explain anything else?")
  277.          (($ areyou)($ sure)(// sent) |?| ) ))
  278.   (setq shortbeclst '(
  279.               (($ bother) "i ask you that?")
  280.               "that's not much of an answer!"
  281.               (($ inter) "why won't you talk about it?")
  282.               "speak up!"
  283.               (($ areyou) ($ afraidof) "talking about it?")
  284.               ("don't be" ($ afraidof) "elaborating.")
  285.               (($ please) "go into more detail.")))
  286.   (setq thlst '(
  287.         (($ maybe)($ things)($ arerelated) this |.|)
  288.         ("is it because of" ($ things) "that you are going through all this?")
  289.         ("how do you reconcile" ($ things) |?| )
  290.         (($ maybe) this ($ isrelated)($ things) |?|) ))
  291.   (setq remlst '( ("earlier you said" ($ history) |?|)
  292.           ("you mentioned that" ($ history) |?|)
  293.           (($ whysay)($ history) |?| ) ))
  294.   (setq toklst
  295.     '("is this how you relax?"
  296.       "how long have you been smoking grass?"
  297.       (($ areyou) ($ afraidof) "of being drawn to using harder stuff?")))
  298.   (setq states
  299.     '(("do you get" (// found) often |?|)
  300.       ("do you enjoy being" (// found) |?|)
  301.       ("what makes you" (// found) |?|)
  302.       ("how often" ($ areyou)(// found) |?|)
  303.       ("when were you last" (// found) |?|)))
  304.   (setq replist 
  305.     '((i . (you))
  306.       (my . (your))
  307.       (me . (you))
  308.       (you . (me))
  309.       (your . (my))
  310.       (mine . (yours))
  311.       (yours . (mine))
  312.       (our . (your))
  313.       (ours . (yours))
  314.       (we . (you))
  315.       (dunno . (do not know))
  316.       ;;      (yes . ())
  317.       (|no,| . ())
  318.       (|yes,| . ())
  319.       (ya . (i))
  320.       (aint . (am not))
  321.       (wanna . (want to))
  322.       (gimme . (give me))
  323.       (gotta . (have to))
  324.       (gonna . (going to))
  325.       (never . (not ever))
  326.       (|doesn't| . (does not))
  327.       (|don't| . (do not))
  328.       (|aren't| . (are not))
  329.       (|isn't| . (is not))
  330.       (|won't| . (will not))
  331.       (|can't| . (cannot))
  332.       (|haven't| . (have not))
  333.       (|i'm| . (you are))
  334.       (ourselves . (yourselves))
  335.       (myself . (yourself))
  336.       (yourself . (myself))
  337.       (|you're| . (i am))
  338.       (|you've| . (i have))
  339.       (|i've| . (you have))
  340.       (|i'll| . (you will))
  341.       (|you'll| . (i shall))
  342.       (|i'd| . (you would))
  343.       (|you'd| . (i would))
  344.       (here . (there))
  345.       (please . ())
  346.       (|eh,| . ())
  347.       (eh . ())
  348.       (|oh,| . ())
  349.       (oh . ())
  350.       (|shouldn't| . (should not))
  351.       (|wouldn't| . (would not))
  352.       (|won't| . (will not))
  353.       (|hasn't| . (has not))))
  354.   (setq schoollst '(
  355.             (($ describe) your (// found) |.|)
  356.             (($ bother) "your grades could" ($ improve) |?|)
  357.             (($ areyou) ($ afraidof) (// found) |?|)
  358.             (($ maybe) this ($ isrelated) "to your attitude.")
  359.             (($ areyou) "absent often?")
  360.             (($ maybe) "you should study" ($ something) |.|)))
  361.   (setq improve '((improve) (be better) (be improved) (be higher)))
  362.   (setq elizalst '(
  363.            (($ areyou) ($ sure) |?|)
  364.            (($ ibelieve) "you have" ($ problems) with (// found) |.|)
  365.            (($ whysay) (// sent) |?|)))
  366.   (setq sportslst '(
  367.             ("tell me" ($ something) about (// found) |.|)
  368.             (($ describe) ($ relation) (// found) |.|)
  369.             ("do you find" (// found) ($ random-adjective) |?|)))
  370.   (setq mathlst '(
  371.           (($ describe) ($ something) "about math.")
  372.           (($ maybe) your ($ problems) ($ arerelated) (// found) |.|)
  373.           ("i don't know much" (// found) ", but" ($ continue)
  374.            "anyway.")))
  375.   (setq zippylst '(
  376.            (($ areyou) Zippy |?|)
  377.            (($ ibelieve) "you have some serious" ($ problems) |.|)
  378.            (($ bother) "you are a pinhead?")))
  379.   (setq chatlst '(
  380.           (($ maybe) "we could chat.")
  381.           (($ please) ($ describe) ($ something) "about chat mode.")
  382.           (($ bother) "our discussion is so" ($ random-adjective) |?|)))
  383.   (setq abuselst '(
  384.            (($ please) "try to be less abusive.")
  385.            (($ describe) "why you call me" (// found) |.|)
  386.            "i've had enough of you!"))
  387.   (setq abusewords '(boring bozo clown clumsy cretin dumb dummy
  388.                 fool foolish gnerd gnurd idiot jerk
  389.                 lose loser louse lousy luse luser
  390.                 moron nerd nurd oaf oafish reek
  391.                 stink stupid tool toolish twit))
  392.   (setq howareyoulst  '((how are you) (hows it going) (hows it going eh)
  393.             (|how's| it going) (|how's| it going eh) (how goes it)
  394.             (whats up) (whats new) (|what's| up) (|what's| new)
  395.             (howre you) (|how're| you) (|how's| everything)
  396.             (how is everything) (how do you do)
  397.             (|how's| it hanging) (que pasa)
  398.             (how are you doing) (what do you say)))
  399.   (setq whereoutp '( huh remem rthing ) )
  400.   (setq subj nil)
  401.   (setq verb nil)
  402.   (setq obj nil)
  403.   (setq feared nil)
  404.   (setq observation-list nil)
  405.   (setq repetitive-shortness '(0 . 0))
  406.   (setq **mad** nil)
  407.   (setq eliza-flag nil)
  408.   (setq zippy-flag nil)
  409.   (setq lover '(your partner))
  410.   (setq bak nil)
  411.   (setq lincount 0)
  412.   (setq *print-upcase* nil)
  413.   (setq *print-space* nil)
  414.   (setq howdyflag nil)
  415.   (setq object nil))
  416.  
  417. ;; Define equivalence classes of words that get treated alike.
  418.  
  419. (defun :meaning (x) (get x ':meaning))
  420.  
  421. (defmacro :put-meaning (symb val)
  422.     "Store the base meaning of a word on the property list"
  423.     (list 'putprop (list 'quote symb) val '':meaning))
  424.  
  425. (:put-meaning howdy 'howdy)
  426. (:put-meaning hi 'howdy)
  427. (:put-meaning greetings 'howdy)
  428. (:put-meaning hello 'howdy)
  429. (:put-meaning tops20 'mach)
  430. (:put-meaning tops-20 'mach)
  431. (:put-meaning tops 'mach)
  432. (:put-meaning pdp11 'mach)
  433. (:put-meaning computer 'mach)
  434. (:put-meaning unix 'mach)
  435. (:put-meaning machine 'mach)
  436. (:put-meaning computers 'mach)
  437. (:put-meaning machines 'mach)
  438. (:put-meaning pdp11s 'mach)
  439. (:put-meaning foo 'mach)
  440. (:put-meaning foobar 'mach)
  441. (:put-meaning multics 'mach)
  442. (:put-meaning macsyma 'mach)
  443. (:put-meaning teletype 'mach)
  444. (:put-meaning la36 'mach)
  445. (:put-meaning vt52 'mach)
  446. (:put-meaning zork 'mach)
  447. (:put-meaning trek 'mach)
  448. (:put-meaning startrek 'mach)
  449. (:put-meaning advent 'mach)
  450. (:put-meaning pdp 'mach)
  451. (:put-meaning dec 'mach)
  452. (:put-meaning commodore 'mach)
  453. (:put-meaning vic 'mach)
  454. (:put-meaning bbs 'mach)
  455. (:put-meaning modem 'mach)
  456. (:put-meaning baud 'mach)
  457. (:put-meaning macintosh 'mach)
  458. (:put-meaning vax 'mach)
  459. (:put-meaning vms 'mach)
  460. (:put-meaning ibm 'mach)
  461. (:put-meaning pc 'mach)
  462. (:put-meaning bitching 'foul)
  463. (:put-meaning shit 'foul)
  464. (:put-meaning bastard 'foul)
  465. (:put-meaning damn 'foul)
  466. (:put-meaning damned 'foul)
  467. (:put-meaning hell 'foul)
  468. (:put-meaning suck 'foul)
  469. (:put-meaning sucking 'foul)
  470. (:put-meaning sux 'foul)
  471. (:put-meaning ass 'foul)
  472. (:put-meaning whore 'foul)
  473. (:put-meaning bitch 'foul)
  474. (:put-meaning asshole 'foul)
  475. (:put-meaning shrink 'foul)
  476. (:put-meaning pot 'toke)
  477. (:put-meaning grass 'toke)
  478. (:put-meaning weed 'toke)
  479. (:put-meaning marijuana 'toke)
  480. (:put-meaning acapulco 'toke)
  481. (:put-meaning columbian 'toke)
  482. (:put-meaning tokin 'toke)
  483. (:put-meaning joint 'toke)
  484. (:put-meaning toke 'toke)
  485. (:put-meaning toking 'toke)
  486. (:put-meaning |tokin'| 'toke)
  487. (:put-meaning toked 'toke)
  488. (:put-meaning roach 'toke)
  489. (:put-meaning pills 'drug)
  490. (:put-meaning dope 'drug)
  491. (:put-meaning acid 'drug)
  492. (:put-meaning lsd 'drug)
  493. (:put-meaning speed 'drug)
  494. (:put-meaning heroin 'drug)
  495. (:put-meaning hash 'drug)
  496. (:put-meaning cocaine 'drug)
  497. (:put-meaning uppers 'drug)
  498. (:put-meaning downers 'drug)
  499. (:put-meaning loves 'loves)
  500. (:put-meaning love 'love)
  501. (:put-meaning loved 'love)
  502. (:put-meaning hates 'hates)
  503. (:put-meaning dislikes 'hates)
  504. (:put-meaning hate 'hate)
  505. (:put-meaning hated 'hate)
  506. (:put-meaning dislike 'hate)
  507. (:put-meaning stoned 'state)
  508. (:put-meaning drunk 'state)
  509. (:put-meaning drunken 'state)
  510. (:put-meaning high 'state)
  511. (:put-meaning horny 'state)
  512. (:put-meaning blasted 'state)
  513. (:put-meaning happy 'state)
  514. (:put-meaning paranoid 'state)
  515. (:put-meaning wish 'desire)
  516. (:put-meaning wishes 'desire)
  517. (:put-meaning want 'desire)
  518. (:put-meaning desire 'desire)
  519. (:put-meaning like 'desire)
  520. (:put-meaning hope 'desire)
  521. (:put-meaning hopes 'desire)
  522. (:put-meaning desires 'desire)
  523. (:put-meaning wants 'desire)
  524. (:put-meaning desires 'desire)
  525. (:put-meaning likes 'desire)
  526. (:put-meaning needs 'desire)
  527. (:put-meaning need 'desire)
  528. (:put-meaning frustrated 'mood)
  529. (:put-meaning depressed 'mood)
  530. (:put-meaning annoyed 'mood)
  531. (:put-meaning upset 'mood)
  532. (:put-meaning unhappy 'mood)
  533. (:put-meaning excited 'mood)
  534. (:put-meaning worried 'mood)
  535. (:put-meaning lonely 'mood)
  536. (:put-meaning angry 'mood)
  537. (:put-meaning mad 'mood)
  538. (:put-meaning pissed 'mood)
  539. (:put-meaning jealous 'mood)
  540. (:put-meaning afraid 'fear)
  541. (:put-meaning terrified 'fear)
  542. (:put-meaning fear 'fear)
  543. (:put-meaning scared 'fear)
  544. (:put-meaning frightened 'fear)
  545. (:put-meaning virginity 'sexnoun)
  546. (:put-meaning virgins 'sexnoun)
  547. (:put-meaning virgin 'sexnoun)
  548. (:put-meaning cock 'sexnoun)
  549. (:put-meaning cocks 'sexnoun)
  550. (:put-meaning dick 'sexnoun)
  551. (:put-meaning dicks 'sexnoun)
  552. (:put-meaning cunt 'sexnoun)
  553. (:put-meaning cunts 'sexnoun)
  554. (:put-meaning prostitute 'sexnoun)
  555. (:put-meaning condom 'sexnoun)
  556. (:put-meaning sex 'sexnoun)
  557. (:put-meaning rapes 'sexnoun)
  558. (:put-meaning wife 'family)
  559. (:put-meaning family 'family)
  560. (:put-meaning brothers 'family)
  561. (:put-meaning sisters 'family)
  562. (:put-meaning parent 'family)
  563. (:put-meaning parents 'family)
  564. (:put-meaning brother 'family)
  565. (:put-meaning sister 'family)
  566. (:put-meaning father 'family)
  567. (:put-meaning mother 'family)
  568. (:put-meaning husband 'family)
  569. (:put-meaning siblings 'family)
  570. (:put-meaning grandmother 'family)
  571. (:put-meaning grandfather 'family)
  572. (:put-meaning maternal 'family)
  573. (:put-meaning paternal 'family)
  574. (:put-meaning stab 'death)
  575. (:put-meaning murder 'death)
  576. (:put-meaning murders 'death)
  577. (:put-meaning suicide 'death)
  578. (:put-meaning suicides 'death)
  579. (:put-meaning kill 'death)
  580. (:put-meaning kills 'death)
  581. (:put-meaning die 'death)
  582. (:put-meaning dies 'death)
  583. (:put-meaning died 'death)
  584. (:put-meaning dead 'death)
  585. (:put-meaning death 'death)
  586. (:put-meaning deaths 'death)
  587. (:put-meaning pain 'symptoms)
  588. (:put-meaning ache 'symptoms)
  589. (:put-meaning fever 'symptoms)
  590. (:put-meaning sore 'symptoms)
  591. (:put-meaning aching 'symptoms)
  592. (:put-meaning stomachache 'symptoms)
  593. (:put-meaning headache 'symptoms)
  594. (:put-meaning hurts 'symptoms)
  595. (:put-meaning disease 'symptoms)
  596. (:put-meaning virus 'symptoms)
  597. (:put-meaning vomit 'symptoms)
  598. (:put-meaning vomiting 'symptoms)
  599. (:put-meaning barf 'symptoms)
  600. (:put-meaning toothache 'symptoms)
  601. (:put-meaning hurt 'symptoms)
  602. (:put-meaning rum 'alcohol)
  603. (:put-meaning gin 'alcohol)
  604. (:put-meaning vodka 'alcohol)
  605. (:put-meaning alcohol 'alcohol)
  606. (:put-meaning bourbon 'alcohol)
  607. (:put-meaning beer 'alcohol)
  608. (:put-meaning wine 'alcohol)
  609. (:put-meaning whiskey 'alcohol)
  610. (:put-meaning scotch 'alcohol)
  611. (:put-meaning fuck 'sexverb)
  612. (:put-meaning fucked 'sexverb)
  613. (:put-meaning screw 'sexverb)
  614. (:put-meaning screwing 'sexverb)
  615. (:put-meaning fucking 'sexverb)
  616. (:put-meaning rape 'sexverb)
  617. (:put-meaning raped 'sexverb)
  618. (:put-meaning kiss 'sexverb)
  619. (:put-meaning kissing 'sexverb)
  620. (:put-meaning kisses 'sexverb)
  621. (:put-meaning screws 'sexverb)
  622. (:put-meaning fucks 'sexverb)
  623. (:put-meaning because 'conj)
  624. (:put-meaning but 'conj)
  625. (:put-meaning however 'conj)
  626. (:put-meaning besides 'conj)
  627. (:put-meaning anyway 'conj)
  628. (:put-meaning that 'conj)
  629. (:put-meaning except 'conj)
  630. (:put-meaning why 'conj)
  631. (:put-meaning how 'conj)
  632. (:put-meaning until 'when)
  633. (:put-meaning when 'when)
  634. (:put-meaning whenever 'when)
  635. (:put-meaning while 'when)
  636. (:put-meaning since 'when)
  637. (:put-meaning school 'school)
  638. (:put-meaning schools 'school)
  639. (:put-meaning skool 'school)
  640. (:put-meaning grade 'school)
  641. (:put-meaning grades 'school)
  642. (:put-meaning teacher 'school)
  643. (:put-meaning teachers 'school)
  644. (:put-meaning classes 'school)
  645. (:put-meaning professor 'school)
  646. (:put-meaning prof 'school)
  647. (:put-meaning profs 'school)
  648. (:put-meaning professors 'school)
  649. (:put-meaning mit 'school)
  650. (:put-meaning emacs 'eliza)
  651. (:put-meaning eliza 'eliza)
  652. (:put-meaning liza 'eliza)
  653. (:put-meaning elisa 'eliza)
  654. (:put-meaning weizenbaum 'eliza)
  655. (:put-meaning doktor 'eliza)
  656. (:put-meaning atheletics 'sports)
  657. (:put-meaning baseball 'sports)
  658. (:put-meaning basketball 'sports)
  659. (:put-meaning football 'sports)
  660. (:put-meaning frisbee 'sports)
  661. (:put-meaning gym 'sports)
  662. (:put-meaning gymnastics 'sports)
  663. (:put-meaning hockey 'sports)
  664. (:put-meaning lacrosse 'sports)
  665. (:put-meaning soccer 'sports)
  666. (:put-meaning softball 'sports)
  667. (:put-meaning sports 'sports)
  668. (:put-meaning swimming 'sports)
  669. (:put-meaning swim 'sports)
  670. (:put-meaning tennis 'sports)
  671. (:put-meaning volleyball 'sports)
  672. (:put-meaning math 'math)
  673. (:put-meaning mathematics 'math)
  674. (:put-meaning mathematical 'math)
  675. (:put-meaning theorem 'math)
  676. (:put-meaning axiom 'math)
  677. (:put-meaning lemma 'math)
  678. (:put-meaning algebra 'math)
  679. (:put-meaning algebraic 'math)
  680. (:put-meaning trig 'math)
  681. (:put-meaning trigonometry 'math)
  682. (:put-meaning trigonometric 'math)
  683. (:put-meaning geometry 'math)
  684. (:put-meaning geometric 'math)
  685. (:put-meaning calculus 'math)
  686. (:put-meaning arithmetic 'math)
  687. (:put-meaning zippy 'zippy)
  688. (:put-meaning zippy 'zippy)
  689. (:put-meaning pinhead 'zippy)
  690. (:put-meaning chat 'chat)
  691.  
  692. (defun doctor ()
  693.   (make-doctor-variables)
  694.   (:type '("i am the psychotherapist."
  695.        ($ please) ($ describe) "your" ($ problems) "."
  696.        "each time you are finished talking, type RET twice."))
  697.   (print)
  698.   (if (eq (peekcn) #\cr) (repeat 2 (readcn)))
  699.   (if (eq (peekcn) #\lf) (readcn))
  700.   (:read-print))
  701.  
  702. (defun :read-print ()
  703.   ;;"top level loop"
  704.   (untilexit doctor
  705.          (let ((sent (:readin)))
  706.            (print)
  707.            (setq lincount (1+ lincount))
  708.            (:doc sent)
  709.            (print)
  710.            (setq bak sent))))
  711.  
  712. (defun :readin ()
  713.   ;;"Read a sentence. Return it as a list of words"
  714.   (let (line-list line)
  715.     (while (not (equal (setq line (readstring)) ""))
  716.       (newr line-list (lowercase line)))
  717.     (mapcan ':string-to-symbol-list line-list)))
  718.  
  719. ;; Main processing function for sentences that have been read.
  720.  
  721. (defun :doc (sent)
  722.   (cond
  723.    ((equal sent '(foo))
  724.     (:type '(|bar!| ($ please)($ continue))))
  725.    ((member sent howareyoulst)
  726.     (:type '("i'm ok."  ($ describe) yourself |.|)))
  727.    ((or (member sent '((good bye) (see you later) (i quit) (so long)
  728.                (go away) (get lost) (see you)))
  729.     (memq (car sent)
  730.           '(bye halt break quit done exit goodbye 
  731.             stop pause stop pause)))
  732.     (:type ($ bye))
  733.     (exit doctor))
  734.    ((and (eq (car sent) 'you)
  735.      (memq (cadr sent) abusewords))
  736.     (setq found (cadr sent))
  737.     (:type ($ abuselst)))
  738.    ((eq (car sent) 'whatmeans)
  739.     (:def (cadr sent)))
  740.    ((equal sent '(parse))
  741.     (:type (list  "subj =" subj))
  742.     (:type (list  "verb =" verb))
  743.     (:type (list  "object phrase =" obj))
  744.     (:type (list  "noun form ="  object))
  745.     (:type (list  "current keyword is : " found))
  746.     (:type (list  "most recent possessive is : " owner))
  747.     (:type (list  "sentence used was..."))
  748.     (:type (list  '(// bak))))
  749.    (t
  750.     (if (:defq sent) (:define sent found))
  751.     (if (> (length sent) 12) (setq sent (:shorten sent)))
  752.     (setq sent (:correct-spelling (:replace sent replist)))
  753.     (cond ((and (not (memq 'me sent))(not (memq 'i sent))
  754.         (memq 'am sent))
  755.        (setq sent (:replace sent '((am . (are)))))))
  756.     (cond ((equal (car sent) 'yow) (:zippy))
  757.       ((< (length sent) 2)
  758.        (cond ((eq (:meaning (car sent)) 'howdy)
  759.           (:howdy))
  760.          (t (:short))))
  761.       (t
  762.        (if (memq 'am sent)
  763.            (setq sent (:replace sent '((me . (i))))))
  764.        (setq sent (:fixup sent))
  765.        (if (and (eq (car sent) 'do) (eq (cadr sent) 'not))
  766.            (cond ((= 0 (random-range 3))
  767.               (:type '("are you" ($ afraidof) "that?")))
  768.              ((= 0 (random-range 2))
  769.               (:type '("don't tell me what to do. i am the
  770.                         psychiatrist here!"))
  771.               (:rthing))
  772.              (t
  773.               (:type '(($ whysay) "that i shouldn't"
  774.                    (cddr sent)
  775.                    |?|))))
  776.          (:go (:wherego sent))))))))
  777.  
  778. ;; Things done to process sentences once read.
  779.  
  780. (defun :correct-spelling (sent)
  781.   ;;"correct the spelling and expand each word in sentence"
  782.   (if sent
  783.       (apply 'append 
  784.          (mapcar
  785.           '(lambda (word)
  786.          (if (memq word typos)
  787.              (get (get word ':correction) ':expansion)
  788.            (list word)))
  789.           sent))))
  790.  
  791. (defun :shorten (sent)
  792.   ;;"Make a sentence managably short using a few hacks"
  793.   (let (foo
  794.     (temp '(because but however besides anyway until
  795.             while that except why how)))
  796.     (while temp
  797.       (setq foo (memq (car temp) sent))
  798.       (if (and foo
  799.            (> (length foo) 3))
  800.       (setq sent foo
  801.         sent (:fixup sent)
  802.         temp nil)
  803.     (nextl temp)))
  804.     sent))
  805.  
  806. (defun :define (sent found)
  807.   (:svo sent found 1 nil) ;;returns subj, verb and object
  808.   (and
  809.    (:nounp subj)
  810.    (not (:pronounp subj))
  811.    subj
  812.    (:meaning object)
  813.    (putprop subj (:meaning object) ':meaning)
  814.    t))
  815.  
  816. (defun :defq (sent)
  817.   ;;"Set global var  found  to first keyword found in sentence SENT"
  818.   (setq found nil)
  819.   (let ((temp '(means applies mean refers refer related
  820.               similar defined associated linked like same)))
  821.     (while temp
  822.        (if (memq (car temp) sent)
  823.            (setq found (car temp)
  824.              temp nil)
  825.            (nextl temp))))
  826.   found)
  827.  
  828. (defun :def (x)
  829.   (progn
  830.    (:type (list 'the 'word x 'means (or (:meaning x) 'nothing) 'to 'me)) 
  831.    nil))
  832.  
  833. (defun :forget ()
  834.   ;;"Delete the last element of the history list"
  835.   (setq history (nreverse (cdr (nreverse history))))) ;****
  836.  
  837. (defun :query (x)
  838.         (prin (concat x " what?  "))
  839.     (let (a retval)
  840.       (while (not retval)
  841.         (setq a (:string-to-symbol-list (readstring)))
  842.         (while (and a (not retval))
  843.           (cond ((:nounp (car a))
  844.              (setq retval (car a)))
  845.             ((:verbp (car a))
  846.              (setq retval (:build
  847.                    (:build x " ")
  848.                    (car a))))
  849.             ((nextl a)))))
  850.       retval))
  851.  
  852. (defun :subjsearch (sent key type)
  853.   ;;"Search for the subject of a sentence SENT, looking for the noun closest to
  854.   ;; and preceding KEY by at least TYPE words. Set global variable subj to the
  855.   ;; subject noun, and return the portion of the sentence following it"
  856.   (let ((i (- (length sent) (length (memq key sent)) type)))
  857.     (while (and (> i -1) (not (:nounp (nth i sent))))
  858.       (decr i))
  859.     (cond ((> i -1)
  860.        (setq subj (nth i sent))
  861.        (nthcdr (1+ i) sent))
  862.       (t
  863.        (setq subj 'you)
  864.        nil))))
  865.  
  866. (defun :nounp (x)
  867.   ;;"Returns t if the symbol argument is a noun"
  868.     (or (:pronounp x)
  869.         (not (or (:verbp x)
  870.              (equal x 'not)
  871.              (:prepp x)
  872.              (:modifierp x) )) ))
  873.  
  874. (defun :pronounp (x)
  875.   ;;"Returns t if the symbol argument is a pronoun"
  876.   (memq x '(
  877.     i me mine myself
  878.     we us ours ourselves ourself
  879.     you yours yourself yourselves
  880.     he him himself she hers herself
  881.     it that those this these things thing
  882.     they them themselves theirs
  883.     anybody everybody somebody
  884.     anyone everyone someone
  885.     anything something everything)))
  886.  
  887. (mapcar (lambda (x) (putprop x 'verb ':sentence-type))
  888.     '(abort aborted aborts ask asked asks am
  889.         applied applies apply are associate
  890.         associated ate
  891.         be became become becomes becoming
  892.         been being believe belived believes
  893.         bit bite bites bore bored bores boring bought buy buys buying
  894.         call called calling calls came can caught catch come
  895.         contract contracted contracts control controlled controls
  896.         could croak croaks croaked cut cuts
  897.         dare dared define defines dial dialed dials did die died dies
  898.         dislike disliked
  899.         dislikes do does drank drink drinks drinking
  900.         drive drives driving drove dying
  901.         eat eating eats expand expanded expands
  902.         expect expected expects expel expels expeled expelled
  903.         explain explained explains
  904.         fart farts feel feels felt fight fights find finds finding
  905.         forget forgets forgot fought found fuck fucked
  906.         fucking fucks
  907.         gave get gets getting give gives go goes going gone got gotten
  908.         had harm harms has hate hated hates have having
  909.         hear heard hears hearing help helped helping helps
  910.         hit hits hope hoped hopes hurt hurts
  911.         implies imply is
  912.         join joined joins jump jumped jumps
  913.         keep keeping keeps kept
  914.         kill killed killing kills kiss kissed kisses kissing
  915.         knew know knows
  916.         laid lay lays let lets lie lied lies like liked likes
  917.         liking listen listens
  918.         login look looked looking looks
  919.         lose losing lost
  920.         love loved loves loving
  921.         luse lusing lust lusts
  922.         made make makes making may mean means meant might
  923.         move moved moves moving must
  924.         need needed needs 
  925.         order ordered orders ought
  926.         paid pay pays pick picked picking picks 
  927.         placed placing prefer prefers put puts
  928.         ran rape raped rapes
  929.         read reading reads recall receive received receives
  930.         refer refered referred refers
  931.         relate related relates remember remembered remembers
  932.         romp romped romps run running runs
  933.         said sang sat saw say says
  934.         screw screwed screwing screws scrod see sees seem seemed
  935.         seems seen sell selling sells
  936.         send sendind sends sent shall shoot shot should
  937.         sing sings sit sits sitting sold studied study
  938.         take takes taking talk talked talking talks tell tells telling
  939.         think thinks
  940.         thought told took tooled touch touched touches touching
  941.         transfer transfered transfers transmit transmits transmitted
  942.         type types types typing
  943.         walk walked walking walks want wanted wants was watch
  944.         watched watching went were will wish would work worked works
  945.         write writes writing wrote use used uses using))
  946.  
  947. (defun :verbp (x) (if (symbolp x)
  948.                 (eq (get x ':sentence-type) 'verb)))
  949.  
  950. (defun :plural (x)
  951.   ;;"form the plural of the word argument"
  952.   (let ((lg (slength x)))
  953.     (cond ((equal (chrnth (1- lg) x) #/s)
  954.        (cond ((equal (chrnth (- lg 2) x) #/s)
  955.           (concat x "es"))
  956.          (t x)))
  957.       ((equal (chrnth(1- lg) x) #/y)
  958.        (concat (substring x 0 (1- lg))) "ies"))
  959.     (t (concat x "s")))))
  960.  
  961. (defun :setprep (sent key)
  962.   (let ((val)
  963.     (foo (memq key sent)))
  964.     (cond ((:prepp (cadr foo))
  965.        (setq val (:getnoun (cddr foo)))
  966.        (cond (val val)
  967.          (t 'something)))
  968.       ((:articlep (cadr foo))
  969.        (setq val (:getnoun (cddr foo)))
  970.        (cond (val (:build (:build (cadr foo) " ") val))
  971.          (t 'something)))
  972.       (t 'something))))
  973.  
  974. (defun :getnoun (x)
  975.   (cond ((null x)(setq object 'something))
  976.     ((atom x)(setq object x))
  977.     ((eq (length x) 1)
  978.      (setq object (cond
  979.                ((:nounp (car x)) (car x))
  980.                (t (:query (car x))))))
  981.     ((eq (car x) 'to)
  982.      (:build "to "  (:getnoun (cdr x))))
  983.     ((:prepp (car x))
  984.      (:getnoun (cdr x)))
  985.     ((not (:nounp (car x)))
  986.      (:build (:build (or (cassq (car x)
  987.                     '((a . this)
  988.                       (some . this)
  989.                       (one . that)))
  990.                  (car x))
  991.              " ")
  992.          (:getnoun (cdr x))))
  993.     (t (setq object (car x))) ))
  994.  
  995. (defun :modifierp (x)
  996.   (or (:adjectivep x)
  997.       (:adverbp x)
  998.       (:othermodifierp x)))
  999.  
  1000. (defun :adjectivep (x)
  1001.   (or (numberp x)
  1002.       (:nmbrp x)
  1003.       (:articlep x)
  1004.       (:colorp x)
  1005.       (:sizep x)
  1006.       (:possessivepronounp x)))
  1007.  
  1008. (defun :adverbp (x)
  1009.   (and (> (slength x) 2)
  1010.        (equal (substring x (- (slength x) 2)) "ly")))
  1011.  
  1012. (defun :articlep (x)
  1013.   (memq x '(the a an)))
  1014.  
  1015. (defun :nmbrp (x)
  1016.   (memq x '(one two three four five six seven eight nine ten
  1017.         eleven twelve thirteen fourteen fifteen
  1018.         sixteen seventeen eighteen nineteen
  1019.         twenty thirty forty fifty sixty seventy eighty ninety
  1020.         hundred thousand million billion
  1021.         half quarter
  1022.         first second third fourth fifth
  1023.         sixth seventh eighth nineth tenth
  1024.         |1| |2| |3| |4| |5| |6| |7| |8| |9| |10| |20| |30|
  1025.         |40| |50| |100| |1000| |1,000,000| |1000000| )))
  1026.          
  1027. (defun :colorp (x)
  1028.   (memq x '(beige black blue brown crimson
  1029.           gray grey green
  1030.           orange pink purple red tan tawny
  1031.           violet white yellow)))
  1032.  
  1033. (defun :sizep (x)
  1034.   (memq x '(big large tall fat wide thick huge 
  1035.         small petite short thin skinny)))
  1036.  
  1037. (defun :possessivepronounp (x)
  1038.   (memq x '(my your his her our their)))
  1039.  
  1040. (defun :othermodifierp (x)
  1041.   (memq x '(all also always amusing any anyway associated awesome
  1042.         bad beautiful best better but certain clear
  1043.         ever every fantastic fun funny
  1044.         good great gross growdy however if ignorant
  1045.         less linked losing lusing many more much
  1046.         never nice obnoxious often poor pretty real related rich
  1047.         similar some stupid super superb
  1048.         terrible terrific too total tubular ugly very)))
  1049.  
  1050. (defun :prepp (x)
  1051.   (memq x '(about above after around as at
  1052.           before beneath behind beside between by
  1053.           for from in inside into
  1054.           like near next of on onto over
  1055.           same through thru to toward towards
  1056.           under underneath with without)))
  1057.  
  1058. (defun :remember (thing)
  1059.   (cond ((null history)
  1060.      (setq history (list thing)))
  1061.     (t (nconc history (list thing)))))
  1062.  
  1063. (defun :type (totype)
  1064.   (let* ((linear-symbol-list (:assm totype)))
  1065.     (:txtype (:fix-2 linear-symbol-list))))
  1066.  
  1067. (defun :fixup (sent)
  1068.   (setq sent (append
  1069.           (cdr (or 
  1070.             (assq (car sent)
  1071.               '((me  i) (him  he) (her  she) (them  they)
  1072.                 (okay) (well) (sigh) (hmm) (hmmm) (hmmmm)
  1073.                 (hmmmmm) (gee) (sure) (great) (oh) (fine)
  1074.                 (ok) (no)))
  1075.             (list t (car sent))))
  1076.           (cdr sent)))
  1077.   (:fix-2 sent))
  1078.  
  1079. (defun :fix-2 (sent)
  1080.   (let ((foo sent))
  1081.     (while foo
  1082.       (if (and (eq (car foo) 'me)
  1083.            (:verbp (cadr foo)))
  1084.       (rplaca foo 'i)
  1085.     (cond ((eq (car foo) 'you)
  1086.            (cond ((memq (cadr foo) '(am be been is))
  1087.               (rplaca (cdr foo) 'are))
  1088.              ((memq (cadr foo) '(has))
  1089.               (rplaca (cdr foo) 'have))
  1090.              ((memq (cadr foo) '(was))
  1091.               (rplaca (cdr foo) 'were))))
  1092.           ((equal (car foo) 'i)
  1093.            (cond ((memq (cadr foo) '(are is be been))
  1094.               (rplaca (cdr foo) 'am))
  1095.              ((memq (cadr foo) '(were))
  1096.               (rplaca (cdr foo) 'was))
  1097.              ((memq (cadr foo) '(has))
  1098.               (rplaca (cdr foo) 'have))))
  1099.           ((and (:verbp (car foo))
  1100.             (eq (cadr foo) 'i)
  1101.             (not (:verbp (car (cddr foo)))))
  1102.            (rplaca (cdr foo) 'me))
  1103.           ((and (eq (car foo) 'a)
  1104.             (:vowelp (chrnth 0 (cadr foo))))
  1105.            (rplaca foo 'an))
  1106.           ((and (eq (car foo) 'an)
  1107.             (not (:vowelp (chrnth 0 (cadr foo)))))
  1108.            (rplaca foo 'a)))
  1109.     (nextl foo)))
  1110.     sent))
  1111.  
  1112. (defun :vowelp (x)
  1113.   (memq x '(#/a #/e #/i #/o #/u)))
  1114.  
  1115. (defun :replace (sent rlist)
  1116.   ;;"Replaces any element of SENT that is the car of a replacement element
  1117.   ;; pair in RLIST"
  1118.   (apply 'append
  1119.      (mapcar
  1120.       (lambda (x)
  1121.         (or (cassq x rlist)        ; either find a replacement
  1122.         (list x)))        ; or fake an identity mapping
  1123.       sent)))
  1124.  
  1125. (defun :wherego (sent)
  1126.   (cond ((null sent)($ whereoutp))
  1127.     ((null (:meaning (car sent)))
  1128.      (:wherego (cond ((= 0 (random-range 2))
  1129.               (reverse (cdr sent)))
  1130.              (t (cdr sent)))))
  1131.     (t
  1132.      (setq found (car sent))
  1133.      (:meaning (car sent)))))
  1134.  
  1135. (defun :svo (sent key type mem)
  1136.   ;;"Find subject, verb and object in sentence SENT with focus on word KEY.
  1137.   ;; TYPE is number of words preceding KEY to start looking for subject. MEM is
  1138.   ;; t if results are to be put on doctor memory stack. Return is in global
  1139.   ;; variables subj, verb and object"
  1140.   (let ((foo (:subjsearch sent key type)))
  1141.     (or foo
  1142.     (setq foo sent
  1143.           mem nil))
  1144.     (while (and (null (:verbp (car foo))) (cdr foo))
  1145.       (nextl foo))
  1146.     (setq verb (car foo))
  1147.     (setq obj (:getnoun (cdr foo)))
  1148.     (cond ((eq object 'i)(setq object 'me))
  1149.       ((eq subj 'me)(setq subj 'i)))
  1150.     (when mem (:remember (list subj verb obj)))))
  1151.  
  1152. (defun :possess (sent key)
  1153.   ;;"Set possessive in SENT for keyword KEY. Hack on previous word, setting
  1154.   ;; global variable owner to possibly correct result"
  1155.   (let* ((i (- (length sent) (length (memq key sent)) 1))
  1156.      (prev (if (< i 0) 'your
  1157.          (nth i sent))))
  1158.     (setq owner (if (or (:possessivepronounp prev)
  1159.             (equal #/s
  1160.                    (chrnth (1- (slength prev)) prev)))
  1161.             prev
  1162.           'your))))
  1163.  
  1164. ;; Output of replies.
  1165.  
  1166. (defun :txtype (ans)
  1167.   ;;"Output to buffer a list of symbols or strings as a sentence"
  1168.   (setq *print-upcase* t *print-space* nil)
  1169.   (mapcar ':type-symbol ans)
  1170.   (print))
  1171.  
  1172. (de capitalize (string)
  1173.     (setq string (string string))
  1174.     (sset string 0 (uppercase (sref string 0)))
  1175.     (concat string))
  1176.  
  1177. (defun :type-symbol (word)
  1178.   ;;"Output a symbol to the buffer with some fancy case and spacing hacks"
  1179.   (if (equal word 'i) (setq word 'I))
  1180.   (if *print-upcase*
  1181.       (setq word (capitalize word)))
  1182.   (cond ((or (scanstring word ".,;:?! ")
  1183.          (null *print-space*))
  1184.      (prin word))
  1185.     (t (princn #\sp) (prin word)))
  1186.   (setq *print-upcase* (scanstring word ".?!")
  1187.     *print-space* t))
  1188.  
  1189. (defun :build (str1 str2)
  1190.   ;;"Make a symbol out of the concatenation of the two non-list arguments"
  1191.   (cond ((null str1) str2)
  1192.     ((null str2) str1)
  1193.     ((and (atom str1)
  1194.           (atom str2))
  1195.      (concat str1 str2))
  1196.     (t "")))
  1197.  
  1198. (defun :assm (proto)
  1199.   ;;"evaluate forms in proto, and returns a linear list of symbols"
  1200.   (:flatten (:tosymbol proto 1)))
  1201.  
  1202. (defun :tosymbol (proto level)
  1203.   (cond ((stringp proto)
  1204.      (:string-to-symbol-list proto))
  1205.     ((symbolp proto)
  1206.      (:string-to-symbol-list (string proto)))
  1207.     ((consp proto)
  1208.      (if (and (symbolp (car proto))
  1209.           (typefn (car proto))
  1210.           (= level 2)) 
  1211.          (:tosymbol (eval proto) 1)
  1212.        (list (:tosymbol (car proto) (1+ level)) 
  1213.          (:tosymbol (cdr proto) level))))
  1214.     (t proto))))
  1215.  
  1216. (defun :string-to-symbol-list (str)
  1217.   (when str
  1218.     (append (let ((idx (scanstring str ".,;:?! ")))
  1219.           (ifn idx
  1220.                (prog1
  1221.                (when (> (slen str) 0) (list (concat str)))
  1222.              (setq str ()))
  1223.                (prog1
  1224.                (if (= (sref str idx) #\sp)
  1225.                    (when (> idx 0)
  1226.                      (list (concat (substring str 0 idx))))
  1227.                  (list (when (> idx 0)
  1228.                      (concat (substring str 0 idx)))
  1229.                    (concat (substring 
  1230.                         str
  1231.                         idx 
  1232.                         (or (and (spanstring str "." idx)
  1233.                              (- (spanstring str "." idx) idx))
  1234.                         1)))))
  1235.              (setq str (if (> (slen str) (1+ idx))
  1236.                        (substring str (1+ idx))
  1237.                      ())))))
  1238.         (:string-to-symbol-list str))))
  1239.  
  1240. (defun :flatten (l)
  1241.   (if (consp l)
  1242.       (if (atomp (car l))
  1243.       (if (car l)
  1244.           (cons (car l) (:flatten (cdr l)))
  1245.           (:flatten (cdr l)))
  1246.       (append (:flatten (car l)) (:flatten (cdr l))))
  1247.       (when l (list l))))
  1248.  
  1249. ;; Functions that handle specific words or meanings when found.
  1250.  
  1251. (defun :go (destination)
  1252.   ;;"Call a #:doctor: function"
  1253.   (funcall (symbol 'doctor (string destination)))))
  1254.  
  1255. (defun :desire1 ()
  1256.   (:go ($ whereoutp)))
  1257.  
  1258. (defun :huh ()
  1259.   (cond ((< (length sent) 9) (:type ($ huhlst)))
  1260.     (t (:type ($ longhuhlst)))))
  1261.  
  1262. (defun :rthing () (:type ($ thlst)))
  1263.  
  1264. (defun :remem () (cond ((null history)(:huh))
  1265.                  ((:type ($ remlst)))))
  1266.  
  1267. (defun :howdy ()
  1268.   (cond ((not howdyflag)
  1269.      (:type '(($ hello) what brings you to see me |?|))
  1270.      (setq howdyflag t))
  1271.     (t
  1272.      (:type '(($ ibelieve) "we've introduced ourselves already."))
  1273.      (:type '(($ please) ($ describe) ($ things) |.|)))))
  1274.  
  1275. (defun :when ()
  1276.   (cond ((< (length (memq found sent)) 3)(:short))
  1277.     (t
  1278.      (setq sent (cdr (memq found sent)))
  1279.      (setq sent (:fixup sent))
  1280.      (:type '(($ whatwhen)(// sent) |?|)))))
  1281.  
  1282. (defun :conj ()
  1283.   (cond ((< (length (memq found sent)) 4)(:short))
  1284.     (t
  1285.      (setq sent (cdr (memq found sent)))
  1286.      (setq sent (:fixup sent))
  1287.      (cond ((eq (car sent) 'of)
  1288.         (:type '("are you" ($ sure) "that is the real reason?"))
  1289.         (setq things (cons (cdr sent) things)))
  1290.            (t
  1291.         (:remember sent)
  1292.         (:type ($ beclst)))))))
  1293.  
  1294. (defun :short ()
  1295.   (cond ((= (car repetitive-shortness) (1- lincount))
  1296.      (rplacd repetitive-shortness
  1297.          (1+ (cdr repetitive-shortness))))
  1298.     (t
  1299.      (rplacd repetitive-shortness 1)))
  1300.   (rplaca repetitive-shortness lincount)
  1301.   (cond ((> (cdr repetitive-shortness) 6)
  1302.      (cond ((not **mad**)
  1303.         (:type '(($ areyou)
  1304.              "just trying to see what kind of things"
  1305.              "i have in my vocabulary? please try to"
  1306.              "carry on a reasonable conversation!"))
  1307.         (setq **mad** t))
  1308.            (t
  1309.         (:type '("i give up. you need a lesson in creative writing..."))
  1310.         )))
  1311.     (t
  1312.      (cond ((equal sent '(yes))
  1313.         (:type '(($ isee) ($ inter) ($ whysay) "this is so?")))
  1314.            ((equal sent '(because))
  1315.         (:type ($ shortbeclst)))
  1316.            ((equal sent '(no))
  1317.         (:type ($ neglst)))
  1318.            (t (:type ($ shortlst)))))))
  1319.        
  1320. (defun :alcohol () (:type ($ drnk)))
  1321.  
  1322. (defun :desire ()
  1323.   (let ((foo (memq found sent)))
  1324.     (cond ((< (length foo) 2)
  1325.        (:go (concat (:meaning found) 1)))
  1326.       ((memq (cadr foo) '(a an))
  1327.        (rplacd foo (append '(to have) (cdr foo)))
  1328.        (:svo sent found 1 nil)
  1329.        (:remember (list subj 'would 'like obj))
  1330.        (:type ($ whywant)))
  1331.       ((not (eq (cadr foo) 'to))
  1332.        (:go (concat (:meaning found) 1)))
  1333.       (t
  1334.        (:svo sent found 1 nil)
  1335.        (:remember (list subj 'would 'like obj))
  1336.        (:type ($ whywant))))))
  1337.  
  1338. (defun :drug ()
  1339.   (:type ($ drugs))
  1340.   (:remember (list 'you 'used found)))
  1341.  
  1342. (defun :toke ()
  1343.   (:type ($ toklst)))
  1344.  
  1345. (defun :state ()
  1346.   (:type ($ states))(:remember (list 'you 'were found)))
  1347.  
  1348. (defun :mood ()
  1349.   (:type ($ moods))(:remember (list 'you 'felt found)))
  1350.  
  1351. (defun :fear ()
  1352.   (setq feared (:setprep sent found))
  1353.   (:type ($ fears))
  1354.   (:remember (list 'you 'were 'afraid 'of feared)))
  1355.  
  1356. (defun :hate ()
  1357.   (:svo sent found 1 t)
  1358.   (cond ((memq 'not sent) (:forget) (:huh))
  1359.     ((equal subj 'you)
  1360.      (:type '(why do you (// verb)(// obj) |?|)))
  1361.     (t (:type '(($ whysay)(list subj verb obj))))))
  1362.  
  1363. (defun :symptoms ()
  1364.   (:type '(($ maybe) "you should consult a doctor of medicine,
  1365.          i am a psychiatrist.")))
  1366.  
  1367. (defun :hates ()
  1368.   (:svo sent found 1 t)
  1369.   (:hates1))
  1370.  
  1371. (defun :hates1 ()
  1372.   (:type '(($ whysay) (list subj verb obj))))
  1373.  
  1374. (defun :loves ()
  1375.   (:svo sent found 1 t)
  1376.   (:qloves))
  1377.  
  1378. (defun :qloves ()
  1379.   (:type '(($ bother) (list subj verb obj) |?|)))
  1380.  
  1381. (defun :love ()
  1382.   (:svo sent found 1 t)
  1383.   (cond ((memq 'not sent) (:forget) (:huh))
  1384.     ((memq 'to sent) (:hates1))
  1385.     (t
  1386.      (cond ((equal object 'something)
  1387.         (setq object '(this person you love))))
  1388.      (cond ((equal subj 'you)
  1389.         (setq lover obj)
  1390.         (cond ((equal lover '(this person you love))
  1391.                (setq lover '(your partner))
  1392.                (:forget)
  1393.                (:type '("with whom are you in love?")))
  1394.               ((:type '(($ please)
  1395.                 ($ describe)
  1396.                 ($ relation)
  1397.                 (// lover)
  1398.                 |.|)))))
  1399.            ((equal subj 'i)
  1400.         (:txtype '("we were discussing you!")))
  1401.            (t (:forget)
  1402.           (setq obj 'someone)
  1403.           (setq verb (:build verb 's))
  1404.           (:qloves))))))
  1405.  
  1406. (defun :mach ()
  1407.   (setq found (:plural found))
  1408.   (:type ($ machlst)))
  1409.  
  1410. (defun :sexnoun () (:sexverb))
  1411.  
  1412. (defun :sexverb ()
  1413.   (if (or (memq 'me sent)(memq 'myself sent)(memq 'i sent))
  1414.       (:foul)
  1415.     (:type ($ sexlst))))
  1416.  
  1417. (defun :death () (:type ($ deathlst)))
  1418.  
  1419. (defun :foul ()
  1420.   (:type ($ foullst)))
  1421.  
  1422. (defun :family ()
  1423.   (:possess sent found)
  1424.   (:type ($ famlst)))
  1425.  
  1426. (defun :school () (:type ($ schoollst)))
  1427.  
  1428. (defun :eliza ()
  1429.   (cond (eliza-flag (:type ($ elizalst)))
  1430.     (t (setq eliza-flag t)
  1431.        (:type '((// found) "? hah!"
  1432.               ($ please) ($ continue) |.|)))))
  1433.        
  1434. (defun :sports ()  (:type ($ sportslst)))
  1435.  
  1436. (defun :math () (:type ($ mathlst)))
  1437.  
  1438. (defun :zippy ()
  1439.   (cond (zippy-flag (:type ($ zippylst)))
  1440.     (t (setq zippy-flag t)
  1441.        (:type '("yow! are we interactive yet?")))))
  1442.  
  1443.  
  1444. (defun :chat () (:type ($ chatlst)))
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.