Recently I found this Java implementation by Charles Hayden of the classic Eliza program. I changed the code a little bit to have it compiled as a Processing library that you can use in your sketches.

Here is a sample program I wrote with the library.

Click here to download the compiled library. Unzip the file and place its contents inside the libraries folder under the Processing location. And here you have the source code.

From what I read, and some tests I made, it seems to be a very faithful implementation of the original Eliza algorithm. I was able to reproduce a conversation presented in the 1966 paper by Eliza’s creator, Joseph Weizenbaum.

The library is easy to use. Just import it, and then create an Eliza object:

import codeanticode.eliza.*;

Eliza eliza;
eliza = new Eliza(this);

String response = eliza.processInput(“Hello”);
println(response);

You can use the readScript() funcion to change the script that Eliza uses to construct its answers:

eliza.readScript(“script”);
eliza.readScript(“http://chayden.net/eliza/script”);

To go back to the default script that is loaded when Eliza is initialized, call the readDefaultScript() function.

Instructions to modify the script file are available here.

3 Comments

  1. Hi. I would like to try your library, but I’m getting this error when running it in Processing:

    The constructor Eliza(Eliza) is undefined.

    The code I’m using is the following:


    import codeanticode.eliza.*;

    Eliza eliza;
    eliza = new Eliza(this);

    String response = eliza.processInput("Hello");
    println(response);

    I’m using processing-0154.

    Thanks!

  2. Hi, I just tried the sample code with Processing 0154 and it worked fine. Did you install the library file in the correct place? Please keep in mind that since Processing 0149, the libraries are not supposed to be installed anymore in the processing folder, but in the sketchbook folder instead.

  3. Yeah the library was in the correct place. And all of a sudden, it worked again :S strange. But thanks anyway!


One Trackback/Pingback

  1. By del.icio.us links-- sketchbook on 16 Jan 2008 at 9:12 pm

    [...] Eliza library for processing « codeanticode (tags: processing.org library ai eliza) [...]

Post a Comment

*
*