Example #1
0
  /** Initializes the pipeline for factoid questions. */
  protected void initFactoid() {
    // question analysis
    Ontology wordNet = new WordNet();
    // - dictionaries for term extraction
    QuestionAnalysis.clearDictionaries();
    QuestionAnalysis.addDictionary(wordNet);
    // - ontologies for term expansion
    QuestionAnalysis.clearOntologies();
    QuestionAnalysis.addOntology(wordNet);

    // query generation
    QueryGeneration.clearQueryGenerators();
    QueryGeneration.addQueryGenerator(new BagOfWordsG());
    QueryGeneration.addQueryGenerator(new BagOfTermsG());
    QueryGeneration.addQueryGenerator(new PredicateG());
    QueryGeneration.addQueryGenerator(new QuestionInterpretationG());
    QueryGeneration.addQueryGenerator(new QuestionReformulationG());

    // search
    // - knowledge miners for unstructured knowledge sources
    Search.clearKnowledgeMiners();

    for (String[] indriIndices : IndriKM.getIndriIndices())
      Search.addKnowledgeMiner(new IndriKM(indriIndices, false));
    //		for (String[] indriServers : IndriKM.getIndriServers())
    //			Search.addKnowledgeMiner(new IndriKM(indriServers, true));
    // - knowledge annotators for (semi-)structured knowledge sources
    Search.clearKnowledgeAnnotators();

    // answer extraction and selection
    // (the filters are applied in this order)
    AnswerSelection.clearFilters();
    // - answer extraction filters
    AnswerSelection.addFilter(new AnswerTypeFilter());
    AnswerSelection.addFilter(new AnswerPatternFilter());
    AnswerSelection.addFilter(new WebDocumentFetcherFilter());
    AnswerSelection.addFilter(new PredicateExtractionFilter());
    AnswerSelection.addFilter(new FactoidsFromPredicatesFilter());
    AnswerSelection.addFilter(new TruncationFilter());
    // - answer selection filters
    AnswerSelection.addFilter(new StopwordFilter());
    AnswerSelection.addFilter(new QuestionKeywordsFilter());
    AnswerSelection.addFilter(new ScoreNormalizationFilter(NORMALIZER));
    AnswerSelection.addFilter(new ScoreCombinationFilter());
    AnswerSelection.addFilter(new FactoidSubsetFilter());
    AnswerSelection.addFilter(new DuplicateFilter());
    AnswerSelection.addFilter(new ScoreSorterFilter());
  }
Example #2
0
  /**
   * Runs the pipeline and returns an array of up to <code>maxAnswers</code> results that have a
   * score of at least <code>absThresh</code>.
   *
   * @param aq analyzed question
   * @param maxAnswers maximum number of answers
   * @param absThresh absolute threshold for scores
   * @return array of results
   */
  protected Result[] runPipeline(AnalyzedQuestion aq, int maxAnswers, float absThresh) {
    // query generation
    MsgPrinter.printGeneratingQueries();
    Query[] queries = QueryGeneration.getQueries(aq);

    // search
    MsgPrinter.printSearching();
    Result[] results = Search.doSearch(queries);

    // answer selection
    MsgPrinter.printSelectingAnswers();
    results = AnswerSelection.getResults(results, maxAnswers, absThresh);

    return results;
  }