/** * 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; }
int k = bigram.getWordID(j); Float smearTerm = getSmearTerm(i, k); out.writeInt(k);
int k = bigram.getWordID(j); putSmearTerm(i, k, in.readFloat());
/** * 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; }
int wordID = bigram.getWordID(j); NGramProbability bgProb = bigram.getNGramProbability(j); float logbgbackoff = ngramBackoffTable[2][bgProb.getBackoffID()]; double bgbackoff = logMath.logToLinear(logbgbackoff); int k = bigram.getWordID(j); NGramBuffer trigram = loadTrigramBuffer(i, k); double bg_denominator = 0; for (int l = 0; l < trigram.getNumberNGrams(); l++) { int m = trigram.getWordID(l); float logtgprob = ngramProbTable[2][trigram .getProbabilityID(l)];
/** * 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; }
int k = bigram.getWordID(j); Float smearTerm = getSmearTerm(i, k); out.writeInt(k);
int k = bigram.getWordID(j); putSmearTerm(i, k, in.readFloat());
/** * 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; }
int wordID = bigram.getWordID(j); NGramProbability bgProb = bigram.getNGramProbability(j); float logbgbackoff = ngramBackoffTable[2][bgProb.getBackoffID()]; double bgbackoff = logMath.logToLinear(logbgbackoff); int k = bigram.getWordID(j); NGramBuffer trigram = loadTrigramBuffer(i, k); double bg_denominator = 0; for (int l = 0; l < trigram.getNumberNGrams(); l++) { int m = trigram.getWordID(l); float logtgprob = ngramProbTable[2][trigram .getProbabilityID(l)];