// See www.openfst.org for extensive documentation on this weighted // finite-state transducer library. #ifndef FST_SCRIPT_RELABEL_H_ #define FST_SCRIPT_RELABEL_H_ #include #include #include #include #include #include namespace fst { namespace script { using RelabelArgs1 = std::tuple; template void Relabel(RelabelArgs1 *args) { MutableFst *ofst = std::get<0>(*args)->GetMutableFst(); Relabel(ofst, std::get<1>(*args), std::get<2>(*args), std::get<3>(*args), std::get<4>(*args), std::get<5>(*args), std::get<6>(*args), std::get<7>(*args), std::get<8>(*args)); } using LabelPair = std::pair; using RelabelArgs2 = std::tuple &, const std::vector &>; template void Relabel(RelabelArgs2 *args) { MutableFst *ofst = std::get<0>(*args)->GetMutableFst(); using LabelPair = std::pair; // In case the MutableFstClass::Label is not the same as Arc::Label, // make a copy. std::vector typed_ipairs(std::get<1>(*args).size()); std::copy(std::get<1>(*args).begin(), std::get<1>(*args).end(), typed_ipairs.begin()); std::vector typed_opairs(std::get<2>(*args).size()); std::copy(std::get<2>(*args).begin(), std::get<2>(*args).end(), typed_opairs.begin()); Relabel(ofst, typed_ipairs, typed_opairs); } void Relabel(MutableFstClass *ofst, const SymbolTable *old_isymbols, const SymbolTable *new_isymbols, const string &unknown_isymbol, bool attach_new_isymbols, const SymbolTable *old_osymbols, const SymbolTable *new_osymbols, const string &unknown_osymbol, bool attach_new_osymbols); void Relabel(MutableFstClass *ofst, const std::vector &ipairs, const std::vector &opairs); } // namespace script } // namespace fst #endif // FST_SCRIPT_RELABEL_H_