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"
|
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:
|
2011-11-09 01:22:34 +04:00
|
|
|
DistortionScoreProducer() : StatefulFeatureFunction("Distortion", 1) {}
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
float CalculateDistortionScore(const Hypothesis& hypo,
|
2009-08-07 20:47:54 +04:00
|
|
|
const WordsRange &prev, const WordsRange &curr, const int FirstGapPosition) const;
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-09-20 14:23:38 +04:00
|
|
|
std::string GetScoreProducerWeightShortName(unsigned) const;
|
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
|
|
|
}
|
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:
|
2011-11-09 01:22:34 +04:00
|
|
|
WordPenaltyProducer() : StatelessFeatureFunction("WordPenalty",1) {}
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-09-20 14:23:38 +04:00
|
|
|
std::string GetScoreProducerWeightShortName(unsigned) const;
|
2009-02-06 18:43:06 +03:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
virtual void Evaluate(
|
2012-09-19 21:00:53 +04:00
|
|
|
const PhraseBasedFeatureContext& context,
|
2012-04-09 23:47:51 +04:00
|
|
|
ScoreComponentCollection* accumulator) const;
|
|
|
|
|
|
|
|
virtual void EvaluateChart(
|
2012-09-21 14:56:01 +04:00
|
|
|
const ChartBasedFeatureContext& context,
|
2012-09-14 01:08:01 +04:00
|
|
|
ScoreComponentCollection* accumulator) const
|
|
|
|
{
|
|
|
|
//required but does nothing.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
2011-11-09 01:22:34 +04:00
|
|
|
UnknownWordPenaltyProducer() : StatelessFeatureFunction("!UnknownWordPenalty",1) {}
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-09-20 14:23:38 +04:00
|
|
|
std::string GetScoreProducerWeightShortName(unsigned) const;
|
2009-02-06 18:43:06 +03:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
virtual bool ComputeValueInTranslationOption() const;
|
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
|
|
|
|
2012-11-16 14:14:22 +04:00
|
|
|
bool ComputeValueInTranslationTable() const {return true;}
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
};
|
|
|
|
|
2012-10-01 23:36:52 +04:00
|
|
|
class MetaFeatureProducer : public StatelessFeatureFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MetaFeatureProducer(std::string shortName) : StatelessFeatureFunction("MetaFeature_"+shortName,1), m_shortName(shortName) {}
|
|
|
|
|
|
|
|
std::string m_shortName;
|
|
|
|
|
|
|
|
std::string GetScoreProducerWeightShortName(unsigned) const;
|
|
|
|
|
2012-10-03 21:53:55 +04:00
|
|
|
void Evaluate(const PhraseBasedFeatureContext& context,
|
|
|
|
ScoreComponentCollection* accumulator) const {
|
|
|
|
//do nothing - not a real feature
|
2012-10-01 23:36:52 +04:00
|
|
|
}
|
|
|
|
|
2012-10-03 21:53:55 +04:00
|
|
|
void EvaluateChart(const ChartBasedFeatureContext& context,
|
|
|
|
ScoreComponentCollection*) const {
|
|
|
|
//do nothing - not a real feature
|
2012-10-01 23:36:52 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
}
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
#endif
|