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