response synthesis
This commit is contained in:
parent
a9f72dbb19
commit
0b951b3ef6
@ -12,10 +12,10 @@ public class AI {
|
|||||||
* Simulates a frame of the ai
|
* Simulates a frame of the ai
|
||||||
* @param input The raw input text
|
* @param input The raw input text
|
||||||
*/
|
*/
|
||||||
public static void simFrame(String input){
|
public static Quote simFrame(String input){
|
||||||
Quote playerQuote = new Quote(input);
|
Quote playerQuote = new Quote(input);
|
||||||
//handle ai statement
|
//handle ai statement
|
||||||
EvaluationTree.evaluate(Globals.conversation, playerQuote);
|
return EvaluationTree.evaluate(Globals.conversation, playerQuote);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package org.studiorailgun;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.studiorailgun.conversation.Conversation;
|
import org.studiorailgun.conversation.Conversation;
|
||||||
import org.studiorailgun.conversation.evaluators.GreetingEval;
|
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
|
||||||
import org.studiorailgun.knowledge.KnowledgeWeb;
|
import org.studiorailgun.knowledge.KnowledgeWeb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -35,7 +35,8 @@ public class AgentLoop {
|
|||||||
if(CommandParser.parseCommands(prompt)){
|
if(CommandParser.parseCommands(prompt)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AI.simFrame(prompt);
|
Quote response = AI.simFrame(prompt);
|
||||||
|
System.out.println(response.getRaw());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package org.studiorailgun.conversation;
|
package org.studiorailgun.conversation;
|
||||||
|
|
||||||
import org.studiorailgun.conversation.evaluators.GreetingData;
|
|
||||||
import org.studiorailgun.conversation.evaluators.goal.GoalData;
|
import org.studiorailgun.conversation.evaluators.goal.GoalData;
|
||||||
|
import org.studiorailgun.conversation.evaluators.greet.GreetingData;
|
||||||
import org.studiorailgun.knowledge.KnowledgeWeb;
|
import org.studiorailgun.knowledge.KnowledgeWeb;
|
||||||
import org.studiorailgun.knowledge.Node;
|
import org.studiorailgun.knowledge.Node;
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import org.studiorailgun.conversation.Conversation;
|
|||||||
import org.studiorailgun.conversation.Quote;
|
import org.studiorailgun.conversation.Quote;
|
||||||
import org.studiorailgun.conversation.categorization.SentenceFunctionCategorizor;
|
import org.studiorailgun.conversation.categorization.SentenceFunctionCategorizor;
|
||||||
import org.studiorailgun.conversation.evaluators.goal.GoalEval;
|
import org.studiorailgun.conversation.evaluators.goal.GoalEval;
|
||||||
|
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
|
||||||
|
import org.studiorailgun.conversation.evaluators.synthesis.ResponseEval;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluates a sentence based on data about the sentence
|
* Evaluates a sentence based on data about the sentence
|
||||||
@ -14,7 +16,7 @@ public class EvaluationTree {
|
|||||||
* Evaluates a quote
|
* Evaluates a quote
|
||||||
* @param quote The quote
|
* @param quote The quote
|
||||||
*/
|
*/
|
||||||
public static void evaluate(Conversation conversation, Quote quote){
|
public static Quote evaluate(Conversation conversation, Quote quote){
|
||||||
//parse data about the quote
|
//parse data about the quote
|
||||||
SentenceFunctionCategorizor.categorize(quote);
|
SentenceFunctionCategorizor.categorize(quote);
|
||||||
|
|
||||||
@ -32,7 +34,9 @@ public class EvaluationTree {
|
|||||||
GoalEval.evaluate(conversation);
|
GoalEval.evaluate(conversation);
|
||||||
|
|
||||||
//synthesize language based on the results of the actions performed
|
//synthesize language based on the results of the actions performed
|
||||||
//TODO
|
Quote response = ResponseEval.evaluate(conversation);
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,8 @@ package org.studiorailgun.conversation.evaluators.goal;
|
|||||||
|
|
||||||
import org.studiorailgun.conversation.ConvParticipant;
|
import org.studiorailgun.conversation.ConvParticipant;
|
||||||
import org.studiorailgun.conversation.Conversation;
|
import org.studiorailgun.conversation.Conversation;
|
||||||
import org.studiorailgun.conversation.evaluators.GreetingData;
|
|
||||||
import org.studiorailgun.conversation.evaluators.goal.GoalData.ConversationGoal;
|
import org.studiorailgun.conversation.evaluators.goal.GoalData.ConversationGoal;
|
||||||
|
import org.studiorailgun.conversation.evaluators.greet.GreetingData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluates the AI's goal in the conversation
|
* Evaluates the AI's goal in the conversation
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package org.studiorailgun.conversation.evaluators;
|
package org.studiorailgun.conversation.evaluators.greet;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.studiorailgun.conversation.evaluators;
|
package org.studiorailgun.conversation.evaluators.greet;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -43,4 +43,14 @@ public class GreetingEval {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a greeting for the other participant
|
||||||
|
* @param conversation The conversation
|
||||||
|
* @return The greeting
|
||||||
|
*/
|
||||||
|
public static Quote constructGreeting(Conversation conversation){
|
||||||
|
Quote response = new Quote("Hello");
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package org.studiorailgun.conversation.evaluators.synthesis;
|
||||||
|
|
||||||
|
import org.studiorailgun.conversation.Conversation;
|
||||||
|
import org.studiorailgun.conversation.Quote;
|
||||||
|
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluates any response the ai might want to construct
|
||||||
|
*/
|
||||||
|
public class ResponseEval {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluates whether the ai wants to respond or not
|
||||||
|
* @param conversation The conversation
|
||||||
|
* @return The quote encapsulating the AI's response
|
||||||
|
*/
|
||||||
|
public static Quote evaluate(Conversation conversation){
|
||||||
|
Quote response = null;
|
||||||
|
switch(conversation.getGoalData().getGoal()){
|
||||||
|
case GREET: {
|
||||||
|
response = GreetingEval.constructGreeting(conversation);
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@ package org.studiorailgun;
|
|||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.studiorailgun.conversation.Quote;
|
||||||
import org.studiorailgun.conversation.evaluators.goal.GoalData.ConversationGoal;
|
import org.studiorailgun.conversation.evaluators.goal.GoalData.ConversationGoal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,4 +29,13 @@ public class GreetingTests {
|
|||||||
assertEquals(Globals.conversation.getGoalData().getGoal(), ConversationGoal.GREET);
|
assertEquals(Globals.conversation.getGoalData().getGoal(), ConversationGoal.GREET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testResponse(){
|
||||||
|
Globals.init("./data/test/webs/web.json");
|
||||||
|
|
||||||
|
Quote response = AI.simFrame("Hello");
|
||||||
|
|
||||||
|
assertNotEquals(response, null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user