lexicalised reordering

This commit is contained in:
Hieu Hoang 2015-12-16 13:11:11 +00:00
parent 4f0dff6a6e
commit 5fdf9d8046
2 changed files with 28 additions and 2 deletions

View File

@ -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 */

View File

@ -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 */