COGSCI 131 – Assignment 3 DUE: Feb 21 at class start
Your job in this problem set will be to implement an ELIZA-like system as a conversational agent, talk with it, and have a friend talk with it. Your job is to implement a system which handles rules like
I love <1> → Why do you love <1>?
<1> love <2> → Tell me more about your feelings on <2>. Hi→ Hello
Each of these rules matches some pattern on the left, and the right says how the chat bot should respond. Importantly, sometimes the response of the chat bot will use variables (“<1>” and “<2>” above) to repeat back a part of the string that matches. For instance, if I wrote
I love accordions
Then these rules specify that the chat bot could say either
Why do you love accordions?
or
Tell me more about your feelings on accordions.
To implement this, you will need to construct a system that reads input (either form sys.stdin or input() for Jupyter), chooses a rule that matches, and responds appropriately. Python’s library for string pattern matching is called “re” (for “regular expression”) and regular expressions will be covered in section, but you might find it helpful to read a tutorial online.1 When multiple rules match, your implementation can pick any of those that match, but you will receive [+10 extra points] if you make it choose at random between all of the available matching rules.
Note: Your implementation does not need to conjugate verbs or do anything fancy to transform the text – simple pattern patching and substitution as above is fine. This means its conversations may be a little imperfect, and that’s okay.
Provide your chat bot with at least 25 rules that you create for discussing a specific domain that you are an expert in. Ensure that at least 10 rules have one variable and at least 10 have two variables.
1. Turn in your code [20pts]. (If you are going for bonus points, write a sentence on how you did it)
2. Turn in two conversations [10pts each] of about 1-2 pages each: first, you talking to the chat bot about the domain, showing how well it responds. Second, give it to a friend who is told nothing about it other than to talk to them about this topic. Write down some of your friend’s impressions.
3. Based on how your ELIZA performs in conversations, describe in a sentence or two one way you could improve its performance, in principle, other than adding more rules [10pts].
4. Finally, turn in a single sentence that you think nobody’s implementation will perform well on, but every human would. Explain why [5pts].
1 For example: https://www.datacamp.com/community/tutorials/python-regular-expression-tutorial#REinPython