clause direct object tracking
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good

This commit is contained in:
austin 2024-12-30 23:12:39 -05:00
parent 962586a5fd
commit f66f1d6816
3 changed files with 52 additions and 11 deletions

View File

@ -5,15 +5,15 @@ sitting in a tavern by a fireplace
Use arguments from clause parsing to perform queries when answering question
- use subject to find some node
- use interrogative argument to apply filters to the lookup
Comprehend the sentence "My name is ${name}" Comprehend the sentence "My name is ${name}"
- Transfer statement eval - Transfer statement eval
Update parsers to use "Arguments" (currently called "NounStack"), "Predicates" (Not defined yet, but essentially verbs), and "Adjuncts" (also not defined yet, are noncritial information eg "yesterday")
Update parsers to determine valence of sentence (maybe create a dictionary to lookup?)

View File

@ -5,6 +5,8 @@ import java.util.Set;
import org.studiorailgun.conversation.evaluators.query.NounStack; import org.studiorailgun.conversation.evaluators.query.NounStack;
import org.studiorailgun.conversation.parser.PennTreebankTagSet; import org.studiorailgun.conversation.parser.PennTreebankTagSet;
import org.studiorailgun.conversation.parser.depend.Clause;
import org.studiorailgun.conversation.parser.depend.Predicate;
import org.studiorailgun.conversation.tracking.Conversation; import org.studiorailgun.conversation.tracking.Conversation;
import org.studiorailgun.conversation.tracking.Quote; import org.studiorailgun.conversation.tracking.Quote;
import org.studiorailgun.conversation.tracking.Sentence; import org.studiorailgun.conversation.tracking.Sentence;
@ -25,14 +27,15 @@ public class AnswerSynthesis {
*/ */
public static Sentence evaluate(Conversation conversation, Quote query, Sentence sentence){ public static Sentence evaluate(Conversation conversation, Quote query, Sentence sentence){
SemanticGraph semanticGraph = sentence.getGraph(); SemanticGraph semanticGraph = sentence.getGraph();
if(semanticGraph.getRoots().size() > 1){
String message = "Multiple roots to sentence!\n" +
"\"" + sentence.getRaw() + "\"\n" +
semanticGraph;
throw new UnsupportedOperationException(message);
}
IndexedWord root = semanticGraph.getFirstRoot(); IndexedWord root = semanticGraph.getFirstRoot();
if(PennTreebankTagSet.isVerb(root.tag())){ Clause mainClause = sentence.getMainClause();
Predicate predicate = mainClause.getPredicate();
if(predicate.getCopular() != null){
String message = "Copular verb type not supported yet!\n" +
"\"" + sentence.getRaw() + "\"\n" +
semanticGraph;
throw new UnsupportedOperationException(message);
} else if(PennTreebankTagSet.isVerb(root.tag())){
if(PennTreebankTagSet.isBe(root.tag())){ if(PennTreebankTagSet.isBe(root.tag())){
String answerRaw = AnswerSynthesis.evaluateBe(conversation, query, sentence); String answerRaw = AnswerSynthesis.evaluateBe(conversation, query, sentence);
Sentence rVal = new Sentence(answerRaw); Sentence rVal = new Sentence(answerRaw);

View File

@ -60,6 +60,11 @@ public class Clause {
*/ */
Argument subject; Argument subject;
/**
* The direct object
*/
Argument directObject;
/** /**
* The adjuncts of the sentence * The adjuncts of the sentence
*/ */
@ -133,6 +138,7 @@ public class Clause {
case "direct object": { case "direct object": {
Argument arg = new Argument(child, ArgumentType.NOMINAL); Argument arg = new Argument(child, ArgumentType.NOMINAL);
rVal.arguments.add(arg); rVal.arguments.add(arg);
rVal.directObject = arg;
} break; } break;
//indirect objects //indirect objects
@ -243,30 +249,62 @@ public class Clause {
return rVal; return rVal;
} }
/**
* Gets the predicate
* @return The predicate
*/
public Predicate getPredicate() { public Predicate getPredicate() {
return predicate; return predicate;
} }
/**
* Gets the arguments of the clause
* @return The arguments
*/
public List<Argument> getArguments() { public List<Argument> getArguments() {
return arguments; return arguments;
} }
/**
* Gets the subject of the clause
* @return The subject
*/
public Argument getSubject() { public Argument getSubject() {
return subject; return subject;
} }
/**
* Gets the adjuncts of the clause
* @return The adjuncts
*/
public List<Adjunct> getAdjuncts() { public List<Adjunct> getAdjuncts() {
return adjuncts; return adjuncts;
} }
/**
* Gets the sub clauses of this clause
* @return The sub clauses
*/
public List<Clause> getClauses(){ public List<Clause> getClauses(){
return clauses; return clauses;
} }
/**
* Gets the coordinator for this clause
* @return The coordinator
*/
public Coordinator getCoordinator(){ public Coordinator getCoordinator(){
return coordinator; return coordinator;
} }
/**
* Gets the direct object
* @return The direct object
*/
public Argument getDirectObject(){
return directObject;
}
} }