|
#pragma once |
|
#include <string> |
|
#include <map> |
|
#include <boost/scoped_ptr.hpp> |
|
|
|
namespace Moses |
|
{ |
|
class Range; |
|
class Bitmap; |
|
class InputType; |
|
class LRState; |
|
class LexicalReordering; |
|
class SparseReordering; |
|
|
|
|
|
class LRModel |
|
{ |
|
public: |
|
friend class LexicalReordering; |
|
enum ModelType { Monotonic, MSD, MSLR, LeftRight, None }; |
|
enum Direction { Forward, Backward, Bidirectional }; |
|
enum Condition { F, E, FE }; |
|
|
|
|
|
|
|
#if 0 |
|
typedef int ReorderingType; |
|
static const ReorderingType M = 0; |
|
static const ReorderingType NM = 1; |
|
static const ReorderingType S = 1; |
|
static const ReorderingType D = 2; |
|
static const ReorderingType DL = 2; |
|
static const ReorderingType DR = 3; |
|
static const ReorderingType R = 0; |
|
static const ReorderingType L = 1; |
|
static const ReorderingType MAX = 3; |
|
#else |
|
enum ReorderingType { |
|
M = 0, |
|
NM = 1, |
|
S = 1, |
|
D = 2, |
|
DL = 2, |
|
DR = 3, |
|
R = 0, |
|
L = 1, |
|
MAX = 3, |
|
NONE = 4 |
|
}; |
|
#endif |
|
|
|
|
|
|
|
ReorderingType |
|
GetOrientation(Range const& cur) const; |
|
|
|
ReorderingType |
|
GetOrientation(Range const& prev, Range const& cur) const; |
|
|
|
ReorderingType |
|
GetOrientation(Range const& prev, Range const& cur, |
|
Bitmap const& cov) const; |
|
|
|
ReorderingType |
|
GetOrientation(int const reoDistance) const; |
|
|
|
LRModel(const std::string &modelType); |
|
|
|
void |
|
ConfigureSparse(const std::map<std::string,std::string>& sparseArgs, |
|
const LexicalReordering* producer); |
|
|
|
LRState* |
|
CreateLRState(const InputType &input) const; |
|
|
|
size_t GetNumberOfTypes() const; |
|
size_t GetNumScoreComponents() const; |
|
void SetAdditionalScoreComponents(size_t number); |
|
|
|
LexicalReordering* |
|
GetScoreProducer() const { |
|
return m_scoreProducer; |
|
} |
|
|
|
ModelType GetModelType() const { |
|
return m_modelType; |
|
} |
|
Direction GetDirection() const { |
|
return m_direction; |
|
} |
|
Condition GetCondition() const { |
|
return m_condition; |
|
} |
|
|
|
bool |
|
IsPhraseBased() const { |
|
return m_phraseBased; |
|
} |
|
|
|
bool |
|
CollapseScores() const { |
|
return m_collapseScores; |
|
} |
|
|
|
SparseReordering const* |
|
GetSparseReordering() const { |
|
return m_sparse.get(); |
|
} |
|
|
|
private: |
|
void |
|
SetScoreProducer(LexicalReordering* scoreProducer) { |
|
m_scoreProducer = scoreProducer; |
|
} |
|
|
|
std::string const& |
|
GetModelString() const { |
|
return m_modelString; |
|
} |
|
|
|
std::string m_modelString; |
|
LexicalReordering *m_scoreProducer; |
|
ModelType m_modelType; |
|
bool m_phraseBased; |
|
bool m_collapseScores; |
|
Direction m_direction; |
|
Condition m_condition; |
|
size_t m_additionalScoreComponents; |
|
boost::scoped_ptr<SparseReordering> m_sparse; |
|
}; |
|
|
|
} |
|
|
|
|