mosesdecoder/moses/FF/StatelessFeatureFunction.h

56 lines
1.3 KiB
C
Raw Normal View History

2013-05-24 21:34:47 +04:00
#pragma once
2013-05-24 22:11:15 +04:00
#include "FeatureFunction.h"
2013-05-24 21:34:47 +04:00
namespace Moses
{
namespace Syntax
{
2015-11-27 15:20:38 +03:00
struct SHyperedge;
}
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
StatelessFeatureFunction(const std::string &line, bool registerNow);
StatelessFeatureFunction(size_t numScoreComponents, const std::string &line);
2013-05-24 22:11:15 +04:00
/**
* This should be implemented for features that apply to phrase-based models.
**/
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.
**/
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
virtual void EvaluateWhenApplied(const Syntax::SHyperedge &,
2015-01-14 14:07:42 +03:00
ScoreComponentCollection*) const {
assert(false);
}
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