FST  openfst-1.7.2
OpenFst Library
disambiguate.h
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 #ifndef FST_SCRIPT_DISAMBIGUATE_H_
5 #define FST_SCRIPT_DISAMBIGUATE_H_
6 
7 #include <tuple>
8 #include <utility>
9 
10 #include <fst/disambiguate.h>
11 #include <fst/script/fst-class.h>
13 
14 namespace fst {
15 namespace script {
16 
18  const float delta;
22 
23  DisambiguateOptions(float delta, const WeightClass &weight_threshold,
24  int64 state_threshold = kNoStateId,
25  int64 subsequential_label = 0)
26  : delta(delta),
27  weight_threshold(weight_threshold),
28  state_threshold(state_threshold),
29  subsequential_label(subsequential_label) {}
30 };
31 
32 using DisambiguateArgs = std::tuple<const FstClass &, MutableFstClass *,
34 
35 template <class Arc>
37  using Weight = typename Arc::Weight;
38  const Fst<Arc> &ifst = *(std::get<0>(*args).GetFst<Arc>());
39  MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
40  const auto &opts = std::get<2>(*args);
41  const auto weight_threshold = *(opts.weight_threshold.GetWeight<Weight>());
42  const fst::DisambiguateOptions<Arc> disargs(opts.delta, weight_threshold,
43  opts.state_threshold,
44  opts.subsequential_label);
45  Disambiguate(ifst, ofst, disargs);
46 }
47 
48 void Disambiguate(const FstClass &ifst, MutableFstClass *ofst,
49  const DisambiguateOptions &opts);
50 
51 } // namespace script
52 } // namespace fst
53 
54 #endif // FST_SCRIPT_DISAMBIGUATE_H_
void Disambiguate(DisambiguateArgs *args)
Definition: disambiguate.h:36
constexpr int kNoStateId
Definition: fst.h:180
int64_t int64
Definition: types.h:27
std::tuple< const FstClass &, MutableFstClass *, const DisambiguateOptions & > DisambiguateArgs
Definition: disambiguate.h:33
DisambiguateOptions(float delta, const WeightClass &weight_threshold, int64 state_threshold=kNoStateId, int64 subsequential_label=0)
Definition: disambiguate.h:23
const WeightClass & weight_threshold
Definition: disambiguate.h:19