middles[i - 2] = new MiddleNgramSet(startPtrs[i - 2], quantProbBoLen, counts[i-1], counts[0], counts[i]);
void readNextRange(int ngramIdx, TrieRange range) { int offset = ngramIdx * totalBits; offset += wordBits; offset += getQuantBits(); range.begin = bitArr.readInt(memPtr, offset, nextMask); offset += totalBits; range.end = bitArr.readInt(memPtr, offset, nextMask); }
/** * Finds ngram index which corresponds to ngram with specified wordId. * Search is performed in specified range. * Fills range with ngram successors if ngram was found, makes range invalid otherwise. * @param ngramSet - set of ngrams of certain order to look in * @param wordId - word id to look for * @param range - range to look in. range contains ngram successors or is invalid after method usage. * @return ngram index that can be converted into byte offset if ngram was found, -1 otherwise */ private int findNgram(NgramSet ngramSet, int wordId, TrieRange range) { int ptr; range.begin--; if ((ptr = uniformFind(ngramSet, range, wordId)) < 0) { range.setFound(false); return -1; } //read next order ngrams for future searches if (ngramSet instanceof MiddleNgramSet) ((MiddleNgramSet)ngramSet).readNextRange(ptr, range); return ptr; }
middles[i - 2] = new MiddleNgramSet(startPtrs[i - 2], quantProbBoLen, counts[i-1], counts[0], counts[i]);
/** * Finds ngram index which corresponds to ngram with specified wordId. * Search is performed in specified range. * Fills range with ngram successors if ngram was found, makes range invalid otherwise. * @param ngramSet - set of ngrams of certain order to look in * @param wordId - word id to look for * @param range - range to look in. range contains ngram successors or is invalid after method usage. * @return ngram index that can be converted into byte offset if ngram was found, -1 otherwise */ private int findNgram(NgramSet ngramSet, int wordId, TrieRange range) { int ptr; range.begin--; if ((ptr = uniformFind(ngramSet, range, wordId)) < 0) { range.setFound(false); return -1; } //read next order ngrams for future searches if (ngramSet instanceof MiddleNgramSet) ((MiddleNgramSet)ngramSet).readNextRange(ptr, range); return ptr; }
void readNextRange(int ngramIdx, TrieRange range) { int offset = ngramIdx * totalBits; offset += wordBits; offset += getQuantBits(); range.begin = bitArr.readInt(memPtr, offset, nextMask); offset += totalBits; range.end = bitArr.readInt(memPtr, offset, nextMask); }