diff options
author | Patrick Simianer <p@simianer.de> | 2013-01-21 12:29:43 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2013-01-21 12:29:43 +0100 |
commit | 50f22047eb1b7f2d60e85cdcf0fcd86342e50523 (patch) | |
tree | 730dabaf2fa57b1e4536d40f036b46795d37f289 /klm/lm/builder/discount.hh | |
parent | 8b399cb09513cd79ed4182be9f75882c1e1b336a (diff) | |
parent | 608886384da40aedfabd629c882b8ea9b3f6348e (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'klm/lm/builder/discount.hh')
-rw-r--r-- | klm/lm/builder/discount.hh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/klm/lm/builder/discount.hh b/klm/lm/builder/discount.hh new file mode 100644 index 00000000..754fb20d --- /dev/null +++ b/klm/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__ |