Comp 170 Lab 5 - Tech Support
The tech support "chatterbot" system attempts to make plausible responses based on
simple matching with the user input. Currently there are two levels:
- Keyword match: match a keyword like "bug" or "windows"
- Random response: if there is no keyword match, choose a generic response at random
Your assignment is to add a third level between these two: after keywords, but
before random responses. You are to look for "question words" that begin
the user input, such as "who", "what", "where", "how", "why". Actually, you
won't require that the word begin the sentence, but you are to find the
first question word, and base the response on that. Thus, if
the user types "why is it that I cannot find what to do", you are
to choose the why response, in the hope that that will be a more accurate "match" than to what.
Note that this requires you to use the
ArrayList representation of user input rather than the HashSet, because you need
to go through the user input in order.
(The basic three-level structure would still work with HashSets;
we just then can't guarantee we're matching the first keyword used.)
You can find the ArrayList version here.
Steps (all changes are to the Responder class)
- Add the appropriate HashMap object, say questionMap.
Like responseMap, it will have type Hashmap<String,String>.
- Initialize questionMap, and fill it with plausible responses.
- In generateResponse, at the indicated place, add a loop to go through each word
of the ArrayList words and see if it is found in questionMap and,
if so, return the response.
Here are the words, together with some possible responses. You are strongly
encouraged to improve them.
Many responses here are based on a rather hypothetical guess as to the actual question.
word |
possible question
|
response |
who |
who is in charge of this mess? |
To contact an individual, go to our home page and click on the "directory" button. |
what |
what is the best way to ...? |
Please check the manual HOW-TO section for that. |
where |
where can I find out how to .... |
have you tried looking in the manual or the help files? |
when |
When will the fix be available? |
We expect to release that feature Real Soon Now. |
how |
how do I file a complaint? |
try looking up your topic in the index, or in the "how-to" tutorial. |
why |
why can't I get cut-and-paste to work? |
Perhaps you should reread the manual on that topic. |
The reason for another level, ie the reason these keywords aren't included in the first keyword HashMap (the HashMap called
responseMap that
includes "bug" and "windows"), is that they
are substantially less precise; we would like to check for all of the first group of
keywords before trying any of these "question" keywords.
Email me your completed project.