示例#1
0
            /**
             * /// Expands the given hmm state tree
             *
             * /// @param parent the parent of the tree
             * /// @param tree   the tree to expand
             * /// @return the final state in the tree
             */
            private HMMStateState ExpandHMMTree(UnitState parent, HMMStateState tree)
            {
                HMMStateState retState = tree;

                foreach (HmmStateArc arc in tree.HmmState.GetSuccessors())
                {
                    HMMStateState newState;
                    if (arc.HmmState.IsEmitting)
                    {
                        newState = new HMMStateState(parent, arc.HmmState);
                    }
                    else
                    {
                        newState = new NonEmittingHMMState(parent, arc.HmmState);
                    }
                    SentenceHMMState existingState = GetExistingState(newState);
                    float            logProb       = arc.LogProbability;
                    if (existingState != null)
                    {
                        AttachState(tree, existingState, LogOne, logProb);
                    }
                    else
                    {
                        AttachState(tree, newState, LogOne, logProb);
                        AddStateToCache(newState);
                        retState = ExpandHMMTree(parent, newState);
                    }
                }
                return(retState);
            }
        /**
         * /// Expands the given hmm state tree
         *
         * /// @param parent the parent of the tree
         * /// @param tree   the tree to expand
         * /// @return the final state in the tree
         */
        protected HMMStateState ExpandHMMTree(UnitState parent, HMMStateState tree)
        {
            var retState = tree;

            foreach (var arc in tree.HmmState.GetSuccessors())
            {
                HMMStateState newState;
                if (arc.HmmState.IsEmitting)
                {
                    newState = new HMMStateState(parent, arc.HmmState);
                }
                else
                {
                    newState = new NonEmittingHMMState(parent, arc.HmmState);
                }
                var existingState = GetExistingState(newState);
                var logProb       = arc.LogProbability;
                if (existingState != null)
                {
                    AttachState(tree, existingState, _parent.LogOne, logProb);
                }
                else
                {
                    AttachState(tree, newState, _parent.LogOne, logProb);
                    AddStateToCache(newState);
                    retState = ExpandHMMTree(parent, newState);
                }
            }
            return(retState);
        }