ace

are you a person3

ace
Feb 10th, 2010
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment