Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

are you a person1

By: ace on Feb 10th, 2010  |  syntax: None  |  size: 0.97 KB  |  hits: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  public String generateResponse(HashSet<String> words)
  2.     {
  3.        if (words.contains("Are you a person?"))
  4.             {
  5.                 response = "Of course I am a person.";
  6.             }
  7.         Iterator<String> it = words.iterator();        
  8.         while(it.hasNext()) {
  9.             String word = it.next();
  10.             String response = null;
  11.             ArrayList<String> keys = new ArrayList<String>();
  12.             keys.addAll(responseMap.keySet());
  13.             for(String s : keys){
  14.                 if(word.contains(s)){
  15.                     response = responseMap.get(s);
  16.                 }
  17.             }
  18.             if(response != null) {
  19.                 return response;
  20.             }
  21.         }
  22.         // If we get here, none of the words from the input line was recognized.
  23.         // In this case we pick one of our default responses (what we say when
  24.         // we cannot think of anything else to say...)
  25.         return pickDefaultResponse();
  26.     }