// See www.openfst.org for extensive documentation on this weighted // finite-state transducer library. // // Compatibility file for old-style Map() functions and MapFst class that have // been renamed to ArcMap (cf. StateMap). #ifndef FST_MAP_H_ #define FST_MAP_H_ #include namespace fst { template void Map(MutableFst *fst, C *mapper) { ArcMap(fst, mapper); } template void Map(MutableFst *fst, C mapper) { ArcMap(fst, mapper); } template void Map(const Fst &ifst, MutableFst *ofst, C *mapper) { ArcMap(ifst, ofst, mapper); } template void Map(const Fst &ifst, MutableFst *ofst, C mapper) { ArcMap(ifst, ofst, mapper); } using MapFstOptions = ArcMapFstOptions; template class MapFst : public ArcMapFst { public: using FromArc = A; using ToArc = B; using StateId = typename ToArc::StateId; using Weight = typename ToArc::Weight; using State = CacheState; MapFst(const Fst &fst, const C &mapper, const MapFstOptions &opts) : ArcMapFst(fst, mapper, opts) {} MapFst(const Fst &fst, C *mapper, const MapFstOptions &opts) : ArcMapFst(fst, mapper, opts) {} MapFst(const Fst &fst, const C &mapper) : ArcMapFst(fst, mapper) {} MapFst(const Fst &fst, C *mapper) : ArcMapFst(fst, mapper) {} // See Fst<>::Copy() for doc. MapFst(const MapFst &fst, bool safe = false) : ArcMapFst(fst, safe) {} // Get a copy of this MapFst. See Fst<>::Copy() for further doc. MapFst *Copy(bool safe = false) const override { return new MapFst(*this, safe); } }; // Specialization for MapFst. template class StateIterator> : public StateIterator> { public: explicit StateIterator(const ArcMapFst &fst) : StateIterator>(fst) {} }; // Specialization for MapFst. template class ArcIterator> : public ArcIterator> { public: ArcIterator(const ArcMapFst &fst, typename A::StateId s) : ArcIterator>(fst, s) {} }; // For backwards compatibility only; use IdentityArcMapper otherwise. template struct IdentityMapper { using FromArc = A; using ToArc = A; ToArc operator()(const FromArc &arc) const { return arc; } constexpr MapFinalAction FinalAction() const { return MAP_NO_SUPERFINAL; } constexpr MapSymbolsAction InputSymbolsAction() const { return MAP_COPY_SYMBOLS; } constexpr MapSymbolsAction OutputSymbolsAction() const { return MAP_COPY_SYMBOLS; } uint64 Properties(uint64 props) const { return props; } }; } // namespace fst #endif // FST_MAP_H_