Commit | Line | Data |
---|---|---|
55535639 | 1 | ;;; doctor.el --- psychological help for frustrated users |
c0274f38 | 2 | |
e597d8fb | 3 | ;; Copyright (C) 1985, 1987, 1994, 1996, 2000 Free Software Foundation, Inc. |
9750e079 | 4 | |
e5167999 | 5 | ;; Maintainer: FSF |
e5167999 ER |
6 | ;; Keywords: games |
7 | ||
6679505f JB |
8 | ;; This file is part of GNU Emacs. |
9 | ||
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 | |
e5167999 | 12 | ;; the Free Software Foundation; either version 2, or (at your option) |
6679505f JB |
13 | ;; any later version. |
14 | ||
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. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
b578f267 EN |
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. | |
6679505f | 24 | |
e41b2db1 ER |
25 | ;;; Commentary: |
26 | ||
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. | |
30 | ||
da4e5ca9 | 31 | ;; This file was for a while censored by the Communications Decency Act. |
46cfd45b RS |
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 | |
f470d537 | 34 | ;; did not contain pornography, but part of it was prohibited |
46cfd45b RS |
35 | ;; nonetheless. |
36 | ||
da4e5ca9 RS |
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. | |
46cfd45b | 39 | ;; For information on US government censorship of the Internet, and |
da4e5ca9 | 40 | ;; what you can do to protect freedom of the press, see the web |
46cfd45b | 41 | ;; site http://www.vtw.org/ |
988dff5e RS |
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. | |
46cfd45b | 45 | |
e5167999 | 46 | ;;; Code: |
6679505f | 47 | |
a3e58c1a | 48 | (defun doc// (x) x) |
6679505f | 49 | |
a3e58c1a | 50 | (defmacro doc$ (what) |
6679505f JB |
51 | "quoted arg form of doctor-$" |
52 | (list 'doctor-$ (list 'quote what))) | |
53 | ||
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)) | |
61 | \f | |
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)) | |
68 | ||
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 \. | |
a3e58c1a | 82 | (doc$ please) (doc$ describe) your (doc$ problems) \. |
6679505f JB |
83 | each time you are finished talking, type \R\E\T twice \.)) |
84 | (insert "\n")) | |
85 | ||
86 | (defun make-doctor-variables () | |
6679505f JB |
87 | (make-local-variable 'typos) |
88 | (setq typos | |
89 | (mapcar (function (lambda (x) | |
454473ea JPW |
90 | (put (car x) 'doctor-correction (cadr x)) |
91 | (put (cadr x) 'doctor-expansion (car (cddr x))) | |
6679505f JB |
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) | |
a3e58c1a JPW |
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) \?) )) | |
6679505f JB |
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) | |
a3e58c1a JPW |
152 | (setq moods '( ((doc$ areyou)(doc// found) often \?) |
153 | (what causes you to be (doc// found) \?) | |
154 | ((doc$ whysay) you are (doc// found) \?) )) | |
6679505f JB |
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 | |
a3e58c1a | 169 | '((do you drink a lot of (doc// found) \?) |
6679505f | 170 | (do you get drunk often \?) |
a1506d29 | 171 | ((doc$ describe) your drinking habits \.) )) |
6679505f | 172 | (make-local-variable 'drugs) |
a3e58c1a JPW |
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) | |
6679505f JB |
176 | \.))) |
177 | (make-local-variable 'whywant) | |
a3e58c1a | 178 | (setq whywant '( ((doc$ whysay) (doc// subj) might (doc$ want) (doc// obj) \?) |
6679505f | 179 | (how does it feel to want \?) |
a3e58c1a JPW |
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) \?) )) | |
6679505f JB |
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 \?) | |
a3e58c1a | 201 | ((doc$ please) continue \.) |
6679505f JB |
202 | (go on\, don\'t be afraid \.) |
203 | (i need a little more detail please \.) | |
a3e58c1a | 204 | (you\'re being a bit brief\, (doc$ please) go into detail \.) |
130b416e | 205 | (can you be more explicit \?) |
6679505f | 206 | (and \?) |
a3e58c1a | 207 | ((doc$ please) go into more detail \?) |
6679505f JB |
208 | (you aren\'t being very talkative today\!) |
209 | (is that all there is to it \?) | |
210 | (why must you respond so briefly \?))) | |
211 | ||
212 | (make-local-variable 'famlst) | |
213 | (setq famlst | |
a3e58c1a JPW |
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 \?))) | |
6679505f JB |
217 | (make-local-variable 'huhlst) |
218 | (setq huhlst | |
a3e58c1a JPW |
219 | '(((doc$ whysay)(doc// sent) \?) |
220 | (is it because of (doc$ things) that you say (doc// sent) \?) )) | |
6679505f JB |
221 | (make-local-variable 'longhuhlst) |
222 | (setq longhuhlst | |
a3e58c1a | 223 | '(((doc$ whysay) that \?) |
6679505f | 224 | (i don\'t understand \.) |
a3e58c1a JPW |
225 | ((doc$ thlst)) |
226 | ((doc$ areyou) (doc$ afraidof) that \?))) | |
b8797e1f | 227 | (make-local-variable 'feelings-about) |
6679505f JB |
228 | (setq feelings-about |
229 | '((feelings about) | |
0f668406 | 230 | (apprehensions toward) |
6679505f JB |
231 | (thoughts on) |
232 | (emotions toward))) | |
b8797e1f | 233 | (make-local-variable 'random-adjective) |
6679505f JB |
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) | |
a1506d29 | 259 | (setq please |
6679505f JB |
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) | |
a1506d29 | 282 | (setq things |
6679505f JB |
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) | |
a1506d29 | 309 | (setq ibelieve |
6679505f JB |
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) | |
a1506d29 | 327 | (setq machlst |
a3e58c1a JPW |
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)\.) | |
6679505f JB |
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 \.) | |
a3e58c1a | 337 | ((doc$ please) allow me to do the questioning \.) |
6679505f | 338 | (i have asked myself that question many times \.) |
a3e58c1a | 339 | ((doc$ please) try to answer that question yourself \.))) |
6679505f JB |
340 | (make-local-variable 'foullst) |
341 | (setq foullst | |
a3e58c1a JPW |
342 | '(((doc$ please) watch your tongue!) |
343 | ((doc$ please) avoid such unwholesome thoughts \.) | |
344 | ((doc$ please) get your mind out of the gutter \.) | |
6679505f JB |
345 | (such lewdness is not appreciated \.))) |
346 | (make-local-variable 'deathlst) | |
347 | (setq deathlst | |
348 | '((this is not a healthy way of thinking \.) | |
a3e58c1a | 349 | ((doc$ bother) you\, too\, may die someday \?) |
eb8c3be9 | 350 | (i am worried by your obsession with this topic!) |
6679505f JB |
351 | (did you watch a lot of crime and violence on television as a child \?)) |
352 | ) | |
353 | (make-local-variable 'sexlst) | |
a1506d29 | 354 | (setq sexlst |
a3e58c1a JPW |
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) \.\.\. \?))) | |
6679505f JB |
361 | (make-local-variable 'neglst) |
362 | (setq neglst | |
363 | '((why not \?) | |
a3e58c1a | 364 | ((doc$ bother) i ask that \?) |
6679505f JB |
365 | (why not \?) |
366 | (why not \?) | |
367 | (how come \?) | |
a3e58c1a | 368 | ((doc$ bother) i ask that \?))) |
6679505f JB |
369 | (make-local-variable 'beclst) |
370 | (setq beclst '( | |
a3e58c1a JPW |
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) \? ) )) | |
6679505f JB |
377 | (make-local-variable 'shortbeclst) |
378 | (setq shortbeclst '( | |
a3e58c1a | 379 | ((doc$ bother) i ask you that \?) |
6679505f | 380 | (that\'s not much of an answer!) |
a3e58c1a | 381 | ((doc$ inter) why won\'t you talk about it \?) |
6679505f | 382 | (speak up!) |
a3e58c1a JPW |
383 | ((doc$ areyou) (doc$ afraidof) talking about it \?) |
384 | (don\'t be (doc$ afraidof) elaborating \.) | |
385 | ((doc$ please) go into more detail \.))) | |
6679505f JB |
386 | (make-local-variable 'thlst) |
387 | (setq thlst '( | |
a3e58c1a JPW |
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) \?) )) | |
6679505f | 392 | (make-local-variable 'remlst) |
a3e58c1a JPW |
393 | (setq remlst '( (earlier you said (doc$ history) \?) |
394 | (you mentioned that (doc$ history) \?) | |
395 | ((doc$ whysay)(doc$ history) \? ) )) | |
6679505f JB |
396 | (make-local-variable 'toklst) |
397 | (setq toklst | |
398 | '((is this how you relax \?) | |
399 | (how long have you been smoking grass \?) | |
a3e58c1a | 400 | ((doc$ areyou) (doc$ afraidof) of being drawn to using harder stuff \?))) |
6679505f JB |
401 | (make-local-variable 'states) |
402 | (setq states | |
a3e58c1a JPW |
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) \?))) | |
6679505f | 408 | (make-local-variable 'replist) |
a1506d29 | 409 | (setq replist |
6679505f JB |
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 '( | |
a3e58c1a JPW |
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 \.))) | |
6679505f JB |
465 | (make-local-variable 'schoollst) |
466 | (setq schoollst '( | |
a3e58c1a JPW |
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) \.))) | |
6679505f JB |
473 | (make-local-variable 'improve) |
474 | (setq improve '((improve) (be better) (be improved) (be higher))) | |
475 | (make-local-variable 'elizalst) | |
476 | (setq elizalst '( | |
a3e58c1a JPW |
477 | ((doc$ areyou) (doc$ sure) \?) |
478 | ((doc$ ibelieve) you have (doc$ problems) with (doc// found) \.) | |
479 | ((doc$ whysay) (doc// sent) \?))) | |
6679505f JB |
480 | (make-local-variable 'sportslst) |
481 | (setq sportslst '( | |
a3e58c1a JPW |
482 | (tell me (doc$ something) about (doc// found) \.) |
483 | ((doc$ describe) (doc$ relation) (doc// found) \.) | |
484 | (do you find (doc// found) (doc$ random-adjective) \?))) | |
6679505f JB |
485 | (make-local-variable 'mathlst) |
486 | (setq mathlst '( | |
a3e58c1a JPW |
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) | |
6679505f JB |
490 | anyway \.))) |
491 | (make-local-variable 'zippylst) | |
492 | (setq zippylst '( | |
a3e58c1a JPW |
493 | ((doc$ areyou) Zippy \?) |
494 | ((doc$ ibelieve) you have some serious (doc$ problems) \.) | |
495 | ((doc$ bother) you are a pinhead \?))) | |
6679505f JB |
496 | (make-local-variable 'chatlst) |
497 | (setq chatlst '( | |
a3e58c1a JPW |
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) \?))) | |
6679505f JB |
501 | (make-local-variable 'abuselst) |
502 | (setq abuselst '( | |
a3e58c1a JPW |
503 | ((doc$ please) try to be less abusive \.) |
504 | ((doc$ describe) why you call me (doc// found) \.) | |
6679505f JB |
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) | |
6679505f JB |
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) | |
f535f6b2 RS |
540 | (make-local-variable 'suicide-flag) |
541 | (setq suicide-flag nil) | |
6679505f JB |
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)) | |
556 | \f | |
557 | ;; Define equivalence classes of words that get treated alike. | |
558 | ||
559 | (defun doctor-meaning (x) (get x 'doctor-meaning)) | |
560 | ||
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)) | |
564 | ||
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) | |
da4e5ca9 | 603 | (doctor-put-meaning shit 'foul) |
6679505f JB |
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) | |
da4e5ca9 | 678 | (doctor-put-meaning pissed 'mood) |
6679505f JB |
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) | |
da4e5ca9 RS |
692 | (doctor-put-meaning cunt 'sexnoun) |
693 | (doctor-put-meaning cunts 'sexnoun) | |
6679505f JB |
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) | |
f535f6b2 | 721 | (doctor-put-meaning killing 'death) |
6679505f JB |
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) | |
da4e5ca9 RS |
752 | (doctor-put-meaning fuck 'sexverb) |
753 | (doctor-put-meaning fucked 'sexverb) | |
6679505f JB |
754 | (doctor-put-meaning screw 'sexverb) |
755 | (doctor-put-meaning screwing 'sexverb) | |
da4e5ca9 | 756 | (doctor-put-meaning fucking 'sexverb) |
6679505f JB |
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) | |
da4e5ca9 | 763 | (doctor-put-meaning fucks 'sexverb) |
6679505f JB |
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) | |
eb8c3be9 | 799 | (doctor-put-meaning athletics 'sports) |
6679505f JB |
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) | |
834 | \f | |
835 | ;;;###autoload | |
836 | (defun doctor () | |
837 | "Switch to *doctor* buffer and start giving psychotherapy." | |
838 | (interactive) | |
839 | (switch-to-buffer "*doctor*") | |
840 | (doctor-mode)) | |
841 | ||
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))) | |
849 | ||
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))) | |
859 | ||
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)) | |
867 | ||
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*"))) | |
875 | \f | |
876 | ;; Main processing function for sentences that have been read. | |
877 | ||
878 | (defun doctor-doc (sent) | |
879 | (cond | |
880 | ((equal sent '(foo)) | |
a3e58c1a | 881 | (doctor-type '(bar! (doc$ please)(doc$ continue) \.))) |
6679505f | 882 | ((member sent howareyoulst) |
a3e58c1a | 883 | (doctor-type '(i\'m ok \. (doc$ describe) yourself \.))) |
6679505f JB |
884 | ((or (member sent '((good bye) (see you later) (i quit) (so long) |
885 | (go away) (get lost))) | |
886 | (memq (car sent) | |
a1506d29 | 887 | '(bye halt break quit done exit goodbye |
6679505f | 888 | bye\, stop pause goodbye\, stop pause))) |
a3e58c1a | 889 | (doctor-type (doc$ bye))) |
6679505f | 890 | ((and (eq (car sent) 'you) |
454473ea JPW |
891 | (memq (cadr sent) abusewords)) |
892 | (setq found (cadr sent)) | |
a3e58c1a | 893 | (doctor-type (doc$ abuselst))) |
6679505f | 894 | ((eq (car sent) 'whatmeans) |
454473ea | 895 | (doctor-def (cadr sent))) |
6679505f JB |
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 | "..." | |
a3e58c1a | 907 | '(doc// bak)))) |
daa6ddb5 | 908 | ((memq (car sent) '(are is do has have how when where who why)) |
a3e58c1a | 909 | (doctor-type (doc$ qlist))) |
6679505f | 910 | ;; ((eq (car sent) 'forget) |
454473ea | 911 | ;; (set (cadr sent) nil) |
a3e58c1a JPW |
912 | ;; (doctor-type '((doc$ isee)(doc$ please) |
913 | ;; (doc$ continue)\.))) | |
6679505f JB |
914 | (t |
915 | (if (doctor-defq sent) (doctor-define sent found)) | |
27664fbe | 916 | (if (> (length sent) 12)(setq sent (doctor-shorten sent))) |
6679505f JB |
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)))) | |
926 | (t | |
927 | (if (memq 'am sent) | |
928 | (setq sent (doctor-replace sent '((me . (i)))))) | |
929 | (setq sent (doctor-fixup sent)) | |
454473ea | 930 | (if (and (eq (car sent) 'do) (eq (cadr sent) 'not)) |
6679505f | 931 | (cond ((zerop (random 3)) |
a3e58c1a | 932 | (doctor-type '(are you (doc$ afraidof) that \?))) |
6679505f JB |
933 | ((zerop (random 2)) |
934 | (doctor-type '(don\'t tell me what to do \. i am the | |
935 | psychiatrist here!)) | |
936 | (doctor-rthing)) | |
937 | (t | |
a3e58c1a | 938 | (doctor-type '((doc$ whysay) that i shouldn\'t |
454473ea | 939 | (cddr sent) |
6679505f JB |
940 | \?)))) |
941 | (doctor-go (doctor-wherego sent)))))))) | |
942 | \f | |
943 | ;; Things done to process sentences once read. | |
944 | ||
945 | (defun doctor-correct-spelling (sent) | |
946 | "Correct the spelling and expand each word in sentence." | |
947 | (if sent | |
7382bcae | 948 | (apply 'append (mapcar (lambda (word) |
6679505f JB |
949 | (if (memq word typos) |
950 | (get (get word 'doctor-correction) 'doctor-expansion) | |
951 | (list word))) | |
952 | sent)))) | |
953 | ||
954 | (defun doctor-shorten (sent) | |
eb8c3be9 | 955 | "Make a sentence manageably short using a few hacks." |
6679505f | 956 | (let (foo |
27664fbe | 957 | (retval sent) |
6679505f JB |
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)) | |
27664fbe RS |
964 | (setq retval (doctor-fixup foo) |
965 | temp nil) | |
6679505f JB |
966 | (setq temp (cdr temp)))) |
967 | retval)) | |
968 | ||
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)) | |
977 | t)) | |
978 | ||
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) | |
990 | ||
991 | (defun doctor-def (x) | |
992 | (progn | |
a1506d29 | 993 | (doctor-type (list 'the 'word x 'means (doctor-meaning x) 'to 'me)) |
6679505f JB |
994 | nil)) |
995 | ||
996 | (defun doctor-forget () | |
997 | "Delete the last element of the history list." | |
998 | (setq history (reverse (cdr (reverse history))))) | |
999 | ||
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)) | |
1023 | ||
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)) | |
1034 | (t | |
1035 | (setq subj 'you) | |
1036 | nil)))) | |
1037 | ||
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) )) )) | |
1045 | ||
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))) | |
1058 | ||
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 | |
eb8c3be9 | 1064 | been being believe believed believes |
6679505f JB |
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 | |
eb8c3be9 | 1074 | expect expected expects expel expels expelled |
6679505f JB |
1075 | explain explained explains |
1076 | fart farts feel feels felt fight fights find finds finding | |
d32de959 | 1077 | forget forgets forgot fought found |
da4e5ca9 | 1078 | fuck fucked fucking fucks |
6679505f JB |
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 | |
a1506d29 | 1096 | need needed needs |
6679505f | 1097 | order ordered orders ought |
a1506d29 | 1098 | paid pay pays pick picked picking picks |
6679505f JB |
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 | |
eb8c3be9 | 1113 | transfer transferred transfers transmit transmits transmitted |
6679505f JB |
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)) | |
1118 | ||
1119 | (defun doctor-verbp (x) (if (symbolp x) | |
1120 | (eq (get x 'doctor-sentence-type) 'verb))) | |
1121 | ||
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")))))) | |
1133 | ||
1134 | (defun doctor-setprep (sent key) | |
1135 | (let ((val) | |
1136 | (foo (memq key sent))) | |
454473ea JPW |
1137 | (cond ((doctor-prepp (cadr foo)) |
1138 | (setq val (doctor-getnoun (cddr foo))) | |
6679505f JB |
1139 | (cond (val val) |
1140 | (t 'something))) | |
454473ea JPW |
1141 | ((doctor-articlep (cadr foo)) |
1142 | (setq val (doctor-getnoun (cddr foo))) | |
1143 | (cond (val (doctor-build (doctor-build (cadr foo) " ") val)) | |
6679505f JB |
1144 | (t 'something))) |
1145 | (t 'something)))) | |
1146 | ||
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)))) | |
daa6ddb5 RS |
1169 | (t (setq object (car x)) |
1170 | (doctor-build (doctor-build (car x) " ") (doctor-getnoun (cdr x)))) | |
1171 | )) | |
6679505f JB |
1172 | |
1173 | (defun doctor-modifierp (x) | |
1174 | (or (doctor-adjectivep x) | |
1175 | (doctor-adverbp x) | |
1176 | (doctor-othermodifierp x))) | |
1177 | ||
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))) | |
1185 | ||
1186 | (defun doctor-adverbp (xx) | |
b8797e1f RS |
1187 | (let ((xxstr (doctor-make-string xx))) |
1188 | (and (>= (length xxstr) 2) | |
1189 | (string-equal (substring (doctor-make-string xx) -2) "ly")))) | |
6679505f JB |
1190 | |
1191 | (defun doctor-articlep (x) | |
1192 | (memq x '(the a an))) | |
1193 | ||
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 | |
eb8c3be9 | 1202 | sixth seventh eighth ninth tenth))) |
a1506d29 | 1203 | |
6679505f JB |
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))) | |
1209 | ||
1210 | (defun doctor-sizep (x) | |
1211 | (memq x '(big large tall fat wide thick | |
1212 | small petite short thin skinny))) | |
1213 | ||
1214 | (defun doctor-possessivepronounp (x) | |
1215 | (memq x '(my your his her our their))) | |
1216 | ||
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 | |
0f668406 | 1221 | good great grody gross however if ignorant |
6679505f JB |
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))) | |
1226 | ||
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))) | |
1234 | ||
1235 | (defun doctor-remember (thing) | |
1236 | (cond ((null history) | |
1237 | (setq history (list thing))) | |
1238 | (t (setq history (append history (list thing)))))) | |
1239 | ||
1240 | (defun doctor-type (x) | |
1241 | (setq x (doctor-fix-2 x)) | |
1242 | (doctor-txtype (doctor-assm x))) | |
1243 | ||
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)) | |
1271 | ||
1272 | (defun doctor-fix-2 (sent) | |
1273 | (let ((foo sent)) | |
1274 | (while foo | |
1275 | (if (and (eq (car foo) 'me) | |
454473ea | 1276 | (doctor-verbp (cadr foo))) |
6679505f JB |
1277 | (rplaca foo 'i) |
1278 | (cond ((eq (car foo) 'you) | |
454473ea | 1279 | (cond ((memq (cadr foo) '(am be been is)) |
6679505f | 1280 | (rplaca (cdr foo) 'are)) |
454473ea | 1281 | ((memq (cadr foo) '(has)) |
6679505f | 1282 | (rplaca (cdr foo) 'have)) |
454473ea | 1283 | ((memq (cadr foo) '(was)) |
6679505f JB |
1284 | (rplaca (cdr foo) 'were)))) |
1285 | ((equal (car foo) 'i) | |
454473ea | 1286 | (cond ((memq (cadr foo) '(are is be been)) |
6679505f | 1287 | (rplaca (cdr foo) 'am)) |
454473ea | 1288 | ((memq (cadr foo) '(were)) |
6679505f | 1289 | (rplaca (cdr foo) 'was)) |
454473ea | 1290 | ((memq (cadr foo) '(has)) |
6679505f JB |
1291 | (rplaca (cdr foo) 'have)))) |
1292 | ((and (doctor-verbp (car foo)) | |
454473ea JPW |
1293 | (eq (cadr foo) 'i) |
1294 | (not (doctor-verbp (car (cddr foo))))) | |
6679505f JB |
1295 | (rplaca (cdr foo) 'me)) |
1296 | ((and (eq (car foo) 'a) | |
1297 | (doctor-vowelp (string-to-char | |
454473ea | 1298 | (doctor-make-string (cadr foo))))) |
6679505f JB |
1299 | (rplaca foo 'an)) |
1300 | ((and (eq (car foo) 'an) | |
1301 | (not (doctor-vowelp (string-to-char | |
454473ea | 1302 | (doctor-make-string (cadr foo)))))) |
6679505f JB |
1303 | (rplaca foo 'a))) |
1304 | (setq foo (cdr foo)))) | |
1305 | sent)) | |
1306 | ||
1307 | (defun doctor-vowelp (x) | |
1308 | (memq x '(?a ?e ?i ?o ?u))) | |
1309 | ||
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))) | |
1320 | ||
1321 | (defun doctor-wherego (sent) | |
a3e58c1a | 1322 | (cond ((null sent)(doc$ whereoutp)) |
6679505f JB |
1323 | ((null (doctor-meaning (car sent))) |
1324 | (doctor-wherego (cond ((zerop (random 2)) | |
1325 | (reverse (cdr sent))) | |
1326 | (t (cdr sent))))) | |
1327 | (t | |
1328 | (setq found (car sent)) | |
1329 | (doctor-meaning (car sent))))) | |
1330 | ||
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." | |
4746118a | 1336 | (let ((foo (doctor-subjsearch sent key type))) |
6679505f JB |
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)))))) | |
1347 | ||
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)))) | |
1360 | \f | |
1361 | ;; Output of replies. | |
1362 | ||
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")) | |
1368 | ||
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))) | |
a1982090 RS |
1382 | (and auto-fill-function |
1383 | (> (current-column) fill-column) | |
1384 | (apply auto-fill-function nil)) | |
6679505f JB |
1385 | (setq *print-upcase* (string-match "[.?!]$" word) |
1386 | *print-space* t)) | |
1387 | ||
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))) | |
1397 | ||
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 ""))) | |
1403 | ||
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))) | |
1409 | ||
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)))))) | |
1416 | \f | |
1417 | ;; Functions that handle specific words or meanings when found. | |
1418 | ||
1419 | (defun doctor-go (destination) | |
1420 | "Call a `doctor-*' function." | |
1421 | (funcall (intern (concat "doctor-" (doctor-make-string destination))))) | |
1422 | ||
1423 | (defun doctor-desire1 () | |
a3e58c1a | 1424 | (doctor-go (doc$ whereoutp))) |
6679505f JB |
1425 | |
1426 | (defun doctor-huh () | |
a3e58c1a JPW |
1427 | (cond ((< (length sent) 9) (doctor-type (doc$ huhlst))) |
1428 | (t (doctor-type (doc$ longhuhlst))))) | |
6679505f | 1429 | |
a3e58c1a | 1430 | (defun doctor-rthing () (doctor-type (doc$ thlst))) |
6679505f JB |
1431 | |
1432 | (defun doctor-remem () (cond ((null history)(doctor-huh)) | |
a3e58c1a | 1433 | ((doctor-type (doc$ remlst))))) |
6679505f JB |
1434 | |
1435 | (defun doctor-howdy () | |
1436 | (cond ((not howdyflag) | |
a3e58c1a | 1437 | (doctor-type '((doc$ hello) what brings you to see me \?)) |
6679505f JB |
1438 | (setq howdyflag t)) |
1439 | (t | |
a3e58c1a JPW |
1440 | (doctor-type '((doc$ ibelieve) we\'ve introduced ourselves already \.)) |
1441 | (doctor-type '((doc$ please) (doc$ describe) (doc$ things) \.))))) | |
6679505f JB |
1442 | |
1443 | (defun doctor-when () | |
1444 | (cond ((< (length (memq found sent)) 3)(doctor-short)) | |
1445 | (t | |
1446 | (setq sent (cdr (memq found sent))) | |
1447 | (setq sent (doctor-fixup sent)) | |
a3e58c1a | 1448 | (doctor-type '((doc$ whatwhen)(doc// sent) \?))))) |
6679505f JB |
1449 | |
1450 | (defun doctor-conj () | |
1451 | (cond ((< (length (memq found sent)) 4)(doctor-short)) | |
1452 | (t | |
1453 | (setq sent (cdr (memq found sent))) | |
1454 | (setq sent (doctor-fixup sent)) | |
1455 | (cond ((eq (car sent) 'of) | |
a3e58c1a | 1456 | (doctor-type '(are you (doc$ sure) that is the real reason \?)) |
6679505f JB |
1457 | (setq things (cons (cdr sent) things))) |
1458 | (t | |
1459 | (doctor-remember sent) | |
a3e58c1a | 1460 | (doctor-type (doc$ beclst))))))) |
6679505f JB |
1461 | |
1462 | (defun doctor-short () | |
1463 | (cond ((= (car repetitive-shortness) (1- lincount)) | |
1464 | (rplacd repetitive-shortness | |
1465 | (1+ (cdr repetitive-shortness)))) | |
1466 | (t | |
1467 | (rplacd repetitive-shortness 1))) | |
1468 | (rplaca repetitive-shortness lincount) | |
1469 | (cond ((> (cdr repetitive-shortness) 6) | |
1470 | (cond ((not **mad**) | |
a3e58c1a | 1471 | (doctor-type '((doc$ areyou) |
6679505f JB |
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)) | |
1476 | (t | |
1477 | (doctor-type '(i give up \. you need a lesson in creative | |
1478 | writing \.\.\.)) | |
6679505f JB |
1479 | ))) |
1480 | (t | |
1481 | (cond ((equal sent (doctor-assm '(yes))) | |
a3e58c1a | 1482 | (doctor-type '((doc$ isee) (doc$ inter) (doc$ whysay) this is so \?))) |
6679505f | 1483 | ((equal sent (doctor-assm '(because))) |
a3e58c1a | 1484 | (doctor-type (doc$ shortbeclst))) |
6679505f | 1485 | ((equal sent (doctor-assm '(no))) |
a3e58c1a JPW |
1486 | (doctor-type (doc$ neglst))) |
1487 | (t (doctor-type (doc$ shortlst))))))) | |
a1506d29 | 1488 | |
a3e58c1a | 1489 | (defun doctor-alcohol () (doctor-type (doc$ drnk))) |
6679505f JB |
1490 | |
1491 | (defun doctor-desire () | |
1492 | (let ((foo (memq found sent))) | |
1493 | (cond ((< (length foo) 2) | |
1494 | (doctor-go (doctor-build (doctor-meaning found) 1))) | |
454473ea | 1495 | ((memq (cadr foo) '(a an)) |
6679505f JB |
1496 | (rplacd foo (append '(to have) (cdr foo))) |
1497 | (doctor-svo sent found 1 nil) | |
1498 | (doctor-remember (list subj 'would 'like obj)) | |
a3e58c1a | 1499 | (doctor-type (doc$ whywant))) |
454473ea | 1500 | ((not (eq (cadr foo) 'to)) |
6679505f JB |
1501 | (doctor-go (doctor-build (doctor-meaning found) 1))) |
1502 | (t | |
1503 | (doctor-svo sent found 1 nil) | |
1504 | (doctor-remember (list subj 'would 'like obj)) | |
a3e58c1a | 1505 | (doctor-type (doc$ whywant)))))) |
6679505f JB |
1506 | |
1507 | (defun doctor-drug () | |
a3e58c1a | 1508 | (doctor-type (doc$ drugs)) |
6679505f JB |
1509 | (doctor-remember (list 'you 'used found))) |
1510 | ||
1511 | (defun doctor-toke () | |
a3e58c1a | 1512 | (doctor-type (doc$ toklst))) |
6679505f JB |
1513 | |
1514 | (defun doctor-state () | |
a3e58c1a | 1515 | (doctor-type (doc$ states))(doctor-remember (list 'you 'were found))) |
6679505f JB |
1516 | |
1517 | (defun doctor-mood () | |
a3e58c1a | 1518 | (doctor-type (doc$ moods))(doctor-remember (list 'you 'felt found))) |
6679505f JB |
1519 | |
1520 | (defun doctor-fear () | |
1521 | (setq feared (doctor-setprep sent found)) | |
a3e58c1a | 1522 | (doctor-type (doc$ fears)) |
6679505f JB |
1523 | (doctor-remember (list 'you 'were 'afraid 'of feared))) |
1524 | ||
1525 | (defun doctor-hate () | |
1526 | (doctor-svo sent found 1 t) | |
1527 | (cond ((memq 'not sent) (doctor-forget) (doctor-huh)) | |
1528 | ((equal subj 'you) | |
a3e58c1a JPW |
1529 | (doctor-type '(why do you (doc// verb)(doc// obj) \?))) |
1530 | (t (doctor-type '((doc$ whysay)(list subj verb obj)))))) | |
6679505f JB |
1531 | |
1532 | (defun doctor-symptoms () | |
a3e58c1a | 1533 | (doctor-type '((doc$ maybe) you should consult a doctor of medicine\, |
6679505f JB |
1534 | i am a psychiatrist \.))) |
1535 | ||
1536 | (defun doctor-hates () | |
1537 | (doctor-svo sent found 1 t) | |
1538 | (doctor-hates1)) | |
1539 | ||
1540 | (defun doctor-hates1 () | |
a3e58c1a | 1541 | (doctor-type '((doc$ whysay)(list subj verb obj) \?))) |
6679505f JB |
1542 | |
1543 | (defun doctor-loves () | |
1544 | (doctor-svo sent found 1 t) | |
1545 | (doctor-qloves)) | |
1546 | ||
1547 | (defun doctor-qloves () | |
a3e58c1a | 1548 | (doctor-type '((doc$ bother)(list subj verb obj) \?))) |
6679505f JB |
1549 | |
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)) | |
1554 | (t | |
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 \?))) | |
a3e58c1a JPW |
1563 | ((doctor-type '((doc$ please) |
1564 | (doc$ describe) | |
1565 | (doc$ relation) | |
1566 | (doc// lover) | |
6679505f JB |
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)))))) | |
1574 | ||
1575 | (defun doctor-mach () | |
1576 | (setq found (doctor-plural found)) | |
a3e58c1a | 1577 | (doctor-type (doc$ machlst))) |
6679505f JB |
1578 | |
1579 | (defun doctor-sexnoun () (doctor-sexverb)) | |
1580 | ||
1581 | (defun doctor-sexverb () | |
1582 | (if (or (memq 'me sent)(memq 'myself sent)(memq 'i sent)) | |
1583 | (doctor-foul) | |
a3e58c1a | 1584 | (doctor-type (doc$ sexlst)))) |
6679505f | 1585 | |
f535f6b2 | 1586 | (defun doctor-death () |
a3e58c1a | 1587 | (cond (suicide-flag (doctor-type (doc$ deathlst))) |
f535f6b2 RS |
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, | |
e597d8fb GM |
1596 | anonymous E-mail: samaritans@anon.twwells.com\ \. |
1597 | or find a Befrienders crisis center at | |
1598 | http://www.befrienders.org/\ \. | |
a3e58c1a JPW |
1599 | (doc$ please) (doc$ continue) \.))) |
1600 | (t (doctor-type (doc$ deathlst))))) | |
6679505f JB |
1601 | |
1602 | (defun doctor-foul () | |
a3e58c1a | 1603 | (doctor-type (doc$ foullst))) |
6679505f JB |
1604 | |
1605 | (defun doctor-family () | |
1606 | (doctor-possess sent found) | |
a3e58c1a | 1607 | (doctor-type (doc$ famlst))) |
6679505f JB |
1608 | |
1609 | ;; I did not add this -- rms. | |
1610 | ;; But he might have removed it. I put it back. --roland | |
1611 | (defun doctor-rms () | |
a3e58c1a | 1612 | (cond (rms-flag (doctor-type (doc$ stallmanlst))) |
6679505f JB |
1613 | (t (setq rms-flag t) (doctor-type '(do you know Stallman \?))))) |
1614 | ||
a3e58c1a | 1615 | (defun doctor-school nil (doctor-type (doc$ schoollst))) |
6679505f JB |
1616 | |
1617 | (defun doctor-eliza () | |
a3e58c1a | 1618 | (cond (eliza-flag (doctor-type (doc$ elizalst))) |
6679505f | 1619 | (t (setq eliza-flag t) |
a3e58c1a JPW |
1620 | (doctor-type '((doc// found) \? hah ! |
1621 | (doc$ please) (doc$ continue) \.))))) | |
a1506d29 | 1622 | |
a3e58c1a | 1623 | (defun doctor-sports () (doctor-type (doc$ sportslst))) |
6679505f | 1624 | |
a3e58c1a | 1625 | (defun doctor-math () (doctor-type (doc$ mathlst))) |
6679505f JB |
1626 | |
1627 | (defun doctor-zippy () | |
a3e58c1a | 1628 | (cond (zippy-flag (doctor-type (doc$ zippylst))) |
6679505f JB |
1629 | (t (setq zippy-flag t) |
1630 | (doctor-type '(yow! are we interactive yet \?))))) | |
1631 | ||
1632 | ||
a3e58c1a | 1633 | (defun doctor-chat () (doctor-type (doc$ chatlst))) |
6679505f | 1634 | |
896546cd RS |
1635 | (provide 'doctor) |
1636 | ||
ab5796a9 | 1637 | ;;; arch-tag: 579380f6-4902-4ea5-bccb-6339e30e1257 |
c0274f38 | 1638 | ;;; doctor.el ends here |