home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
windows
/
winlisp.zip
/
LISPLIB.LZH
/
DOCTOR.DL
< prev
next >
Wrap
Text File
|
1989-09-22
|
44KB
|
1,452 lines
;; Psychological help for frustrated users.
(print "wait a few seconds. The doctor program is loading ...")
(setq #:winlisp:colon 'doctor)
(synonym 'slength 'slen)
(dmd chrnth (n s) `(sref ,s ,n))
(synonym 'assq 'assoc)
(de cassq (s l) (cdr (assq s l)))
(defun random-range (top)
;;"Return a random nonnegative integer less than TOP."
(modulo (random) top))
(defun // (x) x)
(defmacro $ (what)
;;"quoted arg form of :$"
`(:$ ',what))
;;; (list ':$ (list 'quote what)))
(defun :$ (what)
;;"Return the car of a list, rotating the list each time"
(let* ((vv (symeval what))
(first (car vv)))
(set what (nconc (cdr vv) (list first)))
first))
(defun make-doctor-variables ()
(setq typos
(mapcar (lambda (x)
(putprop (car x) (cadr x) ':correction)
(putprop (cadr x) (caddr x) ':expansion)
(car x))
'((theyll |they'll| (they will))
(theyre |they're| (they are))
(hes |he's| (he is))
(he7s |he's| (he is))
(im |i'm| (you are))
(i7m |i'm| (you are))
(isa |is a| (is a))
(thier their (their))
(dont |don't| (do not))
(don7t |don't| (do not))
(you7re |you're| (i am))
(you7ve |you've| (i have))
(you7ll |you'll| (i will)))))
(setq found nil)
(setq owner nil)
(setq history nil)
(setq *debug* nil)
(setq inter
'("well,"
"hmmm ... so,"
"so"
"...and"
"then"))
(setq continue
'("continue"
"proceed"
"go on"
"keep going" ))
(setq relation
'("your relationship with"
"something you remember about"
"your feelings toward"
"some experiences you have had with"
"how you feel about"))
(setq fears '( (($ whysay) "you are" ($ afraidof) (// feared) |?|)
("you seem terrified by" (// feared) |.|)
("when did you first feel" ($ afraidof) (// feared) |?|) ))
(setq sure '("sure" "positive" "certain" "absolutely sure"))
(setq afraidof '("afraid of" "frightened by" "scared of" ))
(setq areyou '("are you" "have you been" "have you been" ))
(setq isrelated '( "has something to do with" "is related to"
"could be the reason for" "is caused by" "is because of"))
(setq arerelated '("have something to do with" "are related to"
"could have caused" "could be the reason for"
"are caused by" "are because of"))
(setq moods '( (($ areyou)(// found) often |?|)
("what causes you to be" (// found) |?|)
(($ whysay) "you are" (// found) |?|) ))
(setq maybe
'("maybe"
"perhaps"
"possibly"))
(setq whatwhen
'("what happened when"
"what would happen if"))
(setq hello
'("how do you do?" "hello." "howdy!" "hello." "hi." "hi there."))
(setq drnk
'(("do you drink a lot of" (// found) |?|)
("do you get drunk often?")
(($ describe) "your drinking habits.") ))
(setq drugs '( ("do you use" (// found) "often?")
(($ areyou) "addicted to" (// found) |?|)
("do you realize that drugs can be very harmful?")
(($ maybe) "you should try to quit using" (// found) |.|)))
(setq whywant '( (($ whysay) (// subj) might ($ want) (// obj) |?|)
("how does it feel to want?")
("why should" (// subj) get (// obj) |?|)
("when did" (// subj) first ($ want) (// obj) |?|)
(($ areyou) "obsessed with" (// obj) |?|)
("why should i give" (// obj) to (// subj) |?|)
("have you ever gotten" (// obj) |?|) ))
(setq canyou '(("of course i can.")
("why should i?")
("what makes you think i would even want to?")
("i am the doctor, i can do anything i damn please.")
("not really, it's not up to me.")
("depends, how important is it?")
("i could, but i don't think it would be a wise thing to do.")
("can you?")
("maybe i can, maybe i can't ...")
("i don't think i should do that.")))
(setq want '("want" "desire" "wish" "want" "hope"))
(setq shortlst
'(("can you elaborate on that?")
(($ please) "continue.")
("go on, don't be afraid.")
("i need a little more detail please.")
("you're being a bit brief," ($ please) "go into detail.")
("can you be more explicit?")
("and?")
(($ please) "go into more detail?")
("you aren't being very talkative today!")
("is that all there is to it?")
("why must you respond so briefly?")))
(setq famlst
'(("tell me" ($ something) about (// owner) "family.")
("you seem to dwell on" (// owner) "family.")
(($ areyou) "hung up on" (// owner) "family?")))
(setq huhlst
'((($ whysay) |"| (// sent) |"| |?|)
("is it because of" ($ things) "that you say" (// sent) |?|) ))
(setq longhuhlst
'((($ whysay) that |?|)
("i don't understand.")
(($ thlst))
(($ areyou) ($ afraidof) "that?")))
(setq feelings-about
'("feelings about"
"aprehensions toward"
"thoughts on"
"emotions toward"))
(setq random-adjective
'("vivid"
"emotionally stimulating"
"exciting"
"boring"
"interesting"
"recent"
"random" ;How can we omit this?
"unusual"
"shocking"
"embarrassing"))
(setq whysay
'("why do you say"
"what makes you believe"
"are you sure that"
"do you really think"
"what makes you think" ))
(setq isee
'(("i see ...")
("yes,")
("i understand.")
("oh.") ))
(setq please
'("please,"
"i would appreciate it if you would"
"perhaps you could"
"please,"
"would you please"
"why don't you"
"could you"))
(setq bye
'("my secretary will send you a bill."
"bye bye."
"see ya."
"ok, talk to you some other time."
"talk to you later."
"ok, have fun."
"ciao."))
(setq something
'("something"
"more"
"how you feel"))
(setq things
'( ;"your interests in computers" ;; let's make this less computer oriented
;"the machines you use"
"your plans"
;"your use of computers"
"your life"
;"other machines you use"
"the people you hang around with"
;"computers you like"
"problems at school"
"any hobbies you have"
;"other computers you use"
"your sex life"
"hangups you have"
"your inhibitions"
"some problems in your childhood"
;"knowledge of computers"
"some problems at home"))
(setq describe
'("describe"
"tell me about"
"talk about"
"discuss"
"tell me more about"
"elaborate on"))
(setq ibelieve
'("i believe" "i think" "i have a feeling" "it seems to me that"
"it looks like"))
(setq problems '( "problems"
"inhibitions"
"hangups"
"difficulties"
"anxieties"
"frustrations" ))
(setq bother
'("does it bother you that"
"are you annoyed that"
"did you ever regret"
"are you sorry"
"are you satisfied with the fact that"))
(setq machlst
'(("you have your mind on" (// found) ",it seems.")
("you think too much about" (// found) ".")
("you should try taking your mind off of" (// found) ".")
"are you a computer hacker?"))
(setq qlist
'("what do you think?"
"i'll ask the questions, if you don't mind!"
"i could ask the same thing myself."
(($ please) "allow me to do the questioning.")
"i have asked myself that question many times."
(($ please) "try to answer that question yourself.")))
(setq elist
'((($ please) "try to calm yourself.")
("you seem very excited. relax." ($ please) ($ describe) ($ things)
|.|)
("you're being very emotional. calm down.")))
(setq foullst
'((($ please) "watch your tongue!")
(($ please) "avoid such unwholesome thoughts.")
(($ please) "get your mind out of the gutter.")
"such lewdness is not appreciated."))
(setq deathlst
'("this is not a healthy way of thinking."
(($ bother) "you, too, may die someday?")
"i am worried by your obssession with this topic!"
"did you watch a lot of crime and violence on television as a child?")
)
(setq sexlst
'((($ areyou) ($ afraidof) "sex?")
(($ describe)($ something) "about your sexual history.")
(($ please)($ describe) "your sex life...")
(($ describe) your ($ feelings-about) "your sexual partner.")
(($ describe) "your most" ($ random-adjective) "sexual experience.")
(($ areyou) "satisfied with" (// lover) "...?")))
(setq neglst
'("why not?"
(($ bother) "i ask that?")
"what makes you answer negatively?"
"could you tell me why you feel that the answer is no?"
"how come?"
(($ bother) "to explain more precisely why?")))
(setq beclst '(
("is it because" (// sent) "that you came to me?")
(($ bother)(// sent) |?|)
("when did you first know that" (// sent) |?|)
("is the fact that" (// sent) "the real reason?")
("does the fact< that" (// sent) "explain anything else?")
(($ areyou)($ sure)(// sent) |?| ) ))
(setq shortbeclst '(
(($ bother) "i ask you that?")
"that's not much of an answer!"
(($ inter) "why won't you talk about it?")
"speak up!"
(($ areyou) ($ afraidof) "talking about it?")
("don't be" ($ afraidof) "elaborating.")
(($ please) "go into more detail.")))
(setq thlst '(
(($ maybe)($ things)($ arerelated) this |.|)
("is it because of" ($ things) "that you are going through all this?")
("how do you reconcile" ($ things) |?| )
(($ maybe) this ($ isrelated)($ things) |?|) ))
(setq remlst '( ("earlier you said" ($ history) |?|)
("you mentioned that" ($ history) |?|)
(($ whysay)($ history) |?| ) ))
(setq toklst
'("is this how you relax?"
"how long have you been smoking grass?"
(($ areyou) ($ afraidof) "of being drawn to using harder stuff?")))
(setq states
'(("do you get" (// found) often |?|)
("do you enjoy being" (// found) |?|)
("what makes you" (// found) |?|)
("how often" ($ areyou)(// found) |?|)
("when were you last" (// found) |?|)))
(setq replist
'((i . (you))
(my . (your))
(me . (you))
(you . (me))
(your . (my))
(mine . (yours))
(yours . (mine))
(our . (your))
(ours . (yours))
(we . (you))
(dunno . (do not know))
;; (yes . ())
(|no,| . ())
(|yes,| . ())
(ya . (i))
(aint . (am not))
(wanna . (want to))
(gimme . (give me))
(gotta . (have to))
(gonna . (going to))
(never . (not ever))
(|doesn't| . (does not))
(|don't| . (do not))
(|aren't| . (are not))
(|isn't| . (is not))
(|won't| . (will not))
(|can't| . (cannot))
(|haven't| . (have not))
(|i'm| . (you are))
(ourselves . (yourselves))
(myself . (yourself))
(yourself . (myself))
(|you're| . (i am))
(|you've| . (i have))
(|i've| . (you have))
(|i'll| . (you will))
(|you'll| . (i shall))
(|i'd| . (you would))
(|you'd| . (i would))
(here . (there))
(please . ())
(|eh,| . ())
(eh . ())
(|oh,| . ())
(oh . ())
(|shouldn't| . (should not))
(|wouldn't| . (would not))
(|won't| . (will not))
(|hasn't| . (has not))))
(setq schoollst '(
(($ describe) your (// found) |.|)
(($ bother) "your grades could" ($ improve) |?|)
(($ areyou) ($ afraidof) (// found) |?|)
(($ maybe) this ($ isrelated) "to your attitude.")
(($ areyou) "absent often?")
(($ maybe) "you should study" ($ something) |.|)))
(setq improve '((improve) (be better) (be improved) (be higher)))
(setq elizalst '(
(($ areyou) ($ sure) |?|)
(($ ibelieve) "you have" ($ problems) with (// found) |.|)
(($ whysay) (// sent) |?|)))
(setq sportslst '(
("tell me" ($ something) about (// found) |.|)
(($ describe) ($ relation) (// found) |.|)
("do you find" (// found) ($ random-adjective) |?|)))
(setq mathlst '(
(($ describe) ($ something) "about math.")
(($ maybe) your ($ problems) ($ arerelated) (// found) |.|)
("i don't know much" (// found) ", but" ($ continue)
"anyway.")))
(setq zippylst '(
(($ areyou) Zippy |?|)
(($ ibelieve) "you have some serious" ($ problems) |.|)
(($ bother) "you are a pinhead?")))
(setq chatlst '(
(($ maybe) "we could chat.")
(($ please) ($ describe) ($ something) "about chat mode.")
(($ bother) "our discussion is so" ($ random-adjective) |?|)))
(setq abuselst '(
(($ please) "try to be less abusive.")
(($ describe) "why you call me" (// found) |.|)
"i've had enough of you!"))
(setq abusewords '(boring bozo clown clumsy cretin dumb dummy
fool foolish gnerd gnurd idiot jerk
lose loser louse lousy luse luser
moron nerd nurd oaf oafish reek
stink stupid tool toolish twit))
(setq howareyoulst '((how are you) (hows it going) (hows it going eh)
(|how's| it going) (|how's| it going eh) (how goes it)
(whats up) (whats new) (|what's| up) (|what's| new)
(howre you) (|how're| you) (|how's| everything)
(how is everything) (how do you do)
(|how's| it hanging) (que pasa)
(how are you doing) (what do you say)))
(setq whereoutp '( huh remem rthing ) )
(setq subj nil)
(setq verb nil)
(setq obj nil)
(setq feared nil)
(setq observation-list nil)
(setq repetitive-shortness '(0 . 0))
(setq **mad** nil)
(setq eliza-flag nil)
(setq zippy-flag nil)
(setq lover '(your partner))
(setq bak nil)
(setq lincount 0)
(setq *print-upcase* nil)
(setq *print-space* nil)
(setq howdyflag nil)
(setq object nil))
;; Define equivalence classes of words that get treated alike.
(defun :meaning (x) (get x ':meaning))
(defmacro :put-meaning (symb val)
"Store the base meaning of a word on the property list"
(list 'putprop (list 'quote symb) val '':meaning))
(:put-meaning howdy 'howdy)
(:put-meaning hi 'howdy)
(:put-meaning greetings 'howdy)
(:put-meaning hello 'howdy)
(:put-meaning tops20 'mach)
(:put-meaning tops-20 'mach)
(:put-meaning tops 'mach)
(:put-meaning pdp11 'mach)
(:put-meaning computer 'mach)
(:put-meaning unix 'mach)
(:put-meaning machine 'mach)
(:put-meaning computers 'mach)
(:put-meaning machines 'mach)
(:put-meaning pdp11s 'mach)
(:put-meaning foo 'mach)
(:put-meaning foobar 'mach)
(:put-meaning multics 'mach)
(:put-meaning macsyma 'mach)
(:put-meaning teletype 'mach)
(:put-meaning la36 'mach)
(:put-meaning vt52 'mach)
(:put-meaning zork 'mach)
(:put-meaning trek 'mach)
(:put-meaning startrek 'mach)
(:put-meaning advent 'mach)
(:put-meaning pdp 'mach)
(:put-meaning dec 'mach)
(:put-meaning commodore 'mach)
(:put-meaning vic 'mach)
(:put-meaning bbs 'mach)
(:put-meaning modem 'mach)
(:put-meaning baud 'mach)
(:put-meaning macintosh 'mach)
(:put-meaning vax 'mach)
(:put-meaning vms 'mach)
(:put-meaning ibm 'mach)
(:put-meaning pc 'mach)
(:put-meaning bitching 'foul)
(:put-meaning shit 'foul)
(:put-meaning bastard 'foul)
(:put-meaning damn 'foul)
(:put-meaning damned 'foul)
(:put-meaning hell 'foul)
(:put-meaning suck 'foul)
(:put-meaning sucking 'foul)
(:put-meaning sux 'foul)
(:put-meaning ass 'foul)
(:put-meaning whore 'foul)
(:put-meaning bitch 'foul)
(:put-meaning asshole 'foul)
(:put-meaning shrink 'foul)
(:put-meaning pot 'toke)
(:put-meaning grass 'toke)
(:put-meaning weed 'toke)
(:put-meaning marijuana 'toke)
(:put-meaning acapulco 'toke)
(:put-meaning columbian 'toke)
(:put-meaning tokin 'toke)
(:put-meaning joint 'toke)
(:put-meaning toke 'toke)
(:put-meaning toking 'toke)
(:put-meaning |tokin'| 'toke)
(:put-meaning toked 'toke)
(:put-meaning roach 'toke)
(:put-meaning pills 'drug)
(:put-meaning dope 'drug)
(:put-meaning acid 'drug)
(:put-meaning lsd 'drug)
(:put-meaning speed 'drug)
(:put-meaning heroin 'drug)
(:put-meaning hash 'drug)
(:put-meaning cocaine 'drug)
(:put-meaning uppers 'drug)
(:put-meaning downers 'drug)
(:put-meaning loves 'loves)
(:put-meaning love 'love)
(:put-meaning loved 'love)
(:put-meaning hates 'hates)
(:put-meaning dislikes 'hates)
(:put-meaning hate 'hate)
(:put-meaning hated 'hate)
(:put-meaning dislike 'hate)
(:put-meaning stoned 'state)
(:put-meaning drunk 'state)
(:put-meaning drunken 'state)
(:put-meaning high 'state)
(:put-meaning horny 'state)
(:put-meaning blasted 'state)
(:put-meaning happy 'state)
(:put-meaning paranoid 'state)
(:put-meaning wish 'desire)
(:put-meaning wishes 'desire)
(:put-meaning want 'desire)
(:put-meaning desire 'desire)
(:put-meaning like 'desire)
(:put-meaning hope 'desire)
(:put-meaning hopes 'desire)
(:put-meaning desires 'desire)
(:put-meaning wants 'desire)
(:put-meaning desires 'desire)
(:put-meaning likes 'desire)
(:put-meaning needs 'desire)
(:put-meaning need 'desire)
(:put-meaning frustrated 'mood)
(:put-meaning depressed 'mood)
(:put-meaning annoyed 'mood)
(:put-meaning upset 'mood)
(:put-meaning unhappy 'mood)
(:put-meaning excited 'mood)
(:put-meaning worried 'mood)
(:put-meaning lonely 'mood)
(:put-meaning angry 'mood)
(:put-meaning mad 'mood)
(:put-meaning pissed 'mood)
(:put-meaning jealous 'mood)
(:put-meaning afraid 'fear)
(:put-meaning terrified 'fear)
(:put-meaning fear 'fear)
(:put-meaning scared 'fear)
(:put-meaning frightened 'fear)
(:put-meaning virginity 'sexnoun)
(:put-meaning virgins 'sexnoun)
(:put-meaning virgin 'sexnoun)
(:put-meaning cock 'sexnoun)
(:put-meaning cocks 'sexnoun)
(:put-meaning dick 'sexnoun)
(:put-meaning dicks 'sexnoun)
(:put-meaning cunt 'sexnoun)
(:put-meaning cunts 'sexnoun)
(:put-meaning prostitute 'sexnoun)
(:put-meaning condom 'sexnoun)
(:put-meaning sex 'sexnoun)
(:put-meaning rapes 'sexnoun)
(:put-meaning wife 'family)
(:put-meaning family 'family)
(:put-meaning brothers 'family)
(:put-meaning sisters 'family)
(:put-meaning parent 'family)
(:put-meaning parents 'family)
(:put-meaning brother 'family)
(:put-meaning sister 'family)
(:put-meaning father 'family)
(:put-meaning mother 'family)
(:put-meaning husband 'family)
(:put-meaning siblings 'family)
(:put-meaning grandmother 'family)
(:put-meaning grandfather 'family)
(:put-meaning maternal 'family)
(:put-meaning paternal 'family)
(:put-meaning stab 'death)
(:put-meaning murder 'death)
(:put-meaning murders 'death)
(:put-meaning suicide 'death)
(:put-meaning suicides 'death)
(:put-meaning kill 'death)
(:put-meaning kills 'death)
(:put-meaning die 'death)
(:put-meaning dies 'death)
(:put-meaning died 'death)
(:put-meaning dead 'death)
(:put-meaning death 'death)
(:put-meaning deaths 'death)
(:put-meaning pain 'symptoms)
(:put-meaning ache 'symptoms)
(:put-meaning fever 'symptoms)
(:put-meaning sore 'symptoms)
(:put-meaning aching 'symptoms)
(:put-meaning stomachache 'symptoms)
(:put-meaning headache 'symptoms)
(:put-meaning hurts 'symptoms)
(:put-meaning disease 'symptoms)
(:put-meaning virus 'symptoms)
(:put-meaning vomit 'symptoms)
(:put-meaning vomiting 'symptoms)
(:put-meaning barf 'symptoms)
(:put-meaning toothache 'symptoms)
(:put-meaning hurt 'symptoms)
(:put-meaning rum 'alcohol)
(:put-meaning gin 'alcohol)
(:put-meaning vodka 'alcohol)
(:put-meaning alcohol 'alcohol)
(:put-meaning bourbon 'alcohol)
(:put-meaning beer 'alcohol)
(:put-meaning wine 'alcohol)
(:put-meaning whiskey 'alcohol)
(:put-meaning scotch 'alcohol)
(:put-meaning fuck 'sexverb)
(:put-meaning fucked 'sexverb)
(:put-meaning screw 'sexverb)
(:put-meaning screwing 'sexverb)
(:put-meaning fucking 'sexverb)
(:put-meaning rape 'sexverb)
(:put-meaning raped 'sexverb)
(:put-meaning kiss 'sexverb)
(:put-meaning kissing 'sexverb)
(:put-meaning kisses 'sexverb)
(:put-meaning screws 'sexverb)
(:put-meaning fucks 'sexverb)
(:put-meaning because 'conj)
(:put-meaning but 'conj)
(:put-meaning however 'conj)
(:put-meaning besides 'conj)
(:put-meaning anyway 'conj)
(:put-meaning that 'conj)
(:put-meaning except 'conj)
(:put-meaning why 'conj)
(:put-meaning how 'conj)
(:put-meaning until 'when)
(:put-meaning when 'when)
(:put-meaning whenever 'when)
(:put-meaning while 'when)
(:put-meaning since 'when)
(:put-meaning school 'school)
(:put-meaning schools 'school)
(:put-meaning skool 'school)
(:put-meaning grade 'school)
(:put-meaning grades 'school)
(:put-meaning teacher 'school)
(:put-meaning teachers 'school)
(:put-meaning classes 'school)
(:put-meaning professor 'school)
(:put-meaning prof 'school)
(:put-meaning profs 'school)
(:put-meaning professors 'school)
(:put-meaning mit 'school)
(:put-meaning emacs 'eliza)
(:put-meaning eliza 'eliza)
(:put-meaning liza 'eliza)
(:put-meaning elisa 'eliza)
(:put-meaning weizenbaum 'eliza)
(:put-meaning doktor 'eliza)
(:put-meaning atheletics 'sports)
(:put-meaning baseball 'sports)
(:put-meaning basketball 'sports)
(:put-meaning football 'sports)
(:put-meaning frisbee 'sports)
(:put-meaning gym 'sports)
(:put-meaning gymnastics 'sports)
(:put-meaning hockey 'sports)
(:put-meaning lacrosse 'sports)
(:put-meaning soccer 'sports)
(:put-meaning softball 'sports)
(:put-meaning sports 'sports)
(:put-meaning swimming 'sports)
(:put-meaning swim 'sports)
(:put-meaning tennis 'sports)
(:put-meaning volleyball 'sports)
(:put-meaning math 'math)
(:put-meaning mathematics 'math)
(:put-meaning mathematical 'math)
(:put-meaning theorem 'math)
(:put-meaning axiom 'math)
(:put-meaning lemma 'math)
(:put-meaning algebra 'math)
(:put-meaning algebraic 'math)
(:put-meaning trig 'math)
(:put-meaning trigonometry 'math)
(:put-meaning trigonometric 'math)
(:put-meaning geometry 'math)
(:put-meaning geometric 'math)
(:put-meaning calculus 'math)
(:put-meaning arithmetic 'math)
(:put-meaning zippy 'zippy)
(:put-meaning zippy 'zippy)
(:put-meaning pinhead 'zippy)
(:put-meaning chat 'chat)
(defun doctor ()
(make-doctor-variables)
(:type '("i am the psychotherapist."
($ please) ($ describe) "your" ($ problems) "."
"each time you are finished talking, type RET twice."))
(print)
(if (eq (peekcn) #\cr) (repeat 2 (readcn)))
(if (eq (peekcn) #\lf) (readcn))
(:read-print))
(defun :read-print ()
;;"top level loop"
(untilexit doctor
(let ((sent (:readin)))
(print)
(setq lincount (1+ lincount))
(:doc sent)
(print)
(setq bak sent))))
(defun :readin ()
;;"Read a sentence. Return it as a list of words"
(let (line-list line)
(while (not (equal (setq line (readstring)) ""))
(newr line-list (lowercase line)))
(mapcan ':string-to-symbol-list line-list)))
;; Main processing function for sentences that have been read.
(defun :doc (sent)
(cond
((equal sent '(foo))
(:type '(|bar!| ($ please)($ continue))))
((member sent howareyoulst)
(:type '("i'm ok." ($ describe) yourself |.|)))
((or (member sent '((good bye) (see you later) (i quit) (so long)
(go away) (get lost) (see you)))
(memq (car sent)
'(bye halt break quit done exit goodbye
stop pause stop pause)))
(:type ($ bye))
(exit doctor))
((and (eq (car sent) 'you)
(memq (cadr sent) abusewords))
(setq found (cadr sent))
(:type ($ abuselst)))
((eq (car sent) 'whatmeans)
(:def (cadr sent)))
((equal sent '(parse))
(:type (list "subj =" subj))
(:type (list "verb =" verb))
(:type (list "object phrase =" obj))
(:type (list "noun form =" object))
(:type (list "current keyword is : " found))
(:type (list "most recent possessive is : " owner))
(:type (list "sentence used was..."))
(:type (list '(// bak))))
(t
(if (:defq sent) (:define sent found))
(if (> (length sent) 12) (setq sent (:shorten sent)))
(setq sent (:correct-spelling (:replace sent replist)))
(cond ((and (not (memq 'me sent))(not (memq 'i sent))
(memq 'am sent))
(setq sent (:replace sent '((am . (are)))))))
(cond ((equal (car sent) 'yow) (:zippy))
((< (length sent) 2)
(cond ((eq (:meaning (car sent)) 'howdy)
(:howdy))
(t (:short))))
(t
(if (memq 'am sent)
(setq sent (:replace sent '((me . (i))))))
(setq sent (:fixup sent))
(if (and (eq (car sent) 'do) (eq (cadr sent) 'not))
(cond ((= 0 (random-range 3))
(:type '("are you" ($ afraidof) "that?")))
((= 0 (random-range 2))
(:type '("don't tell me what to do. i am the
psychiatrist here!"))
(:rthing))
(t
(:type '(($ whysay) "that i shouldn't"
(cddr sent)
|?|))))
(:go (:wherego sent))))))))
;; Things done to process sentences once read.
(defun :correct-spelling (sent)
;;"correct the spelling and expand each word in sentence"
(if sent
(apply 'append
(mapcar
'(lambda (word)
(if (memq word typos)
(get (get word ':correction) ':expansion)
(list word)))
sent))))
(defun :shorten (sent)
;;"Make a sentence managably short using a few hacks"
(let (foo
(temp '(because but however besides anyway until
while that except why how)))
(while temp
(setq foo (memq (car temp) sent))
(if (and foo
(> (length foo) 3))
(setq sent foo
sent (:fixup sent)
temp nil)
(nextl temp)))
sent))
(defun :define (sent found)
(:svo sent found 1 nil) ;;returns subj, verb and object
(and
(:nounp subj)
(not (:pronounp subj))
subj
(:meaning object)
(putprop subj (:meaning object) ':meaning)
t))
(defun :defq (sent)
;;"Set global var found to first keyword found in sentence SENT"
(setq found nil)
(let ((temp '(means applies mean refers refer related
similar defined associated linked like same)))
(while temp
(if (memq (car temp) sent)
(setq found (car temp)
temp nil)
(nextl temp))))
found)
(defun :def (x)
(progn
(:type (list 'the 'word x 'means (or (:meaning x) 'nothing) 'to 'me))
nil))
(defun :forget ()
;;"Delete the last element of the history list"
(setq history (nreverse (cdr (nreverse history))))) ;****
(defun :query (x)
(prin (concat x " what? "))
(let (a retval)
(while (not retval)
(setq a (:string-to-symbol-list (readstring)))
(while (and a (not retval))
(cond ((:nounp (car a))
(setq retval (car a)))
((:verbp (car a))
(setq retval (:build
(:build x " ")
(car a))))
((nextl a)))))
retval))
(defun :subjsearch (sent key type)
;;"Search for the subject of a sentence SENT, looking for the noun closest to
;; and preceding KEY by at least TYPE words. Set global variable subj to the
;; subject noun, and return the portion of the sentence following it"
(let ((i (- (length sent) (length (memq key sent)) type)))
(while (and (> i -1) (not (:nounp (nth i sent))))
(decr i))
(cond ((> i -1)
(setq subj (nth i sent))
(nthcdr (1+ i) sent))
(t
(setq subj 'you)
nil))))
(defun :nounp (x)
;;"Returns t if the symbol argument is a noun"
(or (:pronounp x)
(not (or (:verbp x)
(equal x 'not)
(:prepp x)
(:modifierp x) )) ))
(defun :pronounp (x)
;;"Returns t if the symbol argument is a pronoun"
(memq x '(
i me mine myself
we us ours ourselves ourself
you yours yourself yourselves
he him himself she hers herself
it that those this these things thing
they them themselves theirs
anybody everybody somebody
anyone everyone someone
anything something everything)))
(mapcar (lambda (x) (putprop x 'verb ':sentence-type))
'(abort aborted aborts ask asked asks am
applied applies apply are associate
associated ate
be became become becomes becoming
been being believe belived believes
bit bite bites bore bored bores boring bought buy buys buying
call called calling calls came can caught catch come
contract contracted contracts control controlled controls
could croak croaks croaked cut cuts
dare dared define defines dial dialed dials did die died dies
dislike disliked
dislikes do does drank drink drinks drinking
drive drives driving drove dying
eat eating eats expand expanded expands
expect expected expects expel expels expeled expelled
explain explained explains
fart farts feel feels felt fight fights find finds finding
forget forgets forgot fought found fuck fucked
fucking fucks
gave get gets getting give gives go goes going gone got gotten
had harm harms has hate hated hates have having
hear heard hears hearing help helped helping helps
hit hits hope hoped hopes hurt hurts
implies imply is
join joined joins jump jumped jumps
keep keeping keeps kept
kill killed killing kills kiss kissed kisses kissing
knew know knows
laid lay lays let lets lie lied lies like liked likes
liking listen listens
login look looked looking looks
lose losing lost
love loved loves loving
luse lusing lust lusts
made make makes making may mean means meant might
move moved moves moving must
need needed needs
order ordered orders ought
paid pay pays pick picked picking picks
placed placing prefer prefers put puts
ran rape raped rapes
read reading reads recall receive received receives
refer refered referred refers
relate related relates remember remembered remembers
romp romped romps run running runs
said sang sat saw say says
screw screwed screwing screws scrod see sees seem seemed
seems seen sell selling sells
send sendind sends sent shall shoot shot should
sing sings sit sits sitting sold studied study
take takes taking talk talked talking talks tell tells telling
think thinks
thought told took tooled touch touched touches touching
transfer transfered transfers transmit transmits transmitted
type types types typing
walk walked walking walks want wanted wants was watch
watched watching went were will wish would work worked works
write writes writing wrote use used uses using))
(defun :verbp (x) (if (symbolp x)
(eq (get x ':sentence-type) 'verb)))
(defun :plural (x)
;;"form the plural of the word argument"
(let ((lg (slength x)))
(cond ((equal (chrnth (1- lg) x) #/s)
(cond ((equal (chrnth (- lg 2) x) #/s)
(concat x "es"))
(t x)))
((equal (chrnth(1- lg) x) #/y)
(concat (substring x 0 (1- lg))) "ies"))
(t (concat x "s")))))
(defun :setprep (sent key)
(let ((val)
(foo (memq key sent)))
(cond ((:prepp (cadr foo))
(setq val (:getnoun (cddr foo)))
(cond (val val)
(t 'something)))
((:articlep (cadr foo))
(setq val (:getnoun (cddr foo)))
(cond (val (:build (:build (cadr foo) " ") val))
(t 'something)))
(t 'something))))
(defun :getnoun (x)
(cond ((null x)(setq object 'something))
((atom x)(setq object x))
((eq (length x) 1)
(setq object (cond
((:nounp (car x)) (car x))
(t (:query (car x))))))
((eq (car x) 'to)
(:build "to " (:getnoun (cdr x))))
((:prepp (car x))
(:getnoun (cdr x)))
((not (:nounp (car x)))
(:build (:build (or (cassq (car x)
'((a . this)
(some . this)
(one . that)))
(car x))
" ")
(:getnoun (cdr x))))
(t (setq object (car x))) ))
(defun :modifierp (x)
(or (:adjectivep x)
(:adverbp x)
(:othermodifierp x)))
(defun :adjectivep (x)
(or (numberp x)
(:nmbrp x)
(:articlep x)
(:colorp x)
(:sizep x)
(:possessivepronounp x)))
(defun :adverbp (x)
(and (> (slength x) 2)
(equal (substring x (- (slength x) 2)) "ly")))
(defun :articlep (x)
(memq x '(the a an)))
(defun :nmbrp (x)
(memq x '(one two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen
sixteen seventeen eighteen nineteen
twenty thirty forty fifty sixty seventy eighty ninety
hundred thousand million billion
half quarter
first second third fourth fifth
sixth seventh eighth nineth tenth
|1| |2| |3| |4| |5| |6| |7| |8| |9| |10| |20| |30|
|40| |50| |100| |1000| |1,000,000| |1000000| )))
(defun :colorp (x)
(memq x '(beige black blue brown crimson
gray grey green
orange pink purple red tan tawny
violet white yellow)))
(defun :sizep (x)
(memq x '(big large tall fat wide thick huge
small petite short thin skinny)))
(defun :possessivepronounp (x)
(memq x '(my your his her our their)))
(defun :othermodifierp (x)
(memq x '(all also always amusing any anyway associated awesome
bad beautiful best better but certain clear
ever every fantastic fun funny
good great gross growdy however if ignorant
less linked losing lusing many more much
never nice obnoxious often poor pretty real related rich
similar some stupid super superb
terrible terrific too total tubular ugly very)))
(defun :prepp (x)
(memq x '(about above after around as at
before beneath behind beside between by
for from in inside into
like near next of on onto over
same through thru to toward towards
under underneath with without)))
(defun :remember (thing)
(cond ((null history)
(setq history (list thing)))
(t (nconc history (list thing)))))
(defun :type (totype)
(let* ((linear-symbol-list (:assm totype)))
(:txtype (:fix-2 linear-symbol-list))))
(defun :fixup (sent)
(setq sent (append
(cdr (or
(assq (car sent)
'((me i) (him he) (her she) (them they)
(okay) (well) (sigh) (hmm) (hmmm) (hmmmm)
(hmmmmm) (gee) (sure) (great) (oh) (fine)
(ok) (no)))
(list t (car sent))))
(cdr sent)))
(:fix-2 sent))
(defun :fix-2 (sent)
(let ((foo sent))
(while foo
(if (and (eq (car foo) 'me)
(:verbp (cadr foo)))
(rplaca foo 'i)
(cond ((eq (car foo) 'you)
(cond ((memq (cadr foo) '(am be been is))
(rplaca (cdr foo) 'are))
((memq (cadr foo) '(has))
(rplaca (cdr foo) 'have))
((memq (cadr foo) '(was))
(rplaca (cdr foo) 'were))))
((equal (car foo) 'i)
(cond ((memq (cadr foo) '(are is be been))
(rplaca (cdr foo) 'am))
((memq (cadr foo) '(were))
(rplaca (cdr foo) 'was))
((memq (cadr foo) '(has))
(rplaca (cdr foo) 'have))))
((and (:verbp (car foo))
(eq (cadr foo) 'i)
(not (:verbp (car (cddr foo)))))
(rplaca (cdr foo) 'me))
((and (eq (car foo) 'a)
(:vowelp (chrnth 0 (cadr foo))))
(rplaca foo 'an))
((and (eq (car foo) 'an)
(not (:vowelp (chrnth 0 (cadr foo)))))
(rplaca foo 'a)))
(nextl foo)))
sent))
(defun :vowelp (x)
(memq x '(#/a #/e #/i #/o #/u)))
(defun :replace (sent rlist)
;;"Replaces any element of SENT that is the car of a replacement element
;; pair in RLIST"
(apply 'append
(mapcar
(lambda (x)
(or (cassq x rlist) ; either find a replacement
(list x))) ; or fake an identity mapping
sent)))
(defun :wherego (sent)
(cond ((null sent)($ whereoutp))
((null (:meaning (car sent)))
(:wherego (cond ((= 0 (random-range 2))
(reverse (cdr sent)))
(t (cdr sent)))))
(t
(setq found (car sent))
(:meaning (car sent)))))
(defun :svo (sent key type mem)
;;"Find subject, verb and object in sentence SENT with focus on word KEY.
;; TYPE is number of words preceding KEY to start looking for subject. MEM is
;; t if results are to be put on doctor memory stack. Return is in global
;; variables subj, verb and object"
(let ((foo (:subjsearch sent key type)))
(or foo
(setq foo sent
mem nil))
(while (and (null (:verbp (car foo))) (cdr foo))
(nextl foo))
(setq verb (car foo))
(setq obj (:getnoun (cdr foo)))
(cond ((eq object 'i)(setq object 'me))
((eq subj 'me)(setq subj 'i)))
(when mem (:remember (list subj verb obj)))))
(defun :possess (sent key)
;;"Set possessive in SENT for keyword KEY. Hack on previous word, setting
;; global variable owner to possibly correct result"
(let* ((i (- (length sent) (length (memq key sent)) 1))
(prev (if (< i 0) 'your
(nth i sent))))
(setq owner (if (or (:possessivepronounp prev)
(equal #/s
(chrnth (1- (slength prev)) prev)))
prev
'your))))
;; Output of replies.
(defun :txtype (ans)
;;"Output to buffer a list of symbols or strings as a sentence"
(setq *print-upcase* t *print-space* nil)
(mapcar ':type-symbol ans)
(print))
(de capitalize (string)
(setq string (string string))
(sset string 0 (uppercase (sref string 0)))
(concat string))
(defun :type-symbol (word)
;;"Output a symbol to the buffer with some fancy case and spacing hacks"
(if (equal word 'i) (setq word 'I))
(if *print-upcase*
(setq word (capitalize word)))
(cond ((or (scanstring word ".,;:?! ")
(null *print-space*))
(prin word))
(t (princn #\sp) (prin word)))
(setq *print-upcase* (scanstring word ".?!")
*print-space* t))
(defun :build (str1 str2)
;;"Make a symbol out of the concatenation of the two non-list arguments"
(cond ((null str1) str2)
((null str2) str1)
((and (atom str1)
(atom str2))
(concat str1 str2))
(t "")))
(defun :assm (proto)
;;"evaluate forms in proto, and returns a linear list of symbols"
(:flatten (:tosymbol proto 1)))
(defun :tosymbol (proto level)
(cond ((stringp proto)
(:string-to-symbol-list proto))
((symbolp proto)
(:string-to-symbol-list (string proto)))
((consp proto)
(if (and (symbolp (car proto))
(typefn (car proto))
(= level 2))
(:tosymbol (eval proto) 1)
(list (:tosymbol (car proto) (1+ level))
(:tosymbol (cdr proto) level))))
(t proto))))
(defun :string-to-symbol-list (str)
(when str
(append (let ((idx (scanstring str ".,;:?! ")))
(ifn idx
(prog1
(when (> (slen str) 0) (list (concat str)))
(setq str ()))
(prog1
(if (= (sref str idx) #\sp)
(when (> idx 0)
(list (concat (substring str 0 idx))))
(list (when (> idx 0)
(concat (substring str 0 idx)))
(concat (substring
str
idx
(or (and (spanstring str "." idx)
(- (spanstring str "." idx) idx))
1)))))
(setq str (if (> (slen str) (1+ idx))
(substring str (1+ idx))
())))))
(:string-to-symbol-list str))))
(defun :flatten (l)
(if (consp l)
(if (atomp (car l))
(if (car l)
(cons (car l) (:flatten (cdr l)))
(:flatten (cdr l)))
(append (:flatten (car l)) (:flatten (cdr l))))
(when l (list l))))
;; Functions that handle specific words or meanings when found.
(defun :go (destination)
;;"Call a #:doctor: function"
(funcall (symbol 'doctor (string destination)))))
(defun :desire1 ()
(:go ($ whereoutp)))
(defun :huh ()
(cond ((< (length sent) 9) (:type ($ huhlst)))
(t (:type ($ longhuhlst)))))
(defun :rthing () (:type ($ thlst)))
(defun :remem () (cond ((null history)(:huh))
((:type ($ remlst)))))
(defun :howdy ()
(cond ((not howdyflag)
(:type '(($ hello) what brings you to see me |?|))
(setq howdyflag t))
(t
(:type '(($ ibelieve) "we've introduced ourselves already."))
(:type '(($ please) ($ describe) ($ things) |.|)))))
(defun :when ()
(cond ((< (length (memq found sent)) 3)(:short))
(t
(setq sent (cdr (memq found sent)))
(setq sent (:fixup sent))
(:type '(($ whatwhen)(// sent) |?|)))))
(defun :conj ()
(cond ((< (length (memq found sent)) 4)(:short))
(t
(setq sent (cdr (memq found sent)))
(setq sent (:fixup sent))
(cond ((eq (car sent) 'of)
(:type '("are you" ($ sure) "that is the real reason?"))
(setq things (cons (cdr sent) things)))
(t
(:remember sent)
(:type ($ beclst)))))))
(defun :short ()
(cond ((= (car repetitive-shortness) (1- lincount))
(rplacd repetitive-shortness
(1+ (cdr repetitive-shortness))))
(t
(rplacd repetitive-shortness 1)))
(rplaca repetitive-shortness lincount)
(cond ((> (cdr repetitive-shortness) 6)
(cond ((not **mad**)
(:type '(($ areyou)
"just trying to see what kind of things"
"i have in my vocabulary? please try to"
"carry on a reasonable conversation!"))
(setq **mad** t))
(t
(:type '("i give up. you need a lesson in creative writing..."))
)))
(t
(cond ((equal sent '(yes))
(:type '(($ isee) ($ inter) ($ whysay) "this is so?")))
((equal sent '(because))
(:type ($ shortbeclst)))
((equal sent '(no))
(:type ($ neglst)))
(t (:type ($ shortlst)))))))
(defun :alcohol () (:type ($ drnk)))
(defun :desire ()
(let ((foo (memq found sent)))
(cond ((< (length foo) 2)
(:go (concat (:meaning found) 1)))
((memq (cadr foo) '(a an))
(rplacd foo (append '(to have) (cdr foo)))
(:svo sent found 1 nil)
(:remember (list subj 'would 'like obj))
(:type ($ whywant)))
((not (eq (cadr foo) 'to))
(:go (concat (:meaning found) 1)))
(t
(:svo sent found 1 nil)
(:remember (list subj 'would 'like obj))
(:type ($ whywant))))))
(defun :drug ()
(:type ($ drugs))
(:remember (list 'you 'used found)))
(defun :toke ()
(:type ($ toklst)))
(defun :state ()
(:type ($ states))(:remember (list 'you 'were found)))
(defun :mood ()
(:type ($ moods))(:remember (list 'you 'felt found)))
(defun :fear ()
(setq feared (:setprep sent found))
(:type ($ fears))
(:remember (list 'you 'were 'afraid 'of feared)))
(defun :hate ()
(:svo sent found 1 t)
(cond ((memq 'not sent) (:forget) (:huh))
((equal subj 'you)
(:type '(why do you (// verb)(// obj) |?|)))
(t (:type '(($ whysay)(list subj verb obj))))))
(defun :symptoms ()
(:type '(($ maybe) "you should consult a doctor of medicine,
i am a psychiatrist.")))
(defun :hates ()
(:svo sent found 1 t)
(:hates1))
(defun :hates1 ()
(:type '(($ whysay) (list subj verb obj))))
(defun :loves ()
(:svo sent found 1 t)
(:qloves))
(defun :qloves ()
(:type '(($ bother) (list subj verb obj) |?|)))
(defun :love ()
(:svo sent found 1 t)
(cond ((memq 'not sent) (:forget) (:huh))
((memq 'to sent) (:hates1))
(t
(cond ((equal object 'something)
(setq object '(this person you love))))
(cond ((equal subj 'you)
(setq lover obj)
(cond ((equal lover '(this person you love))
(setq lover '(your partner))
(:forget)
(:type '("with whom are you in love?")))
((:type '(($ please)
($ describe)
($ relation)
(// lover)
|.|)))))
((equal subj 'i)
(:txtype '("we were discussing you!")))
(t (:forget)
(setq obj 'someone)
(setq verb (:build verb 's))
(:qloves))))))
(defun :mach ()
(setq found (:plural found))
(:type ($ machlst)))
(defun :sexnoun () (:sexverb))
(defun :sexverb ()
(if (or (memq 'me sent)(memq 'myself sent)(memq 'i sent))
(:foul)
(:type ($ sexlst))))
(defun :death () (:type ($ deathlst)))
(defun :foul ()
(:type ($ foullst)))
(defun :family ()
(:possess sent found)
(:type ($ famlst)))
(defun :school () (:type ($ schoollst)))
(defun :eliza ()
(cond (eliza-flag (:type ($ elizalst)))
(t (setq eliza-flag t)
(:type '((// found) "? hah!"
($ please) ($ continue) |.|)))))
(defun :sports () (:type ($ sportslst)))
(defun :math () (:type ($ mathlst)))
(defun :zippy ()
(cond (zippy-flag (:type ($ zippylst)))
(t (setq zippy-flag t)
(:type '("yow! are we interactive yet?")))))
(defun :chat () (:type ($ chatlst)))