FST  openfst-1.6.1
OpenFst Library
disambiguate.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/fst-class.h>
7 
8 namespace fst {
9 namespace script {
10 
11 // 1: Full signature.
12 void Disambiguate(const FstClass &ifst, MutableFstClass *ofst,
13  const DisambiguateOptions &opts) {
14  if (!ArcTypesMatch(ifst, *ofst, "Disambiguate") ||
15  !ofst->WeightTypesMatch(opts.weight_threshold, "Disambiguate")) {
16  ofst->SetProperties(kError, kError);
17  return;
18  }
19  DisambiguateArgs1 args(ifst, ofst, opts);
20  Apply<Operation<DisambiguateArgs1>>("Disambiguate", ifst.ArcType(), &args);
21 }
22 
23 // 2: Signature with default WeightClass argument.
24 void Disambiguate(const FstClass &ifst, MutableFstClass *ofst,
25  int64 n, int64 l) {
26  if (!ArcTypesMatch(ifst, *ofst, "Disambiguate")) {
27  ofst->SetProperties(kError, kError);
28  return;
29  }
30  DisambiguateArgs2 args(ifst, ofst, n, l);
31  Apply<Operation<DisambiguateArgs2>>("Disambiguate", ifst.ArcType(), &args);
32 }
33 
37 
41 
42 } // namespace script
43 } // namespace fst
bool WeightTypesMatch(const WeightClass &weight, const string &op_name) const
Definition: fst-class.cc:74
const string & ArcType() const override
Definition: fst-class.h:289
REGISTER_FST_OPERATION(Compress, StdArc, CompressArgs)
int64_t int64
Definition: types.h:27
void Disambiguate(DisambiguateArgs1 *args)
Definition: disambiguate.h:32
constexpr uint64 kError
Definition: properties.h:33
bool ArcTypesMatch(const M &m, const N &n, const string &op_name)
Definition: script-impl.h:177
void SetProperties(uint64 props, uint64 mask)
Definition: fst-class.h:455
const WeightClass & weight_threshold
Definition: disambiguate.h:18