doctor.el 56 KB

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