/**
         * /// Returns the list of successors to this state
         *
         * /// @return a list of SearchState objects
         */
        public override ISearchStateArc[] GetSuccessors()
        {
            ISearchStateArc[] arcs = GetCachedArcs();
            if (arcs == null)
            {
                HMMNode[] nodes = Parent.GetHMMNodes(GetEndNode());
                arcs = new ISearchStateArc[nodes.Length];

                if (Parent.GenerateUnitStates)
                {
                    for (int i = 0; i < nodes.Length; i++)
                    {
                        arcs[i] = new LexTreeUnitState(nodes[i],
                                                       WordHistory, SmearTerm,
                                                       SmearProb, Parent.LogOne, Parent.LogOne,
                                                       GetNode(), Parent);
                    }
                }
                else
                {
                    for (int i = 0; i < nodes.Length; i++)
                    {
                        IHMM hmm = nodes[i].HMM;
                        arcs[i] = new LexTreeHmmState(nodes[i],
                                                      WordHistory, SmearTerm,
                                                      SmearProb, hmm.GetInitialState(),
                                                      Parent.LogOne, Parent.LogOne, GetNode(), Parent);
                    }
                }
                PutCachedArcs(arcs);
            }
            return(arcs);
        }
Esempio n. 2
0
        /**
         * /// Determines if the given object is equal to this object
         *
         * /// @param o the object to test
         * /// @return <code>true</code> if the object is equal to this
         */

        public override bool Equals(Object o)
        {
            if (o == this)
            {
                return(true);
            }
            if (o is LexTreeUnitState)
            {
                LexTreeUnitState other = (LexTreeUnitState)o;
                return(_parentNode == other._parentNode && base.Equals(o));
            }
            return(false);
        }
Esempio n. 3
0
        /**
         * /// Creates a unit search state for the given unit node
         *
         * /// @param hmmNode the unit node
         *
         * /// @return the search state
         */
        public ISearchStateArc CreateUnitStateArc(HMMNode hmmNode, LexTreeState previous)
        {
            ISearchStateArc arc;

            float insertionProbability = Parent.CalculateInsertionProbability(hmmNode);
            float smearProbability     = Parent.GetUnigramSmear(hmmNode) + previous.SmearTerm;
            float languageProbability  = smearProbability - previous.SmearProb;

            //if we want a unit state create it, otherwise
            //get the first hmm state of the unit

            if (Parent.GenerateUnitStates)
            {
                arc = new LexTreeUnitState(hmmNode, WordHistory, previous.SmearTerm, smearProbability, languageProbability,
                                           insertionProbability, Parent);
            }
            else
            {
                IHMM hmm = hmmNode.HMM;
                arc = new LexTreeHmmState(hmmNode, WordHistory, previous.SmearTerm, smearProbability, hmm.GetInitialState(),
                                          languageProbability, insertionProbability, null, Parent);
            }
            return(arc);
        }