|CSC 153||Grinnell College||Spring, 2005|
|Computer Science Fundamentals|
This laboratory exercise explores an object-oriented solution to a problem based on a famous porgram called Eliza, developed by Joseph Weizenbaum.
Consider the following problem statement:
Pattern matching and transformation rules occur frequently in symbolic computation. The following patterns and corresponding response templates can be used to generate "conversations".
|---1 my singleWord ---2 me ---3||tell me about your singleWord|
|---1 i am ---2||i am sorry to hear you are ---2|
|---1 am i ---2||do you believe you are ---2|
|---1 you ---2 me --- 3||why do you think i ---2 you|
|---1||in what way|
In this table, the blank spaces in a pattern, denoted by subscripted dashes, can be filled in with any sequence of words. Similarly, singleWord represents exactly one word in a sentence. For example, these patterns might generate the following "conversation," where the responses are indented and in italics:
well my friend made me come here
tell me about your friend
he says i am depressed
i am sorry to hear you are depressed
i think i need help
in what way
i wonder if you would help me learning to program Scheme
why do you think i would help you
when i registered for the course i wondered am i crazy
do you believe you are crazy
Each of these statements and responses follows the template/response patterns given.
The reading for this lab shows how the first sentence in the sample dialogue maps to the first pattern and response template.
Identify the patterns for each of the other sentences in the above "conversation". Then, for each pattern, write out which words correspond to which pattern elements, and use this analysis to explain each result printed by the Eliza program.
Brainstorm to determine another pattern template and response. Show two examples to illustrate how your template and response might fit into a conversation.
Also, it seems reasonable for the user to quit by typing "exit". The program then should respond program terminated" and stop. Within the current context, it seems natural to consider this interaction as another pattern/response pair, with a special final action.
The reading for this lab identifies the following major objects in an object-oriented solution to this problem:
|input line||-||with 1 line for each user's input|
|6 patterns||-||each of which which includes a template with text/words, wildcards, and singleword designators|
|6 responses||-||corresponding to the patterns, each includes a template with text/words, wildcards, and singleword designators|
|directory/table||-||which matches text/words with wildcards and singleword designators|
The reading also discusses the following diagram shows a sequence of messages that might arise if an input line matches pattern 2.
The reading for this lab describes both Scheme and C++ programs that follow this object-oriented approach to the Eliza problem:
This document is available on the World Wide Web as
created January 17, 2000
last revised March 9, 2005
|For more information, please contact Henry M. Walker at email@example.com.|