def all_suffixes(self, fsa: pynini.Fst) -> pynini.Fst: fsa = fsa.copy() start_state = fsa.start() for s in fsa.states(): fsa.add_arc( start_state, pynini.Arc(0, 0, pynini.Weight.one(fsa.weight_type()), s)) return fsa.optimize()
def all_prefixes(self, fsa: pynini.Fst) -> pynini.Fst: fsa = fsa.copy() for s in fsa.states(): fsa.set_final(s) return fsa.optimize()
def is_subset(self, string: pynini.FstLike, fsa: pynini.Fst) -> bool: fsa = pynini.determinize(fsa.copy().rmepsilon()) string_union_fsa = pynini.determinize( pynini.union(fsa, string).rmepsilon()) return pynini.equivalent(string_union_fsa, fsa)