diff --git a/current_goal.txt b/current_goal.txt index a1bb8ca..7ced37e 100644 --- a/current_goal.txt +++ b/current_goal.txt @@ -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}" - 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?) - - diff --git a/src/main/java/org/studiorailgun/conversation/evaluators/transfer/AnswerSynthesis.java b/src/main/java/org/studiorailgun/conversation/evaluators/transfer/AnswerSynthesis.java index d966879..1d71203 100644 --- a/src/main/java/org/studiorailgun/conversation/evaluators/transfer/AnswerSynthesis.java +++ b/src/main/java/org/studiorailgun/conversation/evaluators/transfer/AnswerSynthesis.java @@ -5,6 +5,8 @@ import java.util.Set; import org.studiorailgun.conversation.evaluators.query.NounStack; 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.Quote; import org.studiorailgun.conversation.tracking.Sentence; @@ -25,14 +27,15 @@ public class AnswerSynthesis { */ public static Sentence evaluate(Conversation conversation, Quote query, Sentence sentence){ 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(); - 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())){ String answerRaw = AnswerSynthesis.evaluateBe(conversation, query, sentence); Sentence rVal = new Sentence(answerRaw); diff --git a/src/main/java/org/studiorailgun/conversation/parser/depend/Clause.java b/src/main/java/org/studiorailgun/conversation/parser/depend/Clause.java index 581109c..5c6a2fc 100644 --- a/src/main/java/org/studiorailgun/conversation/parser/depend/Clause.java +++ b/src/main/java/org/studiorailgun/conversation/parser/depend/Clause.java @@ -60,6 +60,11 @@ public class Clause { */ Argument subject; + /** + * The direct object + */ + Argument directObject; + /** * The adjuncts of the sentence */ @@ -133,6 +138,7 @@ public class Clause { case "direct object": { Argument arg = new Argument(child, ArgumentType.NOMINAL); rVal.arguments.add(arg); + rVal.directObject = arg; } break; //indirect objects @@ -243,30 +249,62 @@ public class Clause { return rVal; } + /** + * Gets the predicate + * @return The predicate + */ public Predicate getPredicate() { return predicate; } + /** + * Gets the arguments of the clause + * @return The arguments + */ public List getArguments() { return arguments; } + /** + * Gets the subject of the clause + * @return The subject + */ public Argument getSubject() { return subject; } + /** + * Gets the adjuncts of the clause + * @return The adjuncts + */ public List getAdjuncts() { return adjuncts; } + /** + * Gets the sub clauses of this clause + * @return The sub clauses + */ public List getClauses(){ return clauses; } + /** + * Gets the coordinator for this clause + * @return The coordinator + */ public Coordinator getCoordinator(){ return coordinator; } + /** + * Gets the direct object + * @return The direct object + */ + public Argument getDirectObject(){ + return directObject; + } + }