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
|
|
|
}
|
|
|
|
|
2013-05-28 13:51:28 +04:00
|
|
|
void WordPenaltyProducer::Evaluate(const Phrase &source
|
2013-05-29 21:16:15 +04:00
|
|
|
, const TargetPhrase &targetPhrase
|
|
|
|
, ScoreComponentCollection &scoreBreakdown
|
|
|
|
, ScoreComponentCollection &estimatedFutureScore) const
|
2013-05-25 03:57:37 +04:00
|
|
|
{
|
|
|
|
float score = - (float) targetPhrase.GetNumTerminals();
|
|
|
|
scoreBreakdown.Assign(this, score);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|