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