Lab 11: Python TechSupport AI ChatterBot

Comp 150, Dordal, Mon, Apr 21, 2006

You are to construct a program to simulate a tech-support conversation with a user:
     Welcome to our software technical support site.
     Type your questions, and our artificial intelligence software will answer them.
     > I don't like your software
     Nobody has ever complained about this before; what is your system configuration?
     > Your program crashes a lot for me
     Well, it never crashes on our system. Tell me more about your configuration.
     > I'm using windows XP
     This is a known Windows bug; please call Microsoft
     > it's also very slow
     I think this has to do with your hardware. Get an upgrade!

The program's responses are rather superficial, demonstrating in essence what is not intelligent behavior, although the Artificial Intelligence community has long used such "chatterbot" programs as examples (of what doesn't pass the Turing test!). This particular chatterbot does two things: first it looks for key words such as "crashes", "windows", "slow", "bug", and "expensive". If it finds a key word, it returns the designated response. If that fails, the second step is to choose a random response from a list of all-purpose responses.

The dictionary I've given you is called responsedict. A few entries:
     responsedict["crashes"]= "Well, it never crashes on our system. Tell me more ...."
     responsedict["windows"]="This is a known Windows bug; please call Microsoft"
     responsedict["slow"]= "I think this has to do with your hardware. Get an upgrade!"
     responsedict["bug"]= "Well, you know, all software has some bugs. "
     responsedict["expensive"]="The cost of our product is quite competitive."
You are encouraged to add additional entries.

The list of responses to be chosen at random is called responselist; it contains entries like:
     "That sounds odd. Could you describe that problem in more detail?",
     "That sounds interesting. Tell me more...",
     "I need a bit more information on that.",
     "Have you checked that you do not have a dll conflict?",
Again, feel free to add entries

I've also given you the main support() function (all in the file tech.py), which reads a line of input (until the user types "quit" to stop), and looks up a suitable response. It's the lookup (that is, the function respond(str)) that you have to do.

Response lookup

Step 1: convert the input string to a list of words, as in lab 7: Here's the lab 7 information on how to do this, for a string str: Now words is a list of the words entered by the user.

Step 2: for each w in words (for w in words:), see if w in responsedict. If so, that means w is a keyword, and you should return responsedict[w].

Step 3: If step 2 failed, choose a random element of responselist and return that. To choose a random i in the range 0..N-1, use i = randrange(0, N). If you do this for N=len(responselist), then a random response is just responselist[i].

Email me your python file, or show it to me.