Command Prompt for Windows




Batch File ELIZA

The following batch file is an implementation of a computer based psychiatrist that may be able to help you with any psychological problems you may have :-

@ECHO OFF
IF NOT "%winone%"=="" GOTO okay
ECHO This Batch file requires the WinOne(R) Command Prompt to run!
EXIT /b
:okay

SETLOCAL
 
DATA can you,can i,you are,youre,i dont,i feel
DATA why dont you,why cant i,are you,i cant,i am,im
DATA you ,i want,what,how,who,where,when,why
DATA name,cause,sorry,dream,hello,hi ,Maybe
DATA  no,your,always,think,alike,yes,friend
DATA computer,nokeyfound
 
DATA  are , am ,were ,was , you , i ,your ,my
DATA  ive , youve , im , youre
DATA  me , !you
 
DATA Don't you believe that I can*
DATA Perhaps you would like to be able to*
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 Tell me more about such feeling.
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 question 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 apologies.
DATA Don't be so defensive!
DATA What does that dream suggest to you?
DATA Do you dream often?
 
DATA What persons appears in your dreams?
DATA Are you distured 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 metion computers?
DATA What do you think machines have to do with your problem?
DATA Don't you think that 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 1,3,4,2,6,4,6,4,10,4,14,3,17,3,20,2,22,3,25,3
DATA 28,4,28,4,32,3,35,5,40,9,40,9,40,9,40,9,40,9,40,9
DATA 49,2,51,4,55,4,59,4,63,1,63,1,64,5,69,5,74,2,76,4
DATA 80,3,83,7,90,3,93,6,99,7,106,6
 
SET n1=36
SET n2=14
SET n3=112
LET n4=%n2% / 2
 
SET p=
 
LET total=%n1% + %n2% + %n3%
READ %total%
 
FOR %%x IS 1 TO %n1% DO {
    READ
    SET s.%%x=%read%
    SET r.%%x=%read%
    SET t=%read%
 
    READ
    LET n.%%x=(%s.%%x% + %read% - 1)
}
 
ECHO Hi!  I'm Eliza Jr.  What's your problem?
 
:start
GETSTR ^>
LOWER %getstr%
SET i=%lower%
 
STRREP "'" "" %i%
SET i=%strrep%
IF ("%i%" == "exit " || "%i%" == "quit ") {
    ECHO Bye bye.
    ENDLOCAL
    END
}
 
IF ("%i%" == " ") {
    GOTO start
} ELSE IF ("%i%" == "%p%") {
    ECHO Please do not repeat yourself!
    GOTO start
}
 
READ 0
SET s=0
FOR %%k IS 1 TO %n1% DO {
    READ
    IF (%s% <= 0) {
        STRFIND "%read%" %i%
        IF (%strfind% != 0) {
            SET s=%%k
            SET t=%strfind%
            SET f=%read%&
        }
    }
}
 
IF (%s% <= 0) {
    SET k=36
    GOTO next
}
 
SET k=%s%
SET l=%t%
 
STRSIZE %f%
LET index=%l% + %strsize%
STRSIZE %i%
SUBSTR %index% %strsize% %i%
SET c= %substr%
 
READ %n1%
FOR %%x IS 1 TO %n4% DO {
    READ
    SET s=%read%&
    READ
    SET r=%read%&
 
    STRREP "%s%" "%r%" %c%&
    IF ("%strrep%" != "%c%") {
        SET c=%strrep%&
    } ELSE {
        STRREP "%r%" "%s%" %c%&
        SET c=%strrep%&
    }
}
 
STRREP "  " " " %c%
STRREP "!" "" %strrep%
STRREP " i " " I " %strrep%
SET c=%strrep%
 
:next
LET a=%n1% + %n2% + %r.k% - 1
READ %a%
READ
STRREP "$" "," %read%
SET f=%strrep%
 
LET r.k=%r.k% + 1
IF (%r.k% > %n.k%) SET r.k=%s.k%
 
SUBSTR -1 1 %f%
IF ("%substr%" != "*") {
    ECHO %f%
} ELSE {
    STRSIZE %f%&
    LET strsize=%strsize% - 1
    SUBSTR 1 %strsize% %f%
    SAY %substr%&
    SAY %c%&
    ECHO.
}
 
SET p=%i%
GOTO start

Running this batch file produces the following output :-

Hi!  I'm Eliza Jr.  What's your problem?
> I'm tired
Did you come to me because you are tired
> yep
Say, do you have any psychological problems?
> I don't
Don't you really
> I'm just sitting here
How long have you been just sitting here
> about 5 minutes
What does that suggest to you?
> exit
Bye bye.