2013-05-24 21:34:47 +04:00
|
|
|
#pragma once
|
|
|
|
|
2013-05-24 22:11:15 +04:00
|
|
|
#include "FeatureFunction.h"
|
|
|
|
|
2014-11-04 16:13:56 +03:00
|
|
|
|
2013-05-24 21:34:47 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2015-11-16 21:58:14 +03:00
|
|
|
namespace Syntax
|
|
|
|
{
|
2015-11-27 15:20:38 +03:00
|
|
|
struct SHyperedge;
|
2015-11-16 21:58:14 +03:00
|
|
|
}
|
|
|
|
|
2013-05-24 22:11:15 +04:00
|
|
|
/** base class for all stateless feature functions.
|
|
|
|
* eg. phrase table, word penalty, phrase penalty
|
|
|
|
*/
|
|
|
|
class StatelessFeatureFunction: public FeatureFunction
|
|
|
|
{
|
|
|
|
//All stateless FFs, except those that cache scores in T-Option
|
|
|
|
static std::vector<const StatelessFeatureFunction*> m_statelessFFs;
|
|
|
|
|
|
|
|
public:
|
2013-05-29 21:16:15 +04:00
|
|
|
static const std::vector<const StatelessFeatureFunction*>& GetStatelessFeatureFunctions() {
|
|
|
|
return m_statelessFFs;
|
|
|
|
}
|
2013-05-24 22:11:15 +04:00
|
|
|
|
2015-04-29 22:16:52 +03:00
|
|
|
StatelessFeatureFunction(const std::string &line, bool registerNow);
|
2013-10-29 22:44:33 +04:00
|
|
|
StatelessFeatureFunction(size_t numScoreComponents, const std::string &line);
|
2014-12-08 21:20:58 +03:00
|
|
|
|
2013-05-24 22:11:15 +04:00
|
|
|
/**
|
|
|
|
* This should be implemented for features that apply to phrase-based models.
|
|
|
|
**/
|
2014-07-10 02:41:08 +04:00
|
|
|
virtual void EvaluateWhenApplied(const Hypothesis& hypo,
|
2015-01-14 14:07:42 +03:00
|
|
|
ScoreComponentCollection* accumulator) const = 0;
|
2013-05-24 22:11:15 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Same for chart-based features.
|
|
|
|
**/
|
2014-07-10 02:54:16 +04:00
|
|
|
virtual void EvaluateWhenApplied(const ChartHypothesis &hypo,
|
2015-01-14 14:07:42 +03:00
|
|
|
ScoreComponentCollection* accumulator) const = 0;
|
2013-05-24 22:11:15 +04:00
|
|
|
|
2014-11-04 16:13:56 +03:00
|
|
|
virtual void EvaluateWhenApplied(const Syntax::SHyperedge &,
|
2015-01-14 14:07:42 +03:00
|
|
|
ScoreComponentCollection*) const {
|
|
|
|
assert(false);
|
|
|
|
}
|
2014-11-04 16:13:56 +03:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
virtual bool IsStateless() const {
|
|
|
|
return true;
|
|
|
|
}
|
2013-05-24 22:11:15 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-05-24 21:34:47 +04:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|