FST  openfst-1.7.7
OpenFst Library
union.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/union.h>
5 
7 
8 namespace fst {
9 namespace script {
10 
11 void Union(MutableFstClass *fst1, const FstClass &fst2) {
12  if (!internal::ArcTypesMatch(*fst1, fst2, "Union")) {
13  fst1->SetProperties(kError, kError);
14  return;
15  }
16  UnionArgs1 args(fst1, fst2);
17  Apply<Operation<UnionArgs1>>("Union", fst1->ArcType(), &args);
18 }
19 
20 void Union(MutableFstClass *fst1, const std::vector<const FstClass *> &fsts2) {
21  for (const auto *fst2 : fsts2) {
22  if (!internal::ArcTypesMatch(*fst1, *fst2, "Union")) {
23  fst1->SetProperties(kError, kError);
24  return;
25  }
26  }
27  UnionArgs2 args(fst1, fsts2);
28  Apply<Operation<UnionArgs2>>("Union", fst1->ArcType(), &args);
29 }
30 
33 
34 } // namespace script
35 } // namespace fst
void Union(UnionArgs1 *args)
Definition: union.h:19
REGISTER_FST_OPERATION_3ARCS(Compress, CompressArgs)
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::pair< MutableFstClass *, const FstClass & > UnionArgs1
Definition: union.h:16
std::tuple< MutableFstClass *, const std::vector< const FstClass * > & > UnionArgs2
Definition: union.h:26
constexpr uint64 kError
Definition: properties.h:36
void SetProperties(uint64 props, uint64 mask)
Definition: fst-class.h:467