FST  openfst-1.7.2
OpenFst Library
determinize.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_DETERMINIZE_H_
5 #define FST_SCRIPT_DETERMINIZE_H_
6 
7 #include <tuple>
8 
9 #include <fst/determinize.h>
10 #include <fst/script/fst-class.h>
12 
13 namespace fst {
14 namespace script {
15 
17  const float delta;
23 
24  DeterminizeOptions(float delta, const WeightClass &weight_threshold,
25  int64 state_threshold = kNoStateId,
26  int64 subsequential_label = 0,
28  bool increment_subsequential_label = false)
29  : delta(delta),
30  weight_threshold(weight_threshold),
31  state_threshold(state_threshold),
32  subsequential_label(subsequential_label),
33  det_type(det_type),
34  increment_subsequential_label(increment_subsequential_label) {}
35 };
36 
37 using DeterminizeArgs = std::tuple<const FstClass &, MutableFstClass *,
39 
40 template <class Arc>
42  using Weight = typename Arc::Weight;
43  const Fst<Arc> &ifst = *(std::get<0>(*args).GetFst<Arc>());
44  MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
45  const auto &opts = std::get<2>(*args);
46  const auto weight_threshold = *(opts.weight_threshold.GetWeight<Weight>());
47  const fst::DeterminizeOptions<Arc> detargs(opts.delta, weight_threshold,
48  opts.state_threshold, opts.subsequential_label, opts.det_type,
49  opts.increment_subsequential_label);
50  Determinize(ifst, ofst, detargs);
51 }
52 
53 void Determinize(const FstClass &ifst, MutableFstClass *ofst,
54  const DeterminizeOptions &opts);
55 
56 } // namespace script
57 } // namespace fst
58 
59 #endif // FST_SCRIPT_DETERMINIZE_H_
DeterminizeOptions(float delta, const WeightClass &weight_threshold, int64 state_threshold=kNoStateId, int64 subsequential_label=0, DeterminizeType det_type=DETERMINIZE_FUNCTIONAL, bool increment_subsequential_label=false)
Definition: determinize.h:24
std::tuple< const FstClass &, MutableFstClass *, const DeterminizeOptions & > DeterminizeArgs
Definition: determinize.h:38
constexpr int kNoStateId
Definition: fst.h:180
int64_t int64
Definition: types.h:27
const WeightClass & weight_threshold
Definition: determinize.h:18
const DeterminizeType det_type
Definition: determinize.h:21
const bool increment_subsequential_label
Definition: determinize.h:22
void Determinize(DeterminizeArgs *args)
Definition: determinize.h:41
DeterminizeType
Definition: determinize.h:358