Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/other-builds/moses/.project10
-rw-r--r--moses/Bitmaps.cpp0
-rw-r--r--moses/Bitmaps.h14
-rw-r--r--moses/ChartHypothesisCollection.h18
-rw-r--r--moses/FF/GlobalLexicalModel.cpp4
-rw-r--r--moses/FF/GlobalLexicalModel.h6
-rw-r--r--moses/GenerationDictionary.h2
-rw-r--r--moses/Hypothesis.h13
-rw-r--r--moses/HypothesisStack.h2
-rw-r--r--moses/Phrase.cpp9
-rw-r--r--moses/Phrase.h8
-rw-r--r--moses/TranslationModel/PhraseDictionaryGroup.cpp3
-rw-r--r--moses/Util.h13
-rw-r--r--moses/Word.h12
14 files changed, 59 insertions, 55 deletions
diff --git a/contrib/other-builds/moses/.project b/contrib/other-builds/moses/.project
index 84de64d9c..ce7912954 100644
--- a/contrib/other-builds/moses/.project
+++ b/contrib/other-builds/moses/.project
@@ -96,6 +96,16 @@
<locationURI>PARENT-3-PROJECT_LOC/moses/BitmapContainer.h</locationURI>
</link>
<link>
+ <name>Bitmaps.cpp</name>
+ <type>1</type>
+ <locationURI>PARENT-3-PROJECT_LOC/moses/Bitmaps.cpp</locationURI>
+ </link>
+ <link>
+ <name>Bitmaps.h</name>
+ <type>1</type>
+ <locationURI>PARENT-3-PROJECT_LOC/moses/Bitmaps.h</locationURI>
+ </link>
+ <link>
<name>BookkeepingOptions.cpp</name>
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/parameters/BookkeepingOptions.cpp</locationURI>
diff --git a/moses/Bitmaps.cpp b/moses/Bitmaps.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/moses/Bitmaps.cpp
diff --git a/moses/Bitmaps.h b/moses/Bitmaps.h
new file mode 100644
index 000000000..62326ba95
--- /dev/null
+++ b/moses/Bitmaps.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <boost/unordered_set.hpp>
+#include "WordsBitmap.h"
+#include "Util.h"
+
+class Bitmaps
+{
+ typedef boost::unordered_set<WordsBitmap*, UnorderedComparer<WordsBitmap>, UnorderedComparer<WordsBitmap> > Coll;
+
+public:
+ const WordsBitmap &GetBitmap();
+
+};
diff --git a/moses/ChartHypothesisCollection.h b/moses/ChartHypothesisCollection.h
index c4297b9b3..169e81f19 100644
--- a/moses/ChartHypothesisCollection.h
+++ b/moses/ChartHypothesisCollection.h
@@ -39,22 +39,6 @@ public:
}
};
-/** functor to compare (chart) hypotheses by feature function states.
- * If 2 hypos are equal, according to this functor, then they can be recombined.
- */
-class ChartHypothesisRecombinationUnordered
-{
-public:
- size_t operator()(const ChartHypothesis* hypo) const {
- return hypo->hash();
- }
-
- bool operator()(const ChartHypothesis* hypoA, const ChartHypothesis* hypoB) const {
- return (*hypoA) == (*hypoB);
- }
-
-};
-
/** Contains a set of unique hypos that have the same HS non-term.
* ie. 1 of these for each target LHS in each cell
*/
@@ -64,7 +48,7 @@ class ChartHypothesisCollection
protected:
//typedef std::set<ChartHypothesis*, ChartHypothesisRecombinationOrderer> HCType;
- typedef boost::unordered_set< ChartHypothesis*, ChartHypothesisRecombinationUnordered, ChartHypothesisRecombinationUnordered > HCType;
+ typedef boost::unordered_set< ChartHypothesis*, UnorderedComparer<ChartHypothesis>, UnorderedComparer<ChartHypothesis> > HCType;
HCType m_hypos;
HypoList m_hyposOrdered;
diff --git a/moses/FF/GlobalLexicalModel.cpp b/moses/FF/GlobalLexicalModel.cpp
index 30cf4444d..d47aeb981 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++ ) {
- boost::unordered_map< const Word*, float, WordComparer, WordComparer>::const_iterator iter2;
+ boost::unordered_map< const Word*, float, UnorderedComparer<Word>, UnorderedComparer<Word> >::const_iterator iter2;
for(iter2 = iter->second.begin(); iter2 != iter->second.end(); iter2++ ) {
delete iter2->first; // delete input word
}
@@ -134,7 +134,7 @@ float GlobalLexicalModel::ScorePhrase( const TargetPhrase& targetPhrase ) const
sum += inputWordHash->second;
}
- set< const Word*, WordComparer > alreadyScored; // do not score a word twice
+ boost::unordered_set< const Word*, UnorderedComparer<Word>, UnorderedComparer<Word> > alreadyScored; // do not score a word twice
for(size_t inputIndex = 0; inputIndex < input.GetSize(); inputIndex++ ) {
const Word& inputWord = input.GetWord( inputIndex );
if ( alreadyScored.find( &inputWord ) == alreadyScored.end() ) {
diff --git a/moses/FF/GlobalLexicalModel.h b/moses/FF/GlobalLexicalModel.h
index 9889b1824..51284863d 100644
--- a/moses/FF/GlobalLexicalModel.h
+++ b/moses/FF/GlobalLexicalModel.h
@@ -33,8 +33,10 @@ class InputType;
*/
class GlobalLexicalModel : public StatelessFeatureFunction
{
- 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 boost::unordered_map< const Word*,
+ boost::unordered_map< const Word*, float, UnorderedComparer<Word> , UnorderedComparer<Word> >,
+ UnorderedComparer<Word>, UnorderedComparer<Word> > DoubleHash;
+ typedef boost::unordered_map< const Word*, float, UnorderedComparer<Word>, UnorderedComparer<Word> > SingleHash;
typedef std::map< const TargetPhrase*, float > LexiconCache;
struct ThreadLocalStorage {
diff --git a/moses/GenerationDictionary.h b/moses/GenerationDictionary.h
index c77fa6fa9..82aa82426 100644
--- a/moses/GenerationDictionary.h
+++ b/moses/GenerationDictionary.h
@@ -44,7 +44,7 @@ typedef boost::unordered_map < Word , ScoreComponentCollection > OutputWordColle
*/
class GenerationDictionary : public DecodeFeature
{
- typedef boost::unordered_map<const Word* , OutputWordCollection, WordComparer, WordComparer> Collection;
+ typedef boost::unordered_map<const Word* , OutputWordCollection, UnorderedComparer<Word>, UnorderedComparer<Word> > Collection;
protected:
static std::vector<GenerationDictionary*> s_staticColl;
diff --git a/moses/Hypothesis.h b/moses/Hypothesis.h
index ba03cb663..07c69379b 100644
--- a/moses/Hypothesis.h
+++ b/moses/Hypothesis.h
@@ -319,18 +319,5 @@ struct CompareHypothesisTotalScore {
#define FREEHYPO(hypo) delete hypo
#endif
-class HypothesisRecombinationUnordered
-{
-public:
- size_t operator()(const Hypothesis* hypo) const {
- return hypo->hash();
- }
-
- bool operator()(const Hypothesis* hypoA, const Hypothesis* hypoB) const {
- return (*hypoA) == (*hypoB);
- }
-
-};
-
}
#endif
diff --git a/moses/HypothesisStack.h b/moses/HypothesisStack.h
index 5c242e596..1994c1d7f 100644
--- a/moses/HypothesisStack.h
+++ b/moses/HypothesisStack.h
@@ -19,7 +19,7 @@ class HypothesisStack
{
protected:
- typedef boost::unordered_set< Hypothesis*, HypothesisRecombinationUnordered, HypothesisRecombinationUnordered > _HCType;
+ typedef boost::unordered_set< Hypothesis*, UnorderedComparer<Hypothesis>, UnorderedComparer<Hypothesis> > _HCType;
_HCType m_hypos; /**< contains hypotheses */
Manager& m_manager;
diff --git a/moses/Phrase.cpp b/moses/Phrase.cpp
index d97f6d712..5661fec28 100644
--- a/moses/Phrase.cpp
+++ b/moses/Phrase.cpp
@@ -254,6 +254,15 @@ int Phrase::Compare(const Phrase &other) const
return 0;
}
+size_t Phrase::hash() const
+{
+ size_t seed = 0;
+ for (size_t i = 0; i < GetSize(); ++i) {
+ boost::hash_combine(seed, GetWord(i));
+ }
+ return seed;
+}
+
bool Phrase::operator== (const Phrase &other) const {
size_t thisSize = GetSize()
,compareSize = other.GetSize();
diff --git a/moses/Phrase.h b/moses/Phrase.h
index a3d58f5d8..4fbf83ba6 100644
--- a/moses/Phrase.h
+++ b/moses/Phrase.h
@@ -192,6 +192,8 @@ public:
return Compare(compare) < 0;
}
+ size_t hash() const;
+
bool operator==(const Phrase &compare) const;
bool operator!=(const Phrase &compare) const
{
@@ -204,11 +206,7 @@ public:
inline size_t hash_value(const Phrase& phrase)
{
- size_t seed = 0;
- for (size_t i = 0; i < phrase.GetSize(); ++i) {
- boost::hash_combine(seed, phrase.GetWord(i));
- }
- return seed;
+ return phrase.hash();
}
struct PhrasePtrComparator {
diff --git a/moses/TranslationModel/PhraseDictionaryGroup.cpp b/moses/TranslationModel/PhraseDictionaryGroup.cpp
index 99429228d..8c7cba475 100644
--- a/moses/TranslationModel/PhraseDictionaryGroup.cpp
+++ b/moses/TranslationModel/PhraseDictionaryGroup.cpp
@@ -112,8 +112,7 @@ TargetPhraseCollection* PhraseDictionaryGroup::CreateTargetPhraseCollection(
{
// Aggregation of phrases and the scores that will be applied to them
vector<TargetPhrase*> allPhrases;
- unordered_map<const TargetPhrase*, vector<float>, PhrasePtrHasher,
- PhrasePtrComparator> allScores;
+ unordered_map<const TargetPhrase*, vector<float>, UnorderedComparer<Phrase>, UnorderedComparer<Phrase> > allScores;
// For each model
size_t offset = 0;
diff --git a/moses/Util.h b/moses/Util.h
index d7dd8af2c..c30ae5018 100644
--- a/moses/Util.h
+++ b/moses/Util.h
@@ -537,6 +537,19 @@ class FeatureFunction;
void PrintFeatureWeight(const FeatureFunction* ff);
void ShowWeights();
+template<typename T>
+class UnorderedComparer
+{
+public:
+ size_t operator()(const T* obj) const {
+ return obj->hash();
+ }
+
+ bool operator()(const T* a, const T* b) const {
+ return (*a) == (*b);
+ }
+
+};
} // namespace
diff --git a/moses/Word.h b/moses/Word.h
index 59f514445..bac69dd0f 100644
--- a/moses/Word.h
+++ b/moses/Word.h
@@ -150,18 +150,6 @@ inline size_t hash_value(const Word& word)
return word.hash();
}
-struct WordComparer {
- size_t operator()(const Word* word) const {
- return word->hash();
- }
-
- bool operator()(const Word* a, const Word* b) const {
- return (*a) == (*b);
- }
-
-};
-
-
}
#endif