FST  openfst-1.6.1
OpenFst Library
determinize.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 with DeterminizeOptions.
12 void Determinize(const FstClass &ifst, MutableFstClass *ofst,
13  const DeterminizeOptions &opts) {
14  if (!ArcTypesMatch(ifst, *ofst, "Determinize") ||
15  !ofst->WeightTypesMatch(opts.weight_threshold, "Determinize")) {
16  ofst->SetProperties(kError, kError);
17  return;
18  }
19  DeterminizeArgs1 args(ifst, ofst, opts);
20  Apply<Operation<DeterminizeArgs1>>("Determinize", ifst.ArcType(), &args);
21 }
22 
23 // 2: Signature with default WeightClass argument.
24 void Determinize(const FstClass &ifst, MutableFstClass *ofst, float d,
25  int64 n, int64 l, DeterminizeType t, bool i) {
26  if (!ArcTypesMatch(ifst, *ofst, "Determinize")) {
27  ofst->SetProperties(kError, kError);
28  return;
29  }
30  DeterminizeArgs2 args(ifst, ofst, d, n, l, t, i);
31  Apply<Operation<DeterminizeArgs2>>("Determinize", 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
const WeightClass & weight_threshold
Definition: determinize.h:18
void Determinize(DeterminizeArgs1 *args)
Definition: determinize.h:39
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
DeterminizeType
Definition: determinize.h:357