|
#pragma once |
|
#include <iostream> |
|
#include <vector> |
|
#include "../Vector.h" |
|
|
|
namespace Moses2 |
|
{ |
|
class System; |
|
class Sentence; |
|
class Bitmap; |
|
class MemPool; |
|
|
|
#define NOT_A_ZONE 999999999 |
|
|
|
class ReorderingConstraint |
|
{ |
|
protected: |
|
|
|
size_t m_size; |
|
bool *m_wall; |
|
|
|
size_t *m_localWall; |
|
Vector< std::pair<size_t,size_t> > m_zone; |
|
bool m_active; |
|
int m_max_distortion; |
|
MemPool &m_pool; |
|
|
|
ReorderingConstraint(const ReorderingConstraint &); |
|
|
|
public: |
|
|
|
|
|
ReorderingConstraint(MemPool &pool) |
|
: m_wall(NULL) |
|
, m_localWall(NULL) |
|
, m_active(false) |
|
, m_pool(pool) |
|
, m_zone(pool) |
|
{} |
|
|
|
|
|
~ReorderingConstraint(); |
|
|
|
|
|
void InitializeWalls(size_t size, int max_distortion); |
|
|
|
|
|
void FinalizeWalls(); |
|
|
|
|
|
void SetWall( size_t pos, bool value ); |
|
|
|
|
|
bool GetWall(size_t pos) const { |
|
return m_wall[pos]; |
|
} |
|
|
|
|
|
bool GetLocalWall(size_t pos, size_t zone ) const { |
|
return (m_localWall[pos] == zone); |
|
} |
|
|
|
|
|
void SetZone( size_t startPos, size_t endPos ); |
|
|
|
|
|
Vector< std::pair< size_t,size_t> > & GetZones() { |
|
return m_zone; |
|
} |
|
|
|
|
|
void SetMonotoneAtPunctuation( const Sentence & sentence ); |
|
|
|
|
|
bool Check( const Bitmap &bitmap, size_t start, size_t end ) const; |
|
|
|
|
|
bool IsActive() const { |
|
return m_active; |
|
} |
|
|
|
std::ostream &Debug(std::ostream &out, const System &system) const; |
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|