Of all the chatterbots—programs that converse with humans—Eliza is the most famous. The original Eliza was written by Professor Joseph Weizenbaum of MIT and described in the Communications of the ACM in 1967 (Vol. 10, No. 8). This program is older than I am, and yet remains fascinating to this day. It’s one of the all-time classic programs in computer science. Eliza pretends to be a Rogerian psychiatrist; whatever the human says, it replies—usually with a question—in an attempt to encourage the patient to elaborate.
While taking a course in Natural Language Processing, I was surprised to find that much of the research in the field still uses Lisp. Lisp is a fine language, but Perl can do anything Lisp can do, and Perl source code is much easier to read. I searched the Web for Eliza clones, but I couldn’t find any written in Perl. So I wrote one.
The Chatbot::Eliza module is a faithful clone of Weizenbaum’s Eliza algorithm. It encapsulates Eliza’s behavior within an object.
You can install Chatbot::Eliza just like any other Perl module. Once installed, this little bit of code is ...