2008-06-11 14:52:57 +04:00
|
|
|
// $Id$
|
2010-09-17 18:25:08 +04:00
|
|
|
#include <vector>
|
2010-10-07 02:06:49 +04:00
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
#include "ScoreComponentCollection.h"
|
|
|
|
#include "StaticData.h"
|
|
|
|
|
2010-10-07 02:06:49 +04:00
|
|
|
using namespace std;
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2008-06-11 14:52:57 +04:00
|
|
|
ScoreComponentCollection::ScoreComponentCollection()
|
|
|
|
{}
|
|
|
|
|
2010-09-28 19:13:50 +04:00
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
float ScoreComponentCollection::GetWeightedScore() const
|
|
|
|
{
|
2010-10-07 02:06:49 +04:00
|
|
|
return m_scores.inner_product(StaticData::Instance().GetAllWeights().m_scores);
|
2010-04-08 21:16:10 +04:00
|
|
|
}
|
|
|
|
|
2010-08-10 17:12:00 +04:00
|
|
|
void ScoreComponentCollection::ZeroAllLM(const LMList& lmList)
|
2010-04-08 21:16:10 +04:00
|
|
|
{
|
2010-10-07 02:06:49 +04:00
|
|
|
for (LMList::const_iterator i = lmList.begin(); i != lmList.end(); ++i) {
|
|
|
|
Assign(*i, 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
|
|
|
{
|
2010-10-07 02:06:49 +04:00
|
|
|
for (LMList::const_iterator i = lmList.begin(); i != lmList.end(); ++i) {
|
|
|
|
PlusEquals(*i,rhs);
|
|
|
|
}
|
2010-04-08 21:16:10 +04:00
|
|
|
}
|
2010-09-16 13:54:13 +04:00
|
|
|
|
2010-09-17 19:20:55 +04:00
|
|
|
|
|
|
|
void ScoreComponentCollection::MultiplyEquals(float scalar)
|
|
|
|
{
|
|
|
|
m_scores *= scalar;
|
|
|
|
}
|
2010-10-28 16:41:33 +04:00
|
|
|
|
|
|
|
void ScoreComponentCollection::DivideEquals(float scalar)
|
|
|
|
{
|
|
|
|
m_scores /= scalar;
|
|
|
|
}
|
|
|
|
|
2010-09-17 19:20:55 +04:00
|
|
|
|
2010-09-17 19:33:21 +04:00
|
|
|
void ScoreComponentCollection::MultiplyEquals(const ScoreComponentCollection& rhs)
|
|
|
|
{
|
|
|
|
m_scores *= rhs.m_scores;
|
|
|
|
}
|
|
|
|
|
2010-09-16 11:06:42 +04:00
|
|
|
std::ostream& operator<<(std::ostream& os, const ScoreComponentCollection& rhs)
|
|
|
|
{
|
2010-10-07 02:06:49 +04:00
|
|
|
os << "<<" << rhs.m_scores;
|
2010-09-16 11:06:42 +04:00
|
|
|
return os << ">>";
|
|
|
|
}
|
2010-09-28 19:13:50 +04:00
|
|
|
void ScoreComponentCollection::L1Normalise() {
|
|
|
|
m_scores /= m_scores.l1norm();
|
|
|
|
}
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|