mosesdecoder/moses/FF/WordPenaltyProducer.cpp
2015-01-14 11:07:42 +00:00

31 lines
750 B
C++

#include "WordPenaltyProducer.h"
#include "moses/TargetPhrase.h"
#include "moses/ScoreComponentCollection.h"
using namespace std;
namespace Moses
{
WordPenaltyProducer *WordPenaltyProducer::s_instance = NULL;
WordPenaltyProducer::WordPenaltyProducer(const std::string &line)
: StatelessFeatureFunction(1, line)
{
ReadParameters();
UTIL_THROW_IF2(s_instance, "Can only have 1 word penalty feature");
s_instance = this;
}
void WordPenaltyProducer::EvaluateInIsolation(const Phrase &source
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection &estimatedFutureScore) const
{
float score = - (float) targetPhrase.GetNumTerminals();
scoreBreakdown.Assign(this, score);
}
}