mosesdecoder/contrib/other-builds/moses2/TargetPhrase.h

78 lines
1.7 KiB
C
Raw Normal View History

2016-04-26 13:40:57 +03:00
/*
* TargetPhrase.h
*
* Created on: 26 Apr 2016
* Author: hieu
*/
#pragma once
#include "Phrase.h"
2016-04-26 16:47:31 +03:00
#include "System.h"
#include "Scores.h"
2016-04-26 13:40:57 +03:00
namespace Moses2
{
class TargetPhrase: public Phrase<Word>
{
friend std::ostream& operator<<(std::ostream &, const TargetPhrase &);
public:
const PhraseTable &pt;
mutable void **ffData;
SCORE *scoreProperties;
2016-04-26 16:47:31 +03:00
TargetPhrase(MemPool &pool, const PhraseTable &pt, const System &system)
: pt(pt)
, scoreProperties(NULL)
2016-04-26 13:40:57 +03:00
{
2016-04-26 16:47:31 +03:00
m_scores = new (pool.Allocate<Scores>()) Scores(system, pool,
system.featureFunctions.GetNumScores());
2016-04-26 13:40:57 +03:00
}
2016-04-26 16:47:31 +03:00
Scores &GetScores()
{ return *m_scores; }
2016-04-26 13:40:57 +03:00
const Scores &GetScores() const
2016-04-26 16:47:31 +03:00
{ return *m_scores; }
2016-04-26 13:40:57 +03:00
2016-04-26 16:47:31 +03:00
SCORE GetFutureScore() const
{ return m_scores->GetTotalScore() + m_estimatedScore; }
2016-04-26 13:40:57 +03:00
void SetEstimatedScore(const SCORE &value)
2016-04-26 16:47:31 +03:00
{ m_estimatedScore = value; }
2016-04-26 13:40:57 +03:00
2016-04-26 16:47:31 +03:00
SCORE *GetScoresProperty(int propertyInd) const
{ return scoreProperties ? scoreProperties + propertyInd : NULL; }
2016-04-26 13:40:57 +03:00
protected:
Scores *m_scores;
SCORE m_estimatedScore;
};
2016-04-26 16:47:31 +03:00
///////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream &out, const TargetPhrase &obj)
{
out << (const Phrase<Word> &) obj << " SCORES:" << obj.GetScores();
return out;
}
///////////////////////////////////////////////////////////////////////
2016-04-26 13:40:57 +03:00
struct CompareFutureScore
{
bool operator()(const TargetPhrase *a, const TargetPhrase *b) const
{
return a->GetFutureScore() > b->GetFutureScore();
}
bool operator()(const TargetPhrase &a, const TargetPhrase &b) const
{
return a.GetFutureScore() > b.GetFutureScore();
}
};
} /* namespace Moses2a */