// See www.openfst.org for extensive documentation on this weighted // finite-state transducer library. #ifndef FST_SCRIPT_ENCODE_H_ #define FST_SCRIPT_ENCODE_H_ #include #include #include #include #include #include #include namespace fst { namespace script { using EncodeArgs1 = std::tuple; template void Encode(EncodeArgs1 *args) { MutableFst *fst = std::get<0>(*args)->GetMutableFst(); const string &coder_fname = std::get<3>(*args); // If true, reuse encode from disk. If false, make a new encoder and just use // the filename argument as the destination state. std::unique_ptr> encoder( std::get<2>(*args) ? EncodeMapper::Read(coder_fname, ENCODE) : new EncodeMapper(std::get<1>(*args), ENCODE)); Encode(fst, encoder.get()); if (!std::get<2>(*args)) encoder->Write(coder_fname); } using EncodeArgs2 = std::pair; template void Encode(EncodeArgs2 *args) { MutableFst *fst = std::get<0>(*args)->GetMutableFst(); EncodeMapper *encoder = std::get<1>(*args)->GetEncodeMapper(); Encode(fst, encoder); } void Encode(MutableFstClass *fst, uint32 flags, bool reuse_encoder, const string &coder_fname); void Encode(MutableFstClass *fst, EncodeMapperClass *encoder); } // namespace script } // namespace fst #endif // FST_SCRIPT_ENCODE_H_