private Set getStartingContexts() { if (this.startingContexts == null) { this.startingContexts = new HashSet(); if (this.node.isEmpty()) { GrammarArc[] successors = this.getSuccessors(); GrammarArc[] array = successors; int num = array.Length; for (int i = 0; i < num; i++) { GrammarArc grammarArc = array[i]; FlatLinguist.GState gstate = this.this_0.getGState(grammarArc.getGrammarNode()); this.startingContexts.addAll(gstate.getStartingContexts()); } } else { Word word = this.node.getWord(); Pronunciation[] pronunciations = word.getPronunciations(); Pronunciation[] array2 = pronunciations; int i = array2.Length; for (int j = 0; j < i; j++) { Pronunciation pronunciation = array2[j]; UnitContext startingContext = this.getStartingContext(pronunciation); this.startingContexts.add(startingContext); } } } return(this.startingContexts); }
public virtual void connect() { GrammarArc[] successors = this.getSuccessors(); int num = successors.Length; for (int i = 0; i < num; i++) { GrammarArc grammarArc = successors[i]; FlatLinguist.GState gstate = this.this_0.getGState(grammarArc.getGrammarNode()); if (gstate.getNode().isEmpty() || !String.instancehelper_equals(gstate.getNode().getWord().getSpelling(), "<s>")) { float num2 = grammarArc.getProbability(); if (FlatLinguist.access_800(this.this_0) && !gstate.getNode().isEmpty()) { int num3 = gstate.getNode().getWord().getPronunciations().Length; num2 -= this.this_0.logMath.linearToLog((double)num3); } float num4 = num2; Iterator iterator = this.exitPoints.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry)iterator.next(); List list = gstate.getEntryPoints((ContextPair)entry.getKey()); if (list != null) { List list2 = (List)entry.getValue(); this.connect(list2, list, num4); } } } } }
protected internal virtual SentenceHMMState findStartingState() { GrammarNode initialNode = this.grammar.getInitialNode(); FlatLinguist.GState gstate = this.getGState(initialNode); return(gstate.getEntryPoint()); }
private void pullRightContexts() { GrammarArc[] successors = this.getSuccessors(); GrammarArc[] array = successors; int num = array.Length; for (int i = 0; i < num; i++) { GrammarArc grammarArc = array[i]; FlatLinguist.GState gstate = this.this_0.getGState(grammarArc.getGrammarNode()); this.rightContexts.addAll(gstate.getStartingContexts()); } }
internal virtual void pushLeftContexts(Set set, Collection collection) { if (set.contains(this.getNode())) { return; } set.add(this.getNode()); GrammarArc[] successors = this.getSuccessors(); int num = successors.Length; for (int i = 0; i < num; i++) { GrammarArc grammarArc = successors[i]; FlatLinguist.GState gstate = this.this_0.getGState(grammarArc.getGrammarNode()); gstate.addLeftContext(collection); if (gstate.getNode().isEmpty()) { gstate.pushLeftContexts(set, collection); } } }
internal static void access_000(FlatLinguist.GState gstate, UnitContext unitContext) { gstate.addLeftContext(unitContext); }
protected internal virtual Collection compileGrammar() { this.initialGrammarState = this.grammar.getInitialNode(); this.nodeStateMap = new HashMap(); this.arcPool = new Cache(); ArrayList arrayList = new ArrayList(); TimerPool.getTimer(this, "Compile").start(); TimerPool.getTimer(this, "Create States").start(); Iterator iterator = this.grammar.getGrammarNodes().iterator(); while (iterator.hasNext()) { GrammarNode grammarNode = (GrammarNode)iterator.next(); FlatLinguist.GState gstate = this.createGState(grammarNode); arrayList.add(gstate); } TimerPool.getTimer(this, "Create States").stop(); this.addStartingPath(); TimerPool.getTimer(this, "Collect Contexts").start(); iterator = arrayList.iterator(); while (iterator.hasNext()) { FlatLinguist.GState gstate2 = (FlatLinguist.GState)iterator.next(); gstate2.collectContexts(); } TimerPool.getTimer(this, "Collect Contexts").stop(); TimerPool.getTimer(this, "Expand States").start(); iterator = arrayList.iterator(); while (iterator.hasNext()) { FlatLinguist.GState gstate2 = (FlatLinguist.GState)iterator.next(); gstate2.expand(); } TimerPool.getTimer(this, "Expand States").stop(); TimerPool.getTimer(this, "Connect Nodes").start(); iterator = arrayList.iterator(); while (iterator.hasNext()) { FlatLinguist.GState gstate2 = (FlatLinguist.GState)iterator.next(); gstate2.connect(); } TimerPool.getTimer(this, "Connect Nodes").stop(); SentenceHMMState sentenceHMMState = this.findStartingState(); if (this.addOutOfGrammarBranch) { CIPhoneLoop ciphoneLoop = new CIPhoneLoop(this.phoneLoopAcousticModel, this.logPhoneInsertionProbability); SentenceHMMState nextState = (SentenceHMMState)ciphoneLoop.getSearchGraph().getInitialState(); sentenceHMMState.connect(this.getArc(nextState, 0f, this.logOutOfGrammarBranchProbability)); } this.searchGraph = new FlatLinguist.FlatSearchGraph(this, sentenceHMMState); TimerPool.getTimer(this, "Compile").stop(); if (this.dumpGStates) { Iterator iterator2 = this.grammar.getGrammarNodes().iterator(); while (iterator2.hasNext()) { GrammarNode node = (GrammarNode)iterator2.next(); FlatLinguist.GState gstate3 = this.getGState(node); gstate3.dumpInfo(); } } this.nodeStateMap = null; this.arcPool = null; return(SentenceHMMState.collectStates(sentenceHMMState)); }
protected internal virtual void addStartingPath(GrammarNode initialNode) { FlatLinguist.GState gstate = this.getGState(initialNode); FlatLinguist.GState.access_000(gstate, UnitContext.SILENCE); }