blob: a364a811fb02a4cc6f68eb28e9a30dbbb373a69b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#pragma once
#include "FeatureFunction.h"
namespace Moses
{
namespace Syntax
{
struct SHyperedge;
}
/** 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:
static const std::vector<const StatelessFeatureFunction*>& GetStatelessFeatureFunctions() {
return m_statelessFFs;
}
StatelessFeatureFunction(const std::string &line, bool registerNow);
StatelessFeatureFunction(size_t numScoreComponents, const std::string &line);
/**
* This should be implemented for features that apply to phrase-based models.
**/
virtual void EvaluateWhenApplied(const Hypothesis& hypo,
ScoreComponentCollection* accumulator) const = 0;
/**
* Same for chart-based features.
**/
virtual void EvaluateWhenApplied(const ChartHypothesis &hypo,
ScoreComponentCollection* accumulator) const = 0;
virtual void EvaluateWhenApplied(const Syntax::SHyperedge &,
ScoreComponentCollection*) const {
assert(false);
}
virtual bool IsStateless() const {
return true;
}
};
} // namespace
|