diff --git a/moses/BitmapContainer.cpp b/moses/BitmapContainer.cpp index 73d4bfde0..718003a6f 100644 --- a/moses/BitmapContainer.cpp +++ b/moses/BitmapContainer.cpp @@ -120,14 +120,14 @@ public: BackwardsEdge::BackwardsEdge(const BitmapContainer &prevBitmapContainer , BitmapContainer &parent , const TranslationOptionList &translations - , const SquareMatrix &futureScores, + , const SquareMatrix &estimatedScores, const InputType& itype, const bool deterministic) : m_initialized(false) , m_prevBitmapContainer(prevBitmapContainer) , m_parent(parent) , m_translations(translations) - , m_futureScores(futureScores) + , m_estimatedScores(estimatedScores) , m_seenPosition() , m_deterministic(deterministic) { @@ -209,7 +209,7 @@ BackwardsEdge::Initialize() const Bitmap &bm = m_hypotheses[0]->GetWordsBitmap(); const Range &newRange = m_translations.Get(0)->GetSourceWordsRange(); - m_futureScore = m_futureScores.CalcFutureScore2(bm, newRange.GetStartPos(), newRange.GetEndPos()); + m_estimatedScore = m_estimatedScores.CalcEstimatedScore(bm, newRange.GetStartPos(), newRange.GetEndPos()); Hypothesis *expanded = CreateHypothesis(*m_hypotheses[0], *m_translations.Get(0)); m_parent.Enqueue(0, 0, expanded, this); @@ -228,7 +228,7 @@ Hypothesis *BackwardsEdge::CreateHypothesis(const Hypothesis &hypothesis, const IFVERBOSE(2) { hypothesis.GetManager().GetSentenceStats().StopTimeBuildHyp(); } - newHypo->EvaluateWhenApplied(m_futureScore); + newHypo->EvaluateWhenApplied(m_estimatedScore); return newHypo; } diff --git a/moses/BitmapContainer.h b/moses/BitmapContainer.h index c496ea6e3..248dd8fee 100644 --- a/moses/BitmapContainer.h +++ b/moses/BitmapContainer.h @@ -184,8 +184,8 @@ private: const BitmapContainer &m_prevBitmapContainer; BitmapContainer &m_parent; const TranslationOptionList &m_translations; - const SquareMatrix &m_futureScores; - float m_futureScore; + const SquareMatrix &m_estimatedScores; + float m_estimatedScore; bool m_deterministic; @@ -206,7 +206,7 @@ public: BackwardsEdge(const BitmapContainer &prevBitmapContainer , BitmapContainer &parent , const TranslationOptionList &translations - , const SquareMatrix &futureScores + , const SquareMatrix &estimatedScores , const InputType& source , const bool deterministic = false); ~BackwardsEdge(); diff --git a/moses/Hypothesis.cpp b/moses/Hypothesis.cpp index cb77a0811..6fa85af65 100644 --- a/moses/Hypothesis.cpp +++ b/moses/Hypothesis.cpp @@ -170,7 +170,7 @@ EvaluateWhenApplied(const StatelessFeatureFunction& slff) */ void Hypothesis:: -EvaluateWhenApplied(float futureScore) +EvaluateWhenApplied(float estimatedScore) { IFVERBOSE(2) { m_manager.GetSentenceStats().StartTimeOtherScore(); @@ -206,7 +206,7 @@ EvaluateWhenApplied(float futureScore) } // FUTURE COST - m_estimatedScore = futureScore; + m_estimatedScore = estimatedScore; // TOTAL m_futureScore = m_currScoreBreakdown.GetWeightedScore() + m_estimatedScore; diff --git a/moses/Hypothesis.h b/moses/Hypothesis.h index 34ea0e9cf..c38fedbf1 100644 --- a/moses/Hypothesis.h +++ b/moses/Hypothesis.h @@ -119,7 +119,7 @@ public: return m_currTargetWordsRange.GetNumWordsCovered(); } - void EvaluateWhenApplied(float futureScore); + void EvaluateWhenApplied(float estimatedScore); int GetId()const { return m_id; diff --git a/moses/HypothesisStackCubePruning.cpp b/moses/HypothesisStackCubePruning.cpp index 743307cc6..2c1ba1391 100644 --- a/moses/HypothesisStackCubePruning.cpp +++ b/moses/HypothesisStackCubePruning.cpp @@ -252,14 +252,14 @@ void HypothesisStackCubePruning::SetBitmapAccessor(const Bitmap &newBitmap , HypothesisStackCubePruning &stack , const Range &/*range*/ , BitmapContainer &bitmapContainer - , const SquareMatrix &futureScore + , const SquareMatrix &estimatedScores , const TranslationOptionList &transOptList) { BitmapContainer *bmContainer = AddBitmapContainer(newBitmap, stack); BackwardsEdge *edge = new BackwardsEdge(bitmapContainer , *bmContainer , transOptList - , futureScore + , estimatedScores , m_manager.GetSource() , m_deterministic); bmContainer->AddBackwardsEdge(edge); diff --git a/moses/HypothesisStackCubePruning.h b/moses/HypothesisStackCubePruning.h index 5eca1f6b1..c9c9057b2 100644 --- a/moses/HypothesisStackCubePruning.h +++ b/moses/HypothesisStackCubePruning.h @@ -125,7 +125,7 @@ public: , HypothesisStackCubePruning &stack , const Range &range , BitmapContainer &bitmapContainer - , const SquareMatrix &futureScore + , const SquareMatrix &estimatedScores , const TranslationOptionList &transOptList); /** pruning, if too large. diff --git a/moses/SearchCubePruning.cpp b/moses/SearchCubePruning.cpp index 55971f96c..87fd3435d 100644 --- a/moses/SearchCubePruning.cpp +++ b/moses/SearchCubePruning.cpp @@ -237,13 +237,13 @@ CreateForwardTodos(Bitmap const& bitmap, Range const& range, size_t numCovered = newBitmap.GetNumWordsCovered(); const TranslationOptionList* transOptList; transOptList = m_transOptColl.GetTranslationOptionList(range); - const SquareMatrix &futureScore = m_transOptColl.GetFutureScore(); + const SquareMatrix &estimatedScores = m_transOptColl.GetEstimatedScores(); if (transOptList && transOptList->size() > 0) { HypothesisStackCubePruning& newStack = *static_cast(m_hypoStackColl[numCovered]); newStack.SetBitmapAccessor(newBitmap, newStack, range, bitmapContainer, - futureScore, *transOptList); + estimatedScores, *transOptList); } } diff --git a/moses/SearchNormal.cpp b/moses/SearchNormal.cpp index 62bf420fc..025e61479 100644 --- a/moses/SearchNormal.cpp +++ b/moses/SearchNormal.cpp @@ -251,14 +251,14 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos float expectedScore = 0.0f; const Bitmap &sourceCompleted = hypothesis.GetWordsBitmap(); - float futureScore = m_transOptColl.GetFutureScore().CalcFutureScore2( sourceCompleted, startPos, endPos ); + float estimatedScore = m_transOptColl.GetEstimatedScores().CalcEstimatedScore( 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 += futureScore; + expectedScore += estimatedScore; } // loop through all translation options @@ -274,7 +274,7 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos TranslationOptionList::const_iterator iter; for (iter = tol->begin() ; iter != tol->end() ; ++iter) { const TranslationOption &transOpt = **iter; - ExpandHypothesis(hypothesis, transOpt, expectedScore, futureScore, nextBitmap); + ExpandHypothesis(hypothesis, transOpt, expectedScore, estimatedScore, nextBitmap); } } @@ -290,7 +290,7 @@ ExpandAllHypotheses(const Hypothesis &hypothesis, size_t startPos, size_t endPos void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis, const TranslationOption &transOpt, float expectedScore, - float futureScore, + float estimatedScore, const Bitmap &bitmap) { const StaticData &staticData = StaticData::Instance(); @@ -307,7 +307,7 @@ void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis, stats.StopTimeBuildHyp(); } if (newHypo==NULL) return; - newHypo->EvaluateWhenApplied(futureScore); + newHypo->EvaluateWhenApplied(estimatedScore); } else // early discarding: check if hypothesis is too bad to build { diff --git a/moses/SearchNormal.h b/moses/SearchNormal.h index ddb3d8234..2e3321d29 100644 --- a/moses/SearchNormal.h +++ b/moses/SearchNormal.h @@ -45,7 +45,7 @@ protected: ExpandHypothesis(const Hypothesis &hypothesis, const TranslationOption &transOpt, float expectedScore, - float futureScore, + float estimatedScore, const Bitmap &bitmap); public: diff --git a/moses/SquareMatrix.cpp b/moses/SquareMatrix.cpp index 81b9f4b06..470ac52d2 100644 --- a/moses/SquareMatrix.cpp +++ b/moses/SquareMatrix.cpp @@ -45,11 +45,11 @@ void SquareMatrix::InitTriangle(float val) * /param bitmap coverage bitmap */ -float SquareMatrix::CalcFutureScore( Bitmap const &bitmap ) const +float SquareMatrix::CalcEstimatedScore( Bitmap const &bitmap ) const { const size_t notInGap= numeric_limits::max(); size_t startGap = notInGap; - float futureScore = 0.0f; + float estimatedScore = 0.0f; for(size_t currPos = 0 ; currPos < bitmap.GetSize() ; currPos++) { // start of a new gap? if(bitmap.GetValue(currPos) == false && startGap == notInGap) { @@ -57,16 +57,16 @@ float SquareMatrix::CalcFutureScore( Bitmap const &bitmap ) const } // end of a gap? else if(bitmap.GetValue(currPos) == true && startGap != notInGap) { - futureScore += GetScore(startGap, currPos - 1); + estimatedScore += GetScore(startGap, currPos - 1); startGap = notInGap; } } // coverage ending with gap? if (startGap != notInGap) { - futureScore += GetScore(startGap, bitmap.GetSize() - 1); + estimatedScore += GetScore(startGap, bitmap.GetSize() - 1); } - return futureScore; + return estimatedScore; } /** @@ -84,12 +84,12 @@ float SquareMatrix::CalcFutureScore( Bitmap const &bitmap ) const * /param endPos end of the span that is added to the coverage */ -float SquareMatrix::CalcFutureScore2( Bitmap const &bitmap, size_t startPos, size_t endPos ) const +float SquareMatrix::CalcEstimatedScore( Bitmap const &bitmap, size_t startPos, size_t endPos ) const { const size_t notInGap= numeric_limits::max(); - float futureScore = 0.0f; + float estimatedScore = 0.0f; size_t startGap = bitmap.GetFirstGapPos(); - if (startGap == NOT_FOUND) return futureScore; // everything filled + if (startGap == NOT_FOUND) return estimatedScore; // everything filled // start loop at first gap size_t startLoop = startGap+1; @@ -108,16 +108,16 @@ float SquareMatrix::CalcFutureScore2( Bitmap const &bitmap, size_t startPos, siz } // end of a gap? else if(startGap != notInGap && (bitmap.GetValue(currPos) == true || (startPos <= currPos && currPos <= endPos))) { - futureScore += GetScore(startGap, currPos - 1); + estimatedScore += GetScore(startGap, currPos - 1); startGap = notInGap; } } // coverage ending with gap? if (lastCovered != bitmap.GetSize() - 1) { - futureScore += GetScore(lastCovered+1, bitmap.GetSize() - 1); + estimatedScore += GetScore(lastCovered+1, bitmap.GetSize() - 1); } - return futureScore; + return estimatedScore; } TO_STRING_BODY(SquareMatrix); diff --git a/moses/SquareMatrix.h b/moses/SquareMatrix.h index 02e25a3a6..d320fb597 100644 --- a/moses/SquareMatrix.h +++ b/moses/SquareMatrix.h @@ -65,8 +65,8 @@ public: inline void SetScore(size_t startPos, size_t endPos, float value) { m_array[startPos * m_size + endPos] = value; } - float CalcFutureScore( Bitmap const& ) const; - float CalcFutureScore2( Bitmap const&, size_t startPos, size_t endPos ) const; + float CalcEstimatedScore( Bitmap const& ) const; + float CalcEstimatedScore( Bitmap const&, size_t startPos, size_t endPos ) const; TO_STRING(); }; diff --git a/moses/TranslationOptionCollection.cpp b/moses/TranslationOptionCollection.cpp index 85ae4286a..058103eb6 100644 --- a/moses/TranslationOptionCollection.cpp +++ b/moses/TranslationOptionCollection.cpp @@ -62,7 +62,7 @@ TranslationOptionCollection(ttasksptr const& ttask, float translationOptionThreshold) : m_ttask(ttask) , m_source(src) - , m_futureScore(src.GetSize()) + , m_estimatedScores(src.GetSize()) , m_maxNoTransOptPerCoverage(maxNoTransOptPerCoverage) , m_translationOptionThreshold(translationOptionThreshold) { @@ -254,10 +254,10 @@ ProcessOneUnknownWord(const InputPath &inputPath, size_t sourcePos, */ void TranslationOptionCollection:: -CalcFutureScore() +CalcEstimatedScore() { // setup the matrix (ignore lower triangle, set upper triangle to -inf - m_futureScore.InitTriangle(-numeric_limits::infinity()); + m_estimatedScores.InitTriangle(-numeric_limits::infinity()); // walk all the translation options and record the cheapest option for each span size_t size = m_source.GetSize(); // the width of the matrix @@ -268,8 +268,8 @@ CalcFutureScore() for(toi = tol.begin() ; toi != tol.end() ; ++toi) { const TranslationOption& to = **toi; float score = to.GetFutureScore(); - if (score > m_futureScore.GetScore(sPos, ePos)) - m_futureScore.SetScore(sPos, ePos, score); + if (score > m_estimatedScores.GetScore(sPos, ePos)) + m_estimatedScores.SetScore(sPos, ePos, score); } ++ePos; } @@ -287,8 +287,8 @@ CalcFutureScore() size_t sPos = diagshift; size_t ePos = colstart+diagshift; for(size_t joinAt = sPos; joinAt < ePos ; joinAt++) { - float joinedScore = m_futureScore.GetScore(sPos, joinAt) - + m_futureScore.GetScore(joinAt+1, ePos); + float joinedScore = m_estimatedScores.GetScore(sPos, joinAt) + + m_estimatedScores.GetScore(joinAt+1, ePos); // uncomment to see the cell filling scheme // TRACE_ERR("[" << sPos << "," << ePos << "] <-? [" // << sPos << "," << joinAt << "]+[" @@ -296,8 +296,8 @@ CalcFutureScore() // << colstart << ", diagshift: " << diagshift << ")" // << endl); - if (joinedScore > m_futureScore.GetScore(sPos, ePos)) - m_futureScore.SetScore(sPos, ePos, joinedScore); + if (joinedScore > m_estimatedScores.GetScore(sPos, ePos)) + m_estimatedScores.SetScore(sPos, ePos, joinedScore); } } } @@ -325,7 +325,7 @@ CalcFutureScore() for(size_t row=0; row > m_collection; /*< contains translation options */ InputType const &m_source; /*< reference to the input */ - SquareMatrix m_futureScore; /*< matrix of future costs for contiguous parts (span) of the input */ + SquareMatrix m_estimatedScores; /*< matrix of future costs for contiguous parts (span) of the input */ const size_t m_maxNoTransOptPerCoverage; /*< maximum number of translation options per input span */ const float m_translationOptionThreshold; /*< threshold for translation options with regard to best option for input span */ std::vector m_unksrcs; @@ -78,7 +78,7 @@ protected: InputType const& src, size_t maxNoTransOptPerCoverage, float translationOptionThreshold); - void CalcFutureScore(); + void CalcEstimatedScore(); //! Force a creation of a translation option where there are none for a particular source position. void ProcessUnknownWord(); @@ -163,8 +163,8 @@ public: //! returns future cost matrix for sentence - inline virtual const SquareMatrix &GetFutureScore() const { - return m_futureScore; + inline virtual const SquareMatrix &GetEstimatedScores() const { + return m_estimatedScores; } //! list of trans opt for a particular span diff --git a/moses/TranslationOptionCollectionLattice.cpp b/moses/TranslationOptionCollectionLattice.cpp index c3b5765e7..10e61b5d4 100644 --- a/moses/TranslationOptionCollectionLattice.cpp +++ b/moses/TranslationOptionCollectionLattice.cpp @@ -168,7 +168,7 @@ void TranslationOptionCollectionLattice::CreateTranslationOptions() Sort(); // future score matrix - CalcFutureScore(); + CalcEstimatedScore(); // Cached lex reodering costs CacheLexReordering();