Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/main/java/chatbot/rivescript/RiveScriptBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,34 @@
* Created by ramgathreya on 5/11/17.
*/
public class RiveScriptBot extends RiveScript {

public RiveScriptBot() {
super();
this.loadDirectory("src/main/resources/rivescript");
this.sortReplies();
}

public String[] answer(String userId, String message) {
return Utility.split(this.reply(userId, message));

String reply = this.reply(userId, message);

// Fallback for unknown / unclear queries
if (reply == null
|| reply.trim().isEmpty()
|| reply.length() < 8
|| reply.equalsIgnoreCase("I see.")
|| reply.equalsIgnoreCase("Please go on.")
|| reply.equalsIgnoreCase("Ok.")
|| reply.contains("ERR")) {

reply = "Sorry, I didn’t quite understand that.\n" +
"You can try asking:\n" +
"- What is DBpedia?\n" +
"- Who is Albert Einstein?\n" +
"- What is RDF?\n" +
"- Tell me about Wikipedia";
}

return Utility.split(reply);
}
}