Joshua
open source statistical hierarchical phrase-based machine translation system
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
src/kenlm/lm/builder/discount.hh
00001 #ifndef LM_BUILDER_DISCOUNT_H
00002 #define LM_BUILDER_DISCOUNT_H
00003 
00004 #include <algorithm>
00005 
00006 #include <stdint.h>
00007 
00008 namespace lm {
00009 namespace builder {
00010 
00011 struct Discount {
00012   float amount[4];
00013 
00014   float Get(uint64_t count) const {
00015     return amount[std::min<uint64_t>(count, 3)];
00016   }
00017 
00018   float Apply(uint64_t count) const {
00019     return static_cast<float>(count) - Get(count);
00020   }
00021 };
00022 
00023 } // namespace builder
00024 } // namespace lm
00025 
00026 #endif // LM_BUILDER_DISCOUNT_H