Search in sources :

Example 1 with QuestionReformulator

use of info.ephyra.querygeneration.QuestionReformulator in project lucida by claritylab.

the class QuestionReformulationG method generateQueries.

/**
	 * Generates queries that are reformulations of the question string.
	 * 
	 * @param aq analyzed question
	 * @return <code>Query</code> objects
	 */
public Query[] generateQueries(AnalyzedQuestion aq) {
    // only generate queries if the answer type is known or the question is
    // not a factoid question
    String[] ats = aq.getAnswerTypes();
    if (ats.length == 0 && aq.isFactoid())
        return new Query[0];
    ArrayList<Query> results = new ArrayList<Query>();
    // create question reformulations
    String verbMod = aq.getVerbMod();
    String[] kws = aq.getKeywords();
    if (reformulators != null) {
        // reformulators loaded
        Query[] queries;
        for (QuestionReformulator reformulator : reformulators) {
            queries = reformulator.apply(verbMod);
            if (queries != null)
                for (Query query : queries) {
                    // include context keywords in the query string
                    String queryString = query.getQueryString();
                    for (String kw : kws) if (!StringUtils.equalsCommonNorm(queryString, kw))
                        queryString += " " + kw;
                    query.setQueryString(queryString);
                    query.setAnalyzedQuestion(aq);
                    query.setExtractionTechniques(EXTRACTION_TECHNIQUES);
                    results.add(query);
                }
        }
    }
    return results.toArray(new Query[results.size()]);
}
Also used : Query(info.ephyra.querygeneration.Query) ArrayList(java.util.ArrayList) QuestionReformulator(info.ephyra.querygeneration.QuestionReformulator)

Aggregations

Query (info.ephyra.querygeneration.Query)1 QuestionReformulator (info.ephyra.querygeneration.QuestionReformulator)1 ArrayList (java.util.ArrayList)1