mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
templatize TargetPhrase class
This commit is contained in:
parent
56be628653
commit
23d3ec326d
@ -12,28 +12,4 @@
|
||||
namespace Moses2
|
||||
{
|
||||
|
||||
TargetPhrase::TargetPhrase(MemPool &pool, const PhraseTable &pt,
|
||||
const System &system) :
|
||||
pt(pt), scoreProperties(NULL)
|
||||
{
|
||||
m_scores = new (pool.Allocate<Scores>()) Scores(system, pool,
|
||||
system.featureFunctions.GetNumScores());
|
||||
}
|
||||
|
||||
SCORE TargetPhrase::GetFutureScore() const
|
||||
{
|
||||
return m_scores->GetTotalScore() + m_estimatedScore;
|
||||
}
|
||||
|
||||
SCORE *TargetPhrase::GetScoresProperty(int propertyInd) const
|
||||
{
|
||||
return scoreProperties ? scoreProperties + propertyInd : NULL;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream &out, const TargetPhrase &obj)
|
||||
{
|
||||
out << (const Phrase<Word> &) obj << " SCORES:" << obj.GetScores();
|
||||
return out;
|
||||
}
|
||||
|
||||
} /* namespace Moses2a */
|
||||
} /* namespace Moses2 */
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
#include "Phrase.h"
|
||||
#include "System.h"
|
||||
#include "Scores.h"
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
@ -20,34 +22,43 @@ public:
|
||||
mutable void **ffData;
|
||||
SCORE *scoreProperties;
|
||||
|
||||
TargetPhrase(MemPool &pool, const PhraseTable &pt, const System &system);
|
||||
TargetPhrase(MemPool &pool, const PhraseTable &pt, const System &system)
|
||||
: pt(pt)
|
||||
, scoreProperties(NULL)
|
||||
{
|
||||
m_scores = new (pool.Allocate<Scores>()) Scores(system, pool,
|
||||
system.featureFunctions.GetNumScores());
|
||||
}
|
||||
|
||||
|
||||
Scores &GetScores()
|
||||
{
|
||||
return *m_scores;
|
||||
}
|
||||
{ return *m_scores; }
|
||||
|
||||
const Scores &GetScores() const
|
||||
{
|
||||
return *m_scores;
|
||||
}
|
||||
{ return *m_scores; }
|
||||
|
||||
SCORE GetFutureScore() const;
|
||||
SCORE GetFutureScore() const
|
||||
{ return m_scores->GetTotalScore() + m_estimatedScore; }
|
||||
|
||||
void SetEstimatedScore(const SCORE &value)
|
||||
{
|
||||
m_estimatedScore = value;
|
||||
}
|
||||
{ m_estimatedScore = value; }
|
||||
|
||||
SCORE *GetScoresProperty(int propertyInd) const;
|
||||
SCORE *GetScoresProperty(int propertyInd) const
|
||||
{ return scoreProperties ? scoreProperties + propertyInd : NULL; }
|
||||
|
||||
protected:
|
||||
Scores *m_scores;
|
||||
SCORE m_estimatedScore;
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
inline std::ostream& operator<<(std::ostream &out, const TargetPhrase &obj)
|
||||
{
|
||||
out << (const Phrase<Word> &) obj << " SCORES:" << obj.GetScores();
|
||||
return out;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
struct CompareFutureScore
|
||||
{
|
||||
bool operator()(const TargetPhrase *a, const TargetPhrase *b) const
|
||||
|
Loading…
Reference in New Issue
Block a user