-
Notifications
You must be signed in to change notification settings - Fork 0
/
ELIZA.BAS
203 lines (203 loc) · 7.45 KB
/
ELIZA.BAS
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
10 DIM S(36),R(36),N(36)
20 N1=36:N2=14:N3=112
30 RESTORE 2030
40 FOR X=1 TO N1
50 READ S(X),L:R(X)=S(X):N(X)=S(X)+L-1
60 NEXT X
70 CLS:PRINT "HI! I'M ELIZA. I AM YOUR PERSONAL THERAPY COMPUTER. PLEASE TELL ME YOUR PROBLEM. (PLEASE TYPE IN CAPITAL LETTERS)"
80 REM
90 REM -----USER INPUT SECTION------
100 REM
110 INPUT I$
120 I$=" "+I$+" "
130 REM GET RID OF APOSTROPHES
140 FOR L=1 TO LEN(I$)
150 IF MID$(I$,L,1)="'" THEN I$=LEFT$(I$,L-1)+RIGHT$(I$,LEN(I$)-L):GOTO 150
160 IF L+4<=LEN(I$) THEN IF MID$(I$,L,4)="SHUT" THEN PRINT "SHUT UP...":END
170 NEXT L
180 IF I$=P$ THEN PRINT "PLEASE DON'T REPEAT YOURSELF!":GOTO 80
190 REM
200 REM ------FIND KEYWORD IN I$------
210 REM
220 RESTORE
230 S=0
240 FOR K=1 TO N1
250 READ K$
260 IF S>0 THEN 300
270 L=INSTR(I$,K$)
280 IF L>0 THEN S=K:T=L:F$=K$
300 NEXT K
310 IF S>0 THEN K=S:L=T:GOTO 340
320 K=36:GOTO 600:REM WE DIDN'FIND ANY KEYWORDS
330 REM
340 REM TAKE RIGHT PART OF STRING AND CONJUGATE IT
350 REM USING THE LIST OF STRINGS TO BE SWAPPED
360 REM
370 RESTORE 820
400 C$=" "+RIGHT$(I$,LEN(I$)-LEN(F$)-L+1)+" "
410 FOR X=1 TO N2/2
420 READ S$,R$
430 FOR L=1 TO LEN(C$)
440 IF L+LEN(S$)>LEN(C$) THEN 490
450 IF MID$(C$,L,LEN(S$))<>S$ THEN 490
460 C$=LEFT$(C$,L-1)+R$+RIGHT$(C$,LEN(C$)-L-LEN(S$)+1)
470 L=L+LEN(R$)
480 GOTO 530
490 IF L+LEN(R$)>LEN(C$) THEN 530
500 IF MID$(C$,L,LEN(R$))<>R$ THEN 530
510 C$=LEFT$(C$,L-1)+S$+RIGHT$(C$,LEN(C$)-L-LEN(R$)+1)
520 L=L+LEN(S$)
530 NEXT L
540 NEXT X
550 IF MID$(C$,2,1)=" "THEN C$=RIGHT$(C$,LEN(C$)-1)
560 FOR L=1 TO LEN(C$)
570 IF MID$(C$,L,1)="!" THEN C$=LEFT$(C$,L-1)+RIGHT$(C$,LEN(C$)-L):GOTO 570
580 NEXT L
590 REM
600 REM NOW USING THE KEYWORD NUMBER (K) GET REPLY
610 REM
620 RESTORE 880
630 FOR X=1 TO R(K):READ F$: NEXT X
640 R(K)=R(K)+1: IF R(K)>N(K) THEN R(K)=S(K)
650 IF RIGHT$(F$, 1)<>"*" THEN PRINT F$:P$=I$:GOTO 80
660 PRINT LEFT$(F$,LEN(F$)-1);C$
670 P$=I$:GOTO 80
680 REM
690 REM ------PROGRAM DATA FOLLOWS
700 REM
710 REM KEYWORDS
720 REM
730 DATA "CAN YOY", "CAN I", "YOU ARE", "YOU'RE", "I DON'T", "I FEEL"
740 DATA "WHY DON'T YOU", "WHY CAN'T I", "ARE YOU", "I CAN'T", "I AM", "I'M"
750 DATA "YOU", "I WANT", "WHAT", "HOW", "WHO", "WHERE", "WHEN", "WHY"
760 DATA "NAME", "CAUSE", "SORRY", "DREAM", "HELLO", "HI", "MAYBE"
770 DATA "NO", "YOUR", "ALWAYS", "THINK", "ALIKE", "YES", "FRIEND"
780 DATA "COMPUTER", "NO KEY FOUND"
790 REM
800 REM STRING DATA FOR CONJUGATIONS
810 REM
820 DATA " ARE ", " AM ", "WE'RE ", " WAS ", " YOU ", " I ", " YOUR ", " MY "
830 DATA " I'VE ", " YOU'VE ", " I'M ", " YOU'RE "
840 DATA " ME ", " !YOU "
850 REM
860 REM REPLIES
870 REM
880 DATA "DON'T YOU BELIEVE THAT I CAN*"
890 DATA "PERHAPS YOU WOULD LIKE TO BE ABLE TO*"
900 DATA "YOU WANT ME TO BE ABLE TO*"
910 DATA "PERHAPS YOU DON'T WANT TO*"
920 DATA "DO YOU WANT TO BE ABLE TO*"
930 DATA "WHAT MAKES YOU THINK I AM*"
940 DATA "DOES IT PLEASE YOU TO BELIEVE I AM*"
950 DATA "PERHAPS YOU WOULD LIKE TO BE*"
960 DATA "DO YOU SOMETIMES WISH YOU WERE*"
970 DATA "DON'T YOU REALLY*"
980 DATA "WHY DON'T YOU*"
990 DATA "DO YOU WISH TO BE ABLE TO*"
1000 DATA "DOES THAT TROUBLE YOU?"
1010 DATA "TELL ME MORE ABOUT SUCH FEELINGS."
1020 DATA "DO YOU OFTEN FEEL*"
1030 DATA "DO YOU ENJOY FEELING*"
1040 DATA "DO YOU REALLY BELIEVE I DON'T*"
1050 DATA "PERHAPS IN GOOD TIME I WILL*"
1060 DATA "DO YOU WANT ME TO*"
1070 DATA "DO YOU THINK YOU SHOULD BE ABLE TO*"
1080 DATA "WHY CAN'T YOU*"
1090 DATA "WHY ARE YOU INTERESTED IN WHETHER OR NOT I AM*"
1100 DATA "WOULD YOU PREFER IF I WERE NOT*"
1110 DATA "PERHAPS IN YOUR FANTASIES I AM*"
1120 DATA "HOW DO YOU KNOW YOU CAN'T*"
1130 DATA "HAVE YOU TRIED?"
1140 DATA "PERHAPS YOU CAN NOW*"
1150 DATA "DID YOU COME TO ME BECAUSE YOU ARE*"
1160 DATA "HOW LONG HAVE YOU BEEN*"
1170 DATA "DO YOU BELIEVE IT IS NORMAL TO BE*"
1180 DATA "DO YOU ENJOY BEING*"
1190 DATA "WE WERE DISCUSSING YOU --NOT ME."
1200 DATA "OH, I*"
1210 DATA "YOU'RE NOT REALLY TALKING ABOUT ME, ARE YOU?"
1220 DATA "WHAT WOULD IT MEAN TO YOU IF YOU GOT*"
1230 DATA "WHY DO YOU WANT*"
1240 DATA "SUPPOSE YOU GOT*"
1250 DATA "WHAT IF YOU NEVER GOT*"
1260 DATA "I SOMETIMES ALSO WANT*"
1270 DATA "WHY DO YOU ASK?"
1280 DATA "DOES THAT QUESTION INTEREST YOU?"
1290 DATA "WHAT ANSWER WOULD PLEASE YOU THE MOST?"
1300 DATA "WHAT DO YOU THINK?"
1310 DATA "ARE SUCH QUESTIONS ON YOUR MIND OFTEN?"
1320 DATA "WHAT IS IT THAT YOU REALLY WANT TO KNOW?"
1330 DATA "HAVE YOU ASKED ANYONE ELSE?"
1340 DATA "HAVE YOU ASKED SUCH QUESTIONS BEFORE?"
1350 DATA "WHAT ELSE COMES TO MIND WHEN YOU ASK THAT?"
1360 DATA "NAMES DON'T INTEREST ME."
1370 DATA "I DON'T CARE ABOUT NAMES--PLEASE GO ON."
1380 DATA "IS THAT THE REAL REASON?"
1390 DATA "DON'T ANY OTHER REASONS COME TO MIND?"
1400 DATA "DOES THAT REASON EXPLAIN ANYTHING ELSE?"
1410 DATA "WHAT OTHER REASONS MIGHT THERE BE?"
1420 DATA "PLEASE DON'T APOLOGISE!"
1430 DATA "APOLOGIES ARE NOT NECESSARY."
1440 DATA "WHAT FEELINGS DO YOU HAVE WHEN YOU APOLOGISE?"
1450 DATA "DON'T BE SO DEFENSIVE!"
1460 DATA "WHAT DOES THAT DREAM SUGGEST TO YOU?"
1470 DATA "DO YOU DREAM OFTEN?"
1480 DATA "WHAT PERSONS APPEAR IN YOUR DREAMS?"
1490 DATA "ARE YOU DISTURBED BY YOUR DREAMS?"
1500 DATA "HOW DO YOU...PLEASE STATE YOUR PROBLEM."
1510 DATA "YOU DON'T SEEM QUITE CERTAIN."
1520 DATA "WHY THE UNCERTAIN TONE?"
1530 DATA "CAN'T YOU BE MORE POSITIVE?"
1540 DATA "YOU AREN'T SURE?"
1550 DATA "DON'T YOU KNOW?"
1560 DATA "ARE YOU SAYING NO JUST TO BE NEGATIVE?"
1570 DATA "YOU ARE BEING A BIT NEGATIVE."
1580 DATA "WHY NOT?"
1590 DATA "ARE YOU SURE?"
1600 DATA "WHY NO?"
1610 DATA "WHY ARE YOU CONCERNED ABOUT MY*"
1620 DATA "WHAT ABOUT YOUR OWN*"
1630 DATA "CAN YOU THINK OF A SPECIFIC EXAMPLE?"
1640 DATA "WHEN?"
1650 DATA "WHAT ARE YOU THINKING OF?"
1660 DATA "REALLY,ALWAYS?"
1670 DATA "DO YOU REALLY THINK SO?"
1680 DATA "BUT YOU ARE NOT SURE YOU*"
1690 DATA "DO YOU DOUBT YOU*"
1700 DATA "IN WHAT WAY?"
1710 DATA "WHAT RESEMBLENCE DO YOU SEE?"
1720 DATA "WHAT DOES THE SIMILARITY SUGGEST TO YOU?"
1730 DATA "WHAT OTHER CONNECTIONS DO YOU SEE?"
1740 DATA "COULD THERE REALLY BE SOME CONNECTION?"
1750 DATA "HOW?"
1760 DATA "YOU SEEM QUITE POSITIVE."
1770 DATA "ARE YOU SURE?"
1780 DATA "I SEE."
1790 DATA "I UNDERSTAND."
1800 DATA "WHY DO YOU BRING UP THE TOPIC OF FRIENDS?"
1810 DATA "DO YOUR FRIENDS WORRY YOU?"
1820 DATA "DO YOUR FRIENDS PICK ON YOU?"
1830 DATA "ARE YOU SURE YOU HAVE ANY FRIENDS?"
1840 DATA "DO YOU IMPOSE ON YOUR FRIENDS?"
1850 DATA "PERHAPS YOUR LOVE FOR FRIENDS WORRIES YOU."
1860 DATA "DO COMPUTERS WORRY YOU?"
1870 DATA "ARE YOU TALKING ABOUT ME IN PARTICULAR?"
1880 DATA "ARE YOU FRIGHTENED BY MACHINES?"
1890 DATA "WHY DO YOU MENTION COMPUTERS?"
1900 DATA "WHAT DO YOU THINK MACHINES HAVE TO DO WITH YOUR PROBLEMS?"
1910 DATA "DON'T YOU THINK COMPUTERS CAN HELP PEOPLE?"
1920 DATA "WHAT IS IT ABOUT MACHINES THAT WORRIES YOU?"
1930 DATA "SAY, DO YOU HAVE ANY PSYCHOLOGICAL PROBLEMS?"
1940 DATA "WHAT DOES THAT SUGGEST TO YOU?"
1950 DATA "I SEE."
1960 DATA "I'M NOT SURE I UNDERSTAND YOU FULLY."
1970 DATA "COME, COME, ELUCIDATE YOUR THOUGHTS."
1980 DATA "CAN YOU ELABORATE ON THAT?"
1990 DATA "THAT IS QUITE INTERESTING."
2000 REM
2010 REM DATA FOR FINDING RIGHT REPLIES
2020 REM
2030 DATA 1,3,4,2,6,4,6,4,10,4,14,3,17,3,20,2,22,3,25,3
2040 DATA 28,4,28,4,32,3,35,5,40,9,40,9,40,9,40,9,40,9,40,9
2050 DATA 49,2,51,4,55,4,59,4,63,1,63,1,64,5,69,5,74,2,76,4
2060 DATA 80,3,83,7,90,3,93,6,99,7,106,6