
new method for ruaperson
By:
ace on
Feb 10th, 2010 | syntax:
None | size: 1.11 KB | hits: 27 | expires: Never
public String generateResponse(ArrayList<String> words)
{
for(String word : words){
System.out.println(word);
}
String response = null;
if (words.contains("Are you a person?"))
{
response = "Of course I am a person.";
}
HashSet<String> keywords = new HashSet<String>(words);
Iterator<String> it = keywords.iterator();
while(it.hasNext()) {
String word = it.next();
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();
}