/** * 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 */ @Override public NGramProbability findNGram(int nthWordID) { int mid, start = 0, end = getNumberNGrams(); 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; }
/** * Returns the NGramProbability of the nth follower. * * @param nthFollower which follower * @return the NGramProbability of the nth follower */ @Override public int getProbabilityID(int nthFollower) { int nthPosition = 0; nthPosition = nthFollower * LargeNGramModel.BYTES_PER_NMAXGRAM * ((is32bits()) ? 4 : 2); setPosition(nthPosition + ((is32bits()) ? 4 : 2)); // to skip the word ID return readBytesAsInt(); }
currentBuffer = new NMaxGramBuffer(buffer, numberNGrams, loader.getBigEndian(), is32bits(), orderBuffer, firstCurrentNGramEntry);
currentBuffer = new NMaxGramBuffer(buffer, numberNGrams, loader.getBigEndian(), is32bits(), orderBuffer, firstCurrentNGramEntry);
/** * Returns the NGramProbability of the nth follower. * * @param nthFollower which follower * @return the NGramProbability of the nth follower */ @Override public NGramProbability getNGramProbability(int nthFollower) { int nthPosition = 0, wordID = 0, probID = 0, backoffID = 0, firstNGram = 0; nthPosition = nthFollower * LargeNGramModel.BYTES_PER_NMAXGRAM * ((is32bits()) ? 4 : 2); setPosition(nthPosition); wordID = readBytesAsInt(); probID = readBytesAsInt(); return (new NGramProbability(nthFollower, wordID, probID, backoffID, firstNGram)); } }
/** * 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 */ @Override public NGramProbability findNGram(int nthWordID) { int mid, start = 0, end = getNumberNGrams(); 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; }
/** * Returns the NGramProbability of the nth follower. * * @param nthFollower which follower * @return the NGramProbability of the nth follower */ @Override public int getProbabilityID(int nthFollower) { int nthPosition = 0; nthPosition = nthFollower * LargeNGramModel.BYTES_PER_NMAXGRAM * ((is32bits()) ? 4 : 2); setPosition(nthPosition + ((is32bits()) ? 4 : 2)); // to skip the word ID return readBytesAsInt(); }
/** * Returns the NGramProbability of the nth follower. * * @param nthFollower which follower * @return the NGramProbability of the nth follower */ @Override public NGramProbability getNGramProbability(int nthFollower) { int nthPosition = 0, wordID = 0, probID = 0, backoffID = 0, firstNGram = 0; nthPosition = nthFollower * LargeNGramModel.BYTES_PER_NMAXGRAM * ((is32bits()) ? 4 : 2); setPosition(nthPosition); wordID = readBytesAsInt(); probID = readBytesAsInt(); return (new NGramProbability(nthFollower, wordID, probID, backoffID, firstNGram)); } }