/** * /// 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); }
/** * /// Returns the list of successors to this state * * /// @return a list of SearchState objects */ public override ISearchStateArc[] GetSuccessors() { ISearchStateArc[] arcs = new ISearchStateArc[1]; IHMM hmm = GetHMMNode().HMM; arcs[0] = new LexTreeHmmState(GetHMMNode(), WordHistory, SmearTerm, SmearProb, hmm.GetInitialState(), _parent.LogOne, _parent.LogOne, _parentNode, _parent); return(arcs); }
/** * /// 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); }
/** * /// Retrieves the set of successors for this state * * /// @return the list of successor states */ public override ISearchStateArc[] GetSuccessors() { var nextStates = GetCachedArcs(); if (nextStates == null) { //if this is an exit state, we are transitioning to a //new unit or to a word end. if (HmmState.IsExitState()) { if (_parentNode == null) { nextStates = base.GetSuccessors(); } else { nextStates = base.GetSuccessors(_parentNode); } } else { //The current hmm state is not an exit state, so we //just go through the next set of successors var arcs = HmmState.GetSuccessors(); nextStates = new ISearchStateArc[arcs.Length]; for (var i = 0; i < arcs.Length; i++) { var arc = arcs[i]; if (arc.HmmState.IsEmitting) { //if its a self loop and the prob. matches //reuse the state if (arc.HmmState == HmmState && _logInsertionProbability == arc.LogProbability) { nextStates[i] = this; } else { nextStates[i] = new LexTreeHmmState( (HMMNode)GetNode(), WordHistory, SmearTerm, SmearProb, arc.HmmState, Parent.LogOne, arc.LogProbability, _parentNode, Parent); } } else { nextStates[i] = new LexTreeNonEmittingHMMState( (HMMNode)GetNode(), WordHistory, SmearTerm, SmearProb, arc.HmmState, arc.LogProbability, _parentNode, Parent); } } } PutCachedArcs(nextStates); } return(nextStates); }