consistent comparitor for PB and SCFG

This commit is contained in:
Hieu Hoang 2016-07-15 16:35:38 +01:00
parent 1c818b270b
commit d6000cdd3d
5 changed files with 13 additions and 17 deletions

View File

@ -35,6 +35,9 @@ public:
virtual ~TargetPhraseImpl();
virtual SCORE GetScoreForPruning() const
{ return GetFutureScore(); }
virtual std::string Debug(const System &system) const;
protected:

View File

@ -56,7 +56,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<TP>());
CompareScoreForPruning<TP>());
if (tableLimit && m_coll.size() > tableLimit) {
m_coll.resize(tableLimit);

View File

@ -68,24 +68,15 @@ public:
void SetAlignmentInfo(const std::string &alignString);
virtual SCORE GetScoreForPruning() const
{ return sortScore; }
std::string Debug(const System &system) const;
//mutable void *chartState;
protected:
};
template<typename TP>
struct CompareSortScore
{
bool operator()(const TP *a, const TP *b) const
{
SCORE scoreA = a->sortScore;
SCORE scoreB = b->sortScore;
return scoreA > scoreB;
}
};
}
}

View File

@ -41,7 +41,7 @@ void TargetPhrases::SortAndPrune(size_t tableLimit)
m_coll.end() : m_coll.begin() + tableLimit;
std::partial_sort(m_coll.begin(), iterMiddle, m_coll.end(),
CompareSortScore<SCFG::TargetPhraseImpl>());
CompareScoreForPruning<SCFG::TargetPhraseImpl>());
if (tableLimit && m_coll.size() > tableLimit) {
m_coll.resize(tableLimit);

View File

@ -40,6 +40,8 @@ public:
SCORE GetFutureScore() const
{ return m_scores->GetTotalScore() + m_estimatedScore; }
virtual SCORE GetScoreForPruning() const = 0;
void SetEstimatedScore(const SCORE &value)
{ m_estimatedScore = value; }
@ -62,16 +64,16 @@ protected:
///////////////////////////////////////////////////////////////////////
template<typename TP>
struct CompareFutureScore
struct CompareScoreForPruning
{
bool operator()(const TP *a, const TP *b) const
{
return a->GetFutureScore() > b->GetFutureScore();
return a->GetScoreForPruning() > b->GetScoreForPruning();
}
bool operator()(const TP &a, const TP &b) const
{
return a.GetFutureScore() > b.GetFutureScore();
return a.GetScoreForPruning() > b.GetScoreForPruning();
}
};