query evaluation work
Some checks failed
studiorailgun/trpg/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-12-30 22:18:18 -05:00
parent 9c7e32094d
commit 9ff39934c5
4 changed files with 58 additions and 20 deletions

View File

@ -1,2 +1,9 @@
word,lemma,valence,tense,mood,aspect
be,be,2,?,?,?
word,lemma
be,be
am,be
is,be
are,be
was,be
were,be
being,be
been,be
1 word lemma valence tense mood aspect
2 be be 2 ? ? ?
3 am be
4 is be
5 are be
6 was be
7 were be
8 being be
9 been be

View File

@ -3,7 +3,8 @@ package org.studiorailgun.conversation.evaluators.query;
import java.util.Iterator;
import java.util.Set;
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;
@ -23,30 +24,35 @@ public class QueryEval {
*/
public static void evaluate(Conversation conversation, Quote quote, Sentence sentence){
SemanticGraph semanticGraph = sentence.getGraph();
if(semanticGraph.getRoots().size() > 1){
String message = "Multiple roots to sentence!\n" +
"\"" + quote.getRaw() + "\"\n" +
semanticGraph;
throw new UnsupportedOperationException(message);
}
IndexedWord root = semanticGraph.getFirstRoot();
if(PennTreebankTagSet.isVerb(root.tag())){
if(PennTreebankTagSet.isBe(root.tag())){
QueryEval.evaluateBe(conversation, quote, sentence);
} else {
String message = "Unsupported root verb type!\n" +
"\"" + sentence.getRaw() + "\"\n" +
semanticGraph;
throw new UnsupportedOperationException(message);
}
Clause mainClause = sentence.getMainClause();
Predicate predicate = mainClause.getPredicate();
if(predicate.getCopular() != null){
QueryEval.evaluateCopular(conversation,quote,sentence);
} else {
String message = "Unsupported root type!\n" +
String message = "Unsupported predicate type!\n" +
"\"" + sentence.getRaw() + "\"\n" +
semanticGraph;
throw new UnsupportedOperationException(message);
}
}
/**
* Evaluates a copular sentence
* @param conversation The conversation
* @param quote The quote
* @param sentence The sentence
*/
private static void evaluateCopular(Conversation conversation, Quote quote, Sentence sentence){
SemanticGraph semanticGraph = sentence.getGraph();
Clause mainClause = sentence.getMainClause();
Predicate predicate = mainClause.getPredicate();
IndexedWord copular = predicate.getCopular();
//todo, different logic based on type of copular verb
QueryEval.evaluateBe(conversation, quote, sentence);
}
/**
* Evaluates an equivalence query
* @param conversation The conversation

View File

@ -0,0 +1,17 @@
package org.studiorailgun.conversation.parser.bank;
/**
* A lemma lookup bank
*/
public class Lemma {
/**
* Gets the lemma of a word
* @param word The word
* @return The lemma of the word
*/
public static String getLemma(String word){
return "be";
}
}

View File

@ -127,6 +127,14 @@ public class Predicate {
this.copularVerb = copularWord;
}
/**
* Gets the copular verb
* @return The copular verb if it exists, null otherwise
*/
public IndexedWord getCopular(){
return this.copularVerb;
}
/**
* Sets the existential status of the predicate
* @param existential true if existential, false otherwise