/** * Finds the NGram index for the given nth word in a NGram * * @param nthWordID the ID of the nth word * @return the NGramIndex of the given nth word */ public int findNGramIndex(int nthWordID) { int mid = -1, start = 0, end = getNumberNGrams() - 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 { break; } } return mid; }
out.writeInt(bigram.getNumberNGrams()); for (int j = 0; j < bigram.getNumberNGrams(); j++) { int k = bigram.getWordID(j); Float smearTerm = getSmearTerm(i, k);
NGramBuffer bigram = getBigramBuffer(i); if (bigram.getNumberNGrams() != numBigrams) { in.close(); throw new IOException("Bad ngrams for unigram " + i + " Found " + numBigrams + " expected " + bigram.getNumberNGrams());
/** * Finds the NGram probabilities for the given nth word in a NGram. * * @param nthWordID the ID of the nth word * @return the NGramProbability of the given nth word */ public NGramProbability findNGram(int nthWordID) { int mid, start = 0, end = getNumberNGrams() - 1; NGramProbability ngram = null; 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 = getNGramProbability(mid); break; } } return ngram; }
/** * 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; }
double ugbackoff = logMath.logToLinear(logugbackoff); for (int j = 0; j < bigram.getNumberNGrams(); j++) { int wordID = bigram.getWordID(j); NGramProbability bgProb = bigram.getNGramProbability(j); continue; for (int j = 0; j < bigram.getNumberNGrams(); j++) { float smearTerm; NGramProbability bgProb = bigram.getNGramProbability(j); double bg_numerator = 0; double bg_denominator = 0; for (int l = 0; l < trigram.getNumberNGrams(); l++) { int m = trigram.getWordID(l); float logtgprob = ngramProbTable[2][trigram
/** * Finds the NGram index for the given nth word in a NGram * * @param nthWordID the ID of the nth word * @return the NGramIndex of the given nth word */ public int findNGramIndex(int nthWordID) { int mid = -1, start = 0, end = getNumberNGrams() - 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 { break; } } return mid; }
out.writeInt(bigram.getNumberNGrams()); for (int j = 0; j < bigram.getNumberNGrams(); j++) { int k = bigram.getWordID(j); Float smearTerm = getSmearTerm(i, k);
NGramBuffer bigram = getBigramBuffer(i); if (bigram.getNumberNGrams() != numBigrams) { in.close(); throw new IOException("Bad ngrams for unigram " + i + " Found " + numBigrams + " expected " + bigram.getNumberNGrams());
/** * 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; }
/** * Finds the NGram probabilities for the given nth word in a NGram. * * @param nthWordID the ID of the nth word * @return the NGramProbability of the given nth word */ public NGramProbability findNGram(int nthWordID) { int mid, start = 0, end = getNumberNGrams() - 1; NGramProbability ngram = null; 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 = getNGramProbability(mid); break; } } return ngram; }
double ugbackoff = logMath.logToLinear(logugbackoff); for (int j = 0; j < bigram.getNumberNGrams(); j++) { int wordID = bigram.getWordID(j); NGramProbability bgProb = bigram.getNGramProbability(j); continue; for (int j = 0; j < bigram.getNumberNGrams(); j++) { float smearTerm; NGramProbability bgProb = bigram.getNGramProbability(j); double bg_numerator = 0; double bg_denominator = 0; for (int l = 0; l < trigram.getNumberNGrams(); l++) { int m = trigram.getWordID(l); float logtgprob = ngramProbTable[2][trigram