diff --git a/moses/Bitmaps.cpp b/moses/Bitmaps.cpp index 2637cd46d..f4c78f914 100644 --- a/moses/Bitmaps.cpp +++ b/moses/Bitmaps.cpp @@ -4,12 +4,6 @@ namespace Moses { -Bitmaps::Bitmaps(size_t inputSize) -{ - m_initBitmap = new WordsBitmap(inputSize); - m_coll.insert(m_initBitmap); -} - Bitmaps::~Bitmaps() { RemoveAllInColl(m_coll); @@ -19,25 +13,10 @@ const WordsBitmap &Bitmaps::GetBitmap(const WordsBitmap &bm) { Coll::const_iterator iter = m_coll.find(&bm); if (iter == m_coll.end()) { - WordsBitmap *newBM = new WordsBitmap(bm); + WordsBitmap *newBM = new WordsBitmap(bm); m_coll.insert(newBM); return *newBM; } else { - return **iter; - } -} - -const WordsBitmap &Bitmaps::GetBitmap(const WordsBitmap &bm, const WordsRange &range) -{ - WordsBitmap *newBM = new WordsBitmap(bm); - newBM->SetValue(range, true); - - Coll::const_iterator iter = m_coll.find(newBM); - if (iter == m_coll.end()) { - m_coll.insert(newBM); - return *newBM; - } else { - delete newBM; return **iter; } } diff --git a/moses/Bitmaps.h b/moses/Bitmaps.h index 8db57a9c3..798aac095 100644 --- a/moses/Bitmaps.h +++ b/moses/Bitmaps.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include "WordsBitmap.h" #include "Util.h" @@ -10,19 +9,12 @@ namespace Moses class Bitmaps { - typedef boost::unordered_set NextBitmaps; typedef boost::unordered_set, UnorderedComparer > Coll; - //typedef std::set > Coll; Coll m_coll; - const WordsBitmap *m_initBitmap; -public: - Bitmaps(size_t inputSize); - virtual ~Bitmaps(); - const WordsBitmap &GetInitialBitmap() const - { return *m_initBitmap; } +public: + virtual ~Bitmaps(); const WordsBitmap &GetBitmap(const WordsBitmap &bm); - const WordsBitmap &GetBitmap(const WordsBitmap &bm, const WordsRange &range); }; diff --git a/moses/Hypothesis.cpp b/moses/Hypothesis.cpp index a426c186c..eafdd8bd7 100644 --- a/moses/Hypothesis.cpp +++ b/moses/Hypothesis.cpp @@ -46,7 +46,7 @@ namespace Moses Hypothesis:: Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt) : m_prevHypo(NULL) - , m_sourceCompleted(manager.GetBitmaps().GetInitialBitmap()) + , m_sourceCompleted(source.GetSize(), manager.GetSource().m_sourceCompleted) , m_sourceInput(source) , m_currSourceWordsRange( m_sourceCompleted.GetFirstGapPos()>0 ? 0 : NOT_FOUND, @@ -77,7 +77,7 @@ Hypothesis(Manager& manager, InputType const& source, const TranslationOption &i Hypothesis:: Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt) : m_prevHypo(&prevHypo) - , m_sourceCompleted(prevHypo.GetManager().GetBitmaps().GetBitmap(prevHypo.GetWordsBitmap(), transOpt.GetSourceWordsRange()) ) + , m_sourceCompleted(prevHypo.m_sourceCompleted ) , m_sourceInput(prevHypo.m_sourceInput) , m_currSourceWordsRange(transOpt.GetSourceWordsRange()) , m_currTargetWordsRange(prevHypo.m_currTargetWordsRange.GetEndPos() + 1, @@ -98,6 +98,8 @@ Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt) // that this hypothesis has already translated! assert(!m_sourceCompleted.Overlap(m_currSourceWordsRange)); + //_hash_computed = false; + m_sourceCompleted.SetValue(m_currSourceWordsRange.GetStartPos(), m_currSourceWordsRange.GetEndPos(), true); m_wordDeleted = transOpt.IsDeletionOption(); m_manager.GetSentenceStats().AddCreated(); } diff --git a/moses/Hypothesis.h b/moses/Hypothesis.h index c7d7c37bb..221f07b1e 100644 --- a/moses/Hypothesis.h +++ b/moses/Hypothesis.h @@ -72,7 +72,7 @@ class Hypothesis protected: const Hypothesis* m_prevHypo; /*! backpointer to previous hypothesis (from which this one was created) */ - const WordsBitmap &m_sourceCompleted; /*! keeps track of which words have been translated so far */ + WordsBitmap m_sourceCompleted; /*! keeps track of which words have been translated so far */ InputType const& m_sourceInput; WordsRange m_currSourceWordsRange; /*! source word positions of the last phrase that was used to create this hypothesis */ WordsRange m_currTargetWordsRange; /*! target word positions of the last phrase that was used to create this hypothesis */ diff --git a/moses/Manager.cpp b/moses/Manager.cpp index 919695196..8112193ef 100644 --- a/moses/Manager.cpp +++ b/moses/Manager.cpp @@ -67,7 +67,6 @@ Manager::Manager(ttasksptr const& ttask) : BaseManager(ttask) , interrupted_flag(0) , m_hypoId(0) - , m_bitmaps(ttask.get()->GetSource().get()->GetSize()) { boost::shared_ptr source = ttask->GetSource(); m_transOptColl = source->CreateTranslationOptionCollection(ttask); diff --git a/moses/Manager.h b/moses/Manager.h index ff8797098..9fffd868d 100644 --- a/moses/Manager.h +++ b/moses/Manager.h @@ -35,7 +35,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "Search.h" #include "SearchCubePruning.h" #include "BaseManager.h" -#include "Bitmaps.h" namespace Moses { @@ -120,7 +119,6 @@ protected: size_t interrupted_flag; std::auto_ptr m_sentenceStats; int m_hypoId; //used to number the hypos as they are created. - Bitmaps m_bitmaps; void GetConnectedGraph( std::map< int, bool >* pConnected, @@ -194,10 +192,6 @@ public: void ResetSentenceStats(const InputType& source); SentenceStats& GetSentenceStats() const; - Bitmaps &GetBitmaps() { - return m_bitmaps; - } - /*** *For Lattice MBR */ diff --git a/moses/Util.h b/moses/Util.h index e557c2e6d..cc0f7314b 100644 --- a/moses/Util.h +++ b/moses/Util.h @@ -537,15 +537,6 @@ class FeatureFunction; void PrintFeatureWeight(const FeatureFunction* ff); void ShowWeights(); -template -class OrderedComparer -{ -public: - bool operator()(const T* a, const T* b) const { - return (*a) < (*b); - } -}; - template class UnorderedComparer {