|
|
|
|
|
|
|
|
|
|
|
|
|
#include <cassert> |
|
#include <boost/foreach.hpp> |
|
#include "TargetPhrases.h" |
|
#include "TargetPhraseImpl.h" |
|
#include "../Phrase.h" |
|
#include "../TargetPhrase.h" |
|
|
|
using namespace std; |
|
|
|
namespace Moses2 |
|
{ |
|
|
|
TargetPhrases::TargetPhrases(MemPool &pool, size_t size) : |
|
m_coll(pool, size), m_currInd(0) |
|
{ |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TargetPhrases::~TargetPhrases() |
|
{ |
|
|
|
} |
|
|
|
std::string TargetPhrases::Debug(const System &system) const |
|
{ |
|
stringstream out; |
|
BOOST_FOREACH(const TargetPhraseImpl *tp, *this) { |
|
out << tp->Debug(system); |
|
out << endl; |
|
} |
|
return out.str(); |
|
} |
|
|
|
void TargetPhrases::SortAndPrune(size_t tableLimit) |
|
{ |
|
iterator iterMiddle; |
|
iterMiddle = |
|
(tableLimit == 0 || m_coll.size() < tableLimit) ? |
|
m_coll.end() : m_coll.begin() + tableLimit; |
|
|
|
std::partial_sort(m_coll.begin(), iterMiddle, m_coll.end(), |
|
CompareScoreForPruning<TP>()); |
|
|
|
if (tableLimit && m_coll.size() > tableLimit) { |
|
m_coll.resize(tableLimit); |
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|