mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
put target phrase into separate class
This commit is contained in:
parent
c847478b46
commit
56be628653
@ -7,6 +7,7 @@
|
||||
#include "LRState.h"
|
||||
#include "LexicalReordering.h"
|
||||
#include "../../Scores.h"
|
||||
#include "../../TargetPhrase.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "../TypeDef.h"
|
||||
#include "../Scores.h"
|
||||
#include "../Phrase.h"
|
||||
#include "../TargetPhrase.h"
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
|
@ -18,6 +18,7 @@ alias deps : ../../..//z ../../..//boost_iostreams ../../..//boost_filesystem .
|
||||
Scores.cpp
|
||||
SubPhrase.cpp
|
||||
System.cpp
|
||||
TargetPhrase.cpp
|
||||
TranslationTask.cpp
|
||||
Vector.cpp
|
||||
Weights.cpp
|
||||
|
@ -17,30 +17,7 @@ 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
|
||||
|
||||
|
@ -132,56 +132,6 @@ inline std::ostream& operator<<(std::ostream &out, const Phrase<WORD> &obj)
|
||||
return out;
|
||||
}
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
class TargetPhrase: public Phrase<Word>
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream &, const TargetPhrase &);
|
||||
|
||||
public:
|
||||
const PhraseTable &pt;
|
||||
mutable void **ffData;
|
||||
SCORE *scoreProperties;
|
||||
|
||||
TargetPhrase(MemPool &pool, const PhraseTable &pt, const System &system);
|
||||
|
||||
Scores &GetScores()
|
||||
{
|
||||
return *m_scores;
|
||||
}
|
||||
|
||||
const Scores &GetScores() const
|
||||
{
|
||||
return *m_scores;
|
||||
}
|
||||
|
||||
SCORE GetFutureScore() const;
|
||||
|
||||
void SetEstimatedScore(const SCORE &value)
|
||||
{
|
||||
m_estimatedScore = value;
|
||||
}
|
||||
|
||||
SCORE *GetScoresProperty(int propertyInd) const;
|
||||
|
||||
protected:
|
||||
Scores *m_scores;
|
||||
SCORE m_estimatedScore;
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
template<typename WORD>
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "../legacy/Bitmap.h"
|
||||
#include "../Scores.h"
|
||||
#include "../Phrase.h"
|
||||
#include "../TargetPhrase.h"
|
||||
#include "../InputPathBase.h"
|
||||
#include "../HypothesisBase.h"
|
||||
#include "../legacy/Range.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <deque>
|
||||
#include "../ManagerBase.h"
|
||||
#include "../Phrase.h"
|
||||
#include "../TargetPhrase.h"
|
||||
#include "../MemPool.h"
|
||||
#include "../Recycler.h"
|
||||
#include "../EstimatedScores.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <iostream>
|
||||
#include "../Phrase.h"
|
||||
#include "../PhraseImplTemplate.h"
|
||||
#include "../TargetPhrase.h"
|
||||
#include "../MemPool.h"
|
||||
#include "../Word.h"
|
||||
#include "../SubPhrase.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include "TargetPhrases.h"
|
||||
#include "../Phrase.h"
|
||||
#include "../TargetPhrase.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <iostream>
|
||||
#include "../Phrase.h"
|
||||
#include "../PhraseImplTemplate.h"
|
||||
#include "../TargetPhrase.h"
|
||||
#include "../MemPool.h"
|
||||
#include "../SubPhrase.h"
|
||||
#include "../AlignmentInfoCollection.h"
|
||||
|
39
contrib/other-builds/moses2/TargetPhrase.cpp
Normal file
39
contrib/other-builds/moses2/TargetPhrase.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* TargetPhrase.cpp
|
||||
*
|
||||
* Created on: 26 Apr 2016
|
||||
* Author: hieu
|
||||
*/
|
||||
|
||||
#include "TargetPhrase.h"
|
||||
#include "System.h"
|
||||
#include "Scores.h"
|
||||
|
||||
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 */
|
66
contrib/other-builds/moses2/TargetPhrase.h
Normal file
66
contrib/other-builds/moses2/TargetPhrase.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* TargetPhrase.h
|
||||
*
|
||||
* Created on: 26 Apr 2016
|
||||
* Author: hieu
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Phrase.h"
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
|
||||
class TargetPhrase: public Phrase<Word>
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream &, const TargetPhrase &);
|
||||
|
||||
public:
|
||||
const PhraseTable &pt;
|
||||
mutable void **ffData;
|
||||
SCORE *scoreProperties;
|
||||
|
||||
TargetPhrase(MemPool &pool, const PhraseTable &pt, const System &system);
|
||||
|
||||
Scores &GetScores()
|
||||
{
|
||||
return *m_scores;
|
||||
}
|
||||
|
||||
const Scores &GetScores() const
|
||||
{
|
||||
return *m_scores;
|
||||
}
|
||||
|
||||
SCORE GetFutureScore() const;
|
||||
|
||||
void SetEstimatedScore(const SCORE &value)
|
||||
{
|
||||
m_estimatedScore = value;
|
||||
}
|
||||
|
||||
SCORE *GetScoresProperty(int propertyInd) const;
|
||||
|
||||
protected:
|
||||
Scores *m_scores;
|
||||
SCORE m_estimatedScore;
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user