summaryrefslogtreecommitdiff
path: root/gi/pf/base_measures.h
diff options
context:
space:
mode:
Diffstat (limited to 'gi/pf/base_measures.h')
-rw-r--r--gi/pf/base_measures.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/gi/pf/base_measures.h b/gi/pf/base_measures.h
index a4e9ac28..7214aa22 100644
--- a/gi/pf/base_measures.h
+++ b/gi/pf/base_measures.h
@@ -72,6 +72,24 @@ struct UnigramWordBase {
const UnigramWordModel un;
};
+struct RuleHasher {
+ size_t operator()(const TRule& r) const {
+ return hash_value(r);
+ }
+};
+
+struct TableLookupBase {
+ TableLookupBase(const std::string& fname);
+
+ prob_t operator()(const TRule& rule) const {
+ const std::tr1::unordered_map<TRule,prob_t>::const_iterator it = table.find(rule);
+ assert(it != table.end());
+ return it->second;
+ }
+
+ std::tr1::unordered_map<TRule,prob_t,RuleHasher> table;
+};
+
struct PhraseConditionalUninformativeBase {
explicit PhraseConditionalUninformativeBase(const unsigned vocab_e_size) :
kUNIFORM_TARGET(1.0 / vocab_e_size) {