protected internal virtual void collectSuccessorTokens(Token token)
        {
            if (token.isFinal())
            {
                this.resultList.add(this.getResultListPredecessor(token));
                return;
            }
            if (!token.isEmitting() && this.keepAllTokens && this.isVisited(token))
            {
                return;
            }
            SearchState searchState = token.getSearchState();

            SearchStateArc[] successors            = searchState.getSuccessors();
            Token            resultListPredecessor = this.getResultListPredecessor(token);

            SearchStateArc[] array = successors;
            int num = array.Length;

            for (int i = 0; i < num; i++)
            {
                SearchStateArc searchStateArc = array[i];
                SearchState    state          = searchStateArc.getState();
                if (this._checkStateOrder)
                {
                    this.checkStateOrder(searchState, state);
                }
                float num2      = token.getScore() + searchStateArc.getProbability();
                Token bestToken = this.getBestToken(state);
                if (bestToken == null)
                {
                    Token token2 = new Token(resultListPredecessor, state, num2, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), this.currentCollectTime);
                    StatisticsVariable statisticsVariable = this.tokensCreated;
                    statisticsVariable.value += (double)1f;
                    this.setBestToken(token2, state);
                    this.activeListAdd(token2);
                }
                else if (bestToken.getScore() < num2)
                {
                    Token token2 = bestToken.getPredecessor();
                    bestToken.update(resultListPredecessor, state, num2, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), this.currentCollectTime);
                    if (this.buildWordLattice && state is WordSearchState)
                    {
                        this.loserManager.addAlternatePredecessor(bestToken, token2);
                    }
                }
                else if (this.buildWordLattice && state is WordSearchState && resultListPredecessor != null)
                {
                    this.loserManager.addAlternatePredecessor(bestToken, resultListPredecessor);
                }
            }
        }
Ejemplo n.º 2
0
        private string getArcColor(SearchStateArc searchStateArc)
        {
            string text = null;

            if ((double)searchStateArc.getLanguageProbability() != (double)0f)
            {
                text = "green";
            }
            if ((double)searchStateArc.getInsertionProbability() != (double)0f)
            {
                if (text == null)
                {
                    text = "blue";
                }
                else
                {
                    text = "purple";
                }
            }
            if (text == null)
            {
                text = "black";
            }
            return(text);
        }
Ejemplo n.º 3
0
        protected internal virtual void collectFastMatchSuccessorTokens(Token token)
        {
            SearchState searchState = token.getSearchState();

            SearchStateArc[] successors = searchState.getSuccessors();
            SearchStateArc[] array      = successors;
            int num = array.Length;

            for (int i = 0; i < num; i++)
            {
                SearchStateArc searchStateArc        = array[i];
                SearchState    state                 = searchStateArc.getState();
                float          num2                  = token.getScore() + searchStateArc.getProbability();
                Token          resultListPredecessor = this.getResultListPredecessor(token);
                if (!state.isEmitting())
                {
                    Token token2 = new Token(resultListPredecessor, state, num2, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), (long)this.currentFastMatchFrameNumber);
                    StatisticsVariable tokensCreated = this.tokensCreated;
                    tokensCreated.value += (double)1f;
                    if (!this.isVisited(token2))
                    {
                        this.collectFastMatchSuccessorTokens(token2);
                    }
                }
                else
                {
                    Token token2 = this.getFastMatchBestToken(state);
                    if (token2 == null)
                    {
                        Token token3 = new Token(resultListPredecessor, state, num2, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), (long)this.currentFastMatchFrameNumber);
                        StatisticsVariable tokensCreated2 = this.tokensCreated;
                        tokensCreated2.value += (double)1f;
                        this.setFastMatchBestToken(token3, state);
                        this.fastmatchActiveList.add(token3);
                    }
                    else if (token2.getScore() <= num2)
                    {
                        token2.update(resultListPredecessor, state, num2, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), (long)this.currentFastMatchFrameNumber);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected internal override void dumpArc(PrintStream @out, SearchState from, SearchStateArc arc, int level)
        {
            ArrayList arrayList = new ArrayList();

            if (this.skipHMMs)
            {
                if (from is HMMSearchState)
                {
                    return;
                }
                if (arc.getState() is HMMSearchState)
                {
                    this.findNextNonHMMArc(arc, arrayList);
                }
                else
                {
                    arrayList.add(arc);
                }
            }
            else
            {
                arrayList.add(arc);
            }
            Iterator iterator = arrayList.iterator();

            while (iterator.hasNext())
            {
                SearchStateArc searchStateArc = (SearchStateArc)iterator.next();
                string         text           = "";
                string         arcColor       = this.getArcColor(searchStateArc);
                if (this.dumpArcLabels)
                {
                    double num  = this.logMath.logToLinear(searchStateArc.getLanguageProbability());
                    double num2 = this.logMath.logToLinear(searchStateArc.getInsertionProbability());
                    text = new StringBuilder().append(" label: ").append(this.qs(new StringBuilder().append('(').append(this.formatEdgeLabel(num)).append(',').append(this.formatEdgeLabel(num2)).append(')').toString())).toString();
                }
                @out.println(new StringBuilder().append("   edge: { sourcename: ").append(this.qs(this.getUniqueName(from))).append(" targetname: ").append(this.qs(this.getUniqueName(searchStateArc.getState()))).append(text).append(" color: ").append(arcColor).append('}').toString());
            }
        }
        protected internal virtual void collectSuccessorTokens(Token token)
        {
            SearchState searchState = token.getSearchState();

            if (token.isFinal())
            {
                this.resultList.add(token);
            }
            if (token.getScore() < this.threshold)
            {
                return;
            }
            if (searchState is WordSearchState && token.getScore() < this.wordThreshold)
            {
                return;
            }
            SearchStateArc[] successors = searchState.getSuccessors();
            SearchStateArc[] array      = successors;
            int num = array.Length;
            int i   = 0;

            while (i < num)
            {
                SearchStateArc searchStateArc = array[i];
                SearchState    state          = searchStateArc.getState();
                float          num2           = token.getScore() + searchStateArc.getProbability();
                if (!this.wantEntryPruning)
                {
                    goto IL_A8;
                }
                if (num2 >= this.threshold)
                {
                    if (!(state is WordSearchState) || num2 >= this.wordThreshold)
                    {
                        goto IL_A8;
                    }
                }
IL_1D7:
                i++;
                continue;
IL_A8:
                Token resultListPredecessor = this.getResultListPredecessor(token);
                if (!state.isEmitting())
                {
                    Token token2 = new Token(resultListPredecessor, state, num2, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), this.currentCollectTime);
                    StatisticsVariable statisticsVariable = this.tokensCreated;
                    statisticsVariable.value += (double)1f;
                    if (!this.isVisited(token2))
                    {
                        this.collectSuccessorTokens(token2);
                        goto IL_1D7;
                    }
                    goto IL_1D7;
                }
                else
                {
                    Token token2 = this.getBestToken(state);
                    if (token2 == null)
                    {
                        Token token3 = new Token(resultListPredecessor, state, num2, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), (long)this.currentFrameNumber);
                        StatisticsVariable statisticsVariable2 = this.tokensCreated;
                        statisticsVariable2.value += (double)1f;
                        this.setBestToken(token3, state);
                        this.activeList.add(token3);
                        goto IL_1D7;
                    }
                    if (token2.getScore() <= num2)
                    {
                        token2.update(resultListPredecessor, state, num2, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), this.currentCollectTime);
                        StatisticsVariable statisticsVariable3 = this.viterbiPruned;
                        statisticsVariable3.value += (double)1f;
                        goto IL_1D7;
                    }
                    StatisticsVariable statisticsVariable4 = this.viterbiPruned;
                    statisticsVariable4.value += (double)1f;
                    goto IL_1D7;
                }
            }
        }
Ejemplo n.º 6
0
        protected internal override void collectSuccessorTokens(Token token)
        {
            if (token.isFinal())
            {
                this.resultList.add(this.getResultListPredecessor(token));
                return;
            }
            if (!token.isEmitting() && this.keepAllTokens && this.isVisited(token))
            {
                return;
            }
            SearchState searchState = token.getSearchState();

            SearchStateArc[] successors            = searchState.getSuccessors();
            Token            resultListPredecessor = this.getResultListPredecessor(token);
            float            score         = token.getScore();
            float            beamThreshold = this.activeList.getBeamThreshold();
            int num = (!(searchState is LexTreeLinguist.LexTreeNonEmittingHMMState) && !(searchState is LexTreeLinguist.LexTreeWordState) && !(searchState is LexTreeLinguist.LexTreeEndUnitState)) ? 0 : 1;

            SearchStateArc[] array = successors;
            int num2 = array.Length;
            int i    = 0;

            while (i < num2)
            {
                SearchStateArc searchStateArc = array[i];
                SearchState    state          = searchStateArc.getState();
                if (num == 0 || !(state is LexTreeLinguist.LexTreeHMMState))
                {
                    goto IL_110;
                }
                int   baseID = ((LexTreeLinguist.LexTreeHMMState)state).getHMMState().getHMM().getBaseUnit().getBaseID();
                Float @float = ((Float)this.penalties.get(Integer.valueOf(baseID))) ?? this.updateLookaheadPenalty(baseID);
                if (score + this.lookaheadWeight * @float.floatValue() >= beamThreshold)
                {
                    goto IL_110;
                }
IL_207:
                i++;
                continue;
IL_110:
                if (this._checkStateOrder)
                {
                    this.checkStateOrder(searchState, state);
                }
                float num3      = score + searchStateArc.getProbability();
                Token bestToken = this.getBestToken(state);
                if (bestToken == null)
                {
                    Token token2 = new Token(resultListPredecessor, state, num3, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), this.currentCollectTime);
                    StatisticsVariable tokensCreated = this.tokensCreated;
                    tokensCreated.value += (double)1f;
                    this.setBestToken(token2, state);
                    this.activeListAdd(token2);
                    goto IL_207;
                }
                if (bestToken.getScore() < num3)
                {
                    Token token2 = bestToken.getPredecessor();
                    bestToken.update(resultListPredecessor, state, num3, searchStateArc.getInsertionProbability(), searchStateArc.getLanguageProbability(), this.currentCollectTime);
                    if (this.buildWordLattice && state is WordSearchState)
                    {
                        this.loserManager.addAlternatePredecessor(bestToken, token2);
                    }
                    goto IL_207;
                }
                if (this.buildWordLattice && state is WordSearchState && resultListPredecessor != null)
                {
                    this.loserManager.addAlternatePredecessor(bestToken, resultListPredecessor);
                    goto IL_207;
                }
                goto IL_207;
            }
        }