diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-05 19:25:17 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-05 19:25:17 +0300 |
commit | 67fb5cd5f038ae9ca4f8d5ef349364372de9db5a (patch) | |
tree | 393ae1a51bc374990727a09f528215c3fdb17358 /moses | |
parent | 89014a9696e77222b7b11ceefc880e2b6be35f66 (diff) |
move CalcFutureScore() out of inner loop.
Diffstat (limited to 'moses')
-rw-r--r-- | moses/BitmapContainer.cpp | 2 | ||||
-rw-r--r-- | moses/Hypothesis.cpp | 4 | ||||
-rw-r--r-- | moses/Hypothesis.h | 2 | ||||
-rw-r--r-- | moses/SearchNormal.cpp | 17 | ||||
-rw-r--r-- | moses/SearchNormal.h | 6 |
5 files changed, 19 insertions, 12 deletions
diff --git a/moses/BitmapContainer.cpp b/moses/BitmapContainer.cpp index ae7c03990..53176f02b 100644 --- a/moses/BitmapContainer.cpp +++ b/moses/BitmapContainer.cpp @@ -211,7 +211,7 @@ Hypothesis *BackwardsEdge::CreateHypothesis(const Hypothesis &hypothesis, const IFVERBOSE(2) { hypothesis.GetManager().GetSentenceStats().StopTimeBuildHyp(); } - newHypo->EvaluateWhenApplied(m_futurescore); + //newHypo->EvaluateWhenApplied(m_futurescore); return newHypo; } diff --git a/moses/Hypothesis.cpp b/moses/Hypothesis.cpp index 5a7833c9f..a75d68049 100644 --- a/moses/Hypothesis.cpp +++ b/moses/Hypothesis.cpp @@ -255,7 +255,7 @@ EvaluateWhenApplied(const StatelessFeatureFunction& slff) */ void Hypothesis:: -EvaluateWhenApplied(const SquareMatrix &futureScore) +EvaluateWhenApplied(float futureScore) { IFVERBOSE(2) { m_manager.GetSentenceStats().StartTimeOtherScore(); @@ -292,7 +292,7 @@ EvaluateWhenApplied(const SquareMatrix &futureScore) } // FUTURE COST - m_futureScore = futureScore.CalcFutureScore( m_sourceCompleted ); + m_futureScore = futureScore; // TOTAL m_totalScore = m_currScoreBreakdown.GetWeightedScore() + m_futureScore; diff --git a/moses/Hypothesis.h b/moses/Hypothesis.h index 0ce75b83c..8c198f2da 100644 --- a/moses/Hypothesis.h +++ b/moses/Hypothesis.h @@ -146,7 +146,7 @@ public: return m_currTargetWordsRange.GetNumWordsCovered(); } - void EvaluateWhenApplied(const SquareMatrix &futureScore); + void EvaluateWhenApplied(float futureScore); int GetId()const { return m_id; diff --git a/moses/SearchNormal.cpp b/moses/SearchNormal.cpp index f547fce06..db1fb6fda 100644 --- a/moses/SearchNormal.cpp +++ b/moses/SearchNormal.cpp @@ -248,14 +248,16 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos // early discarding: check if hypothesis is too bad to build // this idea is explained in (Moore&Quirk, MT Summit 2007) float expectedScore = 0.0f; + + const WordsBitmap &sourceCompleted = hypothesis.GetWordsBitmap(); + float futureScore = m_transOptColl.GetFutureScore().CalcFutureScore2( sourceCompleted, startPos, endPos ); + if (m_options.search.UseEarlyDiscarding()) { // expected score is based on score of current hypothesis expectedScore = hypothesis.GetScore(); // add new future score estimate - expectedScore += - m_transOptColl.GetFutureScore() - .CalcFutureScore2(hypothesis.GetWordsBitmap(), startPos, endPos); + expectedScore += futureScore; } // loop through all translation options @@ -264,7 +266,7 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos if (!tol) return; TranslationOptionList::const_iterator iter; for (iter = tol->begin() ; iter != tol->end() ; ++iter) { - ExpandHypothesis(hypothesis, **iter, expectedScore); + ExpandHypothesis(hypothesis, **iter, expectedScore, futureScore); } } @@ -277,7 +279,10 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos * \param expectedScore base score for early discarding * (base hypothesis score plus future score estimation) */ -void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis, const TranslationOption &transOpt, float expectedScore) +void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis, + const TranslationOption &transOpt, + float expectedScore, + float futureScore) { const StaticData &staticData = StaticData::Instance(); SentenceStats &stats = m_manager.GetSentenceStats(); @@ -293,7 +298,7 @@ void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis, const Translat stats.StopTimeBuildHyp(); } if (newHypo==NULL) return; - newHypo->EvaluateWhenApplied(m_transOptColl.GetFutureScore()); + newHypo->EvaluateWhenApplied(futureScore); } else // early discarding: check if hypothesis is too bad to build { diff --git a/moses/SearchNormal.h b/moses/SearchNormal.h index aa005a5e1..320c047f2 100644 --- a/moses/SearchNormal.h +++ b/moses/SearchNormal.h @@ -44,8 +44,10 @@ protected: ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos); virtual void - ExpandHypothesis(const Hypothesis &hypothesis, const TranslationOption &transOpt, - float expectedScore); + ExpandHypothesis(const Hypothesis &hypothesis, + const TranslationOption &transOpt, + float expectedScore, + float futureScore); public: SearchNormal(Manager& manager, const InputType &source, const TranslationOptionCollection &transOptColl); |