diff options
Diffstat (limited to 'lm/builder/discount.hh')
-rw-r--r-- | lm/builder/discount.hh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lm/builder/discount.hh b/lm/builder/discount.hh new file mode 100644 index 000000000..754fb20db --- /dev/null +++ b/lm/builder/discount.hh @@ -0,0 +1,26 @@ +#ifndef BUILDER_DISCOUNT__ +#define BUILDER_DISCOUNT__ + +#include <algorithm> + +#include <inttypes.h> + +namespace lm { +namespace builder { + +struct Discount { + float amount[4]; + + float Get(uint64_t count) const { + return amount[std::min<uint64_t>(count, 3)]; + } + + float Apply(uint64_t count) const { + return static_cast<float>(count) - Get(count); + } +}; + +} // namespace builder +} // namespace lm + +#endif // BUILDER_DISCOUNT__ |