mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
consistent comparitor for PB and SCFG
This commit is contained in:
parent
1c818b270b
commit
d6000cdd3d
@ -35,6 +35,9 @@ public:
|
||||
|
||||
virtual ~TargetPhraseImpl();
|
||||
|
||||
virtual SCORE GetScoreForPruning() const
|
||||
{ return GetFutureScore(); }
|
||||
|
||||
virtual std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user