/** * Finds the NGram probability ID for the given nth word in a NGram. * * @param nthWordID the ID of the nth word * @return the NGram Probability ID of the given nth word */ public int findProbabilityID(int nthWordID) { int mid, start = 0, end = getNumberNGrams(); int nGram = -1; while ((end - start) > 0) { mid = (start + end) / 2; int midWordID = getWordID(mid); if (midWordID < nthWordID) { start = mid + 1; } else if (midWordID > nthWordID) { end = mid; } else { nGram = getProbabilityID(mid); break; } } return nGram; }
int m = trigram.getWordID(l); float logtgprob = ngramProbTable[2][trigram .getProbabilityID(l)]; double tgprob = logMath.logToLinear(logtgprob); float logbgprob = getBigramProb(k, m);
/** * Finds the NGram probability ID for the given nth word in a NGram. * * @param nthWordID the ID of the nth word * @return the NGram Probability ID of the given nth word */ public int findProbabilityID(int nthWordID) { int mid, start = 0, end = getNumberNGrams(); int nGram = -1; while ((end - start) > 0) { mid = (start + end) / 2; int midWordID = getWordID(mid); if (midWordID < nthWordID) { start = mid + 1; } else if (midWordID > nthWordID) { end = mid; } else { nGram = getProbabilityID(mid); break; } } return nGram; }
int m = trigram.getWordID(l); float logtgprob = ngramProbTable[2][trigram .getProbabilityID(l)]; double tgprob = logMath.logToLinear(logtgprob); float logbgprob = getBigramProb(k, m);