2010-02-24 14:15:44 +03:00
|
|
|
#ifndef moses_LexicalReordering_h
|
|
|
|
#define moses_LexicalReordering_h
|
2008-06-11 14:52:57 +04:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "Factor.h"
|
|
|
|
#include "Phrase.h"
|
|
|
|
#include "TypeDef.h"
|
|
|
|
#include "Util.h"
|
|
|
|
#include "WordsRange.h"
|
|
|
|
|
2010-02-11 20:08:24 +03:00
|
|
|
#include "LexicalReorderingState.h"
|
2008-06-11 14:52:57 +04:00
|
|
|
#include "LexicalReorderingTable.h"
|
2013-05-24 22:11:15 +04:00
|
|
|
#include "moses/FF/StatefulFeatureFunction.h"
|
2013-05-24 21:02:49 +04:00
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
class Factor;
|
|
|
|
class Phrase;
|
|
|
|
class Hypothesis;
|
|
|
|
class InputType;
|
|
|
|
|
2012-06-27 03:45:02 +04:00
|
|
|
/** implementation of lexical reordering (Tilman ...) for phrase-based decoding
|
|
|
|
*/
|
2013-05-29 21:16:15 +04:00
|
|
|
class LexicalReordering : public StatefulFeatureFunction
|
|
|
|
{
|
|
|
|
public:
|
2013-01-15 22:32:13 +04:00
|
|
|
LexicalReordering(const std::string &line);
|
|
|
|
virtual ~LexicalReordering();
|
2013-06-01 02:04:05 +04:00
|
|
|
void Load();
|
2013-01-15 22:32:13 +04:00
|
|
|
|
2013-05-30 15:41:08 +04:00
|
|
|
virtual bool IsUseable(const FactorMask &mask) const;
|
|
|
|
|
2013-01-15 22:32:13 +04:00
|
|
|
virtual const FFState* EmptyHypothesisState(const InputType &input) const;
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
void InitializeForInput(const InputType& i) {
|
|
|
|
m_table->InitializeForInput(i);
|
2013-01-15 22:32:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Scores GetProb(const Phrase& f, const Phrase& e) const;
|
2012-12-04 21:09:23 +04:00
|
|
|
|
2013-05-02 15:15:26 +04:00
|
|
|
virtual FFState* Evaluate(const Hypothesis& cur_hypo,
|
|
|
|
const FFState* prev_state,
|
|
|
|
ScoreComponentCollection* accumulator) const;
|
|
|
|
|
2011-06-16 01:31:27 +04:00
|
|
|
virtual FFState* EvaluateChart(const ChartHypothesis&,
|
|
|
|
int /* featureID */,
|
2013-05-29 21:16:15 +04:00
|
|
|
ScoreComponentCollection*) const {
|
|
|
|
CHECK(0); // not valid for chart decoder
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2010-01-27 17:07:13 +03:00
|
|
|
private:
|
2013-05-29 21:16:15 +04:00
|
|
|
bool DecodeCondition(std::string s);
|
|
|
|
bool DecodeDirection(std::string s);
|
|
|
|
bool DecodeNumFeatureFunctions(std::string s);
|
2010-01-28 13:39:43 +03:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
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;
|
2013-06-01 02:04:05 +04:00
|
|
|
std::string m_filePath;
|
2008-06-11 14:52:57 +04:00
|
|
|
};
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
}
|
2010-02-24 14:15:44 +03:00
|
|
|
|
|
|
|
#endif
|