18 #ifndef NGRAM_NGRAM_MODEL_MERGE_H_ 19 #define NGRAM_NGRAM_MODEL_MERGE_H_ 31 typedef fst::StdArc::Label
Label;
37 Label backoff_label = 0,
double norm_eps =
kNormEps,
38 bool check_consistency =
false)
39 :
NGramMerge(infst1, backoff_label, norm_eps, check_consistency),
42 NGRAMERROR() <<
"NGramModelMerge: Model 1 must be normalized to" 43 <<
" use smoothing in merging";
51 double beta,
bool norm =
false) {
55 NGRAMERROR() <<
"NGramModelMerge: Model 2 must be normalized to" 56 <<
" use smoothing in merging";
63 NGRAMERROR() <<
"NGramModelMerge: Model merging failed";
67 if (!norm) merge_norm_ =
false;
73 bool in_fst1,
bool in_fst2)
const override {
75 return in_fst1 ? w1.Value() : w2.Value();
77 return NegLogSum(w1.Value() + alpha_, w2.Value() + beta_);
83 double NormWeight(StateId st,
bool in_fst1,
bool in_fst2)
const override {
84 return -NegLogSum(alpha_, beta_);
95 #endif // NGRAM_NGRAM_MODEL_MERGE_H_
NGramModelMerge(fst::StdMutableFst *infst1, Label backoff_label=0, double norm_eps=kNormEps, bool check_consistency=false)
bool CheckNormalization() const
fst::StdArc::Weight Weight
double NormWeight(StateId st, bool in_fst1, bool in_fst2) const override
void MergeNGramModels(const fst::StdFst &infst2, double alpha, double beta, bool norm=false)
Label BackoffLabel() const
fst::StdArc::StateId StateId
Weight MergeWeights(StateId s1, StateId s2, Label label, Weight w1, Weight w2, bool in_fst1, bool in_fst2) const override