tests + conversational web functions
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
This commit is contained in:
parent
4e844b85bf
commit
a64489e87b
@ -0,0 +1,24 @@
|
||||
package org.studiorailgun.conversation.web;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.studiorailgun.Globals;
|
||||
import org.studiorailgun.knowledge.Node;
|
||||
import org.studiorailgun.knowledge.query.filter.NameQueryFilter;
|
||||
|
||||
/**
|
||||
* Queries for nodes related to conversations
|
||||
*/
|
||||
public class ConversationQuery {
|
||||
|
||||
/**
|
||||
* Gets the node for the other participant in the conversation
|
||||
* @return The other participant in the conversation
|
||||
*/
|
||||
public static Node getOtherParticipant(){
|
||||
List<Node> nodes = new LinkedList<Node>(Globals.web.getNodes());
|
||||
return NameQueryFilter.withNodeName(nodes, "Other");
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,4 +21,9 @@ public class RelationTypes {
|
||||
*/
|
||||
public static final String QUALITY_OF = "qualityOf";
|
||||
|
||||
/**
|
||||
* The name of a node in a linguistic sense
|
||||
*/
|
||||
public static final String NAME_OF = "nameOf";
|
||||
|
||||
}
|
||||
|
||||
24
src/main/java/org/studiorailgun/linguistics/NameQuery.java
Normal file
24
src/main/java/org/studiorailgun/linguistics/NameQuery.java
Normal file
@ -0,0 +1,24 @@
|
||||
package org.studiorailgun.linguistics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.studiorailgun.Globals;
|
||||
import org.studiorailgun.knowledge.Node;
|
||||
import org.studiorailgun.knowledge.Relation;
|
||||
import org.studiorailgun.knowledge.types.RelationTypes;
|
||||
|
||||
/**
|
||||
* Queries related to the linguistic concept of a name
|
||||
*/
|
||||
public class NameQuery {
|
||||
|
||||
/**
|
||||
* Gets the names of a given node
|
||||
*/
|
||||
public static List<Node> getNames(Node node){
|
||||
List<Relation> relations = Globals.web.getRelationsOfChildNode(node);
|
||||
return relations.stream().filter(relation -> relation.getName().equals(RelationTypes.NAME_OF)).map(relation -> relation.getParent()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package org.studiorailgun.transfer;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.studiorailgun.Globals;
|
||||
import org.studiorailgun.conversation.evaluators.transfer.TransferEval;
|
||||
import org.studiorailgun.conversation.parser.NLPParser;
|
||||
import org.studiorailgun.conversation.tracking.Quote;
|
||||
import org.studiorailgun.conversation.web.ConversationQuery;
|
||||
import org.studiorailgun.knowledge.Node;
|
||||
import org.studiorailgun.linguistics.NameQuery;
|
||||
|
||||
/**
|
||||
* Tests for evaluating transfer statements
|
||||
*/
|
||||
public class TransferEvaluationTests {
|
||||
|
||||
@Test
|
||||
public void testEval1(){
|
||||
Globals.init("./data/webs/test/web.json");
|
||||
Quote input = new Quote("My name is John.");
|
||||
NLPParser.parse(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<Node> names = NameQuery.getNames(otherParticipant);
|
||||
// assertEquals(names.get(0).getName(),"John");
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
package org.studiorailgun;
|
||||
package org.studiorailgun.transfer;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.studiorailgun.Globals;
|
||||
import org.studiorailgun.conversation.parser.NLPParser;
|
||||
import org.studiorailgun.conversation.parser.depend.Clause;
|
||||
import org.studiorailgun.conversation.tracking.Quote;
|
||||
Loading…
Reference in New Issue
Block a user