if (nGProbability != null) {
float probability =
ngramProbTable[numberWords - 1][nGProbability
.getProbabilityID()];
return new ProbDepth(probability, numberWords);
}
if (numberWords == 2) {
UnigramProbability unigramProb = getUnigram(firstWord);
UnigramProbability unigramProb1 =
getUnigram(wordSequence.getWord(1));
float probability =
unigramProb.getLogBackoff() + unigramProb1.getLogProbability();
return new ProbDepth(probability, 1);
}
NGramProbability nMinus1Gram = findNGram(wordSequence.getOldest());
if (nMinus1Gram != null) {
ProbDepth result1 = getProbDepth(wordSequence.getNewest());
float probability =
ngramBackoffTable[numberWords - 1][nMinus1Gram.getBackoffID()] +
result1.probability;
return new ProbDepth(probability, result1.depth);
}
return getProbDepth(wordSequence.getNewest());
}