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
2016-04-27 10:53:51 +03:00
#include "PhraseImplTemplate.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
{
2016-04-26 22:53:53 +03:00
template<typename WORD>
2016-04-27 10:53:51 +03:00
class TargetPhrase: public PhraseImplTemplate<WORD>
2016-04-26 13:40:57 +03:00
{
public:
const PhraseTable &pt;
mutable void **ffData;
SCORE *scoreProperties;
2016-04-27 10:53:51 +03:00
TargetPhrase(MemPool &pool, const PhraseTable &pt, const System &system, size_t size)
: PhraseImplTemplate<WORD>(pool, size)
, pt(pt)
2016-04-26 16:47:31 +03:00
, 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
2016-06-11 04:07:43 +03:00
virtual void Debug(std::ostream &out, const System &system) const
2016-06-11 00:03:11 +03:00
{
2016-06-11 04:07:43 +03:00
Phrase<WORD>::Debug(out, system);
2016-06-11 04:12:48 +03:00
out << " SCORES:";
GetScores().Debug(out, system);
2016-06-11 00:03:11 +03:00
}
2016-04-26 13:40:57 +03:00
protected:
Scores *m_scores;
SCORE m_estimatedScore;
};
2016-04-26 16:47:31 +03:00
///////////////////////////////////////////////////////////////////////
2016-04-26 22:53:53 +03:00
template<typename WORD>
2016-04-26 13:40:57 +03:00
struct CompareFutureScore
{
2016-04-26 22:53:53 +03:00
bool operator()(const TargetPhrase<WORD> *a, const TargetPhrase<WORD> *b) const
2016-04-26 13:40:57 +03:00
{
return a->GetFutureScore() > b->GetFutureScore();
}
2016-04-26 22:53:53 +03:00
bool operator()(const TargetPhrase<WORD> &a, const TargetPhrase<WORD> &b) const
2016-04-26 13:40:57 +03:00
{
return a.GetFutureScore() > b.GetFutureScore();
}
};
} /* namespace Moses2a */