mirrored from git://git.sv.gnu.org/emacs.git
/
doctor.el
1631 lines (1520 loc) · 60.6 KB
/
doctor.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; doctor.el --- psychological help for frustrated users -*- lexical-binding: t -*-
;; Copyright (C) 1985-2024 Free Software Foundation, Inc.
;; Maintainer: emacs-devel@gnu.org
;; Keywords: games
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; The single entry point `doctor', simulates a Rogerian analyst using
;; phrase-production techniques similar to the classic ELIZA demonstration
;; of pseudo-AI.
;;; Code:
(defvar doctor--**mad**)
(defvar doctor--*print-space*)
(defvar doctor--*print-upcase*)
(defvar doctor--abuselst)
(defvar doctor--abusewords)
(defvar doctor--afraidof)
(defvar doctor--arerelated)
(defvar doctor--areyou)
(defvar doctor--bak)
(defvar doctor--beclst)
(defvar doctor--bother)
(defvar doctor--bye)
(defvar doctor--canyou) ; unused?
(defvar doctor--chatlst)
(defvar doctor--continue)
(defvar doctor--deathlst)
(defvar doctor--describe)
(defvar doctor--drnk)
(defvar doctor--drugs)
(defvar doctor--eliza-flag)
(defvar doctor--elizalst)
(defvar doctor--famlst)
(defvar doctor--feared)
(defvar doctor--fears)
(defvar doctor--feelings-about)
(defvar doctor--foullst)
(defvar doctor-found)
(defvar doctor--hello)
(defvar doctor--history)
(defvar doctor--howareyoulst)
(defvar doctor--howdyflag)
(defvar doctor--huhlst)
(defvar doctor--ibelieve)
(defvar doctor--improve)
(defvar doctor--inter)
(defvar doctor--isee)
(defvar doctor--isrelated)
(defvar doctor--lincount)
(defvar doctor--longhuhlst)
(defvar doctor--lover)
(defvar doctor--machlst)
(defvar doctor--mathlst)
(defvar doctor--maybe)
(defvar doctor--moods)
(defvar doctor--neglst)
(defvar doctor-obj)
(defvar doctor-object)
(defvar doctor-owner)
(defvar doctor--please)
(defvar doctor--problems)
(defvar doctor--qlist)
(defvar doctor--random-adjective)
(defvar doctor--relation)
(defvar doctor--remlst)
(defvar doctor--repetitive-shortness)
(defvar doctor--replist)
(defvar doctor--rms-flag)
(defvar doctor--schoollst)
(defvar doctor-sent)
(defvar doctor--sexlst)
(defvar doctor--shortbeclst)
(defvar doctor--shortlst)
(defvar doctor--something)
(defvar doctor--sportslst)
(defvar doctor--stallmanlst)
(defvar doctor--states)
(defvar doctor-subj)
(defvar doctor--suicide-flag)
(defvar doctor--sure)
(defvar doctor--thing)
(defvar doctor--things)
(defvar doctor--thlst)
(defvar doctor--toklst)
(defvar doctor--typos)
(defvar doctor-verb)
(defvar doctor--want)
(defvar doctor--whatwhen)
(defvar doctor--whereoutp)
(defvar doctor--whysay)
(defvar doctor--whywant)
(defvar doctor--zippy-flag)
(defvar doctor--zippylst)
(defun doc// (x) x)
(defmacro doc$ (what)
"Quoted arg form of `doctor-$'."
`(doctor-$ ',what))
(defun doctor-$ (what)
"Return the car of a list, rotating the list each time."
(let* ((vv (symbol-value what))
(first (car vv))
(ww (append (cdr vv) (list first))))
(set what ww)
first))
(defvar-keymap doctor-mode-map
"C-j" #'doctor-read-print
"RET" #'doctor-ret-or-read)
;; Actually defined in textconv.c.
(defvar text-conversion-style)
(define-derived-mode doctor-mode text-mode "Doctor"
"Major mode for running the Doctor (Eliza) program.
Like Text mode with Auto Fill mode
except that RET when point is after a newline, or LFD at any time,
reads the sentence before point, and prints the Doctor's answer."
:interactive nil
(doctor-make-variables)
(turn-on-auto-fill)
;; Make sure RET is processed by Emacs.
(setq text-conversion-style 'action)
(doctor-type '(i am the psychotherapist \.
(doc$ doctor--please) (doc$ doctor--describe) your (doc$ doctor--problems) \.
each time you are finished talking\, type \R\E\T twice \.))
(insert "\n"))
(defun doctor-make-variables ()
(setq-local doctor--typos
(mapcar (lambda (x)
(put (car x) 'doctor-correction (cadr x))
(put (cadr x) 'doctor-expansion (car (cddr x)))
(car x))
'((theyll they\'ll (they will))
(theyre they\'re (they are))
(hes he\'s (he is))
(he7s he\'s (he is))
(im i\'m (you are))
(i7m i\'m (you are))
(isa is\ a (is a))
(thier their (their))
(dont don\'t (do not))
(don7t don\'t (do not))
(you7re you\'re (i am))
(you7ve you\'ve (i have))
(you7ll you\'ll (i will)))))
(setq-local doctor-sent nil)
(setq-local doctor-found nil)
(setq-local doctor-owner nil)
(setq-local doctor--history nil)
(setq-local doctor--inter '((well\,)
(hmmm \.\.\.\ so\,)
(so)
(\.\.\.and)
(then)))
(setq-local doctor--continue '((continue)
(proceed)
(go on)
(keep going)))
(setq-local doctor--relation
'((your relationship with)
(something you remember about)
(your feelings toward)
(some experiences you have had with)
(how you feel about)))
(setq-local doctor--fears
'(((doc$ doctor--whysay) you are (doc$ doctor--afraidof) (doc// doctor--feared) \?)
(you seem terrified by (doc// doctor--feared) \.)
(when did you first feel (doc$ doctor--afraidof) (doc// doctor--feared) \?)))
(setq-local doctor--sure '((sure)
(positive)
(certain)
(absolutely sure)))
(setq-local doctor--afraidof '((afraid of)
(frightened by)
(scared of)))
(setq-local doctor--areyou '((are you)
(have you been)
(have you been)))
(setq-local doctor--isrelated
'((has something to do with)
(is related to)
(could be the reason for)
(is caused by)
(is because of)))
(setq-local doctor--arerelated '((have something to do with)
(are related to)
(could have caused)
(could be the reason for)
(are caused by)
(are because of)))
(setq-local doctor--moods
'(((doc$ doctor--areyou) (doc// doctor-found) often \?)
(what causes you to be (doc// doctor-found) \?)
((doc$ doctor--whysay) you are (doc// doctor-found) \?)))
(setq-local doctor--maybe '((maybe)
(perhaps)
(possibly)))
(setq-local doctor--whatwhen '((what happened when)
(what would happen if)))
(setq-local doctor--hello '((how do you do \?)
(hello \.)
(howdy!)
(hello \.)
(hi \.)
(hi there \.)))
(setq-local doctor--drnk
'((do you drink a lot of (doc// doctor-found) \?)
(do you get drunk often \?)
((doc$ doctor--describe) your drinking habits \.)))
(setq-local doctor--drugs
'((do you use (doc// doctor-found) often \?)
((doc$ doctor--areyou) addicted to (doc// doctor-found) \?)
(do you realize that drugs can be very harmful \?)
((doc$ doctor--maybe) you should try to quit using (doc// doctor-found) \.)))
(setq-local doctor--whywant
'(((doc$ doctor--whysay) (doc// doctor-subj) might (doc$ doctor--want) (doc// doctor-obj) \?)
(how does it feel to want \?)
(why should (doc// doctor-subj) get (doc// doctor-obj) \?)
(when did (doc// doctor-subj) first (doc$ doctor--want) (doc// doctor-obj) \?)
((doc$ doctor--areyou) obsessed with (doc// doctor-obj) \?)
(why should i give (doc// doctor-obj) to (doc// doctor-subj) \?)
(have you ever gotten (doc// doctor-obj) \?)))
(setq-local doctor--canyou
'((of course i can \.)
(why should i \?)
(what makes you think i would even want to \?)
(i am the doctor\, i can do anything i damn please \.)
(not really\, it\'s not up to me \.)
(depends\, how important is it \?)
(i could\, but i don\'t think it would be a wise thing to do \.)
(can you \?)
(maybe i can\, maybe i can\'t \.\.\.)
(i don\'t think i should do that \.)))
(setq-local doctor--want '((want) (desire) (wish) (want) (hope)))
(setq-local doctor--shortlst
'((can you elaborate on that \?)
((doc$ doctor--please) continue \.)
(go on\, don\'t be afraid \.)
(i need a little more detail please \.)
(you\'re being a bit brief\, (doc$ doctor--please) go into detail \.)
(can you be more explicit \?)
(and \?)
((doc$ doctor--please) go into more detail \?)
(you aren\'t being very talkative today\!)
(is that all there is to it \?)
(why must you respond so briefly \?)))
(setq-local doctor--famlst
'((tell me (doc$ doctor--something) about (doc// doctor-owner) family \.)
(you seem to dwell on (doc// doctor-owner) family \.)
((doc$ doctor--areyou) hung up on (doc// doctor-owner) family \?)))
(setq-local doctor--huhlst
'(((doc$ doctor--whysay) (doc// doctor-sent) \?)
(is it because of (doc$ doctor--things) that you say (doc// doctor-sent) \?)))
(setq-local doctor--longhuhlst
'(((doc$ doctor--whysay) that \?)
(i don\'t understand \.)
((doc$ doctor--thlst))
((doc$ doctor--areyou) (doc$ doctor--afraidof) that \?)))
(setq-local doctor--feelings-about '((feelings about)
(apprehensions toward)
(thoughts on)
(emotions toward)))
(setq-local doctor--random-adjective
'((vivid)
(emotionally stimulating)
(exciting)
(boring)
(interesting)
(recent)
(random) ; how can we omit this?
(unusual)
(shocking)
(embarrassing)))
(setq-local doctor--whysay '((why do you say)
(what makes you believe)
(are you sure that)
(do you really think)
(what makes you think)))
(setq-local doctor--isee '((i see \.\.\.)
(yes\,)
(i understand \.)
(oh \.) ))
(setq-local doctor--please '((please\,)
(i would appreciate it if you would)
(perhaps you could)
(please\,)
(would you please)
(why don\'t you)
(could you)))
(setq-local doctor--bye
'((my secretary will send you a bill \.)
(bye bye \.)
(see ya \.)
(ok\, talk to you some other time \.)
(talk to you later \.)
(ok\, have fun \.)
(ciao \.)))
(setq-local doctor--something '((something)
(more)
(how you feel)))
(setq-local doctor--thing '((your life)
(your sex life)))
(setq-local doctor--things '((your plans)
(the people you hang around with)
(problems at school)
(any hobbies you have)
(hangups you have)
(your inhibitions)
(some problems in your childhood)
(some problems at home)))
(setq-local doctor--describe '((describe)
(tell me about)
(talk about)
(discuss)
(tell me more about)
(elaborate on)))
(setq-local doctor--ibelieve
'((i believe) (i think) (i have a feeling) (it seems to me that)
(it looks like)))
(setq-local doctor--problems '((problems)
(inhibitions)
(hangups)
(difficulties)
(anxieties)
(frustrations)))
(setq-local doctor--bother '((does it bother you that)
(are you annoyed that)
(did you ever regret)
(are you sorry)
(are you satisfied with the fact that)))
(setq-local doctor--machlst
'((you have your mind on (doc// doctor-found) \, it seems \.)
(you think too much about (doc// doctor-found) \.)
(you should try taking your mind off of (doc// doctor-found)\.)
(are you a computer hacker \?)))
(setq-local doctor--qlist
'((what do you think \?)
(i\'ll ask the questions\, if you don\'t mind!)
(i could ask the same thing myself \.)
((doc$ doctor--please) allow me to do the questioning \.)
(i have asked myself that question many times \.)
((doc$ doctor--please) try to answer that question yourself \.)))
(setq-local doctor--foullst
'(((doc$ doctor--please) watch your tongue!)
((doc$ doctor--please) avoid such unwholesome thoughts \.)
((doc$ doctor--please) get your mind out of the gutter \.)
(such lewdness is not appreciated \.)))
(setq-local doctor--deathlst
'((this is not a healthy way of thinking \.)
((doc$ doctor--bother) you\, too\, may die someday \?)
(i am worried by your obsession with this topic!)
(did you watch a lot of crime and violence on television as a child \?)))
(setq-local doctor--sexlst
'(((doc$ doctor--areyou) (doc$ doctor--afraidof) sex \?)
((doc$ doctor--describe) (doc$ doctor--something) about your sexual history \.)
((doc$ doctor--please) (doc$ doctor--describe) your sex life \.\.\.)
((doc$ doctor--describe) your (doc$ doctor--feelings-about) your sexual partner \.)
((doc$ doctor--describe) your most (doc$ doctor--random-adjective) sexual experience \.)
((doc$ doctor--areyou) satisfied with (doc// doctor--lover) \.\.\. \?)))
(setq-local doctor--neglst '((why not \?)
((doc$ doctor--bother) i ask that \?)
(why not \?)
(why not \?)
(how come \?)
((doc$ doctor--bother) i ask that \?)))
(setq-local doctor--beclst
'((is it because (doc// doctor-sent) that you came to me \?)
((doc$ doctor--bother) (doc// doctor-sent) \?)
(when did you first know that (doc// doctor-sent) \?)
(is the fact that (doc// doctor-sent) the real reason \?)
(does the fact that (doc// doctor-sent) explain anything else \?)
((doc$ doctor--areyou) (doc$ doctor--sure) (doc// doctor-sent) \? )))
(setq-local doctor--shortbeclst
'(((doc$ doctor--bother) i ask you that \?)
(that\'s not much of an answer!)
((doc$ doctor--inter) why won\'t you talk about it \?)
(speak up!)
((doc$ doctor--areyou) (doc$ doctor--afraidof) talking about it \?)
(don\'t be (doc$ doctor--afraidof) elaborating \.)
((doc$ doctor--please) go into more detail \.)))
(setq-local doctor--thlst
'(((doc$ doctor--maybe) (doc$ doctor--thing) (doc$ doctor--isrelated) this \.)
((doc$ doctor--maybe) (doc$ doctor--things) (doc$ doctor--arerelated) this \.)
(is it because of (doc$ doctor--things) that you are going through all this \?)
(how do you reconcile (doc$ doctor--things) \? )
((doc$ doctor--maybe) this (doc$ doctor--isrelated) (doc$ doctor--things) \?)))
(setq-local doctor--remlst
'((earlier you said (doc$ doctor--history) \?)
(you mentioned that (doc$ doctor--history) \?)
((doc$ doctor--whysay) (doc$ doctor--history) \? )))
(setq-local doctor--toklst
'((is this how you relax \?)
(how long have you been smoking grass \?)
((doc$ doctor--areyou) (doc$ doctor--afraidof) of being drawn to using harder stuff \?)))
(setq-local doctor--states
'((do you get (doc// doctor-found) often \?)
(do you enjoy being (doc// doctor-found) \?)
(what makes you (doc// doctor-found) \?)
(how often (doc$ doctor--areyou) (doc// doctor-found) \?)
(when were you last (doc// doctor-found) \?)))
(setq-local doctor--replist '((i . (you))
(my . (your))
(me . (you))
(you . (me))
(your . (my))
(mine . (yours))
(yours . (mine))
(our . (your))
(ours . (yours))
(we . (you))
(dunno . (do not know))
;; (yes . ())
(no\, . ())
(yes\, . ())
(ya . (i))
(aint . (am not))
(wanna . (want to))
(gimme . (give me))
(gotta . (have to))
(gonna . (going to))
(never . (not ever))
(doesn\'t . (does not))
(don\'t . (do not))
(aren\'t . (are not))
(isn\'t . (is not))
(won\'t . (will not))
(can\'t . (cannot))
(haven\'t . (have not))
(i\'m . (you are))
(ourselves . (yourselves))
(myself . (yourself))
(yourself . (myself))
(you\'re . (i am))
(you\'ve . (i have))
(i\'ve . (you have))
(i\'ll . (you will))
(you\'ll . (i shall))
(i\'d . (you would))
(you\'d . (i would))
(here . (there))
(please . ())
(eh\, . ())
(eh . ())
(oh\, . ())
(oh . ())
(shouldn\'t . (should not))
(wouldn\'t . (would not))
(won\'t . (will not))
(hasn\'t . (has not))))
(setq-local doctor--stallmanlst
'(((doc$ doctor--describe) your (doc$ doctor--feelings-about) him \.)
((doc$ doctor--areyou) a friend of Stallman \?)
((doc$ doctor--bother) Stallman is (doc$ doctor--random-adjective) \?)
((doc$ doctor--ibelieve) you are (doc$ doctor--afraidof) him \.)))
(setq-local doctor--schoollst
'(((doc$ doctor--describe) your (doc// doctor-found) \.)
((doc$ doctor--bother) your grades could (doc$ doctor--improve) \?)
((doc$ doctor--areyou) (doc$ doctor--afraidof) (doc// doctor-found) \?)
((doc$ doctor--maybe) this (doc$ doctor--isrelated) to your attitude \.)
((doc$ doctor--areyou) absent often \?)
((doc$ doctor--maybe) you should study (doc$ doctor--something) \.)))
(setq-local doctor--improve
'((improve) (be better) (be improved) (be higher)))
(setq-local doctor--elizalst
'(((doc$ doctor--areyou) (doc$ doctor--sure) \?)
((doc$ doctor--ibelieve) you have (doc$ doctor--problems) with (doc// doctor-found) \.)
((doc$ doctor--whysay) (doc// doctor-sent) \?)))
(setq-local doctor--sportslst
'((tell me (doc$ doctor--something) about (doc// doctor-found) \.)
((doc$ doctor--describe) (doc$ doctor--relation) (doc// doctor-found) \.)
(do you find (doc// doctor-found) (doc$ doctor--random-adjective) \?)))
(setq-local doctor--mathlst
'(((doc$ doctor--describe) (doc$ doctor--something) about math \.)
((doc$ doctor--maybe) your (doc$ doctor--problems) (doc$ doctor--arerelated) (doc// doctor-found) \.)
(i don\'t know much (doc// doctor-found) \, but (doc$ doctor--continue)
anyway \.)))
(setq-local doctor--zippylst
'(((doc$ doctor--areyou) Zippy \?)
((doc$ doctor--ibelieve) you have some serious (doc$ doctor--problems) \.)
((doc$ doctor--bother) you are a pinhead \?)))
(setq-local doctor--chatlst
'(((doc$ doctor--maybe) we could chat \.)
((doc$ doctor--please) (doc$ doctor--describe) (doc$ doctor--something) about chat mode \.)
((doc$ doctor--bother) our discussion is so (doc$ doctor--random-adjective) \?)))
(setq-local doctor--abuselst
'(((doc$ doctor--please) try to be less abusive \.)
((doc$ doctor--describe) why you call me (doc// doctor-found) \.)
(i\'ve had enough of you!)))
(setq-local doctor--abusewords
'(boring bozo clown clumsy cretin dumb dummy
fool foolish gnerd gnurd idiot jerk
lose loser louse lousy luse luser
moron nerd nurd oaf oafish reek
stink stupid tool toolish twit))
(setq-local doctor--howareyoulst
'((how are you) (hows it going) (hows it going eh)
(how\'s it going) (how\'s it going eh) (how goes it)
(whats up) (whats new) (what\'s up) (what\'s new)
(howre you) (how\'re you) (how\'s everything)
(how is everything) (how do you do)
(how\'s it hanging) (que pasa)
(how are you doing) (what do you say)))
(setq-local doctor--whereoutp '(huh remem rthing))
(setq-local doctor-subj nil)
(setq-local doctor-verb nil)
(setq-local doctor-obj nil)
(setq-local doctor--feared nil)
(setq-local doctor--repetitive-shortness '(0 . 0))
(setq-local doctor--**mad** nil)
(setq-local doctor--rms-flag nil)
(setq-local doctor--eliza-flag nil)
(setq-local doctor--zippy-flag nil)
(setq-local doctor--suicide-flag nil)
(setq-local doctor--lover '(your partner))
(setq-local doctor--bak nil)
(setq-local doctor--lincount 0)
(setq-local doctor--*print-upcase* nil)
(setq-local doctor--*print-space* nil)
(setq-local doctor--howdyflag nil)
(setq-local doctor-object nil))
;; Define equivalence classes of words that get treated alike.
(defun doctor-meaning (x) (get x 'doctor-meaning))
(defmacro doctor-put-meaning (symb val)
"Store the base meaning of a word on the property list."
`(put ',symb 'doctor-meaning ,val))
(doctor-put-meaning howdy 'howdy)
(doctor-put-meaning hi 'howdy)
(doctor-put-meaning greetings 'howdy)
(doctor-put-meaning hello 'howdy)
(doctor-put-meaning tops20 'mach)
(doctor-put-meaning tops-20 'mach)
(doctor-put-meaning tops 'mach)
(doctor-put-meaning pdp11 'mach)
(doctor-put-meaning computer 'mach)
(doctor-put-meaning unix 'mach)
(doctor-put-meaning machine 'mach)
(doctor-put-meaning computers 'mach)
(doctor-put-meaning machines 'mach)
(doctor-put-meaning pdp11s 'mach)
(doctor-put-meaning foo 'mach)
(doctor-put-meaning foobar 'mach)
(doctor-put-meaning multics 'mach)
(doctor-put-meaning macsyma 'mach)
(doctor-put-meaning teletype 'mach)
(doctor-put-meaning la36 'mach)
(doctor-put-meaning vt52 'mach)
(doctor-put-meaning zork 'mach)
(doctor-put-meaning trek 'mach)
(doctor-put-meaning startrek 'mach)
(doctor-put-meaning advent 'mach)
(doctor-put-meaning pdp 'mach)
(doctor-put-meaning dec 'mach)
(doctor-put-meaning commodore 'mach)
(doctor-put-meaning vic 'mach)
(doctor-put-meaning bbs 'mach)
(doctor-put-meaning modem 'mach)
(doctor-put-meaning baud 'mach)
(doctor-put-meaning macintosh 'mach)
(doctor-put-meaning vax 'mach)
(doctor-put-meaning vms 'mach)
(doctor-put-meaning ibm 'mach)
(doctor-put-meaning pc 'mach)
(doctor-put-meaning bitching 'foul)
(doctor-put-meaning shit 'foul)
(doctor-put-meaning bastard 'foul)
(doctor-put-meaning damn 'foul)
(doctor-put-meaning damned 'foul)
(doctor-put-meaning hell 'foul)
(doctor-put-meaning suck 'foul)
(doctor-put-meaning sucking 'foul)
(doctor-put-meaning sux 'foul)
(doctor-put-meaning ass 'foul)
(doctor-put-meaning whore 'foul)
(doctor-put-meaning bitch 'foul)
(doctor-put-meaning asshole 'foul)
(doctor-put-meaning shrink 'foul)
(doctor-put-meaning pot 'toke)
(doctor-put-meaning grass 'toke)
(doctor-put-meaning weed 'toke)
(doctor-put-meaning marijuana 'toke)
(doctor-put-meaning acapulco 'toke)
(doctor-put-meaning columbian 'toke)
(doctor-put-meaning tokin 'toke)
(doctor-put-meaning joint 'toke)
(doctor-put-meaning toke 'toke)
(doctor-put-meaning toking 'toke)
(doctor-put-meaning tokin\' 'toke)
(doctor-put-meaning toked 'toke)
(doctor-put-meaning roach 'toke)
(doctor-put-meaning pills 'drug)
(doctor-put-meaning dope 'drug)
(doctor-put-meaning acid 'drug)
(doctor-put-meaning lsd 'drug)
(doctor-put-meaning speed 'drug)
(doctor-put-meaning heroin 'drug)
(doctor-put-meaning hash 'drug)
(doctor-put-meaning cocaine 'drug)
(doctor-put-meaning uppers 'drug)
(doctor-put-meaning downers 'drug)
(doctor-put-meaning loves 'loves)
(doctor-put-meaning love 'love)
(doctor-put-meaning loved 'love)
(doctor-put-meaning hates 'hates)
(doctor-put-meaning dislikes 'hates)
(doctor-put-meaning hate 'hate)
(doctor-put-meaning hated 'hate)
(doctor-put-meaning dislike 'hate)
(doctor-put-meaning stoned 'state)
(doctor-put-meaning drunk 'state)
(doctor-put-meaning drunken 'state)
(doctor-put-meaning high 'state)
(doctor-put-meaning horny 'state)
(doctor-put-meaning blasted 'state)
(doctor-put-meaning happy 'state)
(doctor-put-meaning paranoid 'state)
(doctor-put-meaning wish 'desire)
(doctor-put-meaning wishes 'desire)
(doctor-put-meaning want 'desire)
(doctor-put-meaning desire 'desire)
(doctor-put-meaning like 'desire)
(doctor-put-meaning hope 'desire)
(doctor-put-meaning hopes 'desire)
(doctor-put-meaning desires 'desire)
(doctor-put-meaning wants 'desire)
(doctor-put-meaning desires 'desire)
(doctor-put-meaning likes 'desire)
(doctor-put-meaning needs 'desire)
(doctor-put-meaning need 'desire)
(doctor-put-meaning frustrated 'mood)
(doctor-put-meaning depressed 'mood)
(doctor-put-meaning annoyed 'mood)
(doctor-put-meaning upset 'mood)
(doctor-put-meaning unhappy 'mood)
(doctor-put-meaning excited 'mood)
(doctor-put-meaning worried 'mood)
(doctor-put-meaning lonely 'mood)
(doctor-put-meaning angry 'mood)
(doctor-put-meaning mad 'mood)
(doctor-put-meaning pissed 'mood)
(doctor-put-meaning jealous 'mood)
(doctor-put-meaning afraid 'fear)
(doctor-put-meaning terrified 'fear)
(doctor-put-meaning fear 'fear)
(doctor-put-meaning scared 'fear)
(doctor-put-meaning frightened 'fear)
(doctor-put-meaning virginity 'sexnoun)
(doctor-put-meaning virgins 'sexnoun)
(doctor-put-meaning virgin 'sexnoun)
(doctor-put-meaning cock 'sexnoun)
(doctor-put-meaning cocks 'sexnoun)
(doctor-put-meaning dick 'sexnoun)
(doctor-put-meaning dicks 'sexnoun)
(doctor-put-meaning cunt 'sexnoun)
(doctor-put-meaning cunts 'sexnoun)
(doctor-put-meaning prostitute 'sexnoun)
(doctor-put-meaning condom 'sexnoun)
(doctor-put-meaning sex 'sexnoun)
(doctor-put-meaning rapes 'sexnoun)
(doctor-put-meaning wife 'family)
(doctor-put-meaning family 'family)
(doctor-put-meaning brothers 'family)
(doctor-put-meaning sisters 'family)
(doctor-put-meaning parent 'family)
(doctor-put-meaning parents 'family)
(doctor-put-meaning brother 'family)
(doctor-put-meaning sister 'family)
(doctor-put-meaning father 'family)
(doctor-put-meaning mother 'family)
(doctor-put-meaning husband 'family)
(doctor-put-meaning siblings 'family)
(doctor-put-meaning grandmother 'family)
(doctor-put-meaning grandfather 'family)
(doctor-put-meaning maternal 'family)
(doctor-put-meaning paternal 'family)
(doctor-put-meaning stab 'death)
(doctor-put-meaning murder 'death)
(doctor-put-meaning murders 'death)
(doctor-put-meaning suicide 'death)
(doctor-put-meaning suicides 'death)
(doctor-put-meaning kill 'death)
(doctor-put-meaning kills 'death)
(doctor-put-meaning killing 'death)
(doctor-put-meaning die 'death)
(doctor-put-meaning dies 'death)
(doctor-put-meaning died 'death)
(doctor-put-meaning dead 'death)
(doctor-put-meaning death 'death)
(doctor-put-meaning deaths 'death)
(doctor-put-meaning pain 'symptoms)
(doctor-put-meaning ache 'symptoms)
(doctor-put-meaning fever 'symptoms)
(doctor-put-meaning sore 'symptoms)
(doctor-put-meaning aching 'symptoms)
(doctor-put-meaning stomachache 'symptoms)
(doctor-put-meaning headache 'symptoms)
(doctor-put-meaning hurts 'symptoms)
(doctor-put-meaning disease 'symptoms)
(doctor-put-meaning virus 'symptoms)
(doctor-put-meaning vomit 'symptoms)
(doctor-put-meaning vomiting 'symptoms)
(doctor-put-meaning barf 'symptoms)
(doctor-put-meaning toothache 'symptoms)
(doctor-put-meaning hurt 'symptoms)
(doctor-put-meaning rum 'alcohol)
(doctor-put-meaning gin 'alcohol)
(doctor-put-meaning vodka 'alcohol)
(doctor-put-meaning alcohol 'alcohol)
(doctor-put-meaning bourbon 'alcohol)
(doctor-put-meaning beer 'alcohol)
(doctor-put-meaning wine 'alcohol)
(doctor-put-meaning whiskey 'alcohol)
(doctor-put-meaning scotch 'alcohol)
(doctor-put-meaning fuck 'sexverb)
(doctor-put-meaning fucked 'sexverb)
(doctor-put-meaning screw 'sexverb)
(doctor-put-meaning screwing 'sexverb)
(doctor-put-meaning fucking 'sexverb)
(doctor-put-meaning rape 'sexverb)
(doctor-put-meaning raped 'sexverb)
(doctor-put-meaning kiss 'sexverb)
(doctor-put-meaning kissing 'sexverb)
(doctor-put-meaning kisses 'sexverb)
(doctor-put-meaning screws 'sexverb)
(doctor-put-meaning fucks 'sexverb)
(doctor-put-meaning because 'conj)
(doctor-put-meaning but 'conj)
(doctor-put-meaning however 'conj)
(doctor-put-meaning besides 'conj)
(doctor-put-meaning anyway 'conj)
(doctor-put-meaning that 'conj)
(doctor-put-meaning except 'conj)
(doctor-put-meaning why 'conj)
(doctor-put-meaning how 'conj)
(doctor-put-meaning until 'when)
(doctor-put-meaning when 'when)
(doctor-put-meaning whenever 'when)
(doctor-put-meaning while 'when)
(doctor-put-meaning since 'when)
(doctor-put-meaning rms 'rms)
(doctor-put-meaning stallman 'rms)
(doctor-put-meaning school 'school)
(doctor-put-meaning schools 'school)
(doctor-put-meaning skool 'school)
(doctor-put-meaning grade 'school)
(doctor-put-meaning grades 'school)
(doctor-put-meaning teacher 'school)
(doctor-put-meaning teachers 'school)
(doctor-put-meaning classes 'school)
(doctor-put-meaning professor 'school)
(doctor-put-meaning prof 'school)
(doctor-put-meaning profs 'school)
(doctor-put-meaning professors 'school)
(doctor-put-meaning mit 'school)
(doctor-put-meaning emacs 'eliza)
(doctor-put-meaning eliza 'eliza)
(doctor-put-meaning liza 'eliza)
(doctor-put-meaning elisa 'eliza)
(doctor-put-meaning weizenbaum 'eliza)
(doctor-put-meaning doktor 'eliza)
(doctor-put-meaning athletics 'sports)
(doctor-put-meaning baseball 'sports)
(doctor-put-meaning basketball 'sports)
(doctor-put-meaning football 'sports)
(doctor-put-meaning frisbee 'sports)
(doctor-put-meaning gym 'sports)
(doctor-put-meaning gymnastics 'sports)
(doctor-put-meaning hockey 'sports)
(doctor-put-meaning lacrosse 'sports)
(doctor-put-meaning soccer 'sports)
(doctor-put-meaning softball 'sports)
(doctor-put-meaning sports 'sports)
(doctor-put-meaning swimming 'sports)
(doctor-put-meaning swim 'sports)
(doctor-put-meaning tennis 'sports)
(doctor-put-meaning volleyball 'sports)
(doctor-put-meaning math 'math)
(doctor-put-meaning mathematics 'math)
(doctor-put-meaning mathematical 'math)
(doctor-put-meaning theorem 'math)
(doctor-put-meaning axiom 'math)
(doctor-put-meaning lemma 'math)
(doctor-put-meaning algebra 'math)
(doctor-put-meaning algebraic 'math)
(doctor-put-meaning trig 'math)
(doctor-put-meaning trigonometry 'math)
(doctor-put-meaning trigonometric 'math)
(doctor-put-meaning geometry 'math)
(doctor-put-meaning geometric 'math)
(doctor-put-meaning calculus 'math)
(doctor-put-meaning arithmetic 'math)
(doctor-put-meaning zippy 'zippy)
(doctor-put-meaning zippy 'zippy)
(doctor-put-meaning pinhead 'zippy)
(doctor-put-meaning chat 'chat)
;;;###autoload
(defun doctor ()
"Switch to *doctor* buffer and start giving psychotherapy."
(interactive)
(switch-to-buffer "*doctor*")
(doctor-mode))
(defun doctor-ret-or-read (arg)
"Insert a newline if preceding character is not a newline.
Otherwise call the Doctor to parse preceding sentence."
(interactive "*p" doctor-mode)
(if (= (preceding-char) ?\n)
(doctor-read-print)
(newline arg)))
(defun doctor-read-print ()
"Top level loop."
(interactive nil doctor-mode)
(setq doctor-sent (doctor-readin))
(insert "\n")
(setq doctor--lincount (1+ doctor--lincount))
(doctor-doc)
(insert "\n")
(setq doctor--bak doctor-sent))
(defun doctor-readin ()
"Read a sentence. Return it as a list of words."
(let (sentence)
(backward-sentence 1)
(while (not (eobp))
(setq sentence (append sentence (list (doctor-read-token)))))
sentence))
(defun doctor-read-token ()
"Read one word from buffer."
(prog1 (intern (downcase (buffer-substring (point)
(progn
(forward-word 1)
(point)))))
(re-search-forward "\\Sw*")))
;; Main processing function for sentences that have been read.
(defun doctor-doc ()
(cond
((equal doctor-sent '(foo))
(doctor-type '(bar! (doc$ doctor--please) (doc$ doctor--continue) \.)))
((member doctor-sent doctor--howareyoulst)
(doctor-type '(i\'m ok \. (doc$ doctor--describe) yourself \.)))
((or (member doctor-sent '((good bye) (see you later) (i quit) (so long)
(go away) (get lost)))
(memq (car doctor-sent)
'(bye halt break quit done exit goodbye
bye\, stop pause goodbye\, stop pause)))
(doctor-type (doc$ doctor--bye)))
((and (eq (car doctor-sent) 'you)
(memq (cadr doctor-sent) doctor--abusewords))
(setq doctor-found (cadr doctor-sent))
(doctor-type (doc$ doctor--abuselst)))
((eq (car doctor-sent) 'whatmeans)
(doctor-def (cadr doctor-sent)))
((equal doctor-sent '(parse))
(doctor-type (list 'subj '= doctor-subj ", "
'verb '= doctor-verb "\n"
'object 'phrase '= doctor-obj ","
'noun 'form '= doctor-object "\n"
'current 'keyword 'is doctor-found
", "
'most 'recent 'possessive
'is doctor-owner "\n"
'sentence 'used 'was
"..."
'(doc// doctor--bak))))
((memq (car doctor-sent) '(are is do has have how when where who why))
(doctor-type (doc$ doctor--qlist)))
;; ((eq (car sent) 'forget)
;; (set (cadr sent) nil)
;; (doctor-type '((doc$ doctor--isee) (doc$ doctor--please)
;; (doc$ doctor--continue)\.)))
(t
(if (doctor-defq doctor-sent) (doctor-define doctor-sent doctor-found))
(if (> (length doctor-sent) 12)
(setq doctor-sent (doctor-shorten doctor-sent)))
(setq doctor-sent (doctor-correct-spelling
(doctor-replace doctor-sent doctor--replist)))
(cond ((and (not (memq 'me doctor-sent)) (not (memq 'i doctor-sent))
(memq 'am doctor-sent))
(setq doctor-sent (doctor-replace doctor-sent '((am . (are)))))))
(cond ((equal (car doctor-sent) 'yow) (doctor-zippy))
((< (length doctor-sent) 2)
(cond ((eq (doctor-meaning (car doctor-sent)) 'howdy)
(doctor-howdy))
(t (doctor-short))))
(t
(if (memq 'am doctor-sent)
(setq doctor-sent (doctor-replace doctor-sent '((me . (i))))))
(setq doctor-sent (doctor-fixup doctor-sent))
(if (and (eq (car doctor-sent) 'do) (eq (cadr doctor-sent) 'not))
(cond ((zerop (random 3))
(doctor-type '(are you (doc$ doctor--afraidof) that \?)))
((zerop (random 2))
(doctor-type '(don\'t tell me what to do \. i am the
doctor here!))
(doctor-rthing))
(t
(doctor-type '((doc$ doctor--whysay) that i shouldn\'t
(cddr doctor-sent)
\?))))
(doctor-go (doctor-wherego doctor-sent))))))))
;; Things done to process sentences once read.
(defun doctor-correct-spelling (sent)
"Correct the spelling and expand each word in sentence."
(if sent
(apply 'append (mapcar (lambda (word)
(if (memq word doctor--typos)
(get (get word 'doctor-correction)
'doctor-expansion)
(list word)))
sent))))
(defun doctor-shorten (sent)
"Make a sentence manageably short using a few hacks."
(let (foo
(retval sent)
(temp '(because but however besides anyway until
while that except why how)))
(while temp
(setq foo (memq (car temp) sent))
(if (and foo
(> (length foo) 3))
(setq retval (doctor-fixup foo)
temp nil)
(setq temp (cdr temp))))
retval))
(defun doctor-define (sent found)
(doctor-svo sent found 1 nil)
(and
(doctor-nounp doctor-subj)
(not (doctor-pronounp doctor-subj))
doctor-subj
(doctor-meaning doctor-object)
(put doctor-subj 'doctor-meaning (doctor-meaning doctor-object))
t))
(defun doctor-defq (sent)
"Set global var DOCTOR-FOUND to first keyword found in sentence SENT."
(setq doctor-found nil)
(let ((temp '(means applies mean refers refer related
similar defined associated linked like same)))
(while temp
(if (memq (car temp) sent)
(setq doctor-found (car temp)
temp nil)
(setq temp (cdr temp)))))
doctor-found)
(defun doctor-def (x)
(doctor-type (list 'the 'word x 'means (doctor-meaning x) 'to 'me))
nil)
(defun doctor-forget ()
"Delete the last element of the history list."
(setq doctor--history (reverse (cdr (reverse doctor--history)))))
(defun doctor-query (x)
"Prompt for a line of input from the minibuffer until a noun or verb is seen.
Put dialogue in buffer."
(let (a
(prompt (concat (doctor-make-string x)
" what ? "))
retval)
(while (not retval)
(while (not a)
(insert ?\n
prompt