2008-06-11 14:52:57 +04:00
|
|
|
// $Id$
|
|
|
|
|
2010-02-24 14:15:44 +03:00
|
|
|
#ifndef moses_DummyScoreProducers_h
|
|
|
|
#define moses_DummyScoreProducers_h
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2009-02-06 18:43:06 +03:00
|
|
|
#include "FeatureFunction.h"
|
2013-02-22 00:03:35 +04:00
|
|
|
#include "util/check.hh"
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
class WordsRange;
|
|
|
|
|
|
|
|
/** Calculates Distortion scores
|
|
|
|
*/
|
2011-02-24 16:14:42 +03:00
|
|
|
class DistortionScoreProducer : public StatefulFeatureFunction
|
|
|
|
{
|
2008-06-11 14:52:57 +04:00
|
|
|
public:
|
2013-02-04 19:41:25 +04:00
|
|
|
DistortionScoreProducer(const std::string &line)
|
|
|
|
: StatefulFeatureFunction("Distortion", 1, line)
|
|
|
|
{}
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2013-02-19 22:31:59 +04:00
|
|
|
static float CalculateDistortionScore(const Hypothesis& hypo,
|
|
|
|
const WordsRange &prev, const WordsRange &curr, const int FirstGapPosition);
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
virtual const FFState* EmptyHypothesisState(const InputType &input) const;
|
2009-02-06 18:43:06 +03:00
|
|
|
|
|
|
|
virtual FFState* Evaluate(
|
|
|
|
const Hypothesis& cur_hypo,
|
|
|
|
const FFState* prev_state,
|
|
|
|
ScoreComponentCollection* accumulator) const;
|
|
|
|
|
2011-06-16 01:31:27 +04:00
|
|
|
virtual FFState* EvaluateChart(
|
2012-09-14 01:08:01 +04:00
|
|
|
const ChartHypothesis& /* cur_hypo */,
|
|
|
|
int /* featureID - used to index the state in the previous hypotheses */,
|
2011-06-16 01:31:27 +04:00
|
|
|
ScoreComponentCollection*) const {
|
2011-11-18 16:07:41 +04:00
|
|
|
CHECK(0); // feature function not valid in chart decoder
|
2011-06-28 23:26:12 +04:00
|
|
|
return NULL;
|
2011-06-16 01:31:27 +04:00
|
|
|
}
|
2013-05-02 15:15:26 +04:00
|
|
|
|
|
|
|
virtual void Evaluate(const TargetPhrase &targetPhrase
|
|
|
|
, ScoreComponentCollection &scoreBreakdown
|
2013-05-02 17:55:26 +04:00
|
|
|
, ScoreComponentCollection &estimatedFutureScore) const;
|
2013-05-02 15:15:26 +04:00
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Doesn't do anything but provide a key into the global
|
2012-06-27 03:45:02 +04:00
|
|
|
* score array to store the word penalty in.
|
2008-06-11 14:52:57 +04:00
|
|
|
*/
|
2011-02-24 16:14:42 +03:00
|
|
|
class WordPenaltyProducer : public StatelessFeatureFunction
|
|
|
|
{
|
2008-06-11 14:52:57 +04:00
|
|
|
public:
|
2013-02-02 00:23:36 +04:00
|
|
|
WordPenaltyProducer(const std::string &line) : StatelessFeatureFunction("WordPenalty",1, line) {}
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
virtual void Evaluate(
|
2012-09-19 21:00:53 +04:00
|
|
|
const PhraseBasedFeatureContext& context,
|
2013-05-20 14:53:59 +04:00
|
|
|
ScoreComponentCollection* accumulator) const
|
|
|
|
{}
|
2012-04-09 23:47:51 +04:00
|
|
|
|
|
|
|
virtual void EvaluateChart(
|
2012-09-21 14:56:01 +04:00
|
|
|
const ChartBasedFeatureContext& context,
|
2013-05-20 14:53:59 +04:00
|
|
|
ScoreComponentCollection* accumulator) const
|
2012-09-14 01:08:01 +04:00
|
|
|
{
|
|
|
|
//required but does nothing.
|
|
|
|
}
|
2013-05-02 15:15:26 +04:00
|
|
|
|
|
|
|
virtual void Evaluate(const TargetPhrase &targetPhrase
|
|
|
|
, ScoreComponentCollection &scoreBreakdown
|
2013-05-02 17:55:26 +04:00
|
|
|
, ScoreComponentCollection &estimatedFutureScore) const;
|
2013-05-02 15:15:26 +04:00
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/** unknown word penalty */
|
2011-02-24 16:14:42 +03:00
|
|
|
class UnknownWordPenaltyProducer : public StatelessFeatureFunction
|
|
|
|
{
|
2008-06-11 14:52:57 +04:00
|
|
|
public:
|
2013-05-09 15:05:19 +04:00
|
|
|
UnknownWordPenaltyProducer(const std::string &line)
|
|
|
|
: StatelessFeatureFunction("UnknownWordPenalty",1, line)
|
|
|
|
{
|
|
|
|
m_tuneable = false;
|
|
|
|
}
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2012-09-19 21:00:53 +04:00
|
|
|
void Evaluate( const PhraseBasedFeatureContext& context,
|
2012-09-13 21:16:13 +04:00
|
|
|
ScoreComponentCollection* accumulator) const
|
|
|
|
{
|
2012-09-13 21:35:33 +04:00
|
|
|
//do nothing - not a real feature
|
2012-09-13 21:16:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void EvaluateChart(
|
2012-09-21 14:56:01 +04:00
|
|
|
const ChartBasedFeatureContext& context,
|
2012-09-13 21:16:13 +04:00
|
|
|
ScoreComponentCollection* accumulator) const
|
|
|
|
{
|
2012-09-13 21:35:33 +04:00
|
|
|
//do nothing - not a real feature
|
2012-09-13 21:16:13 +04:00
|
|
|
}
|
2009-02-06 18:43:06 +03:00
|
|
|
|
2013-05-02 15:15:26 +04:00
|
|
|
virtual void Evaluate(const TargetPhrase &targetPhrase
|
|
|
|
, ScoreComponentCollection &scoreBreakdown
|
2013-05-02 17:55:26 +04:00
|
|
|
, ScoreComponentCollection &estimatedFutureScore) const;
|
|
|
|
|
2013-05-13 19:14:18 +04:00
|
|
|
StatelessFeatureType GetStatelessFeatureType() const
|
|
|
|
{ return SetByOriginator; }
|
2008-06-11 14:52:57 +04:00
|
|
|
};
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
}
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
#endif
|