
are you a person1
By:
ace on
Feb 10th, 2010 | syntax:
None | size: 0.97 KB | hits: 30 | expires: Never
public String generateResponse(HashSet<String> words)
{
if (words.contains("Are you a person?"))
{
response = "Of course I am a person.";
}
Iterator<String> it = words.iterator();
while(it.hasNext()) {
String word = it.next();
String response = null;
ArrayList<String> keys = new ArrayList<String>();
keys.addAll(responseMap.keySet());
for(String s : keys){
if(word.contains(s)){
response = responseMap.get(s);
}
}
if(response != null) {
return response;
}
}
// If we get here, none of the words from the input line was recognized.
// In this case we pick one of our default responses (what we say when
// we cannot think of anything else to say...)
return pickDefaultResponse();
}