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

new method for ruaperson

By: ace on Feb 10th, 2010  |  syntax: None  |  size: 1.11 KB  |  hits: 27  |  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(ArrayList<String> words)
  2.     {
  3.         for(String word : words){
  4.             System.out.println(word);
  5.         }
  6.        String response = null;
  7.         if (words.contains("Are you a person?"))
  8.             {
  9.                 response = "Of course I am a person.";
  10.             }
  11.         HashSet<String> keywords = new HashSet<String>(words);
  12.         Iterator<String> it = keywords.iterator();        
  13.         while(it.hasNext()) {
  14.             String word = it.next();
  15.             ArrayList<String> keys = new ArrayList<String>();
  16.             keys.addAll(responseMap.keySet());
  17.             for(String s : keys){
  18.                 if(word.contains(s)){
  19.                     response = responseMap.get(s);
  20.                 }
  21.             }
  22.             if(response != null) {
  23.                 return response;
  24.             }
  25.         }
  26.         // If we get here, none of the words from the input line was recognized.
  27.         // In this case we pick one of our default responses (what we say when
  28.         // we cannot think of anything else to say...)
  29.         return pickDefaultResponse();
  30.     }