query evaluation work
Some checks failed
studiorailgun/trpg/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/trpg/pipeline/head There was a failure building this commit
This commit is contained in:
parent
9c7e32094d
commit
9ff39934c5
@ -1,2 +1,9 @@
|
|||||||
word,lemma,valence,tense,mood,aspect
|
word,lemma
|
||||||
be,be,2,?,?,?
|
be,be
|
||||||
|
am,be
|
||||||
|
is,be
|
||||||
|
are,be
|
||||||
|
was,be
|
||||||
|
were,be
|
||||||
|
being,be
|
||||||
|
been,be
|
||||||
|
@ -3,7 +3,8 @@ package org.studiorailgun.conversation.evaluators.query;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
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.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;
|
||||||
@ -23,30 +24,35 @@ public class QueryEval {
|
|||||||
*/
|
*/
|
||||||
public static void evaluate(Conversation conversation, Quote quote, Sentence sentence){
|
public static void evaluate(Conversation conversation, Quote quote, Sentence sentence){
|
||||||
SemanticGraph semanticGraph = sentence.getGraph();
|
SemanticGraph semanticGraph = sentence.getGraph();
|
||||||
if(semanticGraph.getRoots().size() > 1){
|
Clause mainClause = sentence.getMainClause();
|
||||||
String message = "Multiple roots to sentence!\n" +
|
Predicate predicate = mainClause.getPredicate();
|
||||||
"\"" + quote.getRaw() + "\"\n" +
|
|
||||||
semanticGraph;
|
|
||||||
throw new UnsupportedOperationException(message);
|
if(predicate.getCopular() != null){
|
||||||
}
|
QueryEval.evaluateCopular(conversation,quote,sentence);
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
String message = "Unsupported root type!\n" +
|
String message = "Unsupported predicate type!\n" +
|
||||||
"\"" + sentence.getRaw() + "\"\n" +
|
"\"" + sentence.getRaw() + "\"\n" +
|
||||||
semanticGraph;
|
semanticGraph;
|
||||||
throw new UnsupportedOperationException(message);
|
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
|
* Evaluates an equivalence query
|
||||||
* @param conversation The conversation
|
* @param conversation The conversation
|
||||||
|
|||||||
@ -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";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -127,6 +127,14 @@ public class Predicate {
|
|||||||
this.copularVerb = copularWord;
|
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
|
* Sets the existential status of the predicate
|
||||||
* @param existential true if existential, false otherwise
|
* @param existential true if existential, false otherwise
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user