eliza.py, ELIZA in Python

This is a little version of ELIZA, a famous natural-language AI demo from the 1960s, packaged up as a Python module. It's all smoke and mirrors; the program doesn't have a clue what it is saying and it's not difficult to catch it out. It's amusing, and it means your chatbot always has something to say.

I adapted Joe Strout's original implementation for Python 2 and packaged it as a module. He's given me his permission to release it.

The eliza.py module includes an interactive mode, so you can get a feel for how it performs. Simply unpack the download and python eliza.py. To use the it from with in your own script do something like

import eliza

therapist = eliza.eliza()

  #get input from somewhere
  reply = therapist.respond(input)
  #send reply somewhere


eliza.py-0.2.tar.gz (3705 bytes)
eliza.py-0.2.zip (3866 bytes)
These packages were uploaded on 28 February 2005.

Talk to Eliza

If you have Yahoo Messenger, you can talk to it here


J. Weizenbaum, ELIZA - A Computer Program For the Study of Natural Language Communication Between Man And Machine Communications of the ACM, Vol 9, No 1, January 1966

There is a online version of the script at http://toms-projekte.de/Eliza/
by Tom [e] [w] on 28th Jun 2009

According to the official Python documentation (http://docs.python.org/release/2.4/lib/module-whrandom.html), whrandom is now depreciated: use the random module instead.

Therefore, if you get the error "python: ImportError: No module named whrandom", in eliza.py:

* line 12, replace "import whrandom" by "import random"

* line 43, replace "resp = whrandom.choice(self.values[i])" by "resp = random.choice(self.values[i])"
by Franck Dernoncourt [e] [w] on 1st Jan 2012

Thanks! Ported this to GoLang:

by anonymous on 4th Mar 2015

Enter your comment

Name Email
If you have an account, please log in.
No account? Just create one.

Jez Higgins