18 #ifndef NGRAM_NGRAM_COUNT_MERGE_H_ 19 #define NGRAM_NGRAM_COUNT_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) {}
44 double beta,
bool norm =
false) {
56 bool in_fst1,
bool in_fst2)
const override {
57 if (in_fst1 && in_fst2) {
58 return NegLogSum(w1.Value() + alpha_, w2.Value() + beta_);
60 return w1.Value() + alpha_;
62 return w2.Value() + beta_;
68 double NormWeight(StateId st,
bool in_fst1,
bool in_fst2)
const override {
69 if (in_fst1 && in_fst2) {
70 return -NegLogSum(alpha_, beta_);
85 return (in_fst1) ? (alpha_ != 0.0) : (beta_ != 0.0);
95 #endif // NGRAM_NGRAM_COUNT_MERGE_H_
fst::StdArc::Weight Weight
fst::StdArc::StateId StateId
NGramCountMerge(fst::StdMutableFst *infst1, Label backoff_label=0, double norm_eps=kNormEps, bool check_consistency=false)
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)
Weight MergeWeights(StateId s1, StateId s2, Label Label, Weight w1, Weight w2, bool in_fst1, bool in_fst2) const override
bool MergeUnshared(bool in_fst1) const override