diff --git a/contrib/server/mosesserver.cpp b/contrib/server/mosesserver.cpp index 79b48f54c..d9bf53da8 100644 --- a/contrib/server/mosesserver.cpp +++ b/contrib/server/mosesserver.cpp @@ -487,7 +487,7 @@ public: } // weighted score - nBestXMLItem["totalScore"] = xmlrpc_c::value_double(path.GetTotalScore()); + nBestXMLItem["totalScore"] = xmlrpc_c::value_double(path.GetFutureScore()); nBestXml.push_back(xmlrpc_c::value_struct(nBestXMLItem)); } retData.insert(pair("nbest", xmlrpc_c::value_array(nBestXml))); diff --git a/moses/BitmapContainer.cpp b/moses/BitmapContainer.cpp index 7adadee82..73d4bfde0 100644 --- a/moses/BitmapContainer.cpp +++ b/moses/BitmapContainer.cpp @@ -180,10 +180,10 @@ BackwardsEdge::BackwardsEdge(const BitmapContainer &prevBitmapContainer } if (m_hypotheses.size() > 1) { - UTIL_THROW_IF2(m_hypotheses[0]->GetTotalScore() < m_hypotheses[1]->GetTotalScore(), + UTIL_THROW_IF2(m_hypotheses[0]->GetFutureScore() < m_hypotheses[1]->GetFutureScore(), "Non-monotonic total score" - << m_hypotheses[0]->GetTotalScore() << " vs. " - << m_hypotheses[1]->GetTotalScore()); + << m_hypotheses[0]->GetFutureScore() << " vs. " + << m_hypotheses[1]->GetFutureScore()); } HypothesisScoreOrdererWithDistortion orderer (&transOptRange, m_deterministic); @@ -460,10 +460,10 @@ BitmapContainer::ProcessBestHypothesis() // check we are pulling things off of priority queue in right order if (!Empty()) { HypothesisQueueItem *check = Dequeue(true); - UTIL_THROW_IF2(item->GetHypothesis()->GetTotalScore() < check->GetHypothesis()->GetTotalScore(), + UTIL_THROW_IF2(item->GetHypothesis()->GetFutureScore() < check->GetHypothesis()->GetFutureScore(), "Non-monotonic total score: " - << item->GetHypothesis()->GetTotalScore() << " vs. " - << check->GetHypothesis()->GetTotalScore()); + << item->GetHypothesis()->GetFutureScore() << " vs. " + << check->GetHypothesis()->GetFutureScore()); } // Logging for the criminally insane diff --git a/moses/BitmapContainer.h b/moses/BitmapContainer.h index 680504b89..c496ea6e3 100644 --- a/moses/BitmapContainer.h +++ b/moses/BitmapContainer.h @@ -109,8 +109,8 @@ class QueueItemOrderer { public: bool operator()(HypothesisQueueItem* itemA, HypothesisQueueItem* itemB) const { - float scoreA = itemA->GetHypothesis()->GetTotalScore(); - float scoreB = itemB->GetHypothesis()->GetTotalScore(); + float scoreA = itemA->GetHypothesis()->GetFutureScore(); + float scoreB = itemB->GetHypothesis()->GetFutureScore(); if (scoreA < scoreB) { return true; @@ -151,8 +151,8 @@ public: bool operator()(const Hypothesis* hypoA, const Hypothesis* hypoB) const { - float scoreA = hypoA->GetTotalScore(); - float scoreB = hypoB->GetTotalScore(); + float scoreA = hypoA->GetFutureScore(); + float scoreB = hypoB->GetFutureScore(); if (scoreA > scoreB) { return true; diff --git a/moses/ChartCell.cpp b/moses/ChartCell.cpp index 2de890740..9f591ee46 100644 --- a/moses/ChartCell.cpp +++ b/moses/ChartCell.cpp @@ -136,8 +136,8 @@ const ChartHypothesis *ChartCell::GetBestHypothesis() const const HypoList &sortedList = iter->second.GetSortedHypotheses(); if (sortedList.size() > 0) { const ChartHypothesis *hypo = sortedList[0]; - if (hypo->GetTotalScore() > bestScore) { - bestScore = hypo->GetTotalScore(); + if (hypo->GetFutureScore() > bestScore) { + bestScore = hypo->GetFutureScore(); ret = hypo; } } diff --git a/moses/ChartHypothesis.cpp b/moses/ChartHypothesis.cpp index 7c9f17621..00d05055f 100644 --- a/moses/ChartHypothesis.cpp +++ b/moses/ChartHypothesis.cpp @@ -207,7 +207,7 @@ void ChartHypothesis::EvaluateWhenApplied() // total scores from prev hypos for (std::vector::const_iterator iter = m_prevHypos.begin(); iter != m_prevHypos.end(); ++iter) { const ChartHypothesis &prevHypo = **iter; - m_totalScore += prevHypo.GetTotalScore(); + m_totalScore += prevHypo.GetFutureScore(); } } @@ -241,7 +241,7 @@ void ChartHypothesis::AddArc(ChartHypothesis *loserHypo) // sorting helper struct CompareChartHypothesisTotalScore { bool operator()(const ChartHypothesis* hypo1, const ChartHypothesis* hypo2) const { - return hypo1->GetTotalScore() > hypo2->GetTotalScore(); + return hypo1->GetFutureScore() > hypo2->GetFutureScore(); } }; @@ -350,7 +350,7 @@ std::ostream& operator<<(std::ostream& out, const ChartHypothesis& hypo) out << " " << prevHypo.GetId(); } - out << " [total=" << hypo.GetTotalScore() << "]"; + out << " [total=" << hypo.GetFutureScore() << "]"; out << " " << hypo.GetScoreBreakdown(); //out << endl; diff --git a/moses/ChartHypothesis.h b/moses/ChartHypothesis.h index 63f59c31e..6f8a578f7 100644 --- a/moses/ChartHypothesis.h +++ b/moses/ChartHypothesis.h @@ -167,7 +167,7 @@ public: } //! Get the weighted total score - float GetTotalScore() const { + float GetFutureScore() const { // scores from current translation rule. eg. translation models & word penalty return m_totalScore; } diff --git a/moses/ChartHypothesisCollection.cpp b/moses/ChartHypothesisCollection.cpp index f7002bfad..701b83a38 100644 --- a/moses/ChartHypothesisCollection.cpp +++ b/moses/ChartHypothesisCollection.cpp @@ -63,14 +63,14 @@ ChartHypothesisCollection::~ChartHypothesisCollection() */ bool ChartHypothesisCollection::AddHypothesis(ChartHypothesis *hypo, ChartManager &manager) { - if (hypo->GetTotalScore() == - std::numeric_limits::infinity()) { + if (hypo->GetFutureScore() == - std::numeric_limits::infinity()) { manager.GetSentenceStats().AddDiscarded(); VERBOSE(3,"discarded, -inf score" << std::endl); delete hypo; return false; } - if (hypo->GetTotalScore() < m_bestScore + m_beamWidth) { + if (hypo->GetFutureScore() < m_bestScore + m_beamWidth) { // really bad score. don't bother adding hypo into collection manager.GetSentenceStats().AddDiscarded(); VERBOSE(3,"discarded, too bad for stack" << std::endl); @@ -97,7 +97,7 @@ bool ChartHypothesisCollection::AddHypothesis(ChartHypothesis *hypo, ChartManage // found existing hypo with same target ending. // keep the best 1 - if (hypo->GetTotalScore() > hypoExisting->GetTotalScore()) { + if (hypo->GetFutureScore() > hypoExisting->GetFutureScore()) { // incoming hypo is better than the one we have VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, "); if (m_nBestIsEnabled) { @@ -138,9 +138,9 @@ pair ChartHypothesisCollectio VERBOSE(3,"added hyp to stack"); // Update best score, if this hypothesis is new best - if (hypo->GetTotalScore() > m_bestScore) { + if (hypo->GetFutureScore() > m_bestScore) { VERBOSE(3,", best on stack"); - m_bestScore = hypo->GetTotalScore(); + m_bestScore = hypo->GetFutureScore(); } // Prune only if stack is twice as big as needed (lazy pruning) @@ -189,7 +189,7 @@ void ChartHypothesisCollection::PruneToSize(ChartManager &manager) float score = 0; while (iter != m_hypos.end()) { ChartHypothesis *hypo = *iter; - score = hypo->GetTotalScore(); + score = hypo->GetFutureScore(); if (score > m_bestScore+m_beamWidth) { bestScores.push(score); } @@ -209,7 +209,7 @@ void ChartHypothesisCollection::PruneToSize(ChartManager &manager) iter = m_hypos.begin(); while (iter != m_hypos.end()) { ChartHypothesis *hypo = *iter; - float score = hypo->GetTotalScore(); + float score = hypo->GetFutureScore(); if (score < scoreThreshold) { HCType::iterator iterRemove = iter++; Remove(iterRemove); @@ -224,7 +224,7 @@ void ChartHypothesisCollection::PruneToSize(ChartManager &manager) TRACE_ERR("stack now contains: "); for(iter = m_hypos.begin(); iter != m_hypos.end(); iter++) { ChartHypothesis *hypo = *iter; - TRACE_ERR( hypo->GetId() << " (" << hypo->GetTotalScore() << ") "); + TRACE_ERR( hypo->GetId() << " (" << hypo->GetFutureScore() << ") "); } TRACE_ERR( endl); } diff --git a/moses/ChartHypothesisCollection.h b/moses/ChartHypothesisCollection.h index b0980abe3..666037f24 100644 --- a/moses/ChartHypothesisCollection.h +++ b/moses/ChartHypothesisCollection.h @@ -36,7 +36,7 @@ class ChartHypothesisScoreOrderer { public: bool operator()(const ChartHypothesis* hypoA, const ChartHypothesis* hypoB) const { - return hypoA->GetTotalScore() > hypoB->GetTotalScore(); + return hypoA->GetFutureScore() > hypoB->GetFutureScore(); } }; diff --git a/moses/ChartKBestExtractor.cpp b/moses/ChartKBestExtractor.cpp index bd5d7cbcd..43e4b7f94 100644 --- a/moses/ChartKBestExtractor.cpp +++ b/moses/ChartKBestExtractor.cpp @@ -54,7 +54,7 @@ void ChartKBestExtractor::Extract( // recombined. for (++p; p != topLevelHypos.end(); ++p) { // Check that the first item in topLevelHypos really was the best. - UTIL_THROW_IF2((*p)->GetTotalScore() > bestTopLevelHypo.GetTotalScore(), + UTIL_THROW_IF2((*p)->GetFutureScore() > bestTopLevelHypo.GetFutureScore(), "top-level hypotheses are not correctly sorted"); // Note: there's no need for a smart pointer here: supremeHypo will take // ownership of altHypo. @@ -308,7 +308,7 @@ ChartKBestExtractor::Derivation::Derivation(const UnweightedHyperarc &e) boost::shared_ptr sub(pred.kBestList[0]); subderivations.push_back(sub); } - score = edge.head->hypothesis.GetTotalScore(); + score = edge.head->hypothesis.GetFutureScore(); } // Construct a Derivation that neighbours an existing Derivation. diff --git a/moses/ChartManager.cpp b/moses/ChartManager.cpp index 767c5b44b..01eb8a98d 100644 --- a/moses/ChartManager.cpp +++ b/moses/ChartManager.cpp @@ -662,7 +662,7 @@ void ChartManager::OutputTranslationOption(std::ostream &out, WriteApplicationContext(out, applicationContext); out << ": " << hypo->GetCurrTargetPhrase().GetTargetLHS() << "->" << hypo->GetCurrTargetPhrase() - << " " << hypo->GetTotalScore() << hypo->GetScoreBreakdown(); + << " " << hypo->GetFutureScore() << hypo->GetScoreBreakdown(); } // Given a hypothesis and sentence, reconstructs the 'application context' -- @@ -837,7 +837,7 @@ void ChartManager::OutputBestHypo(OutputCollector *collector, const ChartHypothe VERBOSE(3,"0" << std::endl); if (options().output.ReportHypoScore) { - out << hypo->GetTotalScore() << " "; + out << hypo->GetFutureScore() << " "; } if (options().output.RecoverPath) { diff --git a/moses/ChartTranslationOptionList.cpp b/moses/ChartTranslationOptionList.cpp index 91a534098..a878fdafd 100644 --- a/moses/ChartTranslationOptionList.cpp +++ b/moses/ChartTranslationOptionList.cpp @@ -169,7 +169,7 @@ float ChartTranslationOptionList::GetBestScore(const ChartCellLabel *chartCell) assert(stack); assert(!stack->empty()); const ChartHypothesis &bestHypo = **(stack->begin()); - return bestHypo.GetTotalScore(); + return bestHypo.GetFutureScore(); } void ChartTranslationOptionList::EvaluateWithSourceContext(const InputType &input, const InputPath &inputPath) diff --git a/moses/Hypothesis.cpp b/moses/Hypothesis.cpp index de4f1849b..cb77a0811 100644 --- a/moses/Hypothesis.cpp +++ b/moses/Hypothesis.cpp @@ -53,7 +53,7 @@ Hypothesis(Manager& manager, InputType const& source, const TranslationOption &i m_sourceCompleted.GetFirstGapPos()>0 ? m_sourceCompleted.GetFirstGapPos()-1 : NOT_FOUND) , m_currTargetWordsRange(NOT_FOUND, NOT_FOUND) , m_wordDeleted(false) - , m_totalScore(0.0f) + , m_futureScore(0.0f) , m_estimatedScore(0.0f) , m_ffStates(StatefulFeatureFunction::GetStatefulFeatureFunctions().size()) , m_arcList(NULL) @@ -84,7 +84,7 @@ Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const prevHypo.m_currTargetWordsRange.GetEndPos() + transOpt.GetTargetPhrase().GetSize()) , m_wordDeleted(false) - , m_totalScore(0.0f) + , m_futureScore(0.0f) , m_estimatedScore(0.0f) , m_ffStates(prevHypo.m_ffStates.size()) , m_arcList(NULL) @@ -209,8 +209,8 @@ EvaluateWhenApplied(float futureScore) m_estimatedScore = futureScore; // TOTAL - m_totalScore = m_currScoreBreakdown.GetWeightedScore() + m_estimatedScore; - if (m_prevHypo) m_totalScore += m_prevHypo->GetScore(); + m_futureScore = m_currScoreBreakdown.GetWeightedScore() + m_estimatedScore; + if (m_prevHypo) m_futureScore += m_prevHypo->GetScore(); IFVERBOSE(2) { m_manager.GetSentenceStats().StopTimeEstimateScore(); @@ -247,7 +247,7 @@ PrintHypothesis() const TRACE_ERR( m_prevHypo->GetCurrTargetPhrase().GetSubString(range) << " "); } TRACE_ERR( ")"<m_totalScore - m_prevHypo->m_estimatedScore) <m_futureScore - m_prevHypo->m_estimatedScore) <GetCurrSourceWordsRange())); // << " => distortion cost "<<(m_score[ScoreType::Distortion]*weightDistortion)< b.m_totalScore; + if (m_futureScore != b.m_futureScore) + return m_futureScore > b.m_futureScore; else if (m_estimatedScore != b.m_estimatedScore) return m_estimatedScore > b.m_estimatedScore; else if (m_prevHypo) diff --git a/moses/Hypothesis.h b/moses/Hypothesis.h index 961286413..34ea0e9cf 100644 --- a/moses/Hypothesis.h +++ b/moses/Hypothesis.h @@ -71,7 +71,7 @@ protected: Range m_currSourceWordsRange; /*! source word positions of the last phrase that was used to create this hypothesis */ Range m_currTargetWordsRange; /*! target word positions of the last phrase that was used to create this hypothesis */ bool m_wordDeleted; - float m_totalScore; /*! score so far */ + float m_futureScore; /*! score so far */ float m_estimatedScore; /*! estimated future cost to translate rest of sentence */ /*! sum of scores of this hypothesis, and previous hypotheses. Lazily initialised. */ mutable boost::scoped_ptr m_scoreBreakdown; @@ -217,11 +217,11 @@ public: } return *(m_scoreBreakdown.get()); } - float GetTotalScore() const { - return m_totalScore; + float GetFutureScore() const { + return m_futureScore; } float GetScore() const { - return m_totalScore-m_estimatedScore; + return m_futureScore-m_estimatedScore; } const FFState* GetFFState(int idx) const { return m_ffStates[idx]; diff --git a/moses/HypothesisStackCubePruning.cpp b/moses/HypothesisStackCubePruning.cpp index 4c9471112..743307cc6 100644 --- a/moses/HypothesisStackCubePruning.cpp +++ b/moses/HypothesisStackCubePruning.cpp @@ -61,9 +61,9 @@ pair HypothesisStackCubePruning::Add VERBOSE(3,"added hyp to stack"); // Update best score, if this hypothesis is new best - if (hypo->GetTotalScore() > m_bestScore) { + if (hypo->GetFutureScore() > m_bestScore) { VERBOSE(3,", best on stack"); - m_bestScore = hypo->GetTotalScore(); + m_bestScore = hypo->GetFutureScore(); // this may also affect the worst score if ( m_bestScore + m_beamWidth > m_worstScore ) m_worstScore = m_bestScore + m_beamWidth; @@ -83,14 +83,14 @@ pair HypothesisStackCubePruning::Add bool HypothesisStackCubePruning::AddPrune(Hypothesis *hypo) { - if (hypo->GetTotalScore() == - std::numeric_limits::infinity()) { + if (hypo->GetFutureScore() == - std::numeric_limits::infinity()) { m_manager.GetSentenceStats().AddDiscarded(); VERBOSE(3,"discarded, constraint" << std::endl); delete hypo; return false; } - if (hypo->GetTotalScore() < m_worstScore) { + if (hypo->GetFutureScore() < m_worstScore) { // too bad for stack. don't bother adding hypo into collection m_manager.GetSentenceStats().AddDiscarded(); VERBOSE(3,"discarded, too bad for stack" << std::endl); @@ -114,7 +114,7 @@ bool HypothesisStackCubePruning::AddPrune(Hypothesis *hypo) // found existing hypo with same target ending. // keep the best 1 - if (hypo->GetTotalScore() > hypoExisting->GetTotalScore()) { + if (hypo->GetFutureScore() > hypoExisting->GetFutureScore()) { // incoming hypo is better than the one we have VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, "); if (m_nBestIsEnabled) { @@ -165,7 +165,7 @@ void HypothesisStackCubePruning::PruneToSize(size_t newSize) float score = 0; while (iter != m_hypos.end()) { Hypothesis *hypo = *iter; - score = hypo->GetTotalScore(); + score = hypo->GetFutureScore(); if (score > m_bestScore+m_beamWidth) { bestScores.push(score); } @@ -185,7 +185,7 @@ void HypothesisStackCubePruning::PruneToSize(size_t newSize) iter = m_hypos.begin(); while (iter != m_hypos.end()) { Hypothesis *hypo = *iter; - float score = hypo->GetTotalScore(); + float score = hypo->GetFutureScore(); if (score < scoreThreshold) { iterator iterRemove = iter++; Remove(iterRemove); @@ -200,7 +200,7 @@ void HypothesisStackCubePruning::PruneToSize(size_t newSize) TRACE_ERR("stack now contains: "); for(iter = m_hypos.begin(); iter != m_hypos.end(); iter++) { Hypothesis *hypo = *iter; - TRACE_ERR( hypo->GetId() << " (" << hypo->GetTotalScore() << ") "); + TRACE_ERR( hypo->GetId() << " (" << hypo->GetFutureScore() << ") "); } TRACE_ERR( endl); } @@ -217,7 +217,7 @@ const Hypothesis *HypothesisStackCubePruning::GetBestHypothesis() const Hypothesis *bestHypo = *iter; while (++iter != m_hypos.end()) { Hypothesis *hypo = *iter; - if (hypo->GetTotalScore() > bestHypo->GetTotalScore()) + if (hypo->GetFutureScore() > bestHypo->GetFutureScore()) bestHypo = hypo; } return bestHypo; diff --git a/moses/HypothesisStackNormal.cpp b/moses/HypothesisStackNormal.cpp index 77347baaf..56ca4f8a5 100644 --- a/moses/HypothesisStackNormal.cpp +++ b/moses/HypothesisStackNormal.cpp @@ -57,17 +57,17 @@ pair HypothesisStackNormal::Add(Hypothesi VERBOSE(3,"added hyp to stack"); // Update best score, if this hypothesis is new best - if (hypo->GetTotalScore() > m_bestScore) { + if (hypo->GetFutureScore() > m_bestScore) { VERBOSE(3,", best on stack"); - m_bestScore = hypo->GetTotalScore(); + m_bestScore = hypo->GetFutureScore(); // this may also affect the worst score if ( m_bestScore + m_beamWidth > m_worstScore ) m_worstScore = m_bestScore + m_beamWidth; } // update best/worst score for stack diversity 1 if ( m_minHypoStackDiversity == 1 && - hypo->GetTotalScore() > GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) { - SetWorstScoreForBitmap( hypo->GetWordsBitmap().GetID(), hypo->GetTotalScore() ); + hypo->GetFutureScore() > GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) { + SetWorstScoreForBitmap( hypo->GetWordsBitmap().GetID(), hypo->GetFutureScore() ); } VERBOSE(3,", now size " << m_hypos.size()); @@ -89,7 +89,7 @@ pair HypothesisStackNormal::Add(Hypothesi bool HypothesisStackNormal::AddPrune(Hypothesis *hypo) { - if (hypo->GetTotalScore() == - std::numeric_limits::infinity()) { + if (hypo->GetFutureScore() == - std::numeric_limits::infinity()) { m_manager.GetSentenceStats().AddDiscarded(); VERBOSE(3,"discarded, constraint" << std::endl); delete hypo; @@ -98,9 +98,9 @@ bool HypothesisStackNormal::AddPrune(Hypothesis *hypo) // too bad for stack. don't bother adding hypo into collection if (!StaticData::Instance().GetDisableDiscarding() && - hypo->GetTotalScore() < m_worstScore + hypo->GetFutureScore() < m_worstScore && ! ( m_minHypoStackDiversity > 0 - && hypo->GetTotalScore() >= GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) ) { + && hypo->GetFutureScore() >= GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) ) { m_manager.GetSentenceStats().AddDiscarded(); VERBOSE(3,"discarded, too bad for stack" << std::endl); delete hypo; @@ -123,7 +123,7 @@ bool HypothesisStackNormal::AddPrune(Hypothesis *hypo) // found existing hypo with same target ending. // keep the best 1 - if (hypo->GetTotalScore() > hypoExisting->GetTotalScore()) { + if (hypo->GetFutureScore() > hypoExisting->GetFutureScore()) { // incoming hypo is better than the one we have VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, "); if (m_nBestIsEnabled) { @@ -181,7 +181,7 @@ void HypothesisStackNormal::PruneToSize(size_t newSize) included[i] = true; diversityCount[ coverage ]++; if (diversityCount[ coverage ] == m_minHypoStackDiversity) - SetWorstScoreForBitmap( coverage, hyp->GetTotalScore()); + SetWorstScoreForBitmap( coverage, hyp->GetFutureScore()); } } } @@ -192,12 +192,12 @@ void HypothesisStackNormal::PruneToSize(size_t newSize) // add best remaining hypotheses for(size_t i=0; iGetTotalScore() > m_bestScore+m_beamWidth; i++) { + && hypos[i]->GetFutureScore() > m_bestScore+m_beamWidth; i++) { if (! included[i]) { m_hypos.insert( hypos[i] ); included[i] = true; if (size() == newSize) - m_worstScore = hypos[i]->GetTotalScore(); + m_worstScore = hypos[i]->GetFutureScore(); } } } @@ -217,7 +217,7 @@ void HypothesisStackNormal::PruneToSize(size_t newSize) TRACE_ERR("stack now contains: "); for(iterator iter = m_hypos.begin(); iter != m_hypos.end(); iter++) { Hypothesis *hypo = *iter; - TRACE_ERR( hypo->GetId() << " (" << hypo->GetTotalScore() << ") "); + TRACE_ERR( hypo->GetId() << " (" << hypo->GetFutureScore() << ") "); } TRACE_ERR( endl); } @@ -230,7 +230,7 @@ const Hypothesis *HypothesisStackNormal::GetBestHypothesis() const Hypothesis *bestHypo = *iter; while (++iter != m_hypos.end()) { Hypothesis *hypo = *iter; - if (hypo->GetTotalScore() > bestHypo->GetTotalScore()) + if (hypo->GetFutureScore() > bestHypo->GetFutureScore()) bestHypo = hypo; } return bestHypo; diff --git a/moses/LatticeMBR.cpp b/moses/LatticeMBR.cpp index 292f59a4c..77e99a722 100644 --- a/moses/LatticeMBR.cpp +++ b/moses/LatticeMBR.cpp @@ -90,7 +90,7 @@ LatticeMBRSolution::LatticeMBRSolution(const TrellisPath& path, bool isMap) : } } if (isMap) { - m_mapScore = path.GetTotalScore(); + m_mapScore = path.GetFutureScore(); } else { m_mapScore = 0; } diff --git a/moses/Manager.cpp b/moses/Manager.cpp index 35342c844..e9f8899aa 100644 --- a/moses/Manager.cpp +++ b/moses/Manager.cpp @@ -1522,7 +1522,7 @@ void Manager::OutputBest(OutputCollector *collector) const bestHypo = GetBestHypothesis(); if (bestHypo) { if (options().output.ReportHypoScore) { - out << bestHypo->GetTotalScore() << ' '; + out << bestHypo->GetFutureScore() << ' '; } if (options().output.RecoverPath) { bestHypo->OutputInput(out); @@ -1691,7 +1691,7 @@ OutputNBest(std::ostream& out, path.GetScoreBreakdown()->OutputAllFeatureScores(out, with_labels); // total - out << " ||| " << path.GetTotalScore(); + out << " ||| " << path.GetFutureScore(); //phrase-to-phrase segmentation if (includeSegmentation) { diff --git a/moses/RuleCubeItem.cpp b/moses/RuleCubeItem.cpp index 976783d65..5ca65c967 100644 --- a/moses/RuleCubeItem.cpp +++ b/moses/RuleCubeItem.cpp @@ -71,7 +71,7 @@ void RuleCubeItem::EstimateScore() std::vector::const_iterator p; for (p = m_hypothesisDimensions.begin(); p != m_hypothesisDimensions.end(); ++p) { - m_score += p->GetHypothesis()->GetTotalScore(); + m_score += p->GetHypothesis()->GetFutureScore(); } } @@ -80,7 +80,7 @@ void RuleCubeItem::CreateHypothesis(const ChartTranslationOptions &transOpt, { m_hypothesis = new ChartHypothesis(transOpt, *this, manager); m_hypothesis->EvaluateWhenApplied(); - m_score = m_hypothesis->GetTotalScore(); + m_score = m_hypothesis->GetFutureScore(); } ChartHypothesis *RuleCubeItem::ReleaseHypothesis() diff --git a/moses/SearchCubePruning.cpp b/moses/SearchCubePruning.cpp index 1d532025e..55971f96c 100644 --- a/moses/SearchCubePruning.cpp +++ b/moses/SearchCubePruning.cpp @@ -24,8 +24,8 @@ public: } // Compare the top hypothesis of each bitmap container using the TotalScore, which includes future cost - const float scoreA = A->Top()->GetHypothesis()->GetTotalScore(); - const float scoreB = B->Top()->GetHypothesis()->GetTotalScore(); + const float scoreA = A->Top()->GetHypothesis()->GetFutureScore(); + const float scoreB = B->Top()->GetHypothesis()->GetFutureScore(); if (scoreA < scoreB) { return true; diff --git a/moses/SentenceStats.h b/moses/SentenceStats.h index 998adc74f..e879fb3ba 100644 --- a/moses/SentenceStats.h +++ b/moses/SentenceStats.h @@ -143,7 +143,7 @@ public: void AddRecombination(const Hypothesis& worseHypo, const Hypothesis& betterHypo) { m_recombinationInfos.push_back(RecombinationInfo(worseHypo.GetWordsBitmap().GetNumWordsCovered(), - betterHypo.GetTotalScore(), worseHypo.GetTotalScore())); + betterHypo.GetFutureScore(), worseHypo.GetFutureScore())); } void AddCreated() { m_numHyposCreated++; diff --git a/moses/TrellisPath.cpp b/moses/TrellisPath.cpp index 7b7baa815..1ff46117a 100644 --- a/moses/TrellisPath.cpp +++ b/moses/TrellisPath.cpp @@ -31,7 +31,7 @@ namespace Moses TrellisPath::TrellisPath(const Hypothesis *hypo) : m_prevEdgeChanged(NOT_FOUND) { - m_totalScore = hypo->GetTotalScore(); + m_totalScore = hypo->GetFutureScore(); // enumerate path using prevHypo while (hypo != NULL) { @@ -42,7 +42,7 @@ TrellisPath::TrellisPath(const Hypothesis *hypo) void TrellisPath::InitTotalScore() { - m_totalScore = m_path[0]->GetWinningHypo()->GetTotalScore(); + m_totalScore = m_path[0]->GetWinningHypo()->GetFutureScore(); //calc score size_t sizePath = m_path.size(); @@ -50,7 +50,7 @@ void TrellisPath::InitTotalScore() const Hypothesis *hypo = m_path[pos]; const Hypothesis *winningHypo = hypo->GetWinningHypo(); if (hypo != winningHypo) { - m_totalScore = m_totalScore - winningHypo->GetTotalScore() + hypo->GetTotalScore(); + m_totalScore = m_totalScore - winningHypo->GetFutureScore() + hypo->GetFutureScore(); } } } @@ -167,7 +167,7 @@ void TrellisPath::CreateDeviantPaths(TrellisPathList &pathColl) const const boost::shared_ptr TrellisPath::GetScoreBreakdown() const { if (!m_scoreBreakdown) { - float totalScore = m_path[0]->GetWinningHypo()->GetTotalScore(); // calculated for sanity check only + float totalScore = m_path[0]->GetWinningHypo()->GetFutureScore(); // calculated for sanity check only m_scoreBreakdown = boost::shared_ptr(new ScoreComponentCollection()); m_scoreBreakdown->PlusEquals(ScoreComponentCollection(m_path[0]->GetWinningHypo()->GetScoreBreakdown())); @@ -178,7 +178,7 @@ const boost::shared_ptr TrellisPath::GetScoreBreakdown const Hypothesis *hypo = m_path[pos]; const Hypothesis *winningHypo = hypo->GetWinningHypo(); if (hypo != winningHypo) { - totalScore = totalScore - winningHypo->GetTotalScore() + hypo->GetTotalScore(); + totalScore = totalScore - winningHypo->GetFutureScore() + hypo->GetFutureScore(); m_scoreBreakdown->MinusEquals(winningHypo->GetScoreBreakdown()); m_scoreBreakdown->PlusEquals(hypo->GetScoreBreakdown()); } diff --git a/moses/TrellisPath.h b/moses/TrellisPath.h index 1e6914a5c..1407f1281 100644 --- a/moses/TrellisPath.h +++ b/moses/TrellisPath.h @@ -70,7 +70,7 @@ public: TrellisPath(const TrellisPath ©, size_t edgeIndex, const Hypothesis *arc); //! get score for this path throught trellis - inline float GetTotalScore() const { + inline float GetFutureScore() const { return m_totalScore; } @@ -113,7 +113,7 @@ inline std::ostream& operator<<(std::ostream& out, const TrellisPath& path) out << edge->GetId() << " " << sourceRange.GetStartPos() << "-" << sourceRange.GetEndPos() << ", "; } // scores - out << " total=" << path.GetTotalScore() + out << " total=" << path.GetFutureScore() << " " << path.GetScoreBreakdown() << std::endl; diff --git a/moses/TrellisPathCollection.h b/moses/TrellisPathCollection.h index 43532cc9a..53e923210 100644 --- a/moses/TrellisPathCollection.h +++ b/moses/TrellisPathCollection.h @@ -31,7 +31,7 @@ namespace Moses struct CompareTrellisPathCollection { bool operator()(const TrellisPath* pathA, const TrellisPath* pathB) const { - return (pathA->GetTotalScore() > pathB->GetTotalScore()); + return (pathA->GetFutureScore() > pathB->GetFutureScore()); } }; diff --git a/moses/server/TranslationRequest.cpp b/moses/server/TranslationRequest.cpp index 83463dcae..ec4d0fad0 100644 --- a/moses/server/TranslationRequest.cpp +++ b/moses/server/TranslationRequest.cpp @@ -205,7 +205,7 @@ outputNBest(const Manager& manager, map& retData) } // weighted score - nBestXmlItem["totalScore"] = xmlrpc_c::value_double(path->GetTotalScore()); + nBestXmlItem["totalScore"] = xmlrpc_c::value_double(path->GetFutureScore()); nBestXml.push_back(xmlrpc_c::value_struct(nBestXmlItem)); } retData["nbest"] = xmlrpc_c::value_array(nBestXml);