summaryrefslogtreecommitdiff
path: root/klm/lm/builder/discount.hh
blob: 754fb20dbe80a18f9e64eeca3c49dce572967a2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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__