18 #ifndef NGRAM_NGRAM_CONTEXT_MERGE_H_ 19 #define NGRAM_NGRAM_CONTEXT_MERGE_H_ 35 typedef fst::StdArc::Label
Label;
41 Label backoff_label = 0,
43 bool check_consistency =
false)
44 :
NGramMerge(infst1, backoff_label, norm_eps, true) {}
52 std::string_view context_pattern,
bool norm =
false) {
54 std::make_unique<NGramExtendedContext>(context_pattern,
HiOrder());
67 const std::vector<Label> &context_begin,
68 const std::vector<Label> &context_end,
70 context_ = std::make_unique<NGramExtendedContext>(context_begin,
81 bool in_fst1,
bool in_fst2)
const override {
82 if (in_fst1 && in_fst2) {
85 return context_->HasContext(ngram,
false) ? w2.Value() : w1.Value();
102 std::unique_ptr<NGramExtendedContext> context_;
107 #endif // NGRAM_NGRAM_CONTEXT_MERGE_H_
fst::StdArc::Weight Weight
const NGramModel< fst::StdArc > & NGram2() 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
NGramContextMerge(fst::StdMutableFst *infst1, Label backoff_label=0, double norm_eps=kNormEps, bool check_consistency=false)
const std::vector< Label > & StateNGram(StateId state) const
void MergeNGramModels(const fst::StdFst &infst2, const std::vector< Label > &context_begin, const std::vector< Label > &context_end, bool norm=false)
void MergeNGramModels(const fst::StdFst &infst2, std::string_view context_pattern, bool norm=false)
bool MergeUnshared(bool in_fst1) const override