Mercurial > emacs
comparison lisp/play/doctor.el @ 47322:8a11a2109567
(doctor-cadr, doctor-caddr, doctor-cddr): Remove.
Update callers.
author | John Paul Wallington <jpw@pobox.com> |
---|---|
date | Mon, 09 Sep 2002 05:50:58 +0000 |
parents | 0b575bd912a4 |
children | d8c0258cdf14 |
comparison
equal
deleted
inserted
replaced
47321:54efbd9f8cab | 47322:8a11a2109567 |
---|---|
42 ;; See also the file etc/CENSORSHIP in the Emacs distribution | 42 ;; See also the file etc/CENSORSHIP in the Emacs distribution |
43 ;; for a discussion of why and how this file was censored, and the | 43 ;; for a discussion of why and how this file was censored, and the |
44 ;; political implications of the issue. | 44 ;; political implications of the issue. |
45 | 45 |
46 ;;; Code: | 46 ;;; Code: |
47 | |
48 (defun doctor-cadr (x) (car (cdr x))) | |
49 (defun doctor-caddr (x) (car (cdr (cdr x)))) | |
50 (defun doctor-cddr (x) (cdr (cdr x))) | |
51 | 47 |
52 (defun // (x) x) | 48 (defun // (x) x) |
53 | 49 |
54 (defmacro $ (what) | 50 (defmacro $ (what) |
55 "quoted arg form of doctor-$" | 51 "quoted arg form of doctor-$" |
89 | 85 |
90 (defun make-doctor-variables () | 86 (defun make-doctor-variables () |
91 (make-local-variable 'typos) | 87 (make-local-variable 'typos) |
92 (setq typos | 88 (setq typos |
93 (mapcar (function (lambda (x) | 89 (mapcar (function (lambda (x) |
94 (put (car x) 'doctor-correction (doctor-cadr x)) | 90 (put (car x) 'doctor-correction (cadr x)) |
95 (put (doctor-cadr x) 'doctor-expansion (doctor-caddr x)) | 91 (put (cadr x) 'doctor-expansion (car (cddr x))) |
96 (car x))) | 92 (car x))) |
97 '((theyll they\'ll (they will)) | 93 '((theyll they\'ll (they will)) |
98 (theyre they\'re (they are)) | 94 (theyre they\'re (they are)) |
99 (hes he\'s (he is)) | 95 (hes he\'s (he is)) |
100 (he7s he\'s (he is)) | 96 (he7s he\'s (he is)) |
890 (memq (car sent) | 886 (memq (car sent) |
891 '(bye halt break quit done exit goodbye | 887 '(bye halt break quit done exit goodbye |
892 bye\, stop pause goodbye\, stop pause))) | 888 bye\, stop pause goodbye\, stop pause))) |
893 (doctor-type ($ bye))) | 889 (doctor-type ($ bye))) |
894 ((and (eq (car sent) 'you) | 890 ((and (eq (car sent) 'you) |
895 (memq (doctor-cadr sent) abusewords)) | 891 (memq (cadr sent) abusewords)) |
896 (setq found (doctor-cadr sent)) | 892 (setq found (cadr sent)) |
897 (doctor-type ($ abuselst))) | 893 (doctor-type ($ abuselst))) |
898 ((eq (car sent) 'whatmeans) | 894 ((eq (car sent) 'whatmeans) |
899 (doctor-def (doctor-cadr sent))) | 895 (doctor-def (cadr sent))) |
900 ((equal sent '(parse)) | 896 ((equal sent '(parse)) |
901 (doctor-type (list 'subj '= subj ", " | 897 (doctor-type (list 'subj '= subj ", " |
902 'verb '= verb "\n" | 898 'verb '= verb "\n" |
903 'object 'phrase '= obj "," | 899 'object 'phrase '= obj "," |
904 'noun 'form '= object "\n" | 900 'noun 'form '= object "\n" |
910 "..." | 906 "..." |
911 '(// bak)))) | 907 '(// bak)))) |
912 ((memq (car sent) '(do has have how when where who why)) | 908 ((memq (car sent) '(do has have how when where who why)) |
913 (doctor-type ($ qlist))) | 909 (doctor-type ($ qlist))) |
914 ;; ((eq (car sent) 'forget) | 910 ;; ((eq (car sent) 'forget) |
915 ;; (set (doctor-cadr sent) nil) | 911 ;; (set (cadr sent) nil) |
916 ;; (doctor-type '(($ isee)($ please) | 912 ;; (doctor-type '(($ isee)($ please) |
917 ;; ($ continue)\.))) | 913 ;; ($ continue)\.))) |
918 (t | 914 (t |
919 (if (doctor-defq sent) (doctor-define sent found)) | 915 (if (doctor-defq sent) (doctor-define sent found)) |
920 (if (> (length sent) 12)(setq sent (doctor-shorten sent))) | 916 (if (> (length sent) 12)(setq sent (doctor-shorten sent))) |
929 (t (doctor-short)))) | 925 (t (doctor-short)))) |
930 (t | 926 (t |
931 (if (memq 'am sent) | 927 (if (memq 'am sent) |
932 (setq sent (doctor-replace sent '((me . (i)))))) | 928 (setq sent (doctor-replace sent '((me . (i)))))) |
933 (setq sent (doctor-fixup sent)) | 929 (setq sent (doctor-fixup sent)) |
934 (if (and (eq (car sent) 'do) (eq (doctor-cadr sent) 'not)) | 930 (if (and (eq (car sent) 'do) (eq (cadr sent) 'not)) |
935 (cond ((zerop (random 3)) | 931 (cond ((zerop (random 3)) |
936 (doctor-type '(are you ($ afraidof) that \?))) | 932 (doctor-type '(are you ($ afraidof) that \?))) |
937 ((zerop (random 2)) | 933 ((zerop (random 2)) |
938 (doctor-type '(don\'t tell me what to do \. i am the | 934 (doctor-type '(don\'t tell me what to do \. i am the |
939 psychiatrist here!)) | 935 psychiatrist here!)) |
940 (doctor-rthing)) | 936 (doctor-rthing)) |
941 (t | 937 (t |
942 (doctor-type '(($ whysay) that i shouldn\'t | 938 (doctor-type '(($ whysay) that i shouldn\'t |
943 (doctor-cddr sent) | 939 (cddr sent) |
944 \?)))) | 940 \?)))) |
945 (doctor-go (doctor-wherego sent)))))))) | 941 (doctor-go (doctor-wherego sent)))))))) |
946 | 942 |
947 ;; Things done to process sentences once read. | 943 ;; Things done to process sentences once read. |
948 | 944 |
1136 (t (intern (concat foo "s")))))) | 1132 (t (intern (concat foo "s")))))) |
1137 | 1133 |
1138 (defun doctor-setprep (sent key) | 1134 (defun doctor-setprep (sent key) |
1139 (let ((val) | 1135 (let ((val) |
1140 (foo (memq key sent))) | 1136 (foo (memq key sent))) |
1141 (cond ((doctor-prepp (doctor-cadr foo)) | 1137 (cond ((doctor-prepp (cadr foo)) |
1142 (setq val (doctor-getnoun (doctor-cddr foo))) | 1138 (setq val (doctor-getnoun (cddr foo))) |
1143 (cond (val val) | 1139 (cond (val val) |
1144 (t 'something))) | 1140 (t 'something))) |
1145 ((doctor-articlep (doctor-cadr foo)) | 1141 ((doctor-articlep (cadr foo)) |
1146 (setq val (doctor-getnoun (doctor-cddr foo))) | 1142 (setq val (doctor-getnoun (cddr foo))) |
1147 (cond (val (doctor-build (doctor-build (doctor-cadr foo) " ") val)) | 1143 (cond (val (doctor-build (doctor-build (cadr foo) " ") val)) |
1148 (t 'something))) | 1144 (t 'something))) |
1149 (t 'something)))) | 1145 (t 'something)))) |
1150 | 1146 |
1151 (defun doctor-getnoun (x) | 1147 (defun doctor-getnoun (x) |
1152 (cond ((null x)(setq object 'something)) | 1148 (cond ((null x)(setq object 'something)) |
1273 | 1269 |
1274 (defun doctor-fix-2 (sent) | 1270 (defun doctor-fix-2 (sent) |
1275 (let ((foo sent)) | 1271 (let ((foo sent)) |
1276 (while foo | 1272 (while foo |
1277 (if (and (eq (car foo) 'me) | 1273 (if (and (eq (car foo) 'me) |
1278 (doctor-verbp (doctor-cadr foo))) | 1274 (doctor-verbp (cadr foo))) |
1279 (rplaca foo 'i) | 1275 (rplaca foo 'i) |
1280 (cond ((eq (car foo) 'you) | 1276 (cond ((eq (car foo) 'you) |
1281 (cond ((memq (doctor-cadr foo) '(am be been is)) | 1277 (cond ((memq (cadr foo) '(am be been is)) |
1282 (rplaca (cdr foo) 'are)) | 1278 (rplaca (cdr foo) 'are)) |
1283 ((memq (doctor-cadr foo) '(has)) | 1279 ((memq (cadr foo) '(has)) |
1284 (rplaca (cdr foo) 'have)) | 1280 (rplaca (cdr foo) 'have)) |
1285 ((memq (doctor-cadr foo) '(was)) | 1281 ((memq (cadr foo) '(was)) |
1286 (rplaca (cdr foo) 'were)))) | 1282 (rplaca (cdr foo) 'were)))) |
1287 ((equal (car foo) 'i) | 1283 ((equal (car foo) 'i) |
1288 (cond ((memq (doctor-cadr foo) '(are is be been)) | 1284 (cond ((memq (cadr foo) '(are is be been)) |
1289 (rplaca (cdr foo) 'am)) | 1285 (rplaca (cdr foo) 'am)) |
1290 ((memq (doctor-cadr foo) '(were)) | 1286 ((memq (cadr foo) '(were)) |
1291 (rplaca (cdr foo) 'was)) | 1287 (rplaca (cdr foo) 'was)) |
1292 ((memq (doctor-cadr foo) '(has)) | 1288 ((memq (cadr foo) '(has)) |
1293 (rplaca (cdr foo) 'have)))) | 1289 (rplaca (cdr foo) 'have)))) |
1294 ((and (doctor-verbp (car foo)) | 1290 ((and (doctor-verbp (car foo)) |
1295 (eq (doctor-cadr foo) 'i) | 1291 (eq (cadr foo) 'i) |
1296 (not (doctor-verbp (car (doctor-cddr foo))))) | 1292 (not (doctor-verbp (car (cddr foo))))) |
1297 (rplaca (cdr foo) 'me)) | 1293 (rplaca (cdr foo) 'me)) |
1298 ((and (eq (car foo) 'a) | 1294 ((and (eq (car foo) 'a) |
1299 (doctor-vowelp (string-to-char | 1295 (doctor-vowelp (string-to-char |
1300 (doctor-make-string (doctor-cadr foo))))) | 1296 (doctor-make-string (cadr foo))))) |
1301 (rplaca foo 'an)) | 1297 (rplaca foo 'an)) |
1302 ((and (eq (car foo) 'an) | 1298 ((and (eq (car foo) 'an) |
1303 (not (doctor-vowelp (string-to-char | 1299 (not (doctor-vowelp (string-to-char |
1304 (doctor-make-string (doctor-cadr foo)))))) | 1300 (doctor-make-string (cadr foo)))))) |
1305 (rplaca foo 'a))) | 1301 (rplaca foo 'a))) |
1306 (setq foo (cdr foo)))) | 1302 (setq foo (cdr foo)))) |
1307 sent)) | 1303 sent)) |
1308 | 1304 |
1309 (defun doctor-vowelp (x) | 1305 (defun doctor-vowelp (x) |
1492 | 1488 |
1493 (defun doctor-desire () | 1489 (defun doctor-desire () |
1494 (let ((foo (memq found sent))) | 1490 (let ((foo (memq found sent))) |
1495 (cond ((< (length foo) 2) | 1491 (cond ((< (length foo) 2) |
1496 (doctor-go (doctor-build (doctor-meaning found) 1))) | 1492 (doctor-go (doctor-build (doctor-meaning found) 1))) |
1497 ((memq (doctor-cadr foo) '(a an)) | 1493 ((memq (cadr foo) '(a an)) |
1498 (rplacd foo (append '(to have) (cdr foo))) | 1494 (rplacd foo (append '(to have) (cdr foo))) |
1499 (doctor-svo sent found 1 nil) | 1495 (doctor-svo sent found 1 nil) |
1500 (doctor-remember (list subj 'would 'like obj)) | 1496 (doctor-remember (list subj 'would 'like obj)) |
1501 (doctor-type ($ whywant))) | 1497 (doctor-type ($ whywant))) |
1502 ((not (eq (doctor-cadr foo) 'to)) | 1498 ((not (eq (cadr foo) 'to)) |
1503 (doctor-go (doctor-build (doctor-meaning found) 1))) | 1499 (doctor-go (doctor-build (doctor-meaning found) 1))) |
1504 (t | 1500 (t |
1505 (doctor-svo sent found 1 nil) | 1501 (doctor-svo sent found 1 nil) |
1506 (doctor-remember (list subj 'would 'like obj)) | 1502 (doctor-remember (list subj 'would 'like obj)) |
1507 (doctor-type ($ whywant)))))) | 1503 (doctor-type ($ whywant)))))) |