Ling/CSE 472 Assignment 1: Regular expressions

Elizalike

This assignment asks you to create a program that behaves like Weizenbaum's ELIZA (see Ch 2 of J&M). We have provided a skeleton of a script that handles input and output, and provides an example of the Python syntax for using regular expressions to modify strings.

Each student should develop their own program, although you are welcome to ask each other questions (in person, over email, or on the Canvas discussion area). You will need to find a partner for this project, as one of the tasks is to test each other's programs (see below).

Specifications: The basic approach is to read in a string of input from the user, modifying it successively (sometimes subtly, sometimes drastically, depending on the input string), and print out the result. To maintain the illusion of a competent conversational partner, it is crucial that elizalike print out grammatical strings. (You may assume that it is given grammatical input.) Furthermore, elizalike should be able to handle person deixis, referring to itself in the first person and to the user in the second person.

Before you start, look at the list of items to turn in below, so you know what you'll need to save.

Your tasks:

  1. Develop a list of sentences that you will use to test your program to make sure it handles the person deixis correctly.
  2. Modify the elizalike script to implement the handling of person deixis.
  3. Add at least two statements that find one keyword in the input and change the whole string to something different. (See the third and fourth examples at the bottom of page 10 of JM Ch2 for a model, but don't copy them exactly!)

  4. Add at least two statements that find some keyword in the input, and return a significantly changed output that noneless contains some part of the input that may vary from time to time. (See the first and second examples on page 10, but feel free to get fancier than that!)

  5. This is the first version of your program. It should be turned in as elizalike1.py (others).

  6. Find a partner and exchange programs. Looking at the code for your partner's program, try to find at least 2 interestingly different inputs that cause their program to produce ungrammatical output. (Keep your inputs grammatical!) We're pretty sure you'll be able to find these, but if your partner's program is too perfect, you can get full credit for this part of the assignment by turning in an explanation of 5 pitfalls you looked for and how they were avoided.

  7. Optional: Modify your program to avoid the ungrammatical outputs your partner found (if any). Document and explain the changes you made at the end of your write-up file.

  8. Write up Part I: In ~5 paragraphs, discuss:
    1. What did you learn about English morphosyntax or what knowledge of English morphosyntax did you apply in this assignment?
    2. In what ways does English morphosyntax make this program relatively straightforward to implement and how might this process be more complicated with another language?
    3. What did you learn about regular expressions? What are some pros and cons of using regular expressions to model and/or process language?


  9. Write up Part II: In ~2 paragraphs, answer:
    1. Describe of a use case for chatbots in the real world (this could be a real instance you've already encountered or something you make up).
    2. What are the beneficial aspects of deploying chatbots in this way, and who receives the benefits of such use?
    3. Imagine that a person is fooled by the chatbot into thinking they're interacting with a real person rather than a computer. What are some potential consequences if this happens?

Turn in instructions

Turn in the following via Canvas. Submit these files, with these names:

FileContents
sentences.txt Your list of test sentences
elizalike1.py The first version of your program
elizalike2.py The second version of your program.
eliza_discussion.pdf Your discussion of English and other language morphology and syntax --- see the last task above.
partner.pdf 1. The name of your partner and the problems you found with their program, or an explanation of how they avoided 5 pitfalls you thought up.
2. Optional: What you changed in your own program to address the issues your partner brought up.
chatbots.pdf Your answers to Write up Part II

Note: We will be executing your code, so make sure it runs on Patas.



Last modified: