2013-05-25 03:57:37 +04:00
|
|
|
#include "WordPenaltyProducer.h"
|
|
|
|
#include "moses/TargetPhrase.h"
|
|
|
|
#include "moses/ScoreComponentCollection.h"
|
|
|
|
|
2013-06-20 15:50:41 +04:00
|
|
|
using namespace std;
|
|
|
|
|
2013-05-25 03:57:37 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2013-12-06 19:57:49 +04:00
|
|
|
WordPenaltyProducer *WordPenaltyProducer::s_instance = NULL;
|
|
|
|
|
2013-06-20 15:50:41 +04:00
|
|
|
WordPenaltyProducer::WordPenaltyProducer(const std::string &line)
|
2013-10-29 22:44:33 +04:00
|
|
|
: StatelessFeatureFunction(1, line)
|
2013-06-26 20:19:09 +04:00
|
|
|
{
|
2013-06-20 16:06:03 +04:00
|
|
|
ReadParameters();
|
2013-12-06 19:57:49 +04:00
|
|
|
|
|
|
|
UTIL_THROW_IF2(s_instance, "Can only have 1 word penalty feature");
|
|
|
|
s_instance = this;
|
2013-06-20 15:50:41 +04:00
|
|
|
}
|
|
|
|
|
2014-07-10 01:35:59 +04:00
|
|
|
void WordPenaltyProducer::EvaluateInIsolation(const Phrase &source
|
2015-01-14 14:07:42 +03:00
|
|
|
, const TargetPhrase &targetPhrase
|
|
|
|
, ScoreComponentCollection &scoreBreakdown
|
2015-11-04 18:10:45 +03:00
|
|
|
, ScoreComponentCollection &estimatedScores) const
|
2013-05-25 03:57:37 +04:00
|
|
|
{
|
|
|
|
float score = - (float) targetPhrase.GetNumTerminals();
|
|
|
|
scoreBreakdown.Assign(this, score);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|