fix goal generation to handle multiple sentences
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good

This commit is contained in:
austin 2024-12-30 13:02:40 -05:00
parent fd5ed6b181
commit c2ddc5818d
4 changed files with 21 additions and 21 deletions

View File

@ -1,5 +1,6 @@
package org.studiorailgun.conversation.evaluators;
import org.studiorailgun.Globals;
import org.studiorailgun.conversation.categorization.SentenceFunctionCategorizor;
import org.studiorailgun.conversation.evaluators.goal.GoalEval;
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
@ -18,7 +19,7 @@ public class EvaluationTree {
/**
* Number of times to evaluate response logic
*/
static final int RESPONSE_EVAL_COUNT = 1;
static final int RESPONSE_EVAL_COUNT = 2;
/**
* Evaluates a quote
@ -62,6 +63,11 @@ public class EvaluationTree {
//evaluate the AI's current goal in the conversation
GoalEval.evaluate(conversation);
//finished evaluation (couldn't find any more goals to pursue)
if(Globals.conversation.getGoalData().getGoal() == null){
break;
}
//synthesize language based on the results of the actions performed
Sentence newSent = ResponseEval.evaluate(conversation);
if(newSent != null){

View File

@ -3,7 +3,6 @@ package org.studiorailgun.conversation.evaluators.goal;
import org.studiorailgun.conversation.evaluators.goal.GoalData.ConversationGoal;
import org.studiorailgun.conversation.evaluators.greet.GreetingData;
import org.studiorailgun.conversation.evaluators.query.QueryData;
import org.studiorailgun.conversation.tracking.ConvParticipant;
import org.studiorailgun.conversation.tracking.Conversation;
/**
@ -20,25 +19,21 @@ public class GoalEval {
GreetingData greetingData = conversation.getGreetingData();
GoalData goalData = conversation.getGoalData();
QueryData queryData = goalData.getQueryData();
ConvParticipant selfParticipant = conversation.getSelf();
boolean set = false;
//evaluate if goal should be to greet
if(!greetingData.getHaveGreeted().contains(selfParticipant)){
if(!greetingData.getHaveGreeted().contains(conversation.getSelf())){
conversation.getGoalData().setGoal(ConversationGoal.GREET);
set = true;
return;
}
//evaluate if goal should be to answer a question
if(queryData.getRecentQueries().size() > 0){
conversation.getGoalData().setGoal(ConversationGoal.ANSWER);
set = true;
return;
}
if(!set){
throw new Error("Failed to find a goal to pursue in the conversation!");
}
//if failed to find a goal, set current goal to null
conversation.getGoalData().setGoal(null);
}
}

View File

@ -12,19 +12,17 @@ import org.studiorailgun.conversation.tracking.Sentence;
*/
public class NLPParser {
public static String text = "Joe Smith was born in California. " +
"In 2017, he went to Paris, France in the summer. " +
"His flight left at 3:00pm on July 10th, 2017. " +
"After eating some escargot for the first time, Joe said, \"That was delicious!\" " +
"He sent a postcard to his sister Jane Smith. " +
"After hearing about Joe's trip, Jane decided she might go to France one day.";
/**
* The CoreNLP pipeline
*/
static StanfordCoreNLP pipeline;
/**
* Initializes the part-of-speech Parser
*/
public static void init(){
System.out.println("Initializing NLP Parser");
// set up pipeline properties
Properties props = new Properties();
// set the list of annotators to run
@ -33,6 +31,8 @@ public class NLPParser {
props.setProperty("coref.algorithm", "neural");
// build pipeline
pipeline = new StanfordCoreNLP(props);
System.out.println("Finished Initializing NLP Parser");
}
/**
@ -54,8 +54,6 @@ public class NLPParser {
quote.addSentence(sentence);
}
}
//TODO: grab information from document here
}
}

View File

@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.studiorailgun.conversation.ConvAI;
import org.studiorailgun.conversation.evaluators.goal.GoalEval;
import org.studiorailgun.conversation.evaluators.goal.GoalData.ConversationGoal;
import org.studiorailgun.conversation.tracking.Quote;
@ -25,7 +26,7 @@ public class GreetingTests {
public void testGoal(){
Globals.init("./data/webs/test/web.json");
ConvAI.simFrame("Hello");
GoalEval.evaluate(Globals.conversation);
assertEquals(Globals.conversation.getGoalData().getGoal(), ConversationGoal.GREET);
}