#include <ReorderingConstraint.h>
Public Member Functions | |
ReorderingConstraint (int max_distortion) | |
create ReorderingConstraint of length size and initialise to zero | |
~ReorderingConstraint () | |
destructer | |
void | InitializeWalls (size_t size) |
allocate memory for memory for a sentence of a given size | |
void | FinalizeWalls () |
changes walls in zones into local walls | |
void | SetWall (size_t pos, bool value) |
set value at a particular position | |
bool | GetWall (size_t pos) const |
whether a word has been translated at a particular position | |
bool | GetLocalWall (size_t pos, size_t zone) const |
whether a word has been translated at a particular position | |
void | SetZone (size_t startPos, size_t endPos) |
set a zone | |
std::vector< std::pair< size_t, size_t > > & | GetZones () |
returns the vector of zones | |
void | SetMonotoneAtPunctuation (const Phrase &sentence) |
set the reordering walls based on punctuation in the sentence | |
bool | Check (const Bitmap &bitmap, size_t start, size_t end) const |
check if all constraints are fulfilled -> all find | |
bool | IsActive () const |
checks if reordering constraints will be enforced | |
Protected Attributes | |
size_t | m_size |
bool * | m_wall |
size_t * | m_localWall |
std::vector< std::pair< size_t, size_t > > | m_zone |
bool | m_active |
int | m_max_distortion |
Friends | |
std::ostream & | operator<< (std::ostream &out, const ReorderingConstraint &obj) |
Definition at line 46 of file ReorderingConstraint.h.
Moses::ReorderingConstraint::ReorderingConstraint | ( | int | max_distortion | ) | [inline] |
create ReorderingConstraint of length size and initialise to zero
Definition at line 60 of file ReorderingConstraint.h.
Moses::ReorderingConstraint::~ReorderingConstraint | ( | ) | [inline] |
destructer
Definition at line 68 of file ReorderingConstraint.h.
References m_localWall, m_wall, and NULL.
bool Moses::ReorderingConstraint::Check | ( | const Bitmap & | bitmap, | |
size_t | start, | |||
size_t | end | |||
) | const |
check if all constraints are fulfilled -> all find
check if the current hypothesis extension violates reordering constraints
Definition at line 108 of file ReorderingConstraint.cpp.
References Moses::Bitmap::GetFirstGapPos(), Moses::Bitmap::GetLastPos(), GetLocalWall(), Moses::Bitmap::GetValue(), GetWall(), IsActive(), m_max_distortion, m_zone, NOT_FOUND, and VERBOSE.
Referenced by Moses::SearchCubePruning::CheckDistortion(), and Moses::SearchNormal::ProcessOneHypothesis().
void Moses::ReorderingConstraint::FinalizeWalls | ( | ) |
changes walls in zones into local walls
has to be called to localized walls
Definition at line 54 of file ReorderingConstraint.cpp.
References m_localWall, m_wall, m_zone, NOT_A_ZONE, and VERBOSE.
bool Moses::ReorderingConstraint::GetLocalWall | ( | size_t | pos, | |
size_t | zone | |||
) | const [inline] |
whether a word has been translated at a particular position
Definition at line 88 of file ReorderingConstraint.h.
References m_localWall.
Referenced by Check().
bool Moses::ReorderingConstraint::GetWall | ( | size_t | pos | ) | const [inline] |
whether a word has been translated at a particular position
Definition at line 83 of file ReorderingConstraint.h.
References m_wall.
Referenced by Check().
std::vector< std::pair<size_t,size_t> >& Moses::ReorderingConstraint::GetZones | ( | ) | [inline] |
returns the vector of zones
Definition at line 96 of file ReorderingConstraint.h.
References m_zone.
void Moses::ReorderingConstraint::InitializeWalls | ( | size_t | size | ) |
allocate memory for memory for a sentence of a given size
allocate memory for reordering walls
Definition at line 32 of file ReorderingConstraint.cpp.
References m_localWall, m_size, m_wall, and NOT_A_ZONE.
bool Moses::ReorderingConstraint::IsActive | ( | ) | const [inline] |
checks if reordering constraints will be enforced
Definition at line 107 of file ReorderingConstraint.h.
References m_active.
Referenced by Check().
void Moses::ReorderingConstraint::SetMonotoneAtPunctuation | ( | const Phrase & | sentence | ) |
set the reordering walls based on punctuation in the sentence
set walls based on "-monotone-at-punctuation" flag
Definition at line 78 of file ReorderingConstraint.cpp.
References Moses::Phrase::GetSize(), Moses::Phrase::GetWord(), m_size, and SetWall().
void Moses::ReorderingConstraint::SetWall | ( | size_t | pos, | |
bool | value | |||
) |
set value at a particular position
Definition at line 46 of file ReorderingConstraint.cpp.
References m_active, m_wall, and VERBOSE.
Referenced by SetMonotoneAtPunctuation().
void Moses::ReorderingConstraint::SetZone | ( | size_t | startPos, | |
size_t | endPos | |||
) |
set a zone
set a reordering zone (once entered, need to finish)
Definition at line 97 of file ReorderingConstraint.cpp.
References m_active, m_zone, and VERBOSE.
Referenced by Moses::ProcessAndStripXMLTags().
std::ostream& operator<< | ( | std::ostream & | out, | |
const ReorderingConstraint & | obj | |||
) | [friend] |
Definition at line 239 of file ReorderingConstraint.cpp.
bool Moses::ReorderingConstraint::m_active [protected] |
zones that limit reordering flag indicating, if there are any active constraints
Definition at line 55 of file ReorderingConstraint.h.
Referenced by IsActive(), SetWall(), and SetZone().
size_t* Moses::ReorderingConstraint::m_localWall [protected] |
flag for each word if it is a local wall
Definition at line 53 of file ReorderingConstraint.h.
Referenced by FinalizeWalls(), GetLocalWall(), InitializeWalls(), Moses::operator<<(), and ~ReorderingConstraint().
int Moses::ReorderingConstraint::m_max_distortion [protected] |
size_t Moses::ReorderingConstraint::m_size [protected] |
number of words in sentence
Definition at line 51 of file ReorderingConstraint.h.
Referenced by InitializeWalls(), Moses::operator<<(), and SetMonotoneAtPunctuation().
bool* Moses::ReorderingConstraint::m_wall [protected] |
flag for each word if it is a wall
Definition at line 52 of file ReorderingConstraint.h.
Referenced by FinalizeWalls(), GetWall(), InitializeWalls(), Moses::operator<<(), SetWall(), and ~ReorderingConstraint().
std::vector< std::pair<size_t,size_t> > Moses::ReorderingConstraint::m_zone [protected] |
Definition at line 54 of file ReorderingConstraint.h.
Referenced by Check(), FinalizeWalls(), GetZones(), Moses::operator<<(), and SetZone().