diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-01-23 15:47:29 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-01-23 15:47:29 -0500 |
commit | 26d9ad04bd81508163d75c99726f970dd75f5127 (patch) | |
tree | 9fc49e4cbe8bdabbdd57ee616dc90094f114f255 /gi/pf/base_measures.h | |
parent | f0bdd4de6455855d705d9056deb2e90c999dc740 (diff) |
more alignment stuff
Diffstat (limited to 'gi/pf/base_measures.h')
-rw-r--r-- | gi/pf/base_measures.h | 18 |
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) { |