mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-11-10 00:47:31 +03:00
31 lines
750 B
C++
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);
|
|
}
|
|
|
|
}
|
|
|