|
#ifndef LM_BUILDER_ADJUST_COUNTS_H |
|
#define LM_BUILDER_ADJUST_COUNTS_H |
|
|
|
#include "lm/builder/discount.hh" |
|
#include "lm/lm_exception.hh" |
|
#include "util/exception.hh" |
|
|
|
#include <vector> |
|
|
|
#include <stdint.h> |
|
|
|
namespace util { namespace stream { class ChainPositions; } } |
|
|
|
namespace lm { |
|
namespace builder { |
|
|
|
class BadDiscountException : public util::Exception { |
|
public: |
|
BadDiscountException() throw(); |
|
~BadDiscountException() throw(); |
|
}; |
|
|
|
struct DiscountConfig { |
|
|
|
std::vector<Discount> overwrite; |
|
|
|
Discount fallback; |
|
|
|
|
|
WarningAction bad_action; |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AdjustCounts { |
|
public: |
|
|
|
|
|
|
|
|
|
AdjustCounts( |
|
const std::vector<uint64_t> &prune_thresholds, |
|
std::vector<uint64_t> &counts, |
|
std::vector<uint64_t> &counts_pruned, |
|
const std::vector<bool> &prune_words, |
|
const DiscountConfig &discount_config, |
|
std::vector<Discount> &discounts) |
|
: prune_thresholds_(prune_thresholds), counts_(counts), counts_pruned_(counts_pruned), |
|
prune_words_(prune_words), discount_config_(discount_config), discounts_(discounts) |
|
{} |
|
|
|
void Run(const util::stream::ChainPositions &positions); |
|
|
|
private: |
|
const std::vector<uint64_t> &prune_thresholds_; |
|
std::vector<uint64_t> &counts_; |
|
std::vector<uint64_t> &counts_pruned_; |
|
const std::vector<bool> &prune_words_; |
|
|
|
DiscountConfig discount_config_; |
|
std::vector<Discount> &discounts_; |
|
}; |
|
|
|
} |
|
} |
|
|
|
#endif |
|
|
|
|