use of info.ephyra.nlp.semantics.Predicate in project lucida by claritylab.
the class BagOfWordsG method generateQueries.
/**
* Generates a "bag of words" query from the keywords in the question
* string.
*
* @param aq analyzed question
* @return <code>Query</code> objects
*/
public Query[] generateQueries(AnalyzedQuestion aq) {
// only generate a query if the answer type is known, predicates could
// be extracted or the question is not a factoid question
String[] ats = aq.getAnswerTypes();
Predicate[] ps = aq.getPredicates();
if (ats.length == 0 && ps.length == 0 && aq.isFactoid())
return new Query[0];
// create query string
Term[] terms = aq.getTerms();
String[] kws = aq.getKeywords();
String queryString = getQueryString(terms, kws);
// create query, set answer types
Query[] queries = new Query[1];
queries[0] = new Query(queryString, aq, SCORE);
queries[0].setExtractionTechniques(EXTRACTION_TECHNIQUES);
return queries;
}
use of info.ephyra.nlp.semantics.Predicate in project lucida by claritylab.
the class TermExpander method isTarget.
/**
* Checks if the term is the target of one of the predicates.
*
* @param term a term
* @param ps predicates in the same sentence
* @return <code>true</code> iff the term is a predicate target
*/
private static boolean isTarget(Term term, Predicate[] ps) {
String text = term.getText();
String lemma = WordNet.getLemma(text, POS.VERB);
for (Predicate p : ps) {
String verb = p.getVerb();
if (verb.matches(".*?\\b" + text + "\\b.*+"))
return true;
// built from an offset annotation)
if (lemma != null && verb.matches(".*?\\b" + lemma + "\\b.*+"))
return true;
}
return false;
}
Aggregations