'cls ? chr$(27)+"[90m"; ? "**************************" ? "ELIZA" ? "CREATIVE COMPUTING" ? "MORRISTOWN, NEW JERSEY" ? ? "ADAPTED FOR IBM PC BY" ? "PATRICIA DANIELSON AND" ? " PAUL HASHFIELD" ? ? "PLEASE DON''T USE COMMAS" ? "OR PERIODS IN YOUR INPUTS" ? "*************************" ?:?:? '' INITIALIZATION DIM S(36),R(36),N(36) DIM KEYWORD(36),WORDIN(7) DIM WORDOUT(7),REPLIES(112) N1=36:N2=14:N3=112 FOR X = 1 TO N1 READ KEYWORD(X) NEXT X FOR X = 1 TO N2/2 READ WORDIN(X) READ WORDOUT(X) NEXT X FOR X = 1 TO N3 READ REPLIES(X) NEXT X FOR X=1 TO N1 READ S(X),L R(X)=S(X) N(X)=S(X)+L-1 NEXT X ? "HI! I''M ELIZA. WHAT''S YOUR PROBLEM?" LABEL HI '' USER INPUT SECTION 200 INPUT I I=UCASE$(I) I=" "+I+" " '' GET RID OF APOSTROPHES FOR L=1 TO LEN(I) if L+4>LEN(I) THEN 250 IF MID(I,L,4) <> "SHUT" THEN 250 ? "O.K. IF YOU FEEL THAT WAY I''LL SHUT UP...." END 250 NEXT L IF I=P ? "PLEASE DON''T REPEAT YOURSELF!" GOTO HI fi 270 '' FIND KEYWORD IN I FOR K=1 TO N1 FOR L=1 TO LEN(I)-LEN(KEYWORD(K))+1 IF MID(I,L,LEN(KEYWORD(K)))<>KEYWORD(K) THEN 350 IF K<>13 THEN 349 IF MID(I,L,LEN(KEYWORD(29)))=KEYWORD(29) THEN K=29 349 F = KEYWORD(K) GOTO 390 350 NEXT L NEXT K 370 K=36: GOTO 570 390 '' '' TAKE PART OF STRING AND CONJUGATE IT '' C=" "+RIGHT(I,LEN(I)-LEN(F)-L+1)+" " FOR X=1 TO N2/2 FOR L=1 TO LEN(C) IF L+LEN(WORDIN(X))>LEN(C) THEN 510 IF MID(C,L,LEN(WORDIN(X)))<>WORDIN(X) THEN 510 C=LEFT(C,L-1)+WORDOUT(X)+RIGHT(C,LEN(C)-L-LEN(WORDIN(X))+1) L = L+LEN(WORDOUT(X)) GOTO 540 510 IF L+LEN(WORDOUT(X))>LEN(C) THEN 540 IF MID(C,L,LEN(WORDOUT(X)))<>WORDOUT(X) THEN 540 C=LEFT(C,L-1)+WORDIN(X)+RIGHT(C,LEN(C)-L-LEN(WORDOUT(X))+1) L=L+LEN(WORDIN(X)) 540 NEXT L NEXT X IF MID(C,2,1)=" " THEN C=RIGHT(C,LEN(C)-1) FI FOR L=1 TO LEN(C) 557 IF MID(C,L,1)="!" C=LEFT(C,L-1)+RIGHT(C,LEN(C)-L) GOTO 557 FI NEXT L 570 F = REPLIES(R(K)) R(K)=R(K)+1 IF R(K)>N(K) THEN R(K)=S(K) IF RIGHT(F,1)<>"*" THEN ? F P=I GOTO HI FI IF C<>" " then 630 ? "YOU WILL HAVE TO ELABORATE MORE FOR ME TO HELP YOU" GOTO HI 630 ? LEFT(F,LEN(F)-1);C P=I GOTO HI '' === DATA === '' KEYWORDS DATA "CAN YOU ","CAN I ","YOU ARE ","YOU''RE " DATA "I DON''T ","I FEEL " DATA "WHY DON''T YOU ","WHY CAN''T I ","ARE YOU " DATA "I CAN''T ","I AM ","I''M " DATA "YOU ","I WANT ","WHAT ","HOW ","WHO " DATA "WHERE ","WHEN ","WHY " DATA "NAME ","CAUSE ","SORRY ","DREAM " DATA "HELLO ","HI ","MAYBE " DATA "NO","YOUR ","ALWAYS ","THINK " DATA "ALIKE ","YES ","FRIEND " DATA "COMPUTER", "NOKEYFOUND" '' STRING DATA FOR CONJUGATIONS DATA " ARE "," AM "," WERE "," WAS " DATA " YOU "," I "," YOUR"," MY " DATA " I''VE "," YOU''VE "," I''M "," YOU''RE " DATA " ME "," YOU " '' REPLIES DATA "DON''T YOU BELIEVE THAT I CAN*" DATA "PERHAPS YOU WOULD LIKE TO BE LIKE ME*" DATA "YOU WANT ME TO BE ABLE TO*" DATA "PERHAPS YOU DON''T WANT TO*" DATA "DO YOU WANT TO BE ABLE TO*" DATA "WHAT MAKES YOU THINK I AM*" DATA "DOES IT PLEASE YOU TO BELIEVE I AM*" DATA "PERHAPS YOU WOULD LIKE TO BE*" DATA "DO YOU SOMETIMES WISH YOU WERE*" DATA "DON''T YOU REALLY*" DATA "WHY DON''T YOU*" DATA "DO YOU WISH TO BE ABLE TO*" DATA "DOES THAT TROUBLE YOU*" DATA "DO YOU OFTEN FEEL*" DATA "DO YOU OFTEN FEEL*" DATA "DO YOU ENJOY FEELING*" DATA "DO YOU REALLY BELIEVE I DON''T*" DATA "PERHAPS IN GOOD TIME I WILL*" DATA "DO YOU WANT ME TO*" DATA "DO YOU THINK YOU SHOULD BE ABLE TO*" DATA "WHY CAN''T YOU*" DATA "WHY ARE YOU INTERESTED IN WHETHER OR NOT I AM*" DATA "WOULD YOU PREFER IF I WERE NOT*" DATA "PERHAPS IN YOUR FANTASIES I AM*" DATA "HOW DO YOU KNOW YOU CAN''T*" DATA "HAVE YOU TRIED?" DATA "PERHAPS YOU CAN NOW*" DATA "DID YOU COME TO ME BECAUSE YOU ARE*" DATA "HOW LONG HAVE YOU BEEN*" DATA "DO YOU BELIEVE IT IS NORMAL TO BE*" DATA "DO YOU ENJOY BEING*" DATA "WE WERE DISCUSSING YOU--NOT ME." DATA "OH, I*" DATA "YOU''RE NOT REALLY TALKING ABOUT ME, ARE YOU?" DATA "WHAT WOULD IT MEAN TO YOU IF YOU GOT*" DATA "WHY DO YOU WANT*" DATA "SUPPOSE YOU SOON GOT*" DATA "WHAT IF YOU NEVER GOT*" DATA "I SOMETIMES ALSO WANT*" DATA "WHY DO YOU ASK?" DATA "DOES THAT QUESTION INTEREST YOU?" DATA "WHAT ANSWER WOULD PLEASE YOU THE MOST?" DATA "WHAT DO YOU THINK?" DATA "ARE SUCH QUESTIONS ON YOUR MIND OFTEN?" DATA "WHAT IS IT THAT YOU REALLY WANT TO KNOW?" DATA "HAVE YOU ASKED ANYONE ELSE?" DATA "HAVE YOU ASKED SUCH QUESTIONS BEFORE?" DATA "WHAT ELSE COMES TO MIND WHEN YOU ASK THAT?" DATA "NAMES DON''T INTEREST ME." DATA "I DON''T CARE ABOUT NAMES --PLEASE GO ON." DATA "IS THAT THE REAL REASON?" DATA "DON''T ANY OTHER REASONS COME TO MIND?" DATA "DOES THAT REASON EXPLAIN ANYTHING ELSE?" DATA "WHAT OTHER REASONS MIGHT THERE BE?" DATA "PLEASE DON''T APOLOGIZE!" DATA "APOLOGIES ARE NOT NECESSARY." DATA "WHAT FEELINGS DO YOU HAVE WHEN YOU APOLOGIZE?" DATA "DON''T BE SO DEFENSIVE!" DATA "WHAT DOES THAT DREAM SUGGEST TO YOU?" DATA "DO YOU DREAM OFTEN?" DATA "WHAT PERSONS APPEAR IN YOUR DREAMS?" DATA "ARE YOU DISTURBED BY YOUR DREAMS?" DATA "HOW DO YOU DO ...PLEASE STATE YOUR PROBLEM." DATA "YOU DON''T SEEM QUITE CERTAIN." DATA "WHY THE UNCERTAIN TONE?" DATA "CAN''T YOU BE MORE POSITIVE?" DATA "YOU AREN''T SURE?" DATA "DON''T YOU KNOW?" DATA "ARE YOU SAYING NO JUST TO BE NEGATIVE?" DATA "YOU ARE BEING A BIT NEGATIVE." DATA "WHY NOT?" DATA "ARE YOU SURE?" DATA "WHY NO?" DATA "WHY ARE YOU CONCERNED ABOUT MY*" DATA "WHAT ABOUT YOUR OWN*" DATA "CAN YOU THINK OF A SPECIFIC EXAMPLE?" DATA "WHEN?" DATA "WHAT ARE YOU THINKING OF?" DATA "REALLY, ALWAYS?" DATA "DO YOU REALLY THINK SO?" DATA "BUT YOU ARE NOT SURE YOU*" DATA "DO YOU DOUBT YOU*" DATA "IN WHAT WAY?" DATA "WHAT RESEMBLANCE DO YOU SEE?" DATA "WHAT DOES THE SIMILARITY SUGGEST TO YOU?" DATA "WHAT OTHER CONNECTIONS DO YOU SEE?" DATA "COULD THERE REALLY BE SOME CONNECTION?" DATA "HOW?" DATA "YOU SEEM QUITE POSITIVE." DATA "ARE YOU SURE?" DATA "I SEE." DATA "I UNDERSTAND." DATA "WHY DO YOU BRING UP THE TOPIC OF FRIENDS?" DATA "DO YOUR FRIENDS WORRY YOU?" DATA "DO YOUR FRIENDS PICK ON YOU?" DATA "ARE YOU SURE YOU HAVE ANY FRIENDS?" DATA "DO YOU IMPOSE ON YOUR FRIENDS?" DATA "PERHAPS YOUR LOVE FOR FRIENDS WORRIES YOU." DATA "DO COMPUTERS WORRY YOU?" DATA "ARE YOU TALKING ABOUT ME IN PARTICULAR?" DATA "ARE YOU FRIGHTENED BY MACHINES?" DATA "WHY DO YOU MENTION COMPUTERS?" DATA "WHAT DO YOU THINK MACHINES HAVE TO DO WITH YOUR PROBLEM?" DATA "DON''T YOU THINK COMPUTERS CAN HELP PEOPLE?" DATA "WHAT IS IT ABOUT MACHINES THAT WORRIES YOU?" DATA "SAY, DO YOU HAVE ANY PSYCHOLOGICAL PROBLEMS?" DATA "WHAT DOES THAT SUGGEST TO YOU?" DATA "I SEE." DATA "I''M NOT SURE I UNDERSTAND YOU FULLY." DATA "COME COME ELUCIDATE YOUR THOUGHTS." DATA "CAN YOU ELABORATE ON THAT?" DATA "THAT IS QUITE INTERESTING." '' DATA FOR FINDING RIGHT REPLIES DATA 1,3,4,2,6,4,6,4,10,4,14,3,17 DATA 3,20,2,22,3,25,3 DATA 28,4,28,4,32,3,35,5,40,9,40 DATA 9,40,9,40,9,40,9,40,9 DATA 49,2,51,4,55,4,59,4,63,1,63 DATA 1,64,5,69,5,74,2,76,4 DATA 80,3,83,7,90,3,93,6,99,7,106,6 '