From 16e8e666d43d3cac193cafd5b96ad2cebcd8bb0d Mon Sep 17 00:00:00 2001 From: austin Date: Tue, 31 Dec 2024 19:44:13 -0500 Subject: [PATCH] name transmission tests --- current_goal.txt | 1 - .../name/TransferNameEvaluationTests.java | 69 +++++++++++++++++++ .../name/TransferNameParsingTests.java | 60 ++++++++++++++++ 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/studiorailgun/transfer/name/TransferNameEvaluationTests.java create mode 100644 src/test/java/org/studiorailgun/transfer/name/TransferNameParsingTests.java diff --git a/current_goal.txt b/current_goal.txt index 53a6090..b533d4e 100644 --- a/current_goal.txt +++ b/current_goal.txt @@ -5,7 +5,6 @@ sitting in a tavern by a fireplace -Parse the sentence "I am John" diff --git a/src/test/java/org/studiorailgun/transfer/name/TransferNameEvaluationTests.java b/src/test/java/org/studiorailgun/transfer/name/TransferNameEvaluationTests.java new file mode 100644 index 0000000..c430f60 --- /dev/null +++ b/src/test/java/org/studiorailgun/transfer/name/TransferNameEvaluationTests.java @@ -0,0 +1,69 @@ +package org.studiorailgun.transfer.name; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.List; + +import org.junit.Test; +import org.studiorailgun.Globals; +import org.studiorailgun.ai.conversation.evaluators.transfer.TransferEval; +import org.studiorailgun.ai.conversation.parser.NLPParser; +import org.studiorailgun.ai.conversation.tracking.Quote; +import org.studiorailgun.ai.conversation.web.ConversationQuery; +import org.studiorailgun.ai.knowledge.Node; +import org.studiorailgun.ai.linguistics.NameQuery; + +/** + * Tests for evaluating transfer statements + */ +public class TransferNameEvaluationTests { + + @Test + public void testEval1(){ + Globals.init("./data/webs/test/web.json"); + Quote input = new Quote("My name is John."); + NLPParser.parse(input); + + Globals.conversation.addQuote(ConversationQuery.getOtherParticipant(), input); + + TransferEval.evaluate(Globals.conversation, input, input.getSentences().get(0)); + + //search for the name being assigned in the knowledge web + Node otherParticipant = ConversationQuery.getOtherParticipant(); + List names = NameQuery.getNames(otherParticipant); + assertEquals(names.get(0).getName(),"John"); + } + + @Test + public void testEval2(){ + Globals.init("./data/webs/test/web.json"); + Quote input = new Quote("I am John."); + NLPParser.parse(input); + + Globals.conversation.addQuote(ConversationQuery.getOtherParticipant(), input); + + TransferEval.evaluate(Globals.conversation, input, input.getSentences().get(0)); + + //search for the name being assigned in the knowledge web + Node otherParticipant = ConversationQuery.getOtherParticipant(); + List names = NameQuery.getNames(otherParticipant); + assertEquals(names.get(0).getName(),"John"); + } + + @Test + public void testEval3(){ + Globals.init("./data/webs/test/web.json"); + Quote input = new Quote("I'm John."); + NLPParser.parse(input); + + Globals.conversation.addQuote(ConversationQuery.getOtherParticipant(), input); + + TransferEval.evaluate(Globals.conversation, input, input.getSentences().get(0)); + + //search for the name being assigned in the knowledge web + Node otherParticipant = ConversationQuery.getOtherParticipant(); + List names = NameQuery.getNames(otherParticipant); + assertEquals(names.get(0).getName(),"John"); + } + +} diff --git a/src/test/java/org/studiorailgun/transfer/name/TransferNameParsingTests.java b/src/test/java/org/studiorailgun/transfer/name/TransferNameParsingTests.java new file mode 100644 index 0000000..e950197 --- /dev/null +++ b/src/test/java/org/studiorailgun/transfer/name/TransferNameParsingTests.java @@ -0,0 +1,60 @@ +package org.studiorailgun.transfer.name; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.Test; +import org.studiorailgun.Globals; +import org.studiorailgun.ai.conversation.parser.NLPParser; +import org.studiorailgun.ai.conversation.parser.depend.Clause; +import org.studiorailgun.ai.conversation.tracking.Quote; +import org.studiorailgun.ai.conversation.tracking.Sentence; + +/** + * Transfer statement parsing tests + */ +public class TransferNameParsingTests { + + @Test + public void testParse1(){ + Globals.init("./data/webs/test/web.json"); + Quote input = new Quote("My name is John."); + NLPParser.parse(input); + Sentence sentence = input.getSentences().get(0); + Clause mainClause = sentence.getMainClause(); + + //has a copular verb + assertEquals(mainClause.getPredicate().getRoot().originalText(),"John"); + assertEquals(mainClause.getPredicate().getCopular().originalText(),"is"); + assertEquals(mainClause.getSubject().getRoot().originalText(), "name"); + assertEquals(mainClause.getSubject().getPossessiveModifier().originalText(), "My"); + } + + @Test + public void testParse2(){ + Globals.init("./data/webs/test/web.json"); + Quote input = new Quote("I am John."); + NLPParser.parse(input); + Sentence sentence = input.getSentences().get(0); + Clause mainClause = sentence.getMainClause(); + + //has a copular verb + assertEquals(mainClause.getPredicate().getRoot().originalText(),"John"); + assertEquals(mainClause.getPredicate().getCopular().originalText(),"am"); + assertEquals(mainClause.getSubject().getRoot().originalText(), "I"); + } + + @Test + public void testParse3(){ + Globals.init("./data/webs/test/web.json"); + Quote input = new Quote("I'm John."); + NLPParser.parse(input); + Sentence sentence = input.getSentences().get(0); + Clause mainClause = sentence.getMainClause(); + + //has a copular verb + assertEquals(mainClause.getPredicate().getRoot().originalText(),"John"); + assertEquals(mainClause.getPredicate().getCopular().originalText(),"'m"); + assertEquals(mainClause.getSubject().getRoot().originalText(), "I"); + } + +}