Eliza library for Processing   18 comments

Update: The Eliza library evolved into the chatbots library that adds support for other chatter bots like RebeccaAIML. It now it has its own github repository and project page, including only the original Eliza code (August 30, 2013).

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.

Advertisements

Posted November 12, 2007 by ac in Programming

Tagged with , , , , ,

18 responses to “Eliza library for Processing

Subscribe to comments with RSS.

  1. Pingback: del.icio.us links-- sketchbook

  2. 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!

  3. 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.

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

  5. Hello, I am trying to create my own script sheet for Eliza and I am unsure how to go about doing it. I edited your script in a text editor but its unclear to me how to get that file to be referenced. How can I save it as just “script” and not “script.rtf” or .txt with an extension after it? Also would I just drop that file into the sketch’s data folder after that?

    • Hi, you have to save the new script file in plain text format. Doing this depends on the text editor you are using.

      After you drop the file inside the sketch’s data folder, you can load it from your code with:

      eliza.readScript(“new-script”);

      if the file is called “new-script”. Change this line according to the filename you are using for your script file.

  6. Pingback: Digital Media Course Blog » Basic Techniques – Week 4 – Processing

  7. Pingback: stimulusresponse

  8. The first thing I did with this cool library was hook it up to itself. :)

  9. Pingback: GuruQuest | Pippin Barr.

  10. Hi, I just installed the Eliza library in processing 2.2.1, and I’m getting an error when I run the default code above. On the line

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

    It’s throwing:

    ‘processing.app.SketchException: unexpected char: ‘\’
    at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:386)
    at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:192)
    at processing.mode.java.JavaBuild.build(JavaBuild.java:151)
    at processing.mode.java.JavaBuild.build(JavaBuild.java:130)
    at processing.mode.java.JavaMode.handleRun(JavaMode.java:120)
    at processing.mode.java.JavaEditor$23.run(JavaEditor.java:697)
    at java.lang.Thread.run(Thread.java:745)

    The example on program from the github repo works fine, but not sure how to install that as a library. If you have any ideas or help to offer it’d be much appreciated, thanks for making this tool!

  11. does anyone have a how to install this in Processing? i dont see this in the download manager

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: