The mother of all chatbots is Joseph Weizenbaum‘s Eliza first developed in the late 1960s. Interestingly, ELIZA was in fact the name of the general purpose program that would converse with read input from a remote user and send back a response. The particular character most associated with the program was the DOCTOR script, modeled on a Rogerian therapist whose “mirroring” technique was comfortably approximated using text pattern matching and replacement (then state of the art, now a kind of staple of computational treatments of text).

A particularly faithful reimplementation of Weizenbaum’s program was made in the 1990s by Charles Hayden and was published as a Java applet. The instructions are a very concise description of how ELIZA performs its script.

In sum, the text processing follows these steps:

  1. The sentence broken down into words, separated by spaces. All further processing takes place on these words as a whole, not on the individual characters in them.
  2. A set of pre-substitutions takes place.
  3. Eliza takes all the words in the sentence and makes a list of all keywords it finds. It sorts this keyword list in descending weight. It process these keywords until it produces an output.
  4. For the given keyword, a list of decomposition patterns is searched. The first one that matches is selected. If no match is found, the next keyword is selected instead.
  5. For the matching decomposition pattern, a reassembly pattern is selected. There may be several reassembly patterns, but only one is used for a given sentence. If a subsequent sentence selects the same decomposition pattern, the next reassembly pattern in sequence is used, until they have all been used, at which point Eliza starts over with the first reassembly pattern.
  6. A set of post-substitutions takes place.

Finally, the resulting sentence is displayed as output.

For working with students on chatbots, I create a simple editing interface on top of the Hayden java app to quickly create new bots by editing a script.