blob: e979b5bf5725ed44ff60d9a60081db82fe6c0531 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#ifndef moses_LexicalReordering_h
#define moses_LexicalReordering_h
#include <string>
#include <vector>
#include "Factor.h"
#include "Phrase.h"
#include "TypeDef.h"
#include "Util.h"
#include "WordsRange.h"
#include "ScoreProducer.h"
#include "FeatureFunction.h"
#include "LexicalReorderingState.h"
#include "LexicalReorderingTable.h"
namespace Moses
{
class Factor;
class Phrase;
class Hypothesis;
class InputType;
class LexicalReordering : public StatefulFeatureFunction {
public:
LexicalReordering(std::vector<FactorType>& f_factors,
std::vector<FactorType>& e_factors,
const LexicalReorderingConfiguration& configuration,
const std::string &filePath,
const std::vector<float>& weights);
virtual ~LexicalReordering();
virtual FFState* Evaluate(const Hypothesis& cur_hypo,
const FFState* prev_state,
ScoreComponentCollection* accumulator) const;
virtual const FFState* EmptyHypothesisState(const InputType &input) const;
std::string GetScoreProducerWeightShortName(unsigned) const {
return "d";
};
void InitializeForInput(const InputType& i){
m_table->InitializeForInput(i);
}
Scores GetProb(const Phrase& f, const Phrase& e) const;
virtual FFState* EvaluateChart(const ChartHypothesis&,
int /* featureID */,
ScoreComponentCollection*) const {
CHECK(0); // not valid for chart decoder
return NULL;
}
private:
bool DecodeCondition(std::string s);
bool DecodeDirection(std::string s);
bool DecodeNumFeatureFunctions(std::string s);
LexicalReorderingConfiguration m_configuration;
std::string m_modelTypeString;
std::vector<std::string> m_modelType;
LexicalReorderingTable* m_table;
//std::vector<Direction> m_direction;
std::vector<LexicalReorderingConfiguration::Condition> m_condition;
//std::vector<size_t> m_scoreOffset;
//bool m_oneScorePerDirection;
std::vector<FactorType> m_factorsE, m_factorsF;
};
}
#endif
|