private UnitContext getStartingContext(Pronunciation pronunciation) { int rightContextSize = this.getRightContextSize(); Unit[] units = pronunciation.getUnits(); Unit[] array = (units.Length <= rightContextSize) ? units : ((Unit[])Arrays.copyOf(units, rightContextSize)); return(UnitContext.get(array)); }
internal virtual UnitContext generateNextLeftContext(UnitContext unitContext, Unit unit) { Unit[] units = unitContext.getUnits(); int num = Math.min(units.Length, this.getLeftContextSize()); if (num == 0) { return(UnitContext.EMPTY); } Unit[] array = (Unit[])Arrays.copyOfRange(units, 1, num + 1); array[num - 1] = unit; return(UnitContext.get(array)); }
private SentenceHMMState attachUnit(PronunciationState parent, SentenceHMMState sentenceHMMState, Unit[] array, int num, UnitContext unitContext, UnitContext unitContext2) { Unit[] lc = this.getLC(unitContext, array, num); Unit[] rc = this.getRC(array, num, unitContext2); UnitContext unitContext3 = UnitContext.get(rc); LeftRightContext context = LeftRightContext.get(lc, rc); Unit unit = FlatLinguist.access_200(this.this_0).getUnit(array[num].getName(), array[num].isFiller(), context); ExtendedUnitState extendedUnitState = new ExtendedUnitState(parent, num, unit); float logInsertionProbablity; if (extendedUnitState.getUnit().isSilence()) { logInsertionProbablity = FlatLinguist.access_300(this.this_0); } else if (extendedUnitState.getUnit().isFiller()) { logInsertionProbablity = FlatLinguist.access_400(this.this_0); } else if (extendedUnitState.getWhich() == 0) { logInsertionProbablity = FlatLinguist.access_500(this.this_0); } else { logInsertionProbablity = FlatLinguist.access_600(this.this_0); } SentenceHMMState existingState = this.getExistingState(extendedUnitState); if (existingState != null) { this.attachState(sentenceHMMState, existingState, 0f, logInsertionProbablity); return(null); } this.attachState(sentenceHMMState, extendedUnitState, 0f, logInsertionProbablity); this.addStateToCache(extendedUnitState); sentenceHMMState = this.expandUnit(extendedUnitState); if (extendedUnitState.isLast()) { UnitContext unitContext4 = this.generateNextLeftContext(unitContext, array[num]); ContextPair contextPair = ContextPair.get(unitContext4, unitContext3); this.addExitPoint(contextPair, sentenceHMMState); } return(sentenceHMMState); }
internal virtual Collection getEndingContexts() { ArrayList arrayList = new ArrayList(); if (!this.node.isEmpty()) { int leftContextSize = this.getLeftContextSize(); Word word = this.node.getWord(); Pronunciation[] pronunciations = word.getPronunciations(); Pronunciation[] array = pronunciations; int num = array.Length; for (int i = 0; i < num; i++) { Pronunciation pronunciation = array[i]; Unit[] units = pronunciation.getUnits(); int num2 = units.Length; Unit[] array2 = (num2 <= leftContextSize) ? units : ((Unit[])Arrays.copyOfRange(units, num2 - leftContextSize, num2)); arrayList.add(UnitContext.get(array2)); } } return(arrayList); }