00001 #pragma once
00002 #include <string>
00003 #include <map>
00004 #include <boost/scoped_ptr.hpp>
00005
00006 namespace Moses
00007 {
00008 class Range;
00009 class Bitmap;
00010 class InputType;
00011 class LRState;
00012 class LexicalReordering;
00013 class SparseReordering;
00014
00016 class LRModel
00017 {
00018 public:
00019 friend class LexicalReordering;
00020 enum ModelType { Monotonic, MSD, MSLR, LeftRight, None };
00021 enum Direction { Forward, Backward, Bidirectional };
00022 enum Condition { F, E, FE };
00023
00024
00025
00026 #if 0
00027 typedef int ReorderingType;
00028 static const ReorderingType M = 0;
00029 static const ReorderingType NM = 1;
00030 static const ReorderingType S = 1;
00031 static const ReorderingType D = 2;
00032 static const ReorderingType DL = 2;
00033 static const ReorderingType DR = 3;
00034 static const ReorderingType R = 0;
00035 static const ReorderingType L = 1;
00036 static const ReorderingType MAX = 3;
00037 #else
00038 enum ReorderingType {
00039 M = 0,
00040 NM = 1,
00041 S = 1,
00042 D = 2,
00043 DL = 2,
00044 DR = 3,
00045 R = 0,
00046 L = 1,
00047 MAX = 3,
00048 NONE = 4
00049 };
00050 #endif
00051
00052
00053
00054 ReorderingType
00055 GetOrientation(Range const& cur) const;
00056
00057 ReorderingType
00058 GetOrientation(Range const& prev, Range const& cur) const;
00059
00060 ReorderingType
00061 GetOrientation(Range const& prev, Range const& cur,
00062 Bitmap const& cov) const;
00063
00064 ReorderingType
00065 GetOrientation(int const reoDistance) const;
00066
00067 LRModel(const std::string &modelType);
00068
00069 void
00070 ConfigureSparse(const std::map<std::string,std::string>& sparseArgs,
00071 const LexicalReordering* producer);
00072
00073 LRState*
00074 CreateLRState(const InputType &input) const;
00075
00076 size_t GetNumberOfTypes() const;
00077 size_t GetNumScoreComponents() const;
00078 void SetAdditionalScoreComponents(size_t number);
00079
00080 LexicalReordering*
00081 GetScoreProducer() const {
00082 return m_scoreProducer;
00083 }
00084
00085 ModelType GetModelType() const {
00086 return m_modelType;
00087 }
00088 Direction GetDirection() const {
00089 return m_direction;
00090 }
00091 Condition GetCondition() const {
00092 return m_condition;
00093 }
00094
00095 bool
00096 IsPhraseBased() const {
00097 return m_phraseBased;
00098 }
00099
00100 bool
00101 CollapseScores() const {
00102 return m_collapseScores;
00103 }
00104
00105 SparseReordering const*
00106 GetSparseReordering() const {
00107 return m_sparse.get();
00108 }
00109
00110 private:
00111 void
00112 SetScoreProducer(LexicalReordering* scoreProducer) {
00113 m_scoreProducer = scoreProducer;
00114 }
00115
00116 std::string const&
00117 GetModelString() const {
00118 return m_modelString;
00119 }
00120
00121 std::string m_modelString;
00122 LexicalReordering *m_scoreProducer;
00123 ModelType m_modelType;
00124 bool m_phraseBased;
00125 bool m_collapseScores;
00126 Direction m_direction;
00127 Condition m_condition;
00128 size_t m_additionalScoreComponents;
00129 boost::scoped_ptr<SparseReordering> m_sparse;
00130 };
00131
00132 }
00133