コード例 #1
0
ファイル: GState.cs プロジェクト: pgrudzien12/syn-speech
 /// <summary>
 /// Expands each GState into the sentence HMM States
 /// </summary>
 public void Expand()
 {
     //this.LogDebug("Item Context: {0} : {1} : {2}",startingContexts.Count, rightContexts.Count, leftContexts.Count);
     // for each left context/starting context pair create a list
     // of starting states.
     foreach (UnitContext leftContext in _leftContexts)
     {
         foreach (UnitContext startingContext in GetStartingContexts())
         {
             ContextPair contextPair = ContextPair.Get(leftContext, startingContext);
             if (!_entryPoints.ContainsKey(contextPair))
             {
                 _entryPoints.Add(contextPair, new List <ISearchState>());
             }
         }
     }
     this.LogDebug("Item entryPoints Count: {0}", _entryPoints.Count);
     // if this is a final node don't expand it, just create a
     // state and add it to all entry points
     if (_node.IsFinalNode)
     {
         GrammarState gs = new GrammarState(_node);
         foreach (List <ISearchState> epList in _entryPoints.Values)
         {
             epList.Add(gs);
         }
     }
     else if (!_node.IsEmpty)
     {
         // its a full fledged node with a word
         // so expand it. Nodes without words don't need
         // to be expanded.
         foreach (UnitContext leftContext in _leftContexts)
         {
             ExpandWord(leftContext);
         }
     }
     else
     {
         //if the node is empty, populate the set of entry and exit
         //points with a branch state. The branch state
         // branches to the successor entry points for this
         // state
         // the exit point should consist of the set of
         // incoming left contexts and outgoing right contexts
         // the 'entryPoint' table already consists of such
         // pairs so we can use that
         foreach (var entry in _entryPoints)
         {
             ContextPair         cp     = entry.Key;
             List <ISearchState> epList = entry.Value;
             SentenceHMMState    bs     = new BranchState(cp.LeftContext.ToString(), cp.RightContext.ToString(), _node.ID);
             epList.Add(bs);
             AddExitPoint(cp, bs);
         }
     }
     AddEmptyEntryPoints();
 }
コード例 #2
0
 /* Creates a WordState
  * /// @param which*/
 public AlternativeState(GrammarState parent, int which)
     : base("A", parent, which)
 {
 }