diff --git a/contrib/other-builds/moses2/FF/LexicalReordering.cpp b/contrib/other-builds/moses2/FF/LexicalReordering.cpp index f6ed46cc2..695c297a8 100644 --- a/contrib/other-builds/moses2/FF/LexicalReordering.cpp +++ b/contrib/other-builds/moses2/FF/LexicalReordering.cpp @@ -114,9 +114,9 @@ void LexicalReordering::EvaluateWhenApplied(const Manager &mgr, const Hypothesis &hypo, const FFState &prevState, Scores &scores, - FFState &state) const + FFState &state) const { - + //const Phrase &source = hypo.ge } const LexicalReordering::Values *LexicalReordering::GetValues(const Phrase &source, const Phrase &target) const @@ -132,4 +132,25 @@ const LexicalReordering::Values *LexicalReordering::GetValues(const Phrase &sour } } +size_t LexicalReordering::GetOrientation(Range const& cur) const +{ + return (cur.GetStartPos() == 0) ? 0 : 1; +} + +size_t LexicalReordering::GetOrientation(Range const& prev, Range const& cur) const +{ + if (cur.GetStartPos() == prev.GetEndPos() + 1) { + // monotone + return 0; + } + else if (prev.GetStartPos() == cur.GetEndPos() + 1) { + // swap + return 1; + } + else { + // discontinuous + return 2; + } +} + } /* namespace Moses2 */ diff --git a/contrib/other-builds/moses2/FF/LexicalReordering.h b/contrib/other-builds/moses2/FF/LexicalReordering.h index d0150d894..920a65da8 100644 --- a/contrib/other-builds/moses2/FF/LexicalReordering.h +++ b/contrib/other-builds/moses2/FF/LexicalReordering.h @@ -11,6 +11,7 @@ #include "StatefulFeatureFunction.h" #include "../TypeDef.h" #include "../Phrase.h" +#include "../legacy/Range.h" namespace Moses2 { @@ -78,6 +79,10 @@ protected: Coll m_coll; const Values *GetValues(const Phrase &source, const Phrase &target) const; + + size_t GetOrientation(Range const& cur) const; + size_t GetOrientation(Range const& prev, Range const& cur) const; + }; } /* namespace Moses2 */