FST  openfst-1.7.7
OpenFst Library
replace.cc
Go to the documentation of this file.
1 // See www.openfst.org for extensive documentation on this weighted
2 // finite-state transducer library.
3 
4 #include <fst/script/replace.h>
5 
7 
8 namespace fst {
9 namespace script {
10 
11 void Replace(const std::vector<std::pair<int64, const FstClass *>> &pairs,
12  MutableFstClass *ofst, const ReplaceOptions &opts) {
13  for (const auto &pair : pairs) {
14  if (!internal::ArcTypesMatch(*pair.second, *ofst, "Replace")) {
15  ofst->SetProperties(kError, kError);
16  return;
17  }
18  }
19  ReplaceArgs args(pairs, ofst, opts);
20  Apply<Operation<ReplaceArgs>>("Replace", ofst->ArcType(), &args);
21 }
22 
24 
25 } // namespace script
26 } // namespace fst
REGISTER_FST_OPERATION_3ARCS(Compress, CompressArgs)
void Replace(ReplaceArgs *args)
Definition: replace.h:39
const std::string & ArcType() const final
Definition: fst-class.h:300
bool ArcTypesMatch(const M &m, const N &n, const std::string &op_name)
Definition: script-impl.h:178
std::tuple< const std::vector< std::pair< int64, const FstClass * >> &, MutableFstClass *, const ReplaceOptions & > ReplaceArgs
Definition: replace.h:36
constexpr uint64 kError
Definition: properties.h:36
void SetProperties(uint64 props, uint64 mask)
Definition: fst-class.h:467