CIS 700 Assignment 3: Eliza
Summer II 2010, David Matuszek
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? .
Write an Eliza-like program that interactively "converses" with the user. Your program should have the following features:
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.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.
def, up to a maximum of 10 points.=>, up to a maximum of 20 points. (That includes its use in match statements.) map, filter, flatMap, foreach, forall, exists, find, and span, up to a maximum of 20 points. (Note: When you use these with =>, you get credit for both.)var and while and 10 points for each occurrence of null. (This is to get you to use for, List, and maybe Some). You will be allowed one "free" use of null, so that you can use a file chooser to read the rules.txt file.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.
ScalatestSince 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:
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. |
Zip your complete program, and submit it via Blackboard before midnight, Sunday July 25.
Your zip file should include:
.scala source file or files..class binary files.rules.txt and readme.txt files.example.txt) showing a complete sample interaction with your program.scaladoc.Common errors: