Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String generateResponse(ArrayList<String> words)
- {
- String response = null;
- String personquery = words.toString();
- if (personquery.contains("Are you a person?"))
- {
- response = "Of course I am a person.";
- return response;
- }
- for(String word : words){
- System.out.println(word);
- }
- 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();
- }
Advertisement
Add Comment
Please, Sign In to add comment