Eliza Test

Bookmark and Share

This applet implements the classic "Eliza" program, a program that communicates in natural language. It pretends to be a Rogerian psychologist.

The original ELIZA was described by Joseph Weizenbaum in Communications of the ACM in January 1966. ELIZA was one of the first programs that attempted to communicate in natural language. The article was an attempt to demystify the behavior of the program, and included a detailed description of the program. ELIZA is based on a "script" consisting of patterns and corresponding responses. An appendiz to the article contained the complete script for the Rogerial psychologist.

This rendition of ELIZA is a complete and faithful implementation of the program described by Weizenbaum. The script language has been reformatted for clarity, but is unchanged in its content.

The Source

The Script

Instructions on how to modify the script file.

The Executable

This zip file contains the compiled class files and the script.

I wrote this to help learn Java. You are welcome to make use of it however you want. This version is a reworking of a program I wrote back in 1983 to teach myself how to use the Macintosh. I had written some really good documentation at that time, explaining how to write your own scripts. For now, you can look at Weizenbaum's article and the script I have provided to see how to write scripts.

You can specify your own script as an applet parameter. See the source of this page to see how to do that.

Note on making your own page: I don't fully understand all the interactions of the components of the applet tag. Here is what I use:
<applet code="Eliza/Eliza.class" width="600" height="200">
<param name="script" value="http://chayden.org/chayden/eliza/script">

This says that the compiled class file Eliza.class is in a subdirectory Eliza (capitalization is important). Since there are many class files, and they are all in the Eliza subdirectory, it would seem to make sense to set "codebase" to "Eliza" and code to "Eliza.class". However, this does not work.

Once the program starts, it needs to read a script file, and so the "param" value gives a URL of the script file. This must be on the same server that supplied the applet (because of Java security rules).

If you use the HTML shown above, and it you store the class files in an Eliza subdirectory relative to the web page, and if you point to a script file on the same server, you should be able to get this program running on your machine (many people have reported success in doing this). Be aware that certain tools (such as Microsoft Front Page) will split the "code" tag into "code" and "codebase" breaking the applet. This is the major source of difficulties reported to me.

If you have comments or suggestions, please let me know.

oGo back to Charles Hayden's Home Page