diff --git a/moses/FF/GlobalLexicalModel.cpp b/moses/FF/GlobalLexicalModel.cpp index ef3fa4691..30cf4444d 100644 --- a/moses/FF/GlobalLexicalModel.cpp +++ b/moses/FF/GlobalLexicalModel.cpp @@ -43,7 +43,7 @@ GlobalLexicalModel::~GlobalLexicalModel() // delete words in the hash data structure DoubleHash::const_iterator iter; for(iter = m_hash.begin(); iter != m_hash.end(); iter++ ) { - map< const Word*, float, WordComparer >::const_iterator iter2; + boost::unordered_map< const Word*, float, WordComparer, WordComparer>::const_iterator iter2; for(iter2 = iter->second.begin(); iter2 != iter->second.end(); iter2++ ) { delete iter2->first; // delete input word } diff --git a/moses/FF/GlobalLexicalModel.h b/moses/FF/GlobalLexicalModel.h index 3d7f559d0..9889b1824 100644 --- a/moses/FF/GlobalLexicalModel.h +++ b/moses/FF/GlobalLexicalModel.h @@ -33,8 +33,8 @@ class InputType; */ class GlobalLexicalModel : public StatelessFeatureFunction { - typedef std::map< const Word*, std::map< const Word*, float, WordComparer >, WordComparer > DoubleHash; - typedef std::map< const Word*, float, WordComparer > SingleHash; + typedef boost::unordered_map< const Word*, boost::unordered_map< const Word*, float, WordComparer, WordComparer >, WordComparer, WordComparer > DoubleHash; + typedef boost::unordered_map< const Word*, float, WordComparer, WordComparer > SingleHash; typedef std::map< const TargetPhrase*, float > LexiconCache; struct ThreadLocalStorage { diff --git a/moses/GenerationDictionary.h b/moses/GenerationDictionary.h index 67bbe1e91..33121315d 100644 --- a/moses/GenerationDictionary.h +++ b/moses/GenerationDictionary.h @@ -44,7 +44,7 @@ typedef std::map < Word , ScoreComponentCollection > OutputWordCollection; */ class GenerationDictionary : public DecodeFeature { - typedef std::map Collection; + typedef boost::unordered_map Collection; protected: static std::vector s_staticColl; diff --git a/moses/Word.h b/moses/Word.h index d82574573..d2b85296b 100644 --- a/moses/Word.h +++ b/moses/Word.h @@ -130,11 +130,6 @@ public: return !(*this == compare); } - int Compare(const Word &other) const { - return Compare(*this, other); - } - - /* static functions */ /** transitive comparison of 2 word objects. Used by operator<. @@ -159,10 +154,14 @@ public: }; struct WordComparer { - //! returns true if hypoA can be recombined with hypoB - bool operator()(const Word *a, const Word *b) const { - return *a < *b; + size_t operator()(const Word* word) const { + return word->hash(); } + + bool operator()(const Word* a, const Word* b) const { + return (*a) == (*b); + } + };