Brain in a Jar - Creating the Mind
To make the BIAJ talk, we wanted some kind of chatbot to respond to typed comments. My first thought was of the classic ELIZA program, but I wondered if there might be something more appropriate.
Of course, there has been a lot of work done on AI since that first ELIZA program. However, the work has all been aimed at making the responses more human, which is not exactly what we're looking for. Too, the subsequent programs are less about source code than they are about building a system for machine learning and then letting humans train up the machine. That allows the machine system to learn to mimic the human trainers, but it leaves you with a system that is plastic. At the beginning of the day, the brain might seem appropriately creepy, but by the end of the day it would probably just seem like an average of all the visitors.
I found a Java implementation of ELIZA written by Charles Hayden and downloaded that source. Then I started munging on it. First, I migrated all the classes into a different package so that he wouldn't get blamed for anything I did.
The applet is designed to run in a browser and who knows what version of Java a website visitor might have. The original code, therefore, is written for Java 1.3 at the latest (at the time of writing the current stable version of the language is 1.6 and 1.7 is getting firmed up). I wanted to refactor the code to be a bit more modern. I decided to write regression tests for any classes I was going to change so that I could validate the behaviors before and after. I chose TestNG as the testing framework.
With the classes refactored, I started going after the UI. We do not intend the project to be an applet so I could just delete that code. I created an interface for the chatbot with the idea that we might drop in different chatbot implementations. Maybe I'd find or write something better. I use IntelliJ IDEA as my IDE and it has a very nice GUI builder. I defined a simple chat interface with a scrolling text field for the history, an input field, and a submit button. I wired that UI up to the ELIZA implementation of the IChatbot interface and, presto!, there was a simple chatbot.
Next steps in the modification of the chatbot is to modify the script for ELIZA so the responses are not so much about psychotherapy and more like the musings of a disembodied brain.
Post new comment