mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
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:
parent
c10551cdda
commit
5761322d09
@ -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;
|
||||
|
||||
|
@ -10,6 +10,12 @@ ScoreComponentCollection::ScoreComponentCollection()
|
||||
, m_sim(&StaticData::Instance().GetScoreIndexManager())
|
||||
{}
|
||||
|
||||
float ScoreComponentCollection::GetWeightedScore() const
|
||||
{
|
||||
float ret = InnerProduct(StaticData::Instance().GetAllWeights());
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,6 +178,8 @@ public:
|
||||
return m_scores[begin];
|
||||
}
|
||||
|
||||
float GetWeightedScore() const;
|
||||
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const ScoreComponentCollection& rhs)
|
||||
|
Loading…
Reference in New Issue
Block a user