2008-06-11 14:52:57 +04:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
#include "ScoreComponentCollection.h"
|
|
|
|
#include "StaticData.h"
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2008-06-11 14:52:57 +04:00
|
|
|
ScoreComponentCollection::ScoreComponentCollection()
|
2010-09-15 21:27:37 +04:00
|
|
|
: m_scores(StaticData::Instance().GetTotalScoreComponents(), 0.0f)
|
2008-06-11 14:52:57 +04:00
|
|
|
, m_sim(&StaticData::Instance().GetScoreIndexManager())
|
|
|
|
{}
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
float ScoreComponentCollection::GetWeightedScore() const
|
|
|
|
{
|
|
|
|
float ret = InnerProduct(StaticData::Instance().GetAllWeights());
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-08-10 17:12:00 +04:00
|
|
|
void ScoreComponentCollection::ZeroAllLM(const LMList& lmList)
|
2010-04-08 21:16:10 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
for (size_t ind = lmList.GetMinIndex(); ind <= lmList.GetMaxIndex(); ++ind)
|
|
|
|
{
|
2010-09-15 20:30:52 +04:00
|
|
|
m_scores[m_sim->GetFeatureName(ind)] = 0;
|
2010-04-08 21:16:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-10 17:12:00 +04:00
|
|
|
void ScoreComponentCollection::PlusEqualsAllLM(const LMList& lmList, const ScoreComponentCollection& rhs)
|
2010-04-08 21:16:10 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
for (size_t ind = lmList.GetMinIndex(); ind <= lmList.GetMaxIndex(); ++ind)
|
|
|
|
{
|
2010-09-15 20:30:52 +04:00
|
|
|
m_scores[m_sim->GetFeatureName(ind)] += rhs.m_scores[m_sim->GetFeatureName(ind)];
|
2010-04-08 21:16:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|