10 REM
20 REM	ELISA DOCTOR
30 REM	CREATED BY JOSEPH WEIZENBAUM
40 REM	THIS VERSION BY JEFF SHRAGER
50 REM	EDITED AND MODIFIED FOR MITS 8K BASIC 4.0 BY 
60 REM	STEVE NORTH -- CREATIVE COMPUTING
70 REM	PO BOX 789-M MORRISTOWN NJ  07960
80 REM
90 REM	-INITIALIZATION-
100 HOME:CLEAR 1000
110 DIM C$(72),I$(72),K$(72),F$(72),S$(72),R$(72),P$(72),Z$(72)
120 DIM S(36),R(36),N(36)
130 N1=36:N2=12:N3=112
140 FOR X=1 TO N1+N2+N3:READ Z$:NEXT X:REM SAME AS RESTORE
150 FOR X=1 TO N1
160 READ S(X),L:R(X)=S(X):N(X)=S(X)+L-1
170 NEXT X
180 PRINT "HI!  I'M ELIZA.  WHAT'S YOUR PROBLEM?"
190 REM
200 REM	-USER INPUT SECTION-
210 REM
220 INPUT I$
230 I$=" "+I$+" "
240 REM	GET RID OF APOSTROPHES
250 FOR L=1 TO LEN(I$)
260 IF MID$(I$,L,1)="'"

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