private static List getNextGrammarNodesWithWords(GrammarNode grammarNode) { ArrayList arrayList = new ArrayList(); GrammarArc[] successors = grammarNode.getSuccessors(); int num = successors.Length; for (int i = 0; i < num; i++) { GrammarArc grammarArc = successors[i]; GrammarNode grammarNode2 = grammarArc.getGrammarNode(); if (grammarNode2.getAlternatives().Length == 0) { if (grammarNode2.isFinalNode()) { arrayList.add(grammarNode2); } else { arrayList.addAll(GrammarPoint.getNextGrammarNodesWithWords(grammarNode2)); } } else { arrayList.add(grammarNode2); } } return(arrayList); }
private void initUnitMaps(GrammarNode grammarNode) { if (this.nodeToNextUnitArrayMap.get(grammarNode) == null) { HashSet hashSet = new HashSet(); HashSet hashSet2 = new HashSet(); GrammarArc[] successors = grammarNode.getSuccessors(); GrammarArc[] array = successors; int num = array.Length; for (int i = 0; i < num; i++) { GrammarArc grammarArc = array[i]; GrammarNode grammarNode2 = grammarArc.getGrammarNode(); this.collectNextUnits(grammarNode2, hashSet, hashSet2); } int[] array2 = new int[hashSet2.size()]; num = 0; Iterator iterator = hashSet2.iterator(); while (iterator.hasNext()) { Unit unit = (Unit)iterator.next(); int[] array3 = array2; int num2 = num; num++; array3[num2] = unit.getBaseID(); } this.nodeToNextUnitArrayMap.put(grammarNode, array2); } if (this.nodeToUnitSetMap.get(grammarNode) == null) { HashSet hashSet = new HashSet(); HashSet hashSet2 = new HashSet(); this.collectNextUnits(grammarNode, hashSet, hashSet2); this.nodeToUnitSetMap.put(grammarNode, hashSet2); } }
private void collectNextUnits(GrammarNode grammarNode, Set set, Set set2) { if (set.contains(grammarNode)) { return; } set.add(grammarNode); if (grammarNode.isFinalNode()) { set2.add(UnitManager.__SILENCE); } else if (!grammarNode.isEmpty()) { Word word = grammarNode.getWord(); Pronunciation[] pronunciations = word.getPronunciations(); Pronunciation[] array = pronunciations; int i = array.Length; for (int j = 0; j < i; j++) { Pronunciation pronunciation = array[j]; set2.add(pronunciation.getUnits()[0]); } } else { GrammarArc[] successors = grammarNode.getSuccessors(); GrammarArc[] array2 = successors; int num = array2.Length; for (int i = 0; i < num; i++) { GrammarArc grammarArc = array2[i]; GrammarNode grammarNode2 = grammarArc.getGrammarNode(); this.collectNextUnits(grammarNode2, set, set2); } } }