diff options
author | hieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-08-01 05:21:55 +0400 |
---|---|---|
committer | hieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-08-01 05:21:55 +0400 |
commit | d286cf724c46062ee3c9e2943f41a45760490ff6 (patch) | |
tree | a0dbb91942bc0d6999bb218549e4286294c9c025 | |
parent | 5f3965de12becb739df04e4b873fde76f65b888d (diff) |
hypo uses ref to phrase, rather than copy
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@436 1f5c12ca-751b-0410-a591-d2e778427230
-rwxr-xr-x | moses/src/Hypothesis.cpp | 8 | ||||
-rwxr-xr-x | moses/src/Hypothesis.h | 12 | ||||
-rwxr-xr-x | moses/src/Manager.cpp | 3 | ||||
-rwxr-xr-x | moses/src/Manager.h | 3 |
4 files changed, 12 insertions, 14 deletions
diff --git a/moses/src/Hypothesis.cpp b/moses/src/Hypothesis.cpp index e274b4d73..a453e7a6f 100755 --- a/moses/src/Hypothesis.cpp +++ b/moses/src/Hypothesis.cpp @@ -40,9 +40,9 @@ unsigned int Hypothesis::s_numNodes = 0; unsigned int Hypothesis::s_HypothesesCreated = 0; -Hypothesis::Hypothesis(InputType const& source) +Hypothesis::Hypothesis(InputType const& source, const TargetPhrase &emptyTarget) : m_prevHypo(NULL) - , m_targetPhrase(Output) + , m_targetPhrase(emptyTarget) , m_sourceCompleted(source.GetSize()) , m_sourceInput(source) , m_currSourceWordsRange(NOT_FOUND, NOT_FOUND) @@ -144,9 +144,9 @@ Hypothesis* Hypothesis::Create(const Hypothesis &prevHypo, const TranslationOpti * return the subclass of Hypothesis most appropriate to the given target phrase */ -Hypothesis* Hypothesis::Create(InputType const& m_source) +Hypothesis* Hypothesis::Create(InputType const& m_source, const TargetPhrase &emptyTarget) { - return new Hypothesis(m_source); + return new Hypothesis(m_source, emptyTarget); } bool Hypothesis::IsCompatible(const Phrase &phrase) const diff --git a/moses/src/Hypothesis.h b/moses/src/Hypothesis.h index a27401abe..2190027e5 100755 --- a/moses/src/Hypothesis.h +++ b/moses/src/Hypothesis.h @@ -54,7 +54,7 @@ private: protected: const Hypothesis* m_prevHypo; - Phrase m_targetPhrase; //target phrase being created at the current decoding step + const Phrase &m_targetPhrase; //target phrase being created at the current decoding step WordsBitmap m_sourceCompleted; //TODO: how to integrate this into confusion network framework; what if //it's a confusion network in the end??? @@ -93,7 +93,7 @@ public: static unsigned int s_numNodes; // Statistics: how many hypotheses were created in total int m_id; - Hypothesis(InputType const& source); + Hypothesis(InputType const& source, const TargetPhrase &emptyTarget); // used for initial seeding of trans process Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt); // create next @@ -111,7 +111,7 @@ public: /*** * return the subclass of Hypothesis most appropriate to the given target phrase */ - static Hypothesis* Create(InputType const& source); + static Hypothesis* Create(InputType const& source, const TargetPhrase &emptyTarget); /*** @@ -176,10 +176,6 @@ public: // curr - pos is relative from CURRENT hypothesis's starting ind ex // (ie, start of sentence would be some negative number, which is // not allowed- USE WITH CAUTION) - inline FactorArray &GetCurrFactorArray(size_t pos) - { - return m_targetPhrase.GetFactorArray(pos); - } inline const FactorArray &GetCurrFactorArray(size_t pos) const { return m_targetPhrase.GetFactorArray(pos); @@ -195,8 +191,8 @@ public: while (pos < hypo->GetCurrTargetWordsRange().GetStartPos()) { hypo = hypo->GetPrevHypo(); + assert(hypo != NULL); } - assert(hypo != NULL); return hypo->GetCurrFactorArray(pos - hypo->GetCurrTargetWordsRange().GetStartPos()); } inline const Factor* GetFactor(size_t pos, FactorType factorType) const diff --git a/moses/src/Manager.cpp b/moses/src/Manager.cpp index 6a318e1a4..2f0949537 100755 --- a/moses/src/Manager.cpp +++ b/moses/src/Manager.cpp @@ -39,6 +39,7 @@ Manager::Manager(InputType const& source, ,m_hypoStack(source.GetSize() + 1) ,m_staticData(staticData) ,m_possibleTranslations(toc) //dynamic_cast<Sentence const&>(source)) +,m_initialTargetPhrase(Output) { std::vector < HypothesisCollection >::iterator iterStack; for (iterStack = m_hypoStack.begin() ; iterStack != m_hypoStack.end() ; ++iterStack) @@ -73,7 +74,7 @@ void Manager::ProcessSentence() // initial seed hypothesis: nothing translated, no words produced { - Hypothesis *hypo = Hypothesis::Create(m_source); + Hypothesis *hypo = Hypothesis::Create(m_source, m_initialTargetPhrase); m_hypoStack[0].AddPrune(hypo); } diff --git a/moses/src/Manager.h b/moses/src/Manager.h index 60b0586c1..13fdd0018 100755 --- a/moses/src/Manager.h +++ b/moses/src/Manager.h @@ -46,7 +46,8 @@ protected: // no of elements = no of words in source + 1 StaticData &m_staticData; TranslationOptionCollection &m_possibleTranslations; - + TargetPhrase m_initialTargetPhrase; // used to seed 1st hypo + // functions for creating hypotheses void ProcessOneHypothesis(const Hypothesis &hypothesis); void ExpandAllHypotheses(const Hypothesis &hypothesis,const TranslationOptionList &transOptList); |