Skip to content

Commit

Permalink
feature: choose message via entity value
Browse files Browse the repository at this point in the history
  • Loading branch information
Aran30 committed Jul 5, 2023
1 parent 01f409c commit db7b74a
Showing 1 changed file with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,16 @@ public void handleMessages(ArrayList<MessageInfo> messageInfos, Bot bot) {
if (state == null || state.expectsFile()) {
if(this.knownIntents.get("0") != null){
state = this.knownIntents.get("0");
} else{
state = this.knownIntents.get("default");
} else {
if(intent.getEntitieValues().size() > 0){
state = this.knownIntents.get(intent.getEntitieValues().get(0));
if(state == null){
state = this.knownIntents.get("default");
}
}

}
}
}
System.out.println(intent.getKeyword() + " detected with " + intent.getConfidence()
+ " confidence.");
stateMap.put(message.getChannel(), state);
Expand Down Expand Up @@ -493,6 +499,25 @@ public void handleMessages(ArrayList<MessageInfo> messageInfos, Bot bot) {
stateMap.put(message.getChannel(), state);
addEntityToRecognizedList(message.getChannel(), intent.getEntities());
}
} else if (intent.getEntitieValues().size() > 0 && state.getFollowingMessages().get(intent.getEntitieValues().get(0)) != null) {
System.out.println("try follow up message with entity");
// check if a file was received during a conversation and search for a follow up
// incoming message which expects a file.
if (message.getFileBody() != null) {
if (state.getFollowingMessages().get(intent.getEntitieValues().get(0)).expectsFile()) {
state = state.getFollowingMessages().get(intent.getEntitieValues().get(0));
stateMap.put(message.getChannel(), state);
addEntityToRecognizedList(message.getChannel(), intent.getEntities());
} else {
state = checkDefault(state, message);
}
} else if (state.getFollowingMessages().get(intent.getEntitieValues().get(0)).expectsFile()) {
state = checkDefault(state, message);
} else {
state = state.getFollowingMessages().get(intent.getEntitieValues().get(0));
stateMap.put(message.getChannel(), state);
addEntityToRecognizedList(message.getChannel(), intent.getEntities());
}
} else {
//System.out.println("\u001B[33mDebug --- Followups: " + state.getFollowingMessages() + "\u001B[0m");
//System.out.println("\u001B[33mDebug --- Emptiness: " + state.getFollowingMessages().keySet().isEmpty() + "\u001B[0m");
Expand Down

0 comments on commit db7b74a

Please sign in to comment.