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 person3

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