Change CompareFutureScore()

This commit is contained in:
Hieu Hoang 2016-06-13 13:59:26 +01:00
parent 14bfbdc5e3
commit 8f4764f1bc
3 changed files with 8 additions and 7 deletions

View File

@ -54,7 +54,7 @@ void TargetPhrases::SortAndPrune(size_t tableLimit)
m_coll.end() : m_coll.begin() + tableLimit;
std::partial_sort(m_coll.begin(), iterMiddle, m_coll.end(),
CompareFutureScore<Word>());
CompareFutureScore<TP>());
if (tableLimit && m_coll.size() > tableLimit) {
m_coll.resize(tableLimit);

View File

@ -19,7 +19,8 @@ class System;
class TargetPhrases
{
typedef Array<const TargetPhrase<Moses2::Word>*> Coll;
typedef TargetPhrase<Moses2::Word> TP;
typedef Array<const TP*> Coll;
public:
typedef Coll::iterator iterator;
typedef Coll::const_iterator const_iterator;
@ -37,7 +38,7 @@ public:
//TargetPhrases(MemPool &pool, const System &system, const TargetPhrases &copy);
virtual ~TargetPhrases();
void AddTargetPhrase(const TargetPhrase<Moses2::Word> &targetPhrase)
void AddTargetPhrase(const TP &targetPhrase)
{
m_coll[m_currInd++] = &targetPhrase;
}
@ -47,7 +48,7 @@ public:
return m_coll.size();
}
const TargetPhrase<Moses2::Word>& operator[](size_t ind) const
const TP& operator[](size_t ind) const
{
return *m_coll[ind];
}

View File

@ -58,15 +58,15 @@ protected:
};
///////////////////////////////////////////////////////////////////////
template<typename WORD>
template<typename TP>
struct CompareFutureScore
{
bool operator()(const TargetPhrase<WORD> *a, const TargetPhrase<WORD> *b) const
bool operator()(const TP *a, const TP *b) const
{
return a->GetFutureScore() > b->GetFutureScore();
}
bool operator()(const TargetPhrase<WORD> &a, const TargetPhrase<WORD> &b) const
bool operator()(const TP &a, const TP &b) const
{
return a.GetFutureScore() > b.GetFutureScore();
}