public override void Allocate()
        {
            // tokenTracker = new TokenTracker();
            // tokenTypeTracker = new TokenTypeTracker();

            ScoreTimer = TimerPool.GetTimer(this, "Score");
            PruneTimer = TimerPool.GetTimer(this, "Prune");
            GrowTimer  = TimerPool.GetTimer(this, "Grow");

            TotalTokensScored = StatisticsVariable.GetStatisticsVariable("totalTokensScored");
            CurTokensScored   = StatisticsVariable.GetStatisticsVariable("curTokensScored");
            TokensCreated     = StatisticsVariable.GetStatisticsVariable("tokensCreated");

            try
            {
                Linguist.Allocate();
                Pruner.Allocate();
                Scorer.Allocate();
            }
            catch (IOException e)
            {
                throw new SystemException("Allocation of search manager resources failed", e);
            }
        }
        /// <summary>
        /// @see Search.SearchManager#allocate()
        /// </summary>
        public override void Allocate()
        {
            _totalTokensScored = StatisticsVariable.GetStatisticsVariable("totalTokensScored");
            _tokensPerSecond   = StatisticsVariable.GetStatisticsVariable("tokensScoredPerSecond");
            _curTokensScored   = StatisticsVariable.GetStatisticsVariable("curTokensScored");
            TokensCreated      = StatisticsVariable.GetStatisticsVariable("tokensCreated");
            _viterbiPruned     = StatisticsVariable.GetStatisticsVariable("viterbiPruned");
            _beamPruned        = StatisticsVariable.GetStatisticsVariable("beamPruned");

            try
            {
                Linguist.Allocate();
                _pruner.Allocate();
                _scorer.Allocate();
            }
            catch (IOException e)
            {
                throw new SystemException("Allocation of search manager resources failed", e);
            }

            _scoreTimer = TimerPool.GetTimer(this, "Score");
            _pruneTimer = TimerPool.GetTimer(this, "Prune");
            GrowTimer   = TimerPool.GetTimer(this, "Grow");
        }
示例#3
0
        /// <summary>
        /// @see Search.SearchManager#allocate()
        /// </summary>
        override public void allocate()
        {
            totalTokensScored = StatisticsVariable.getStatisticsVariable("totalTokensScored");
            tokensPerSecond   = StatisticsVariable.getStatisticsVariable("tokensScoredPerSecond");
            curTokensScored   = StatisticsVariable.getStatisticsVariable("curTokensScored");
            tokensCreated     = StatisticsVariable.getStatisticsVariable("tokensCreated");
            viterbiPruned     = StatisticsVariable.getStatisticsVariable("viterbiPruned");
            beamPruned        = StatisticsVariable.getStatisticsVariable("beamPruned");

            try
            {
                linguist.allocate();
                pruner.allocate();
                scorer.allocate();
            }
            catch (IOException e)
            {
                throw new SystemException("Allocation of search manager resources failed", e);
            }

            scoreTimer = TimerPool.getTimer(this, "Score");
            pruneTimer = TimerPool.getTimer(this, "Prune");
            growTimer  = TimerPool.getTimer(this, "Grow");
        }
        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;
                }
            }
        }
示例#5
0
        public static void main(string[] argv)
        {
            if (argv.Length < 2)
            {
                [email protected]("Usage: BatchDecoder propertiesFile batchFile [-shell]");
                java.lang.System.exit(1);
            }
            string text  = argv[0];
            string text2 = argv[1];

            try
            {
                URL url = new File(text).toURI().toURL();
                ConfigurationManager configurationManager = new ConfigurationManager(url);
                BatchModeRecognizer  batchModeRecognizer  = (BatchModeRecognizer)configurationManager.lookup("batch");
                if (batchModeRecognizer != null)
                {
                    if (argv.Length >= 3 && String.instancehelper_equals(argv[2], "-shell"))
                    {
                        batchModeRecognizer.shell(text2);
                    }
                    else
                    {
                        batchModeRecognizer.decode(text2);
                    }
                    [email protected](new StringBuilder().append("Tokens created: ").append(StatisticsVariable.getStatisticsVariable("totalTokensScored").value).toString());
                }
                java.lang.System.err.println(new StringBuilder().append("Can't find batchModeRecognizer in ").append(text).toString());
            }
            catch (System.Exception ex)
            {
                java.lang.System.err.println("Error during decoding: \n  ");
                Throwable.instancehelper_printStackTrace(ex);
            }
        }
示例#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;
            }
        }