mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 13:23:25 +03:00
73 lines
2.0 KiB
C++
73 lines
2.0 KiB
C++
#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 "FeatureFunction.h"
|
|
|
|
#include "LexicalReorderingState.h"
|
|
#include "LexicalReorderingTable.h"
|
|
|
|
namespace Moses
|
|
{
|
|
|
|
class Factor;
|
|
class Phrase;
|
|
class Hypothesis;
|
|
class InputType;
|
|
|
|
/** implementation of lexical reordering (Tilman ...) for phrase-based decoding
|
|
*/
|
|
class LexicalReordering : public StatefulFeatureFunction {
|
|
public:
|
|
LexicalReordering(const std::string &line);
|
|
virtual ~LexicalReordering();
|
|
|
|
virtual const FFState* EmptyHypothesisState(const InputType &input) const;
|
|
|
|
void InitializeForInput(const InputType& i){
|
|
m_table->InitializeForInput(i);
|
|
}
|
|
|
|
Scores GetProb(const Phrase& f, const Phrase& e) const;
|
|
|
|
virtual FFState* Evaluate(const Hypothesis& cur_hypo,
|
|
const FFState* prev_state,
|
|
ScoreComponentCollection* accumulator) const;
|
|
|
|
virtual FFState* EvaluateChart(const ChartHypothesis&,
|
|
int /* featureID */,
|
|
ScoreComponentCollection*) const {
|
|
CHECK(0); // not valid for chart decoder
|
|
return NULL;
|
|
}
|
|
|
|
virtual void Evaluate(const TargetPhrase &targetPhrase
|
|
, ScoreComponentCollection &scoreBreakdown
|
|
, ScoreComponentCollection &estimatedFutureScore) const;
|
|
|
|
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
|