Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef FST_SCRIPT_REWEIGHT_H_
00018 #define FST_SCRIPT_REWEIGHT_H_
00019
00020 #include <vector>
00021 using std::vector;
00022
00023 #include <fst/script/arg-packs.h>
00024 #include <fst/script/fst-class.h>
00025 #include <fst/script/weight-class.h>
00026 #include <fst/reweight.h>
00027
00028 namespace fst {
00029 namespace script {
00030
00031 typedef args::Package<MutableFstClass *, const vector<WeightClass> &,
00032 ReweightType> ReweightArgs;
00033
00034 template<class Arc>
00035 void Reweight(ReweightArgs *args) {
00036 MutableFst<Arc> *fst = args->arg1->GetMutableFst<Arc>();
00037 typedef typename Arc::Weight Weight;
00038 vector<Weight> potentials(args->arg2.size());
00039
00040 for (unsigned i = 0; i < args->arg2.size(); ++i) {
00041 potentials[i] = *(args->arg2[i].GetWeight<Weight>());
00042 }
00043
00044 Reweight(fst, potentials, args->arg3);
00045 }
00046
00047 void Reweight(MutableFstClass *fst, const vector<WeightClass> &potential,
00048 ReweightType reweight_type);
00049
00050 }
00051 }
00052
00053 #endif /// FST_SCRIPT_REWEIGHT_H_
00054