/** * Calculate the epsilon closure */ private static void calcClosure(Fst fst, State state, HashMap<State, Float>[] cl, Semiring semiring) { State s = state; float pathWeight; int numArcs = s.getNumArcs(); for (int j = 0; j < numArcs; j++) { Arc a = s.getArc(j); if ((a.getIlabel() == 0) && (a.getOlabel() == 0)) { if (cl[a.getNextState().getId()] == null) { calcClosure(fst, a.getNextState(), cl, semiring); } if (cl[a.getNextState().getId()] != null) { for (State pathFinalState : cl[a.getNextState().getId()] .keySet()) { pathWeight = semiring.times( getPathWeight(a.getNextState(), pathFinalState, cl), a.getWeight()); add(state, pathFinalState, pathWeight, cl, semiring); } } add(state, a.getNextState(), a.getWeight(), cl, semiring); } } }
/** * Calculate the epsilon closure */ private static void calcClosure(Fst fst, State state, HashMap<State, Float>[] cl, Semiring semiring) { State s = state; float pathWeight; int numArcs = s.getNumArcs(); for (int j = 0; j < numArcs; j++) { Arc a = s.getArc(j); if ((a.getIlabel() == 0) && (a.getOlabel() == 0)) { if (cl[a.getNextState().getId()] == null) { calcClosure(fst, a.getNextState(), cl, semiring); } if (cl[a.getNextState().getId()] != null) { for (State pathFinalState : cl[a.getNextState().getId()] .keySet()) { pathWeight = semiring.times( getPathWeight(a.getNextState(), pathFinalState, cl), a.getWeight()); add(state, pathFinalState, pathWeight, cl, semiring); } } add(state, a.getNextState(), a.getWeight(), cl, semiring); } } }