public static Set collectStates(SentenceHMMState start)
        {
            HashSet    hashSet    = new HashSet();
            LinkedList linkedList = new LinkedList();

            linkedList.add(start);
            while (!linkedList.isEmpty())
            {
                SentenceHMMState sentenceHMMState = (SentenceHMMState)linkedList.remove(0);
                hashSet.add(sentenceHMMState);
                SearchStateArc[] successors = sentenceHMMState.getSuccessors();
                SearchStateArc[] array      = successors;
                int num = array.Length;
                for (int i = 0; i < num; i++)
                {
                    SearchStateArc   searchStateArc    = array[i];
                    SentenceHMMState sentenceHMMState2 = (SentenceHMMState)searchStateArc.getState();
                    if (!hashSet.contains(sentenceHMMState2) && !linkedList.contains(sentenceHMMState2))
                    {
                        linkedList.add(sentenceHMMState2);
                    }
                }
            }
            return(hashSet);
        }
Exemplo 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);
        }
Exemplo n.º 3
0
 public override SearchStateArc[] getSuccessors()
 {
     SearchStateArc[] array = this.getCachedSuccessors();
     if (array != null)
     {
         return(array);
     }
     if (this.isFinal())
     {
         array = DynamicFlatLinguist.access_100(this.this_0);
     }
     else if (this.node.isEmpty())
     {
         array = this.getNextGrammarStates(this.lc, this.nextBaseID);
     }
     else
     {
         Word             word           = this.node.getWord();
         Pronunciation[]  pronunciations = word.getPronunciations();
         SearchStateArc[] array2         = new SearchStateArc[pronunciations.Length];
         for (int i = 0; i < pronunciations.Length; i++)
         {
             array2[i] = new DynamicFlatLinguist.PronunciationState(this.this_0, this, pronunciations[i]);
         }
         array = array2;
     }
     this.cacheSuccessors(array);
     return(array);
 }
Exemplo n.º 4
0
 internal SearchStateArc[] getSuccessors(int num, int num2)
 {
     SearchStateArc[] array;
     if (num2 == this.pronunciation.getUnits().Length - 1)
     {
         if (this.isContextIndependentUnit(this.pronunciation.getUnits()[num2]))
         {
             array = new SearchStateArc[]
             {
                 new DynamicFlatLinguist.FullHMMSearchState(this.this_0, this, num2, num, 0)
             };
         }
         else
         {
             int[] nextUnits = this.gs.getNextUnits();
             array = new SearchStateArc[nextUnits.Length];
             for (int i = 0; i < array.Length; i++)
             {
                 array[i] = new DynamicFlatLinguist.FullHMMSearchState(this.this_0, this, num2, num, nextUnits[i]);
             }
         }
     }
     else
     {
         array = new SearchStateArc[]
         {
             new DynamicFlatLinguist.FullHMMSearchState(this.this_0, this, num2, num)
         };
     }
     return(array);
 }
Exemplo n.º 5
0
            public override SearchStateArc[] getSuccessors()
            {
                AFlatLinguist.access_108(this.this_0);
                ulong num  = (ulong)AFlatLinguist.access_100(this.this_0);
                ulong num2 = (ulong)500000;

                if (((num2 != 18446744073709551615UL) ? (num % num2) : 0UL) == 0UL)
                {
                    AFlatLinguist.access_200(this.this_0).info(new StringBuilder().append("Free Memory= ").append(this.this_0.runtime.freeMemory() / (long)((ulong)1048576)).append(" MB\tMax Memory= ").append(this.this_0.runtime.maxMemory() / (long)((ulong)1048576)).append("MB").toString());
                }
                SearchStateArc[] array = this.getCachedSuccessors();
                if (array == null)
                {
                    if (this.isFinal())
                    {
                        array = AFlatLinguist.access_300(this.this_0);
                    }
                    else if (this.node.isEmpty())
                    {
                        array = this.getNextGrammarStates(this.lc, this.nextBaseID);
                    }
                    else
                    {
                        Word            word   = this.node.getWord();
                        Pronunciation[] array2 = word.getPronunciations();
                        array2 = this.filter(array2, this.nextBaseID);
                        SearchStateArc[] array3;
                        if (AFlatLinguist.access_400(this.this_0))
                        {
                            array3 = new SearchStateArc[array2.Length + 1];
                        }
                        else
                        {
                            array3 = new SearchStateArc[array2.Length];
                        }
                        for (int i = 0; i < array2.Length; i++)
                        {
                            array3[i] = new AFlatLinguist.PronunciationState(this.this_0, this, array2[i]);
                        }
                        SearchStateArc[] toGrammarSearchState = new SearchStateArc[]
                        {
                            this
                        };
                        if (AFlatLinguist.access_400(this.this_0))
                        {
                            PhoneLoop phoneLoop = new PhoneLoop(AFlatLinguist.access_500(this.this_0), AFlatLinguist.access_600(this.this_0), AFlatLinguist.access_700(this.this_0), toGrammarSearchState);
                            array3[array2.Length] = phoneLoop.getPhoneLoop();
                        }
                        array = array3;
                    }
                    this.cacheSuccessors(array);
                }
                return(array);
            }
Exemplo n.º 6
0
 internal SearchStateArc[] getNextGrammarStates(int num, int num2)
 {
     GrammarArc[] array = this.node.getSuccessors();
     array = this.filter(array, num2);
     SearchStateArc[] array2 = new SearchStateArc[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         GrammarArc grammarArc = array[i];
         array2[i] = new DynamicFlatLinguist.GrammarState(this.this_0, grammarArc.getGrammarNode(), grammarArc.getProbability(), num, num2);
     }
     return(array2);
 }
        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);
                }
            }
        }
Exemplo n.º 8
0
 public override SearchStateArc[] getSuccessors()
 {
     SearchStateArc[] array = this.getCachedSuccessors();
     if (array == null)
     {
         array = new SearchStateArc[]
         {
             new DynamicFlatLinguist.HMMStateSearchState(this.this_0, this, this.hmm.getInitialState())
         };
         this.cacheSuccessors(array);
     }
     return(array);
 }
Exemplo n.º 9
0
 public override SearchStateArc[] getSuccessors()
 {
     if (this.hmmState.isExitState())
     {
         return(PhoneLoop.access_400(this.this_0));
     }
     HMMStateArc[]    successors = this.hmmState.getSuccessors();
     SearchStateArc[] array      = new SearchStateArc[successors.Length];
     for (int i = 0; i < successors.Length; i++)
     {
         array[i] = new PhoneLoop.OogHMMState(this.this_0, successors[i].getHMMState(), successors[i].getLogProbability());
     }
     return(array);
 }
Exemplo n.º 10
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);
                    }
                }
            }
        }
 public virtual SearchStateArc[] getSuccessors()
 {
     SearchStateArc[] array;
     if (this.state.isExitState())
     {
         ArrayList units = this.linguist.getUnits(((SenoneHMM)this.state.getHMM()).getSenoneSequence());
         array = new SearchStateArc[units.size()];
         for (int i = 0; i < array.Length; i++)
         {
             array[i] = new PhoneNonEmittingSearchState((Unit)units.get(i), this.linguist, this.insertionProb, this.languageProb);
         }
         return(array);
     }
     HMMStateArc[] successors = this.state.getSuccessors();
     array = new SearchStateArc[successors.Length];
     for (int i = 0; i < successors.Length; i++)
     {
         array[i] = new PhoneHmmSearchState(successors[i].getHMMState(), this.linguist, this.insertionProb, this.languageProb);
     }
     return(array);
 }
Exemplo n.º 12
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());
            }
        }
Exemplo n.º 13
0
 public override SearchStateArc[] getSuccessors()
 {
     SearchStateArc[] array = this.getCachedSuccessors();
     if (array == null)
     {
         if (this.hmmState.isExitState())
         {
             array = this.fullHMMSearchState.getNextArcs();
         }
         else
         {
             HMMStateArc[] successors = this.hmmState.getSuccessors();
             array = new SearchStateArc[successors.Length];
             for (int i = 0; i < array.Length; i++)
             {
                 array[i] = new DynamicFlatLinguist.HMMStateSearchState(this.this_0, this.fullHMMSearchState, successors[i].getHMMState(), successors[i].getLogProbability());
             }
         }
         this.cacheSuccessors(array);
     }
     return(array);
 }
Exemplo n.º 14
0
            private void dumpExitPoints(Collection collection)
            {
                Iterator iterator = collection.iterator();

                while (iterator.hasNext())
                {
                    List     list      = (List)iterator.next();
                    Iterator iterator2 = list.iterator();
                    while (iterator2.hasNext())
                    {
                        SearchState searchState = (SearchState)iterator2.next();
                        [email protected](new StringBuilder().append("      Arcs from: ").append(searchState).toString());
                        SearchStateArc[] successors = searchState.getSuccessors();
                        int num = successors.Length;
                        for (int i = 0; i < num; i++)
                        {
                            SearchStateArc searchStateArc = successors[i];
                            [email protected](new StringBuilder().append("          ").append(searchStateArc.getState()).toString());
                        }
                    }
                }
            }
Exemplo n.º 15
0
        private void findNextNonHMMArc(SearchStateArc searchStateArc, List list)
        {
            HashSet   hashSet   = new HashSet();
            ArrayList arrayList = new ArrayList();

            arrayList.add(searchStateArc);
            while (!arrayList.isEmpty())
            {
                SearchStateArc searchStateArc2 = (SearchStateArc)arrayList.remove(0);
                if (!hashSet.contains(searchStateArc2))
                {
                    hashSet.add(searchStateArc2);
                    if (!(searchStateArc2.getState() is HMMSearchState))
                    {
                        list.add(searchStateArc2);
                    }
                    else
                    {
                        arrayList.addAll(Arrays.asList(searchStateArc2.getState().getSuccessors()));
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void expandState(int num, List list, SearchState searchState)
        {
            SearchStateArc[] successors = searchState.getSuccessors();
            this.totalStates++;
            if (successors.Length > this.maxSuccessors)
            {
                this.maxSuccessors = successors.Length;
            }
            SearchStateArc[] array = successors;
            int num2 = array.Length;

            for (int i = 0; i < num2; i++)
            {
                SearchStateArc searchStateArc = array[i];
                SearchState    state          = searchStateArc.getState();
                if (state.isEmitting())
                {
                    this.totalEmittingStates++;
                    list.add(state);
                }
                else if (!state.isFinal())
                {
                    this.totalNonEmittingStates++;
                    list.add(state);
                    if (this.details && state.isFinal())
                    {
                        [email protected](new StringBuilder().append("result ").append(state.toPrettyString()).toString());
                    }
                    this.expandState(num + 1, list, state);
                }
                else
                {
                    this.totalFinalStates++;
                }
                this.totalStates++;
            }
        }
Exemplo n.º 17
0
 public void addArc(SearchStateArc searchStateArc)
 {
     this.nextArcs.add(searchStateArc);
 }
Exemplo n.º 18
0
 protected internal virtual void dumpArc(PrintStream @out, SearchState from, SearchStateArc arc, int level)
 {
 }
Exemplo n.º 19
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;
            }
        }
        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;
                }
            }
        }