CIS 700 Assignment 3: Eliza
Summer II 2010, David Matuszek

Purpose of this assignment

Background

The original Eliza program was published by Joseph Weizenbaum in 1966. It simulated a Rogerian therapist; that is, most of what it said was merely repeating (with appropriate substitutions) what it was told. Here is a bit of sample dialogue (from Rich & Knight, 1983):

Person: Men are all alike.
Eliza: In what way?
Person: They're always bugging us about something or other.
Eliza: Can you think of a specific example?
Person: Well, my boyfriend made me come here.
Eliza: Your boyfriend made you come here.
Person: He says I'm depressed much of the time.
Eliza: I am sorry to hear you are depressed.
Person: It's true. I am unhappy.
Eliza: Do you think that coming here will help you not to be unhappy?
Person: I need some help, that much seems certain.
Eliza: What would it mean to you if you got some help?
Person: Perhaps I could learn to get along with my mother.
Eliza: Tell me more about your family.

Eliza worked by applying pattern-matching rules. It looked for a rule whose left side matched the last sentence entered by the user, then used the right side of that rule to generate a response. A sample rule might be something like:
      I remember $1 => What makes you think of $1? .

The assignment

Write an Eliza-like program that interactively "converses" with the user. Your program should have the following features:

  1. It should read in a list of rules from a file (you supply the list of rules)--name it rules.txt. The above example hints at a suggested format, but you can use whatever format you like for the rules. Provide a readme.txt file that explains the format and its intended interpretation.
  2. It should do simple pattern matching and substitution: "I remember the first day of school" => "Why do you remember the first day of school just now?"
  3. The pattern matching should include pronoun substitution: "My boyfriend made me come here" => "Your boyfriend made you come here." Note that pronoun substitution should occur in addition to any other pattern matching and substitution.
  4. It should recognize certain keywords and respond to those. For example: "I think I'm in love" => "Love isn't always a simple thing."
  5. It should provide general-purpose responses if no other patterns match, for example: "Tell me more about that." There should be more than one such response, selected randomly.
  6. Remember some topics that were discussed earlier, and incorporate them into your general-purpose responses: "Tell me more about your trip to Brazil."

Grading

Your program is expected to work; please don't turn in one that doesn't. The penalty for late programs is 10% per day 5% per day, but it's much more severe if your program doesn't work.

Every method should have Scaladoc comments. Be sure to use the @author tag in the comment for your Eliza object, so we know who you are.

Special rules

As before, the reasons for these rules are twofold: (1) They are intended to get you thinking functionally, and (2) It is easy to write a program to count these keywords.

Scalatest

Since I was unable to get Scalatest working earlier, this section is extra credit (up to 20 points). Scalatest will be required on the next Scala assignment. Here's what you need:

  • Java 5 or 6 (presumably you already have that)
  • An up-to-date version of Scala. Scalatest and scala-2.8.0.final are compatible; earlier versions of Scala may or may not work (you can try yours and see). I found upgrading with the IzPack installer very easy.
  • Some version of ant. The latest is 1.8.1; I have 1.7.1 and it works fine. It's also very easy to install; I did a Google search for how to install ant and picked the instructions that seemed most appropriate.
  • The very nice package put together for us by Yuvi: Eliza.zip. Download and unzip this, read the README.rst, and try it out. Look at the sample program in src/Eliza.scala and the sample test in test/ElizaTest.scala. (Note: May be slow to download.)

This seems like a lot, but it's really not. The Scala and ant installers work very well, and Yuvi's made it easy for us. Using ant is slow, though, so I'm still looking for a way to use Scalatest from jEdit or some other IDE.

Due date

Zip your complete program, and submit it via Blackboard before midnight, Sunday July 25.

Your zip file should include:

Common errors: