/** * Computes the composition of two Fsts. The two Fsts are augmented in order * to avoid multiple epsilon paths in the resulting Fst * * @param fst1 the first Fst * @param fst2 the second Fst * @param semiring the semiring to use in the operation * @return the composed Fst */ public static Fst get(Fst fst1, Fst fst2, Semiring semiring) { if ((fst1 == null) || (fst2 == null)) { return null; } if (!Arrays.equals(fst1.getOsyms(), fst2.getIsyms())) { // symboltables do not match return null; } Fst filter = getFilter(fst1.getOsyms(), semiring); augment(1, fst1, semiring); augment(0, fst2, semiring); Fst tmp = Compose.compose(fst1, filter, semiring, false); Fst res = Compose.compose(tmp, fst2, semiring, false); // Connect.apply(res); return res; }
/** * Initialize the decoder */ private void init() { skipSeqs.add(eps); skipSeqs.add(sb); skipSeqs.add(se); skipSeqs.add(skip); skipSeqs.add("-"); // keep an augmented copy (for compose) Compose.augment(0, g2pmodel, g2pmodel.getSemiring()); ArcSort.apply(g2pmodel, new ILabelCompare()); String[] isyms = g2pmodel.getIsyms(); loadClusters(isyms); // get epsilon filter for composition epsilonFilter = Compose.getFilter(g2pmodel.getIsyms(), g2pmodel.getSemiring()); ArcSort.apply(epsilonFilter, new ILabelCompare()); }
Fst efst = entryToFSA(entry); Semiring s = efst.getSemiring(); Compose.augment(1, efst, s); ArcSort.apply(efst, new OLabelCompare()); Fst result = Compose.compose(efst, epsilonFilter, s, true);
/** * Computes the composition of two Fsts. The two Fsts are augmented in order * to avoid multiple epsilon paths in the resulting Fst * * @param fst1 the first Fst * @param fst2 the second Fst * @param semiring the semiring to use in the operation * @return the composed Fst */ public static Fst get(Fst fst1, Fst fst2, Semiring semiring) { if ((fst1 == null) || (fst2 == null)) { return null; } if (!Arrays.equals(fst1.getOsyms(), fst2.getIsyms())) { // symboltables do not match return null; } Fst filter = getFilter(fst1.getOsyms(), semiring); augment(1, fst1, semiring); augment(0, fst2, semiring); Fst tmp = Compose.compose(fst1, filter, semiring, false); Fst res = Compose.compose(tmp, fst2, semiring, false); // Connect.apply(res); return res; }
/** * Initialize the decoder */ private void init() { skipSeqs.add(eps); skipSeqs.add(sb); skipSeqs.add(se); skipSeqs.add(skip); skipSeqs.add("-"); // keep an augmented copy (for compose) Compose.augment(0, g2pmodel, g2pmodel.getSemiring()); ArcSort.apply(g2pmodel, new ILabelCompare()); String[] isyms = g2pmodel.getIsyms(); loadClusters(isyms); // get epsilon filter for composition epsilonFilter = Compose.getFilter(g2pmodel.getIsyms(), g2pmodel.getSemiring()); ArcSort.apply(epsilonFilter, new ILabelCompare()); }
Fst efst = entryToFSA(entry); Semiring s = efst.getSemiring(); Compose.augment(1, efst, s); ArcSort.apply(efst, new OLabelCompare()); Fst result = Compose.compose(efst, epsilonFilter, s, true);