mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-07 20:17:48 +03:00
clean up comparison functions for Words and Phrases
This commit is contained in:
parent
563552aea6
commit
5754a46905
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -44,7 +44,7 @@ typedef std::map < Word , ScoreComponentCollection > OutputWordCollection;
|
||||
*/
|
||||
class GenerationDictionary : public DecodeFeature
|
||||
{
|
||||
typedef std::map<const Word* , OutputWordCollection, WordComparer> Collection;
|
||||
typedef boost::unordered_map<const Word* , OutputWordCollection, WordComparer, WordComparer> Collection;
|
||||
protected:
|
||||
static std::vector<GenerationDictionary*> s_staticColl;
|
||||
|
||||
|
15
moses/Word.h
15
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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user