public virtual NgramTrieQuant readQuant(int order) { int num = Utilities.readLittleEndianInt(this.inStream); if (num < 0 || num >= NgramTrieQuant.QuantType.values().Length) { string text = new StringBuilder().append("Unknown quantatization type: ").append(num).toString(); throw new Error(text); } NgramTrieQuant.QuantType quantType = NgramTrieQuant.QuantType.values()[num]; NgramTrieQuant ngramTrieQuant = new NgramTrieQuant(order, quantType); for (int i = 2; i <= order; i++) { ngramTrieQuant.setTable(this.readFloatArr(ngramTrieQuant.getProbTableLen()), i, true); if (i < order) { ngramTrieQuant.setTable(this.readFloatArr(ngramTrieQuant.getBackoffTableLen()), i, false); } } return(ngramTrieQuant); }
public virtual float readNgramProb(int wordId, int orderMinusTwo, NgramTrieModel.TrieRange range, NgramTrieQuant quant) { NgramTrie.NgramSet ngram = this.getNgram(orderMinusTwo); int num; if ((num = this.findNgram(ngram, wordId, range)) < 0) { return(0f); } return(quant.readProb(this.bitArr, ngram.memPtr, ngram.getNgramWeightsOffset(num), orderMinusTwo)); }