Search in sources :

Example 11 with Predicate

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;
}
Also used : Query(info.ephyra.querygeneration.Query) Term(info.ephyra.questionanalysis.Term) Predicate(info.ephyra.nlp.semantics.Predicate)

Example 12 with Predicate

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;
}
Also used : Predicate(info.ephyra.nlp.semantics.Predicate)

Aggregations

Predicate (info.ephyra.nlp.semantics.Predicate)12 Query (info.ephyra.querygeneration.Query)6 Term (info.ephyra.questionanalysis.Term)6 ArrayList (java.util.ArrayList)4 Result (info.ephyra.search.Result)3 HashSet (java.util.HashSet)3 IOException (java.io.IOException)2 ParseException (java.text.ParseException)2 Hashtable (java.util.Hashtable)2 AnalyzedQuestion (info.ephyra.questionanalysis.AnalyzedQuestion)1 Dictionary (info.ephyra.util.Dictionary)1 FileCache (info.ephyra.util.FileCache)1 FileOutputStream (java.io.FileOutputStream)1 PrintWriter (java.io.PrintWriter)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1