mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-16 06:50:32 +03:00
vector -> pair
This commit is contained in:
parent
60b83e7963
commit
93dd29639a
@ -54,8 +54,8 @@ void ReorderingConstraint::SetWall( size_t pos, bool value )
|
|||||||
void ReorderingConstraint::FinalizeWalls()
|
void ReorderingConstraint::FinalizeWalls()
|
||||||
{
|
{
|
||||||
for(size_t z = 0; z < m_zone.size(); z++ ) {
|
for(size_t z = 0; z < m_zone.size(); z++ ) {
|
||||||
const size_t startZone = m_zone[z][0];
|
const size_t startZone = m_zone[z].first;
|
||||||
const size_t endZone = m_zone[z][1];// note: wall after endZone is not local
|
const size_t endZone = m_zone[z].second;// note: wall after endZone is not local
|
||||||
for( size_t pos = startZone; pos < endZone; pos++ ) {
|
for( size_t pos = startZone; pos < endZone; pos++ ) {
|
||||||
if (m_wall[ pos ]) {
|
if (m_wall[ pos ]) {
|
||||||
m_localWall[ pos ] = z;
|
m_localWall[ pos ] = z;
|
||||||
@ -65,8 +65,8 @@ void ReorderingConstraint::FinalizeWalls()
|
|||||||
// enforce that local walls only apply to innermost zone
|
// enforce that local walls only apply to innermost zone
|
||||||
else if (m_localWall[ pos ] != NOT_A_ZONE) {
|
else if (m_localWall[ pos ] != NOT_A_ZONE) {
|
||||||
size_t assigned_z = m_localWall[ pos ];
|
size_t assigned_z = m_localWall[ pos ];
|
||||||
if ((m_zone[assigned_z][0] < startZone) ||
|
if ((m_zone[assigned_z].first < startZone) ||
|
||||||
(m_zone[assigned_z][1] > endZone)) {
|
(m_zone[assigned_z].second > endZone)) {
|
||||||
m_localWall[ pos ] = z;
|
m_localWall[ pos ] = z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,9 +97,9 @@ void ReorderingConstraint::SetMonotoneAtPunctuation( const Phrase &sentence )
|
|||||||
void ReorderingConstraint::SetZone( size_t startPos, size_t endPos )
|
void ReorderingConstraint::SetZone( size_t startPos, size_t endPos )
|
||||||
{
|
{
|
||||||
VERBOSE(3,"SETTING zone " << startPos << "-" << endPos << std::endl);
|
VERBOSE(3,"SETTING zone " << startPos << "-" << endPos << std::endl);
|
||||||
std::vector< size_t > newZone;
|
std::pair<size_t,size_t> newZone;
|
||||||
newZone.push_back( startPos );
|
newZone.first = startPos;
|
||||||
newZone.push_back( endPos );
|
newZone.second = endPos;
|
||||||
m_zone.push_back( newZone );
|
m_zone.push_back( newZone );
|
||||||
m_active = true;
|
m_active = true;
|
||||||
}
|
}
|
||||||
@ -138,8 +138,8 @@ bool ReorderingConstraint::Check( const Bitmap &bitmap, size_t startPos, size_t
|
|||||||
|
|
||||||
// check zones
|
// check zones
|
||||||
for(size_t z = 0; z < m_zone.size(); z++ ) {
|
for(size_t z = 0; z < m_zone.size(); z++ ) {
|
||||||
const size_t startZone = m_zone[z][0];
|
const size_t startZone = m_zone[z].first;
|
||||||
const size_t endZone = m_zone[z][1];
|
const size_t endZone = m_zone[z].second;
|
||||||
|
|
||||||
// fine, if translation has not reached zone yet and phrase outside zone
|
// fine, if translation has not reached zone yet and phrase outside zone
|
||||||
if (lastPos < startZone && ( endPos < startZone || startPos > endZone ) ) {
|
if (lastPos < startZone && ( endPos < startZone || startPos > endZone ) ) {
|
||||||
@ -240,9 +240,8 @@ std::ostream& operator<<(std::ostream& out, const ReorderingConstraint &obj)
|
|||||||
{
|
{
|
||||||
out << "Zones:";
|
out << "Zones:";
|
||||||
for (size_t i = 0; i < obj.m_zone.size(); ++i) {
|
for (size_t i = 0; i < obj.m_zone.size(); ++i) {
|
||||||
const std::vector< size_t > &zone1 = obj.m_zone[i];
|
const std::pair<size_t,size_t> &zone1 = obj.m_zone[i];
|
||||||
UTIL_THROW_IF2(zone1.size() != 2, "m_zone[" << i << "] != 2");
|
out << zone1.first << "-" << zone1.second << " ";
|
||||||
out << zone1[0] << "-" << zone1[1] << " ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "Walls:";
|
out << "Walls:";
|
||||||
|
@ -51,7 +51,7 @@ protected:
|
|||||||
size_t m_size; /**< number of words in sentence */
|
size_t m_size; /**< number of words in sentence */
|
||||||
bool *m_wall; /**< flag for each word if it is a wall */
|
bool *m_wall; /**< flag for each word if it is a wall */
|
||||||
size_t *m_localWall; /**< flag for each word if it is a local wall */
|
size_t *m_localWall; /**< flag for each word if it is a local wall */
|
||||||
std::vector< std::vector< size_t > > m_zone; /** zones that limit reordering */
|
std::vector< std::pair<size_t,size_t> > m_zone; /** zones that limit reordering */
|
||||||
bool m_active; /**< flag indicating, if there are any active constraints */
|
bool m_active; /**< flag indicating, if there are any active constraints */
|
||||||
int m_max_distortion;
|
int m_max_distortion;
|
||||||
public:
|
public:
|
||||||
@ -93,7 +93,7 @@ public:
|
|||||||
void SetZone( size_t startPos, size_t endPos );
|
void SetZone( size_t startPos, size_t endPos );
|
||||||
|
|
||||||
//! returns the vector of zones
|
//! returns the vector of zones
|
||||||
std::vector< std::vector< size_t > > & GetZones() {
|
std::vector< std::pair<size_t,size_t> > & GetZones() {
|
||||||
return m_zone;
|
return m_zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user