/** * Assign scores for similarity in n-gram frequency to the given question to every sentence in the * possible answer. */ public void annotate(PossibleAnswer possibleAnswer) { // count n-gram frequencies of question text Question question = possibleAnswer.getQuestion(); Text text = possibleAnswer.getAnnotatedText(); NGramFrequencyMap questionFreq; for (NGramFreqCounter freqCounter : freqCounters) { questionFreq = freqCounter.extractFreqs(question.getAnnotatedText()); NGramFrequencyMap answerFreq; Double distance; for (Sentence sentence : text.getSentences()) { // count n-gram frequencies for every sentence in the answer-text answerFreq = freqCounter.extractFreqs(sentence); // compare to question frequencies distance = distEval.evaluateDistance(questionFreq, answerFreq); // store distance in sentence sentence.addNgramDistance(extractDescription(freqCounter), distance); } } }
public String extractDescription(NGramFreqCounter freqCounter) { return freqCounter.getDescription() + "_" + distEval.getDescription(); }