#ifndef LM_BUILDER_COMBINE_COUNTS_H #define LM_BUILDER_COMBINE_COUNTS_H #include "payload.hh" #include "../common/ngram.hh" #include "../common/compare.hh" #include "../word_index.hh" #include "../../util/stream/sort.hh" #include #include namespace lm { namespace builder { // Sum counts for the same n-gram. struct CombineCounts { bool operator()(void *first_void, const void *second_void, const SuffixOrder &compare) const { NGram first(first_void, compare.Order()); // There isn't a const version of NGram. NGram second(const_cast(second_void), compare.Order()); if (memcmp(first.begin(), second.begin(), sizeof(WordIndex) * compare.Order())) return false; first.Value().count += second.Value().count; return true; } }; } // namespace builder } // namespace lm #endif // LM_BUILDER_COMBINE_COUNTS_H