Lab 9: Python TechSupport AI ChatterBot

Comp 150, Dordal

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.

I've provided you with a python dictionary 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), converts to lowercase, breaks the line up into words, and looks up a suitable response. It's the lookup (that is, the function respond(str)) that you have to do.

Response lookup

The parameter to respond() is a list of strings; each string is one of the original words the user provided.

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

Step 2: If step 1 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 the random response you want is just responselist[i].

Email me your python file.