FST  openfst-1.7.2
OpenFst Library
reweight.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_REWEIGHT_H_
5 #define FST_SCRIPT_REWEIGHT_H_
6 
7 #include <tuple>
8 #include <vector>
9 
10 #include <fst/reweight.h>
11 #include <fst/script/fst-class.h>
12 #include <fst/script/script-impl.h>
14 
15 namespace fst {
16 namespace script {
17 
18 using ReweightArgs = std::tuple<MutableFstClass *,
19  const std::vector<WeightClass> &, ReweightType>;
20 
21 template <class Arc>
22 void Reweight(ReweightArgs *args) {
23  using Weight = typename Arc::Weight;
24  MutableFst<Arc> *fst = std::get<0>(*args)->GetMutableFst<Arc>();
25  const std::vector<WeightClass> &potentials = std::get<1>(*args);
26  std::vector<Weight> typed_potentials;
27  internal::CopyWeights(potentials, &typed_potentials);
28  Reweight(fst, typed_potentials, std::get<2>(*args));
29 }
30 
31 void Reweight(MutableFstClass *fst, const std::vector<WeightClass> &potentials,
32  ReweightType reweight_type);
33 
34 } // namespace script
35 } // namespace fst
36 
37 #endif // FST_SCRIPT_REWEIGHT_H_
ReweightType
Definition: reweight.h:17
void CopyWeights(const std::vector< WeightClass > &weights, std::vector< Weight > *typed_weights)
Definition: script-impl.h:187
std::tuple< MutableFstClass *, const std::vector< WeightClass > &, ReweightType > ReweightArgs
Definition: reweight.h:19
void Reweight(ReweightArgs *args)
Definition: reweight.h:22