wer producer

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/branches/mt3_constraint@2046 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
hieuhoang1972 2009-01-29 18:02:34 +00:00
parent c10551cdda
commit 5761322d09
3 changed files with 20 additions and 0 deletions

View File

@ -327,6 +327,15 @@ void Hypothesis::ResetScore()
m_futureScore = m_totalScore = 0.0f;
}
void GetRecursivePhrase(const Hypothesis *hypo, Phrase &phrase)
{
if (hypo != NULL)
{
GetRecursivePhrase(hypo->GetPrevHypo(), phrase);
phrase.Append(hypo->GetCurrTargetPhrase());
}
}
/***
* calculate the logarithm of our total translation score (sum up components)
*/
@ -358,11 +367,14 @@ void Hypothesis::CalcScore(const SquareMatrix &futureScore, const Phrase *constr
// wer score
Phrase hypPhrase(Output);
GetRecursivePhrase(this, hypPhrase);
const WERScoreProducer *werProducer = staticData.GetWERScoreProducer();
float werScore = werProducer->CalculateScore(hypPhrase, *constraint);
m_scoreBreakdown.PlusEquals(werProducer, werScore);
cerr << m_scoreBreakdown.GetWeightedScore() << " " << hypPhrase << endl;
// TOTAL
m_totalScore = m_scoreBreakdown.InnerProduct(staticData.GetAllWeights()) + m_futureScore;

View File

@ -10,6 +10,12 @@ ScoreComponentCollection::ScoreComponentCollection()
, m_sim(&StaticData::Instance().GetScoreIndexManager())
{}
float ScoreComponentCollection::GetWeightedScore() const
{
float ret = InnerProduct(StaticData::Instance().GetAllWeights());
return ret;
}
}

View File

@ -178,6 +178,8 @@ public:
return m_scores[begin];
}
float GetWeightedScore() const;
};
inline std::ostream& operator<<(std::ostream& os, const ScoreComponentCollection& rhs)