Consistent naming: total score -> m_futureScore

This commit is contained in:
Hieu Hoang 2015-11-09 12:44:39 +00:00
parent 176573c072
commit d0be56f8ab
24 changed files with 83 additions and 83 deletions

View File

@ -487,7 +487,7 @@ public:
} }
// weighted score // 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)); nBestXml.push_back(xmlrpc_c::value_struct(nBestXMLItem));
} }
retData.insert(pair<string, xmlrpc_c::value>("nbest", xmlrpc_c::value_array(nBestXml))); retData.insert(pair<string, xmlrpc_c::value>("nbest", xmlrpc_c::value_array(nBestXml)));

View File

@ -180,10 +180,10 @@ BackwardsEdge::BackwardsEdge(const BitmapContainer &prevBitmapContainer
} }
if (m_hypotheses.size() > 1) { 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" "Non-monotonic total score"
<< m_hypotheses[0]->GetTotalScore() << " vs. " << m_hypotheses[0]->GetFutureScore() << " vs. "
<< m_hypotheses[1]->GetTotalScore()); << m_hypotheses[1]->GetFutureScore());
} }
HypothesisScoreOrdererWithDistortion orderer (&transOptRange, m_deterministic); HypothesisScoreOrdererWithDistortion orderer (&transOptRange, m_deterministic);
@ -460,10 +460,10 @@ BitmapContainer::ProcessBestHypothesis()
// check we are pulling things off of priority queue in right order // check we are pulling things off of priority queue in right order
if (!Empty()) { if (!Empty()) {
HypothesisQueueItem *check = Dequeue(true); 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: " "Non-monotonic total score: "
<< item->GetHypothesis()->GetTotalScore() << " vs. " << item->GetHypothesis()->GetFutureScore() << " vs. "
<< check->GetHypothesis()->GetTotalScore()); << check->GetHypothesis()->GetFutureScore());
} }
// Logging for the criminally insane // Logging for the criminally insane

View File

@ -109,8 +109,8 @@ class QueueItemOrderer
{ {
public: public:
bool operator()(HypothesisQueueItem* itemA, HypothesisQueueItem* itemB) const { bool operator()(HypothesisQueueItem* itemA, HypothesisQueueItem* itemB) const {
float scoreA = itemA->GetHypothesis()->GetTotalScore(); float scoreA = itemA->GetHypothesis()->GetFutureScore();
float scoreB = itemB->GetHypothesis()->GetTotalScore(); float scoreB = itemB->GetHypothesis()->GetFutureScore();
if (scoreA < scoreB) { if (scoreA < scoreB) {
return true; return true;
@ -151,8 +151,8 @@ public:
bool operator()(const Hypothesis* hypoA, const Hypothesis* hypoB) const { bool operator()(const Hypothesis* hypoA, const Hypothesis* hypoB) const {
float scoreA = hypoA->GetTotalScore(); float scoreA = hypoA->GetFutureScore();
float scoreB = hypoB->GetTotalScore(); float scoreB = hypoB->GetFutureScore();
if (scoreA > scoreB) { if (scoreA > scoreB) {
return true; return true;

View File

@ -136,8 +136,8 @@ const ChartHypothesis *ChartCell::GetBestHypothesis() const
const HypoList &sortedList = iter->second.GetSortedHypotheses(); const HypoList &sortedList = iter->second.GetSortedHypotheses();
if (sortedList.size() > 0) { if (sortedList.size() > 0) {
const ChartHypothesis *hypo = sortedList[0]; const ChartHypothesis *hypo = sortedList[0];
if (hypo->GetTotalScore() > bestScore) { if (hypo->GetFutureScore() > bestScore) {
bestScore = hypo->GetTotalScore(); bestScore = hypo->GetFutureScore();
ret = hypo; ret = hypo;
} }
} }

View File

@ -207,7 +207,7 @@ void ChartHypothesis::EvaluateWhenApplied()
// total scores from prev hypos // total scores from prev hypos
for (std::vector<const ChartHypothesis*>::const_iterator iter = m_prevHypos.begin(); iter != m_prevHypos.end(); ++iter) { for (std::vector<const ChartHypothesis*>::const_iterator iter = m_prevHypos.begin(); iter != m_prevHypos.end(); ++iter) {
const ChartHypothesis &prevHypo = **iter; const ChartHypothesis &prevHypo = **iter;
m_totalScore += prevHypo.GetTotalScore(); m_totalScore += prevHypo.GetFutureScore();
} }
} }
@ -241,7 +241,7 @@ void ChartHypothesis::AddArc(ChartHypothesis *loserHypo)
// sorting helper // sorting helper
struct CompareChartHypothesisTotalScore { struct CompareChartHypothesisTotalScore {
bool operator()(const ChartHypothesis* hypo1, const ChartHypothesis* hypo2) const { 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 << " " << prevHypo.GetId();
} }
out << " [total=" << hypo.GetTotalScore() << "]"; out << " [total=" << hypo.GetFutureScore() << "]";
out << " " << hypo.GetScoreBreakdown(); out << " " << hypo.GetScoreBreakdown();
//out << endl; //out << endl;

View File

@ -167,7 +167,7 @@ public:
} }
//! Get the weighted total score //! Get the weighted total score
float GetTotalScore() const { float GetFutureScore() const {
// scores from current translation rule. eg. translation models & word penalty // scores from current translation rule. eg. translation models & word penalty
return m_totalScore; return m_totalScore;
} }

View File

@ -63,14 +63,14 @@ ChartHypothesisCollection::~ChartHypothesisCollection()
*/ */
bool ChartHypothesisCollection::AddHypothesis(ChartHypothesis *hypo, ChartManager &manager) bool ChartHypothesisCollection::AddHypothesis(ChartHypothesis *hypo, ChartManager &manager)
{ {
if (hypo->GetTotalScore() == - std::numeric_limits<float>::infinity()) { if (hypo->GetFutureScore() == - std::numeric_limits<float>::infinity()) {
manager.GetSentenceStats().AddDiscarded(); manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, -inf score" << std::endl); VERBOSE(3,"discarded, -inf score" << std::endl);
delete hypo; delete hypo;
return false; 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 // really bad score. don't bother adding hypo into collection
manager.GetSentenceStats().AddDiscarded(); manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, too bad for stack" << std::endl); 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. // found existing hypo with same target ending.
// keep the best 1 // keep the best 1
if (hypo->GetTotalScore() > hypoExisting->GetTotalScore()) { if (hypo->GetFutureScore() > hypoExisting->GetFutureScore()) {
// incoming hypo is better than the one we have // incoming hypo is better than the one we have
VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, "); VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, ");
if (m_nBestIsEnabled) { if (m_nBestIsEnabled) {
@ -138,9 +138,9 @@ pair<ChartHypothesisCollection::HCType::iterator, bool> ChartHypothesisCollectio
VERBOSE(3,"added hyp to stack"); VERBOSE(3,"added hyp to stack");
// Update best score, if this hypothesis is new best // Update best score, if this hypothesis is new best
if (hypo->GetTotalScore() > m_bestScore) { if (hypo->GetFutureScore() > m_bestScore) {
VERBOSE(3,", best on stack"); 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) // Prune only if stack is twice as big as needed (lazy pruning)
@ -189,7 +189,7 @@ void ChartHypothesisCollection::PruneToSize(ChartManager &manager)
float score = 0; float score = 0;
while (iter != m_hypos.end()) { while (iter != m_hypos.end()) {
ChartHypothesis *hypo = *iter; ChartHypothesis *hypo = *iter;
score = hypo->GetTotalScore(); score = hypo->GetFutureScore();
if (score > m_bestScore+m_beamWidth) { if (score > m_bestScore+m_beamWidth) {
bestScores.push(score); bestScores.push(score);
} }
@ -209,7 +209,7 @@ void ChartHypothesisCollection::PruneToSize(ChartManager &manager)
iter = m_hypos.begin(); iter = m_hypos.begin();
while (iter != m_hypos.end()) { while (iter != m_hypos.end()) {
ChartHypothesis *hypo = *iter; ChartHypothesis *hypo = *iter;
float score = hypo->GetTotalScore(); float score = hypo->GetFutureScore();
if (score < scoreThreshold) { if (score < scoreThreshold) {
HCType::iterator iterRemove = iter++; HCType::iterator iterRemove = iter++;
Remove(iterRemove); Remove(iterRemove);
@ -224,7 +224,7 @@ void ChartHypothesisCollection::PruneToSize(ChartManager &manager)
TRACE_ERR("stack now contains: "); TRACE_ERR("stack now contains: ");
for(iter = m_hypos.begin(); iter != m_hypos.end(); iter++) { for(iter = m_hypos.begin(); iter != m_hypos.end(); iter++) {
ChartHypothesis *hypo = *iter; ChartHypothesis *hypo = *iter;
TRACE_ERR( hypo->GetId() << " (" << hypo->GetTotalScore() << ") "); TRACE_ERR( hypo->GetId() << " (" << hypo->GetFutureScore() << ") ");
} }
TRACE_ERR( endl); TRACE_ERR( endl);
} }

View File

@ -36,7 +36,7 @@ class ChartHypothesisScoreOrderer
{ {
public: public:
bool operator()(const ChartHypothesis* hypoA, const ChartHypothesis* hypoB) const { bool operator()(const ChartHypothesis* hypoA, const ChartHypothesis* hypoB) const {
return hypoA->GetTotalScore() > hypoB->GetTotalScore(); return hypoA->GetFutureScore() > hypoB->GetFutureScore();
} }
}; };

View File

@ -54,7 +54,7 @@ void ChartKBestExtractor::Extract(
// recombined. // recombined.
for (++p; p != topLevelHypos.end(); ++p) { for (++p; p != topLevelHypos.end(); ++p) {
// Check that the first item in topLevelHypos really was the best. // 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"); "top-level hypotheses are not correctly sorted");
// Note: there's no need for a smart pointer here: supremeHypo will take // Note: there's no need for a smart pointer here: supremeHypo will take
// ownership of altHypo. // ownership of altHypo.
@ -308,7 +308,7 @@ ChartKBestExtractor::Derivation::Derivation(const UnweightedHyperarc &e)
boost::shared_ptr<Derivation> sub(pred.kBestList[0]); boost::shared_ptr<Derivation> sub(pred.kBestList[0]);
subderivations.push_back(sub); subderivations.push_back(sub);
} }
score = edge.head->hypothesis.GetTotalScore(); score = edge.head->hypothesis.GetFutureScore();
} }
// Construct a Derivation that neighbours an existing Derivation. // Construct a Derivation that neighbours an existing Derivation.

View File

@ -662,7 +662,7 @@ void ChartManager::OutputTranslationOption(std::ostream &out,
WriteApplicationContext(out, applicationContext); WriteApplicationContext(out, applicationContext);
out << ": " << hypo->GetCurrTargetPhrase().GetTargetLHS() out << ": " << hypo->GetCurrTargetPhrase().GetTargetLHS()
<< "->" << hypo->GetCurrTargetPhrase() << "->" << hypo->GetCurrTargetPhrase()
<< " " << hypo->GetTotalScore() << hypo->GetScoreBreakdown(); << " " << hypo->GetFutureScore() << hypo->GetScoreBreakdown();
} }
// Given a hypothesis and sentence, reconstructs the 'application context' -- // 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); VERBOSE(3,"0" << std::endl);
if (options().output.ReportHypoScore) { if (options().output.ReportHypoScore) {
out << hypo->GetTotalScore() << " "; out << hypo->GetFutureScore() << " ";
} }
if (options().output.RecoverPath) { if (options().output.RecoverPath) {

View File

@ -169,7 +169,7 @@ float ChartTranslationOptionList::GetBestScore(const ChartCellLabel *chartCell)
assert(stack); assert(stack);
assert(!stack->empty()); assert(!stack->empty());
const ChartHypothesis &bestHypo = **(stack->begin()); const ChartHypothesis &bestHypo = **(stack->begin());
return bestHypo.GetTotalScore(); return bestHypo.GetFutureScore();
} }
void ChartTranslationOptionList::EvaluateWithSourceContext(const InputType &input, const InputPath &inputPath) void ChartTranslationOptionList::EvaluateWithSourceContext(const InputType &input, const InputPath &inputPath)

View File

@ -53,7 +53,7 @@ Hypothesis(Manager& manager, InputType const& source, const TranslationOption &i
m_sourceCompleted.GetFirstGapPos()>0 ? m_sourceCompleted.GetFirstGapPos()-1 : NOT_FOUND) m_sourceCompleted.GetFirstGapPos()>0 ? m_sourceCompleted.GetFirstGapPos()-1 : NOT_FOUND)
, m_currTargetWordsRange(NOT_FOUND, NOT_FOUND) , m_currTargetWordsRange(NOT_FOUND, NOT_FOUND)
, m_wordDeleted(false) , m_wordDeleted(false)
, m_totalScore(0.0f) , m_futureScore(0.0f)
, m_estimatedScore(0.0f) , m_estimatedScore(0.0f)
, m_ffStates(StatefulFeatureFunction::GetStatefulFeatureFunctions().size()) , m_ffStates(StatefulFeatureFunction::GetStatefulFeatureFunctions().size())
, m_arcList(NULL) , m_arcList(NULL)
@ -84,7 +84,7 @@ Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const
prevHypo.m_currTargetWordsRange.GetEndPos() prevHypo.m_currTargetWordsRange.GetEndPos()
+ transOpt.GetTargetPhrase().GetSize()) + transOpt.GetTargetPhrase().GetSize())
, m_wordDeleted(false) , m_wordDeleted(false)
, m_totalScore(0.0f) , m_futureScore(0.0f)
, m_estimatedScore(0.0f) , m_estimatedScore(0.0f)
, m_ffStates(prevHypo.m_ffStates.size()) , m_ffStates(prevHypo.m_ffStates.size())
, m_arcList(NULL) , m_arcList(NULL)
@ -209,8 +209,8 @@ EvaluateWhenApplied(float futureScore)
m_estimatedScore = futureScore; m_estimatedScore = futureScore;
// TOTAL // TOTAL
m_totalScore = m_currScoreBreakdown.GetWeightedScore() + m_estimatedScore; m_futureScore = m_currScoreBreakdown.GetWeightedScore() + m_estimatedScore;
if (m_prevHypo) m_totalScore += m_prevHypo->GetScore(); if (m_prevHypo) m_futureScore += m_prevHypo->GetScore();
IFVERBOSE(2) { IFVERBOSE(2) {
m_manager.GetSentenceStats().StopTimeEstimateScore(); m_manager.GetSentenceStats().StopTimeEstimateScore();
@ -247,7 +247,7 @@ PrintHypothesis() const
TRACE_ERR( m_prevHypo->GetCurrTargetPhrase().GetSubString(range) << " "); TRACE_ERR( m_prevHypo->GetCurrTargetPhrase().GetSubString(range) << " ");
} }
TRACE_ERR( ")"<<endl); TRACE_ERR( ")"<<endl);
TRACE_ERR( "\tbase score "<< (m_prevHypo->m_totalScore - m_prevHypo->m_estimatedScore) <<endl); TRACE_ERR( "\tbase score "<< (m_prevHypo->m_futureScore - m_prevHypo->m_estimatedScore) <<endl);
TRACE_ERR( "\tcovering "<<m_currSourceWordsRange.GetStartPos()<<"-"<<m_currSourceWordsRange.GetEndPos() TRACE_ERR( "\tcovering "<<m_currSourceWordsRange.GetStartPos()<<"-"<<m_currSourceWordsRange.GetEndPos()
<<": " << m_transOpt.GetInputPath().GetPhrase() << endl); <<": " << m_transOpt.GetInputPath().GetPhrase() << endl);
@ -257,7 +257,7 @@ PrintHypothesis() const
// TRACE_ERR( "\tdistance: "<<GetCurrSourceWordsRange().CalcDistortion(m_prevHypo->GetCurrSourceWordsRange())); // << " => distortion cost "<<(m_score[ScoreType::Distortion]*weightDistortion)<<endl; // TRACE_ERR( "\tdistance: "<<GetCurrSourceWordsRange().CalcDistortion(m_prevHypo->GetCurrSourceWordsRange())); // << " => distortion cost "<<(m_score[ScoreType::Distortion]*weightDistortion)<<endl;
// TRACE_ERR( "\tlanguage model cost "); // <<m_score[ScoreType::LanguageModelScore]<<endl; // TRACE_ERR( "\tlanguage model cost "); // <<m_score[ScoreType::LanguageModelScore]<<endl;
// TRACE_ERR( "\tword penalty "); // <<(m_score[ScoreType::WordPenalty]*weightWordPenalty)<<endl; // TRACE_ERR( "\tword penalty "); // <<(m_score[ScoreType::WordPenalty]*weightWordPenalty)<<endl;
TRACE_ERR( "\tscore "<<m_totalScore - m_estimatedScore<<" + future cost "<<m_estimatedScore<<" = "<<m_totalScore<<endl); TRACE_ERR( "\tscore "<<m_futureScore - m_estimatedScore<<" + future cost "<<m_estimatedScore<<" = "<<m_futureScore<<endl);
TRACE_ERR( "\tunweighted feature scores: " << m_currScoreBreakdown << endl); TRACE_ERR( "\tunweighted feature scores: " << m_currScoreBreakdown << endl);
//PrintLMScores(); //PrintLMScores();
} }
@ -326,7 +326,7 @@ ostream& operator<<(ostream& out, const Hypothesis& hypo)
out << "[" << hypo.m_sourceCompleted << "] "; out << "[" << hypo.m_sourceCompleted << "] ";
// scores // scores
out << " [total=" << hypo.GetTotalScore() << "]"; out << " [total=" << hypo.GetFutureScore() << "]";
out << " " << hypo.GetScoreBreakdown(); out << " " << hypo.GetScoreBreakdown();
// alignment // alignment
@ -607,8 +607,8 @@ bool
Hypothesis:: Hypothesis::
beats(Hypothesis const& b) const beats(Hypothesis const& b) const
{ {
if (m_totalScore != b.m_totalScore) if (m_futureScore != b.m_futureScore)
return m_totalScore > b.m_totalScore; return m_futureScore > b.m_futureScore;
else if (m_estimatedScore != b.m_estimatedScore) else if (m_estimatedScore != b.m_estimatedScore)
return m_estimatedScore > b.m_estimatedScore; return m_estimatedScore > b.m_estimatedScore;
else if (m_prevHypo) else if (m_prevHypo)

View File

@ -71,7 +71,7 @@ protected:
Range m_currSourceWordsRange; /*! source word positions of the last phrase that was used to create this hypothesis */ 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 */ Range m_currTargetWordsRange; /*! target word positions of the last phrase that was used to create this hypothesis */
bool m_wordDeleted; 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 */ float m_estimatedScore; /*! estimated future cost to translate rest of sentence */
/*! sum of scores of this hypothesis, and previous hypotheses. Lazily initialised. */ /*! sum of scores of this hypothesis, and previous hypotheses. Lazily initialised. */
mutable boost::scoped_ptr<ScoreComponentCollection> m_scoreBreakdown; mutable boost::scoped_ptr<ScoreComponentCollection> m_scoreBreakdown;
@ -217,11 +217,11 @@ public:
} }
return *(m_scoreBreakdown.get()); return *(m_scoreBreakdown.get());
} }
float GetTotalScore() const { float GetFutureScore() const {
return m_totalScore; return m_futureScore;
} }
float GetScore() const { float GetScore() const {
return m_totalScore-m_estimatedScore; return m_futureScore-m_estimatedScore;
} }
const FFState* GetFFState(int idx) const { const FFState* GetFFState(int idx) const {
return m_ffStates[idx]; return m_ffStates[idx];

View File

@ -61,9 +61,9 @@ pair<HypothesisStackCubePruning::iterator, bool> HypothesisStackCubePruning::Add
VERBOSE(3,"added hyp to stack"); VERBOSE(3,"added hyp to stack");
// Update best score, if this hypothesis is new best // Update best score, if this hypothesis is new best
if (hypo->GetTotalScore() > m_bestScore) { if (hypo->GetFutureScore() > m_bestScore) {
VERBOSE(3,", best on stack"); VERBOSE(3,", best on stack");
m_bestScore = hypo->GetTotalScore(); m_bestScore = hypo->GetFutureScore();
// this may also affect the worst score // this may also affect the worst score
if ( m_bestScore + m_beamWidth > m_worstScore ) if ( m_bestScore + m_beamWidth > m_worstScore )
m_worstScore = m_bestScore + m_beamWidth; m_worstScore = m_bestScore + m_beamWidth;
@ -83,14 +83,14 @@ pair<HypothesisStackCubePruning::iterator, bool> HypothesisStackCubePruning::Add
bool HypothesisStackCubePruning::AddPrune(Hypothesis *hypo) bool HypothesisStackCubePruning::AddPrune(Hypothesis *hypo)
{ {
if (hypo->GetTotalScore() == - std::numeric_limits<float>::infinity()) { if (hypo->GetFutureScore() == - std::numeric_limits<float>::infinity()) {
m_manager.GetSentenceStats().AddDiscarded(); m_manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, constraint" << std::endl); VERBOSE(3,"discarded, constraint" << std::endl);
delete hypo; delete hypo;
return false; return false;
} }
if (hypo->GetTotalScore() < m_worstScore) { if (hypo->GetFutureScore() < m_worstScore) {
// too bad for stack. don't bother adding hypo into collection // too bad for stack. don't bother adding hypo into collection
m_manager.GetSentenceStats().AddDiscarded(); m_manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, too bad for stack" << std::endl); 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. // found existing hypo with same target ending.
// keep the best 1 // keep the best 1
if (hypo->GetTotalScore() > hypoExisting->GetTotalScore()) { if (hypo->GetFutureScore() > hypoExisting->GetFutureScore()) {
// incoming hypo is better than the one we have // incoming hypo is better than the one we have
VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, "); VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, ");
if (m_nBestIsEnabled) { if (m_nBestIsEnabled) {
@ -165,7 +165,7 @@ void HypothesisStackCubePruning::PruneToSize(size_t newSize)
float score = 0; float score = 0;
while (iter != m_hypos.end()) { while (iter != m_hypos.end()) {
Hypothesis *hypo = *iter; Hypothesis *hypo = *iter;
score = hypo->GetTotalScore(); score = hypo->GetFutureScore();
if (score > m_bestScore+m_beamWidth) { if (score > m_bestScore+m_beamWidth) {
bestScores.push(score); bestScores.push(score);
} }
@ -185,7 +185,7 @@ void HypothesisStackCubePruning::PruneToSize(size_t newSize)
iter = m_hypos.begin(); iter = m_hypos.begin();
while (iter != m_hypos.end()) { while (iter != m_hypos.end()) {
Hypothesis *hypo = *iter; Hypothesis *hypo = *iter;
float score = hypo->GetTotalScore(); float score = hypo->GetFutureScore();
if (score < scoreThreshold) { if (score < scoreThreshold) {
iterator iterRemove = iter++; iterator iterRemove = iter++;
Remove(iterRemove); Remove(iterRemove);
@ -200,7 +200,7 @@ void HypothesisStackCubePruning::PruneToSize(size_t newSize)
TRACE_ERR("stack now contains: "); TRACE_ERR("stack now contains: ");
for(iter = m_hypos.begin(); iter != m_hypos.end(); iter++) { for(iter = m_hypos.begin(); iter != m_hypos.end(); iter++) {
Hypothesis *hypo = *iter; Hypothesis *hypo = *iter;
TRACE_ERR( hypo->GetId() << " (" << hypo->GetTotalScore() << ") "); TRACE_ERR( hypo->GetId() << " (" << hypo->GetFutureScore() << ") ");
} }
TRACE_ERR( endl); TRACE_ERR( endl);
} }
@ -217,7 +217,7 @@ const Hypothesis *HypothesisStackCubePruning::GetBestHypothesis() const
Hypothesis *bestHypo = *iter; Hypothesis *bestHypo = *iter;
while (++iter != m_hypos.end()) { while (++iter != m_hypos.end()) {
Hypothesis *hypo = *iter; Hypothesis *hypo = *iter;
if (hypo->GetTotalScore() > bestHypo->GetTotalScore()) if (hypo->GetFutureScore() > bestHypo->GetFutureScore())
bestHypo = hypo; bestHypo = hypo;
} }
return bestHypo; return bestHypo;

View File

@ -57,17 +57,17 @@ pair<HypothesisStackNormal::iterator, bool> HypothesisStackNormal::Add(Hypothesi
VERBOSE(3,"added hyp to stack"); VERBOSE(3,"added hyp to stack");
// Update best score, if this hypothesis is new best // Update best score, if this hypothesis is new best
if (hypo->GetTotalScore() > m_bestScore) { if (hypo->GetFutureScore() > m_bestScore) {
VERBOSE(3,", best on stack"); VERBOSE(3,", best on stack");
m_bestScore = hypo->GetTotalScore(); m_bestScore = hypo->GetFutureScore();
// this may also affect the worst score // this may also affect the worst score
if ( m_bestScore + m_beamWidth > m_worstScore ) if ( m_bestScore + m_beamWidth > m_worstScore )
m_worstScore = m_bestScore + m_beamWidth; m_worstScore = m_bestScore + m_beamWidth;
} }
// update best/worst score for stack diversity 1 // update best/worst score for stack diversity 1
if ( m_minHypoStackDiversity == 1 && if ( m_minHypoStackDiversity == 1 &&
hypo->GetTotalScore() > GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) { hypo->GetFutureScore() > GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) {
SetWorstScoreForBitmap( hypo->GetWordsBitmap().GetID(), hypo->GetTotalScore() ); SetWorstScoreForBitmap( hypo->GetWordsBitmap().GetID(), hypo->GetFutureScore() );
} }
VERBOSE(3,", now size " << m_hypos.size()); VERBOSE(3,", now size " << m_hypos.size());
@ -89,7 +89,7 @@ pair<HypothesisStackNormal::iterator, bool> HypothesisStackNormal::Add(Hypothesi
bool HypothesisStackNormal::AddPrune(Hypothesis *hypo) bool HypothesisStackNormal::AddPrune(Hypothesis *hypo)
{ {
if (hypo->GetTotalScore() == - std::numeric_limits<float>::infinity()) { if (hypo->GetFutureScore() == - std::numeric_limits<float>::infinity()) {
m_manager.GetSentenceStats().AddDiscarded(); m_manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, constraint" << std::endl); VERBOSE(3,"discarded, constraint" << std::endl);
delete hypo; delete hypo;
@ -98,9 +98,9 @@ bool HypothesisStackNormal::AddPrune(Hypothesis *hypo)
// too bad for stack. don't bother adding hypo into collection // too bad for stack. don't bother adding hypo into collection
if (!StaticData::Instance().GetDisableDiscarding() && if (!StaticData::Instance().GetDisableDiscarding() &&
hypo->GetTotalScore() < m_worstScore hypo->GetFutureScore() < m_worstScore
&& ! ( m_minHypoStackDiversity > 0 && ! ( m_minHypoStackDiversity > 0
&& hypo->GetTotalScore() >= GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) ) { && hypo->GetFutureScore() >= GetWorstScoreForBitmap( hypo->GetWordsBitmap() ) ) ) {
m_manager.GetSentenceStats().AddDiscarded(); m_manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, too bad for stack" << std::endl); VERBOSE(3,"discarded, too bad for stack" << std::endl);
delete hypo; delete hypo;
@ -123,7 +123,7 @@ bool HypothesisStackNormal::AddPrune(Hypothesis *hypo)
// found existing hypo with same target ending. // found existing hypo with same target ending.
// keep the best 1 // keep the best 1
if (hypo->GetTotalScore() > hypoExisting->GetTotalScore()) { if (hypo->GetFutureScore() > hypoExisting->GetFutureScore()) {
// incoming hypo is better than the one we have // incoming hypo is better than the one we have
VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, "); VERBOSE(3,"better than matching hyp " << hypoExisting->GetId() << ", recombining, ");
if (m_nBestIsEnabled) { if (m_nBestIsEnabled) {
@ -181,7 +181,7 @@ void HypothesisStackNormal::PruneToSize(size_t newSize)
included[i] = true; included[i] = true;
diversityCount[ coverage ]++; diversityCount[ coverage ]++;
if (diversityCount[ coverage ] == m_minHypoStackDiversity) 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 // add best remaining hypotheses
for(size_t i=0; i<hypos.size() for(size_t i=0; i<hypos.size()
&& size() < newSize && size() < newSize
&& hypos[i]->GetTotalScore() > m_bestScore+m_beamWidth; i++) { && hypos[i]->GetFutureScore() > m_bestScore+m_beamWidth; i++) {
if (! included[i]) { if (! included[i]) {
m_hypos.insert( hypos[i] ); m_hypos.insert( hypos[i] );
included[i] = true; included[i] = true;
if (size() == newSize) 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: "); TRACE_ERR("stack now contains: ");
for(iterator iter = m_hypos.begin(); iter != m_hypos.end(); iter++) { for(iterator iter = m_hypos.begin(); iter != m_hypos.end(); iter++) {
Hypothesis *hypo = *iter; Hypothesis *hypo = *iter;
TRACE_ERR( hypo->GetId() << " (" << hypo->GetTotalScore() << ") "); TRACE_ERR( hypo->GetId() << " (" << hypo->GetFutureScore() << ") ");
} }
TRACE_ERR( endl); TRACE_ERR( endl);
} }
@ -230,7 +230,7 @@ const Hypothesis *HypothesisStackNormal::GetBestHypothesis() const
Hypothesis *bestHypo = *iter; Hypothesis *bestHypo = *iter;
while (++iter != m_hypos.end()) { while (++iter != m_hypos.end()) {
Hypothesis *hypo = *iter; Hypothesis *hypo = *iter;
if (hypo->GetTotalScore() > bestHypo->GetTotalScore()) if (hypo->GetFutureScore() > bestHypo->GetFutureScore())
bestHypo = hypo; bestHypo = hypo;
} }
return bestHypo; return bestHypo;

View File

@ -90,7 +90,7 @@ LatticeMBRSolution::LatticeMBRSolution(const TrellisPath& path, bool isMap) :
} }
} }
if (isMap) { if (isMap) {
m_mapScore = path.GetTotalScore(); m_mapScore = path.GetFutureScore();
} else { } else {
m_mapScore = 0; m_mapScore = 0;
} }

View File

@ -1522,7 +1522,7 @@ void Manager::OutputBest(OutputCollector *collector) const
bestHypo = GetBestHypothesis(); bestHypo = GetBestHypothesis();
if (bestHypo) { if (bestHypo) {
if (options().output.ReportHypoScore) { if (options().output.ReportHypoScore) {
out << bestHypo->GetTotalScore() << ' '; out << bestHypo->GetFutureScore() << ' ';
} }
if (options().output.RecoverPath) { if (options().output.RecoverPath) {
bestHypo->OutputInput(out); bestHypo->OutputInput(out);
@ -1691,7 +1691,7 @@ OutputNBest(std::ostream& out,
path.GetScoreBreakdown()->OutputAllFeatureScores(out, with_labels); path.GetScoreBreakdown()->OutputAllFeatureScores(out, with_labels);
// total // total
out << " ||| " << path.GetTotalScore(); out << " ||| " << path.GetFutureScore();
//phrase-to-phrase segmentation //phrase-to-phrase segmentation
if (includeSegmentation) { if (includeSegmentation) {

View File

@ -71,7 +71,7 @@ void RuleCubeItem::EstimateScore()
std::vector<HypothesisDimension>::const_iterator p; std::vector<HypothesisDimension>::const_iterator p;
for (p = m_hypothesisDimensions.begin(); for (p = m_hypothesisDimensions.begin();
p != m_hypothesisDimensions.end(); ++p) { 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 = new ChartHypothesis(transOpt, *this, manager);
m_hypothesis->EvaluateWhenApplied(); m_hypothesis->EvaluateWhenApplied();
m_score = m_hypothesis->GetTotalScore(); m_score = m_hypothesis->GetFutureScore();
} }
ChartHypothesis *RuleCubeItem::ReleaseHypothesis() ChartHypothesis *RuleCubeItem::ReleaseHypothesis()

View File

@ -24,8 +24,8 @@ public:
} }
// Compare the top hypothesis of each bitmap container using the TotalScore, which includes future cost // Compare the top hypothesis of each bitmap container using the TotalScore, which includes future cost
const float scoreA = A->Top()->GetHypothesis()->GetTotalScore(); const float scoreA = A->Top()->GetHypothesis()->GetFutureScore();
const float scoreB = B->Top()->GetHypothesis()->GetTotalScore(); const float scoreB = B->Top()->GetHypothesis()->GetFutureScore();
if (scoreA < scoreB) { if (scoreA < scoreB) {
return true; return true;

View File

@ -143,7 +143,7 @@ public:
void AddRecombination(const Hypothesis& worseHypo, const Hypothesis& betterHypo) { void AddRecombination(const Hypothesis& worseHypo, const Hypothesis& betterHypo) {
m_recombinationInfos.push_back(RecombinationInfo(worseHypo.GetWordsBitmap().GetNumWordsCovered(), m_recombinationInfos.push_back(RecombinationInfo(worseHypo.GetWordsBitmap().GetNumWordsCovered(),
betterHypo.GetTotalScore(), worseHypo.GetTotalScore())); betterHypo.GetFutureScore(), worseHypo.GetFutureScore()));
} }
void AddCreated() { void AddCreated() {
m_numHyposCreated++; m_numHyposCreated++;

View File

@ -31,7 +31,7 @@ namespace Moses
TrellisPath::TrellisPath(const Hypothesis *hypo) TrellisPath::TrellisPath(const Hypothesis *hypo)
: m_prevEdgeChanged(NOT_FOUND) : m_prevEdgeChanged(NOT_FOUND)
{ {
m_totalScore = hypo->GetTotalScore(); m_totalScore = hypo->GetFutureScore();
// enumerate path using prevHypo // enumerate path using prevHypo
while (hypo != NULL) { while (hypo != NULL) {
@ -42,7 +42,7 @@ TrellisPath::TrellisPath(const Hypothesis *hypo)
void TrellisPath::InitTotalScore() void TrellisPath::InitTotalScore()
{ {
m_totalScore = m_path[0]->GetWinningHypo()->GetTotalScore(); m_totalScore = m_path[0]->GetWinningHypo()->GetFutureScore();
//calc score //calc score
size_t sizePath = m_path.size(); size_t sizePath = m_path.size();
@ -50,7 +50,7 @@ void TrellisPath::InitTotalScore()
const Hypothesis *hypo = m_path[pos]; const Hypothesis *hypo = m_path[pos];
const Hypothesis *winningHypo = hypo->GetWinningHypo(); const Hypothesis *winningHypo = hypo->GetWinningHypo();
if (hypo != winningHypo) { 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<ScoreComponentCollection> TrellisPath::GetScoreBreakdown() const const boost::shared_ptr<ScoreComponentCollection> TrellisPath::GetScoreBreakdown() const
{ {
if (!m_scoreBreakdown) { 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<ScoreComponentCollection>(new ScoreComponentCollection()); m_scoreBreakdown = boost::shared_ptr<ScoreComponentCollection>(new ScoreComponentCollection());
m_scoreBreakdown->PlusEquals(ScoreComponentCollection(m_path[0]->GetWinningHypo()->GetScoreBreakdown())); m_scoreBreakdown->PlusEquals(ScoreComponentCollection(m_path[0]->GetWinningHypo()->GetScoreBreakdown()));
@ -178,7 +178,7 @@ const boost::shared_ptr<ScoreComponentCollection> TrellisPath::GetScoreBreakdown
const Hypothesis *hypo = m_path[pos]; const Hypothesis *hypo = m_path[pos];
const Hypothesis *winningHypo = hypo->GetWinningHypo(); const Hypothesis *winningHypo = hypo->GetWinningHypo();
if (hypo != winningHypo) { if (hypo != winningHypo) {
totalScore = totalScore - winningHypo->GetTotalScore() + hypo->GetTotalScore(); totalScore = totalScore - winningHypo->GetFutureScore() + hypo->GetFutureScore();
m_scoreBreakdown->MinusEquals(winningHypo->GetScoreBreakdown()); m_scoreBreakdown->MinusEquals(winningHypo->GetScoreBreakdown());
m_scoreBreakdown->PlusEquals(hypo->GetScoreBreakdown()); m_scoreBreakdown->PlusEquals(hypo->GetScoreBreakdown());
} }

View File

@ -70,7 +70,7 @@ public:
TrellisPath(const TrellisPath &copy, size_t edgeIndex, const Hypothesis *arc); TrellisPath(const TrellisPath &copy, size_t edgeIndex, const Hypothesis *arc);
//! get score for this path throught trellis //! get score for this path throught trellis
inline float GetTotalScore() const { inline float GetFutureScore() const {
return m_totalScore; return m_totalScore;
} }
@ -113,7 +113,7 @@ inline std::ostream& operator<<(std::ostream& out, const TrellisPath& path)
out << edge->GetId() << " " << sourceRange.GetStartPos() << "-" << sourceRange.GetEndPos() << ", "; out << edge->GetId() << " " << sourceRange.GetStartPos() << "-" << sourceRange.GetEndPos() << ", ";
} }
// scores // scores
out << " total=" << path.GetTotalScore() out << " total=" << path.GetFutureScore()
<< " " << path.GetScoreBreakdown() << " " << path.GetScoreBreakdown()
<< std::endl; << std::endl;

View File

@ -31,7 +31,7 @@ namespace Moses
struct CompareTrellisPathCollection { struct CompareTrellisPathCollection {
bool operator()(const TrellisPath* pathA, const TrellisPath* pathB) const { bool operator()(const TrellisPath* pathA, const TrellisPath* pathB) const {
return (pathA->GetTotalScore() > pathB->GetTotalScore()); return (pathA->GetFutureScore() > pathB->GetFutureScore());
} }
}; };

View File

@ -205,7 +205,7 @@ outputNBest(const Manager& manager, map<string, xmlrpc_c::value>& retData)
} }
// weighted score // 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)); nBestXml.push_back(xmlrpc_c::value_struct(nBestXmlItem));
} }
retData["nbest"] = xmlrpc_c::value_array(nBestXml); retData["nbest"] = xmlrpc_c::value_array(nBestXml);