mosesdecoder/moses/FF/WordPenaltyProducer.cpp

31 lines
832 B
C++
Raw Normal View History

#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)
2013-06-26 20:19:09 +04:00
{
ReadParameters();
UTIL_THROW_IF2(s_instance, "Can only have 1 word penalty feature");
s_instance = this;
}
void WordPenaltyProducer::Evaluate(const Phrase &source
2013-05-29 21:16:15 +04:00
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection &estimatedFutureScore) const
{
float score = - (float) targetPhrase.GetNumTerminals();
scoreBreakdown.Assign(this, score);
}
}