From b5f0758ee453fa351980a2d52375bf1cc1f66c32 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 20 Oct 2015 00:50:40 +0100 Subject: [PATCH] make bitmap in hypo class a reference --- moses/Hypothesis.cpp | 4 ++-- moses/Hypothesis.h | 2 +- moses/SearchCubePruning.cpp | 3 ++- moses/SearchCubePruning.h | 1 + moses/SearchNormal.cpp | 3 ++- moses/SearchNormal.h | 3 +++ 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/moses/Hypothesis.cpp b/moses/Hypothesis.cpp index eafdd8bd7..6776943bb 100644 --- a/moses/Hypothesis.cpp +++ b/moses/Hypothesis.cpp @@ -44,9 +44,9 @@ using namespace std; namespace Moses { Hypothesis:: -Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt) +Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt, const WordsBitmap &bitmap) : m_prevHypo(NULL) - , m_sourceCompleted(source.GetSize(), manager.GetSource().m_sourceCompleted) + , m_sourceCompleted(bitmap) , m_sourceInput(source) , m_currSourceWordsRange( m_sourceCompleted.GetFirstGapPos()>0 ? 0 : NOT_FOUND, diff --git a/moses/Hypothesis.h b/moses/Hypothesis.h index 221f07b1e..dc7186a02 100644 --- a/moses/Hypothesis.h +++ b/moses/Hypothesis.h @@ -92,7 +92,7 @@ protected: public: /*! used by initial seeding of the translation process */ - Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt); + Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt, const WordsBitmap &bitmap); /*! used when creating a new hypothesis using a translation option (phrase translation) */ Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt); ~Hypothesis(); diff --git a/moses/SearchCubePruning.cpp b/moses/SearchCubePruning.cpp index 5dc481202..8e6cf993d 100644 --- a/moses/SearchCubePruning.cpp +++ b/moses/SearchCubePruning.cpp @@ -49,6 +49,7 @@ SearchCubePruning(Manager& manager, const InputType &source, const TranslationOptionCollection &transOptColl) : Search(manager) , m_source(source) + , m_initBitmap(source.GetSize()) , m_hypoStackColl(source.GetSize() + 1) , m_transOptColl(transOptColl) { @@ -74,7 +75,7 @@ SearchCubePruning::~SearchCubePruning() void SearchCubePruning::Decode() { // initial seed hypothesis: nothing translated, no words produced - Hypothesis *hypo = new Hypothesis(m_manager, m_source, m_initialTransOpt); + Hypothesis *hypo = new Hypothesis(m_manager, m_source, m_initialTransOpt, m_initBitmap); HypothesisStackCubePruning &firstStack = *static_cast(m_hypoStackColl.front()); diff --git a/moses/SearchCubePruning.h b/moses/SearchCubePruning.h index 334204004..b30adf772 100644 --- a/moses/SearchCubePruning.h +++ b/moses/SearchCubePruning.h @@ -19,6 +19,7 @@ class SearchCubePruning: public Search { protected: const InputType &m_source; + WordsBitmap m_initBitmap; std::vector < HypothesisStack* > m_hypoStackColl; /**< stacks to store hypotheses (partial translations) */ // no of elements = no of words in source + 1 const TranslationOptionCollection &m_transOptColl; /**< pre-computed list of translation options for the phrases in this sentence */ diff --git a/moses/SearchNormal.cpp b/moses/SearchNormal.cpp index 2d4d45a8a..69dbe0d56 100644 --- a/moses/SearchNormal.cpp +++ b/moses/SearchNormal.cpp @@ -86,7 +86,8 @@ void SearchNormal::Decode() // SentenceStats &stats = m_manager.GetSentenceStats(); // initial seed hypothesis: nothing translated, no words produced - Hypothesis *hypo = new Hypothesis(m_manager, m_source, m_initialTransOpt); + const WordsBitmap &bitmap = m_bitmaps.GetBitmap(WordsBitmap(m_source.GetSize())); + Hypothesis *hypo = new Hypothesis(m_manager, m_source, m_initialTransOpt, bitmap); m_hypoStackColl[0]->AddPrune(hypo); diff --git a/moses/SearchNormal.h b/moses/SearchNormal.h index 3a57e1a75..43d0ad824 100644 --- a/moses/SearchNormal.h +++ b/moses/SearchNormal.h @@ -6,6 +6,7 @@ #include "HypothesisStackNormal.h" #include "TranslationOptionCollection.h" #include "Timer.h" +#include "Bitmaps.h" namespace Moses { @@ -32,6 +33,8 @@ protected: /** pre-computed list of translation options for the phrases in this sentence */ const TranslationOptionCollection &m_transOptColl; + Bitmaps m_bitmaps; + // functions for creating hypotheses virtual bool