Exemplo n.º 1
0
        public NgramTrieQuant(int order, NgramTrieQuant.QuantType quantType)
        {
            int num = NgramTrieQuant_1._SwitchMap_edu_cmu_sphinx_linguist_language_ngram_trie_NgramTrieQuant_QuantType[quantType.ordinal()];

            if (num == 1)
            {
                return;
            }
            if (num == 2)
            {
                this.probBits    = 16;
                this.backoffBits = 16;
                this.probMask    = (1 << this.probBits) - 1;
                this.backoffMask = (1 << this.backoffBits) - 1;
                this.tables      = new float[(order - 1) * 2 - 1][];
                this.quantType   = quantType;
                return;
            }
            string text = new StringBuilder().append("Unsupported quantization type: ").append(quantType).toString();

            throw new Error(text);
        }
Exemplo n.º 2
0
        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);
        }