FST  openfst-1.8.2.post1
OpenFst Library
push.h
Go to the documentation of this file.
1 // Copyright 2005-2020 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the 'License');
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an 'AS IS' BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // See www.openfst.org for extensive documentation on this weighted
16 // finite-state transducer library.
17 
18 #ifndef FST_SCRIPT_PUSH_H_
19 #define FST_SCRIPT_PUSH_H_
20 
21 #include <cstdint>
22 #include <tuple>
23 
24 #include <fst/push.h>
25 #include <fst/script/fst-class.h>
26 
27 namespace fst {
28 namespace script {
29 
30 using FstPushArgs1 = std::tuple<MutableFstClass *, ReweightType, float, bool>;
31 
32 template <class Arc>
33 void Push(FstPushArgs1 *args) {
34  MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
35  Push(fst, std::get<1>(*args), std::get<2>(*args), std::get<3>(*args));
36 }
37 
38 using FstPushArgs2 = std::tuple<const FstClass &, MutableFstClass *, uint8_t,
39  ReweightType, float>;
40 
41 template <class Arc>
42 void Push(FstPushArgs2 *args) {
43  const Fst<Arc> &ifst = *std::get<0>(*args).GetFst<Arc>();
44  MutableFst<Arc> *ofst = std::get<1>(*args)->GetMutableFst<Arc>();
45  switch (std::get<3>(*args)) {
46  case REWEIGHT_TO_FINAL: {
47  Push<Arc, REWEIGHT_TO_FINAL>(ifst, ofst, std::get<2>(*args),
48  std::get<4>(*args));
49  return;
50  }
51  case REWEIGHT_TO_INITIAL: {
52  Push<Arc, REWEIGHT_TO_INITIAL>(ifst, ofst, std::get<2>(*args),
53  std::get<4>(*args));
54  return;
55  }
56  }
57 }
58 
59 void Push(MutableFstClass *fst, ReweightType type = REWEIGHT_TO_INITIAL,
60  float delta = kShortestDelta, bool remove_total_weight = false);
61 
62 void Push(const FstClass &ifst, MutableFstClass *ofst, uint8_t flags,
63  ReweightType rew_type, float delta = kShortestDelta);
64 
65 } // namespace script
66 } // namespace fst
67 
68 #endif // FST_SCRIPT_PUSH_H_
ReweightType
Definition: reweight.h:34
std::tuple< const FstClass &, MutableFstClass *, uint8_t, ReweightType, float > FstPushArgs2
Definition: push.h:39
constexpr float kShortestDelta
void Push(FstPushArgs1 *args)
Definition: push.h:33
std::tuple< MutableFstClass *, ReweightType, float, bool > FstPushArgs1
Definition: push.h:30