FST  openfst-1.7.1
OpenFst Library
push.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_PUSH_H_
5 #define FST_SCRIPT_PUSH_H_
6 
7 #include <tuple>
8 
9 #include <fst/push.h>
10 #include <fst/script/fst-class.h>
11 
12 namespace fst {
13 namespace script {
14 
15 using PushArgs1 = std::tuple<MutableFstClass *, ReweightType, float, bool>;
16 
17 template <class Arc>
18 void Push(PushArgs1 *args) {
19  MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
20  Push(fst, std::get<1>(*args), std::get<2>(*args), std::get<3>(*args));
21 }
22 
23 using PushArgs2 = std::tuple<const FstClass &, MutableFstClass *, uint32,
24  ReweightType, float>;
25 
26 template <class Arc>
27 void Push(PushArgs2 *args) {
28  const Fst<Arc> &ifst = *(std::get<0>(*args).GetFst<Arc>());
29  MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
30  switch (std::get<3>(*args)) {
31  case REWEIGHT_TO_FINAL: {
32  Push<Arc, REWEIGHT_TO_FINAL>(ifst, ofst, std::get<2>(*args),
33  std::get<4>(*args));
34  return;
35  }
36  case REWEIGHT_TO_INITIAL: {
37  Push<Arc, REWEIGHT_TO_INITIAL>(ifst, ofst, std::get<2>(*args),
38  std::get<4>(*args));
39  return;
40  }
41  }
42 }
43 
44 void Push(MutableFstClass *fst, ReweightType rew_type, float delta = kDelta,
45  bool remove_total_weight = false);
46 
47 void Push(const FstClass &ifst, MutableFstClass *ofst, uint32 flags,
48  ReweightType rew_type, float delta = kDelta);
49 
50 } // namespace script
51 } // namespace fst
52 
53 #endif // FST_SCRIPT_PUSH_H_
ReweightType
Definition: reweight.h:17
std::tuple< MutableFstClass *, ReweightType, float, bool > PushArgs1
Definition: push.h:15
uint32_t uint32
Definition: types.h:31
void Push(PushArgs1 *args)
Definition: push.h:18
std::tuple< const FstClass &, MutableFstClass *, uint32, ReweightType, float > PushArgs2
Definition: push.h:24
constexpr float kDelta
Definition: weight.h:109