blob: 6d8d21a4224ab345a1620bb30e6ee914bf7d7d77 (
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
|
#ifndef moses_SourceWordDeletionFeature_h
#define moses_SourceWordDeletionFeature_h
#include <string>
#include <map>
#include "FeatureFunction.h"
#include "FactorCollection.h"
#include "AlignmentInfo.h"
namespace Moses
{
/** Sets the features for source word deletion
*/
class SourceWordDeletionFeature : public StatelessFeatureFunction {
private:
std::set<std::string> m_vocab;
FactorType m_factorType;
bool m_unrestricted;
public:
SourceWordDeletionFeature(FactorType factorType = 0):
StatelessFeatureFunction("swd", ScoreProducer::unlimited),
m_factorType(factorType),
m_unrestricted(true)
{
std::cerr << "Initializing source word deletion feature.." << std::endl;
}
bool Load(const std::string &filePath);
void Evaluate(const Hypothesis& cur_hypo,
ScoreComponentCollection* accumulator) const;
void EvaluateChart(const ChartHypothesis& cur_hypo,
int featureId,
ScoreComponentCollection* accumulator) const;
void ComputeFeatures(const TargetPhrase& targetPhrase,
ScoreComponentCollection* accumulator,
const AlignmentInfo::CollType &alignment) const;
// basic properties
std::string GetScoreProducerWeightShortName(unsigned) const { return "swd"; }
size_t GetNumInputScores() const { return 0; }
};
}
#endif // moses_SourceWordDeletionFeature_h
|