templatize Phrase class

This commit is contained in:
Hieu Hoang 2016-04-26 12:23:18 +04:00
parent 9f66954c4b
commit 86cdcdb00c
38 changed files with 100 additions and 100 deletions

View File

@ -92,7 +92,7 @@ void Distortion::EmptyHypothesisState(FFState &state, const ManagerBase &mgr,
}
void Distortion::EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores,
const Phrase<Moses2::Word> &source, const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{
}

View File

@ -26,7 +26,7 @@ public:
const InputType &input, const Hypothesis &hypo) const;
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;

View File

@ -11,12 +11,12 @@
#include <string>
#include <vector>
#include "../TypeDef.h"
#include "../Phrase.h"
namespace Moses2
{
class System;
class Phrase;
class PhraseImpl;
class TargetPhrase;
class TargetPhrases;
@ -73,7 +73,7 @@ public:
// For SCFG decoding, the source contains non-terminals, NOT the raw
// source from the input sentence
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const = 0;
@ -86,7 +86,7 @@ public:
*/
virtual void EvaluateAfterTablePruning(MemPool &pool,
const TargetPhrases &tps, const Phrase &sourcePhrase) const
const TargetPhrases &tps, const Phrase<Moses2::Word> &sourcePhrase) const
{
}

View File

@ -164,7 +164,7 @@ const PhraseTable *FeatureFunctions::GetPhraseTablesExcludeUnknownWordPenalty(
}
void FeatureFunctions::EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, TargetPhrase &targetPhrase) const
const Phrase<Moses2::Word> &source, TargetPhrase &targetPhrase) const
{
SCORE estimatedScore = 0;
@ -177,27 +177,13 @@ void FeatureFunctions::EvaluateInIsolation(MemPool &pool, const System &system,
}
void FeatureFunctions::EvaluateAfterTablePruning(MemPool &pool,
const TargetPhrases &tps, const Phrase &sourcePhrase) const
const TargetPhrases &tps, const Phrase<Moses2::Word> &sourcePhrase) const
{
BOOST_FOREACH(const FeatureFunction *ff, m_featureFunctions){
ff->EvaluateAfterTablePruning(pool, tps, sourcePhrase);
}
}
/*
void
FeatureFunctions::EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, SCFG::TargetPhrase &targetPhrase) const
{
SCORE estimatedScore = 0;
BOOST_FOREACH(const FeatureFunction *ff, m_featureFunctions) {
Scores& scores = targetPhrase.GetScores();
ff->EvaluateInIsolation(pool, system, source, targetPhrase, scores, &estimatedScore);
}
//targetPhrase.SetEstimatedScore(estimatedScore);
}
*/
}

View File

@ -12,6 +12,7 @@
#include <string>
#include "../legacy/Parameter.h"
#include "FeatureRegistry.h"
#include "../Phrase.h"
namespace Moses2
{
@ -22,7 +23,6 @@ class StatefulFeatureFunction;
class PhraseTable;
class Manager;
class MemPool;
class Phrase;
class PhraseImpl;
class TargetPhrase;
class TargetPhrases;
@ -69,14 +69,10 @@ public:
// the pool here must be the system pool if the rule was loaded during load, or the mgr pool if it was loaded on demand
void EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, TargetPhrase &targetPhrase) const;
const Phrase<Moses2::Word> &source, TargetPhrase &targetPhrase) const;
void EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps,
const Phrase &sourcePhrase) const;
const Phrase<Moses2::Word> &sourcePhrase) const;
/*
void EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, SCFG::TargetPhrase &targetPhrase) const;
*/
protected:
std::vector<const FeatureFunction*> m_featureFunctions;
std::vector<const StatefulFeatureFunction*> m_statefulFeatureFunctions;

View File

@ -124,13 +124,13 @@ void LexicalReordering::EmptyHypothesisState(FFState &state,
}
void LexicalReordering::EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores,
const Phrase<Moses2::Word> &source, const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{
}
void LexicalReordering::EvaluateAfterTablePruning(MemPool &pool,
const TargetPhrases &tps, const Phrase &sourcePhrase) const
const TargetPhrases &tps, const Phrase<Moses2::Word> &sourcePhrase) const
{
BOOST_FOREACH(const TargetPhrase *tp, tps){
EvaluateAfterTablePruning(pool, *tp, sourcePhrase);
@ -138,7 +138,7 @@ void LexicalReordering::EvaluateAfterTablePruning(MemPool &pool,
}
void LexicalReordering::EvaluateAfterTablePruning(MemPool &pool,
const TargetPhrase &targetPhrase, const Phrase &sourcePhrase) const
const TargetPhrase &targetPhrase, const Phrase<Moses2::Word> &sourcePhrase) const
{
if (m_propertyInd >= 0) {
SCORE *scoreArr = targetPhrase.GetScoresProperty(m_propertyInd);
@ -190,7 +190,7 @@ void LexicalReordering::EvaluateWhenApplied(const ManagerBase &mgr,
}
const LexicalReordering::Values *LexicalReordering::GetValues(
const Phrase &source, const Phrase &target) const
const Phrase<Moses2::Word> &source, const Phrase<Moses2::Word> &target) const
{
Key key(&source, &target);
Coll::const_iterator iter;

View File

@ -39,13 +39,13 @@ public:
const InputType &input, const Hypothesis &hypo) const;
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;
virtual void
EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps,
const Phrase &sourcePhrase) const;
const Phrase<Moses2::Word> &sourcePhrase) const;
virtual void EvaluateWhenApplied(const ManagerBase &mgr,
const Hypothesis &hypo, const FFState &prevState, Scores &scores,
@ -61,17 +61,17 @@ protected:
virtual void
EvaluateAfterTablePruning(MemPool &pool, const TargetPhrase &targetPhrase,
const Phrase &sourcePhrase) const;
const Phrase<Moses2::Word> &sourcePhrase) const;
// PROPERTY IN PT
int m_propertyInd;
// COMPACT MODEL
LexicalReorderingTableCompact *m_compactModel;
Phrase *m_blank;
Phrase<Moses2::Word> *m_blank;
// MEMORY MODEL
typedef std::pair<const Phrase*, const Phrase*> Key;
typedef std::pair<const Phrase<Moses2::Word>*, const Phrase<Moses2::Word>* > Key;
typedef std::vector<SCORE> Values;
struct KeyComparer
@ -99,7 +99,7 @@ protected:
typedef boost::unordered_map<Key, Values, KeyComparer, KeyComparer> Coll;
Coll *m_coll;
const Values *GetValues(const Phrase &source, const Phrase &target) const;
const Values *GetValues(const Phrase<Moses2::Word> &source, const Phrase<Moses2::Word> &target) const;
};
} /* namespace Moses2 */

View File

@ -23,7 +23,7 @@ PhrasePenalty::~PhrasePenalty()
}
void PhrasePenalty::EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores,
const Phrase<Moses2::Word> &source, const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{
scores.PlusEquals(system, *this, 1);

View File

@ -19,7 +19,7 @@ public:
virtual ~PhrasePenalty();
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;

View File

@ -69,7 +69,7 @@ void SkeletonStatefulFF::EmptyHypothesisState(FFState &state,
}
void SkeletonStatefulFF::EvaluateInIsolation(MemPool &pool,
const System &system, const Phrase &source,
const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{

View File

@ -24,7 +24,7 @@ public:
const InputType &input, const Hypothesis &hypo) const;
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;

View File

@ -24,7 +24,7 @@ SkeletonStatelessFF::~SkeletonStatelessFF()
}
void SkeletonStatelessFF::EvaluateInIsolation(MemPool &pool,
const System &system, const Phrase &source,
const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{

View File

@ -19,7 +19,7 @@ public:
virtual ~SkeletonStatelessFF();
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;

View File

@ -25,7 +25,7 @@ WordPenalty::~WordPenalty()
}
void WordPenalty::EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores,
const Phrase<Moses2::Word> &source, const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{
SCORE score = -(SCORE) targetPhrase.GetSize();

View File

@ -20,7 +20,7 @@ public:
virtual ~WordPenalty();
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;

View File

@ -130,7 +130,7 @@ void KENLM<Model>::EmptyHypothesisState(FFState &state, const ManagerBase &mgr,
template<class Model>
void KENLM<Model>::EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores,
const Phrase<Moses2::Word> &source, const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{
// contains factors used by this LM
@ -231,7 +231,7 @@ void KENLM<Model>::EvaluateWhenApplied(const ManagerBase &mgr,
}
template<class Model>
void KENLM<Model>::CalcScore(const Phrase &phrase, float &fullScore,
void KENLM<Model>::CalcScore(const Phrase<Moses2::Word> &phrase, float &fullScore,
float &ngramScore, std::size_t &oovCount) const
{
fullScore = 0;

View File

@ -43,7 +43,7 @@ public:
const InputType &input, const Hypothesis &hypo) const;
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;
@ -60,7 +60,7 @@ protected:
boost::shared_ptr<Model> m_ngram;
void CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore,
void CalcScore(const Phrase<Moses2::Word> &phrase, float &fullScore, float &ngramScore,
std::size_t &oovCount) const;
inline lm::WordIndex TranslateID(const Word &word) const

View File

@ -142,7 +142,7 @@ void LanguageModel::EmptyHypothesisState(FFState &state, const ManagerBase &mgr,
}
void LanguageModel::EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores,
const Phrase<Moses2::Word> &source, const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{
if (targetPhrase.GetSize() == 0) {

View File

@ -59,7 +59,7 @@ public:
const InputType &input, const Hypothesis &hypo) const;
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;

View File

@ -38,7 +38,7 @@ SCORE *TargetPhrase::GetScoresProperty(int propertyInd) const
std::ostream& operator<<(std::ostream &out, const TargetPhrase &obj)
{
out << (const Phrase&) obj << " SCORES:" << obj.GetScores();
out << (const Phrase<Word> &) obj << " SCORES:" << obj.GetScores();
return out;
}

View File

@ -24,6 +24,7 @@ class PhraseTable;
class MemPool;
class System;
template<typename WORD>
class Phrase
{
friend std::ostream& operator<<(std::ostream &, const Phrase &);
@ -106,20 +107,33 @@ public:
};
////////////////////////////////////////////////////////////////////////
inline std::ostream& operator<<(std::ostream &out, const Phrase &obj)
inline std::ostream& operator<<(std::ostream &out, const Phrase<Moses2::Word> &obj)
{
if (obj.GetSize()) {
out << obj[0];
for (size_t i = 1; i < obj.GetSize(); ++i) {
const Word &word = obj[i];
const Moses2::Word &word = obj[i];
out << " " << word;
}
}
return out;
}
/*
template<typename WORD>
inline std::ostream& operator<<(std::ostream &out, const Phrase<WORD> &obj)
{
if (obj.GetSize()) {
out << obj[0];
for (size_t i = 1; i < obj.GetSize(); ++i) {
const WORD &word = obj[i];
out << " " << word;
}
}
return out;
}
*/
////////////////////////////////////////////////////////////////////////
class TargetPhrase: public Phrase
class TargetPhrase: public Phrase<Word>
{
friend std::ostream& operator<<(std::ostream &, const TargetPhrase &);
@ -170,10 +184,11 @@ struct CompareFutureScore
};
////////////////////////////////////////////////////////////////////////
template<typename WORD>
class PhraseOrdererLexical
{
public:
bool operator()(const Phrase &a, const Phrase &b) const
bool operator()(const Phrase<WORD> &a, const Phrase<WORD> &b) const
{
size_t minSize = std::min(a.GetSize(), b.GetSize());
for (size_t i = 0; i < minSize; ++i) {

View File

@ -14,6 +14,7 @@
#include "../InputPathBase.h"
#include "../System.h"
#include "../Scores.h"
#include "../Phrase.h"
#include "../FF/StatefulFeatureFunction.h"
using namespace std;
@ -114,7 +115,7 @@ void Hypothesis::OutputToStream(std::ostream &out) const
//cerr << *this << endl;
if (GetTargetPhrase().GetSize()) {
const Phrase &phrase = GetTargetPhrase();
const Phrase<Moses2::Word> &phrase = GetTargetPhrase();
out << phrase << " ";
}

View File

@ -108,7 +108,7 @@ class HypothesisTargetPhraseOrderer
public:
bool operator()(const Hypothesis* a, const Hypothesis* b) const
{
PhraseOrdererLexical phraseCmp;
PhraseOrdererLexical<Moses2::Word> phraseCmp;
bool ret = phraseCmp(a->GetTargetPhrase(), b->GetTargetPhrase());
/*
std::cerr << (const Phrase&) a->GetTargetPhrase() << " ||| "

View File

@ -50,7 +50,7 @@ TargetPhraseImpl::~TargetPhraseImpl()
std::ostream& operator<<(std::ostream &out, const TargetPhraseImpl &obj)
{
out << (const Phrase&) obj << " SCORES:" << obj.GetScores();
out << (const Phrase<Moses2::Word>&) obj << " SCORES:" << obj.GetScores();
return out;
}

View File

@ -5,7 +5,7 @@
namespace Moses2
{
class PhraseImpl: public Phrase, public PhraseImplTemplate<Word>
class PhraseImpl: public Phrase<Word>, public PhraseImplTemplate<Word>
{
public:
static PhraseImpl *CreateFromString(MemPool &pool, FactorCollection &vocab,

View File

@ -8,7 +8,7 @@ namespace Moses2
namespace SCFG
{
class PhraseImpl: public Phrase, public PhraseImplTemplate<SCFG::Word>
class PhraseImpl: public Phrase<SCFG::Word>, public PhraseImplTemplate<SCFG::Word>
{
public:
static PhraseImpl *CreateFromString(MemPool &pool, FactorCollection &vocab,
@ -36,8 +36,8 @@ public:
SubPhrase GetSubPhrase(size_t start, size_t size) const
{
SubPhrase ret(*this, start, size);
return ret;
//SubPhrase ret(*this, start, size);
//return ret;
}
};

View File

@ -10,10 +10,6 @@ using namespace std;
namespace Moses2
{
SubPhrase::SubPhrase(const Phrase &origPhrase, size_t start, size_t size) :
m_origPhrase(&origPhrase), m_start(start), m_size(size)
{
}
const Word &SubPhrase::operator[](size_t pos) const
{

View File

@ -4,11 +4,16 @@
namespace Moses2
{
class SubPhrase: public Phrase
class SubPhrase: public Phrase<Word>
{
friend std::ostream& operator<<(std::ostream &, const SubPhrase &);
public:
SubPhrase(const Phrase &origPhrase, size_t start, size_t size);
SubPhrase(const Phrase<Word> &origPhrase, size_t start, size_t size)
:m_origPhrase(&origPhrase)
,m_start(start)
,m_size(size)
{}
virtual const Word& operator[](size_t pos) const;
virtual size_t GetSize() const

View File

@ -9,6 +9,7 @@
#include <boost/foreach.hpp>
#include "../../PhraseBased/TargetPhrases.h"
#include "../../System.h"
#include "../../Phrase.h"
namespace Moses2
{
@ -32,12 +33,12 @@ public:
~Node()
{}
void AddRule(Phrase &source, TargetPhrase *target)
void AddRule(Phrase<WORD> &source, TargetPhrase *target)
{
AddRule(source, target, 0);
}
TargetPhrases *Find(const Phrase &source, size_t pos = 0) const
TargetPhrases *Find(const Phrase<WORD> &source, size_t pos = 0) const
{
assert(source.GetSize());
if (pos == source.GetSize()) {
@ -101,10 +102,10 @@ public:
protected:
Children m_children;
TargetPhrases *m_targetPhrases;
Phrase *m_source;
Phrase<WORD> *m_source;
std::vector<TargetPhrase*> *m_unsortedTPS;
Node &AddRule(Phrase &source, TargetPhrase *target, size_t pos)
Node &AddRule(Phrase<WORD> &source, TargetPhrase *target, size_t pos)
{
if (pos == source.GetSize()) {
if (m_unsortedTPS == NULL) {

View File

@ -67,7 +67,7 @@ void PhraseTableMemory::Load(System &system)
UTIL_THROW_IF2(toks.size() < 3, "Wrong format");
//cerr << "line=" << line << endl;
Phrase *source;
Phrase<Moses2::Word> *source;
TargetPhrase *target;
if (m_isPb) {
@ -79,8 +79,8 @@ void PhraseTableMemory::Load(System &system)
//cerr << "created target" << endl;
}
else {
source = SCFG::PhraseImpl::CreateFromString(tmpSourcePool, vocab, system,
toks[0]);
//source = SCFG::PhraseImpl::CreateFromString(tmpSourcePool, vocab, system,
// toks[0]);
//cerr << "created soure" << endl;
SCFG::TargetPhraseImpl *targetSCFG;
targetSCFG = SCFG::TargetPhraseImpl::CreateFromString(systemPool, *this,

View File

@ -82,7 +82,7 @@ TargetPhrases *PhraseTable::Lookup(const Manager &mgr, MemPool &pool,
}
void PhraseTable::EvaluateInIsolation(MemPool &pool, const System &system,
const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores,
const Phrase<Moses2::Word> &source, const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{
}

View File

@ -49,7 +49,7 @@ public:
}
virtual void
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source,
EvaluateInIsolation(MemPool &pool, const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;

View File

@ -116,7 +116,7 @@ TargetPhrases* ProbingPT::Lookup(const Manager &mgr, MemPool &pool,
return tpsAndKey.first;
}
*/
const Phrase &sourcePhrase = inputPath.subPhrase;
const Phrase<Moses2::Word> &sourcePhrase = inputPath.subPhrase;
// get hash for source phrase
std::pair<bool, uint64_t> keyStruct = GetSourceProbingId(sourcePhrase);
@ -138,7 +138,7 @@ TargetPhrases* ProbingPT::Lookup(const Manager &mgr, MemPool &pool,
}
std::pair<bool, uint64_t> ProbingPT::GetSourceProbingId(
const Phrase &sourcePhrase) const
const Phrase<Moses2::Word> &sourcePhrase) const
{
std::pair<bool, uint64_t> ret;
@ -161,7 +161,7 @@ std::pair<bool, uint64_t> ProbingPT::GetSourceProbingId(
}
TargetPhrases *ProbingPT::CreateTargetPhrase(MemPool &pool,
const System &system, const Phrase &sourcePhrase, uint64_t key) const
const System &system, const Phrase<Moses2::Word> &sourcePhrase, uint64_t key) const
{
TargetPhrases *tps = NULL;
@ -255,7 +255,7 @@ TargetPhrase *ProbingPT::CreateTargetPhrase(MemPool &pool, const System &system,
return tp;
}
void ProbingPT::ConvertToProbingSourcePhrase(const Phrase &sourcePhrase,
void ProbingPT::ConvertToProbingSourcePhrase(const Phrase<Moses2::Word> &sourcePhrase,
bool &ok, uint64_t probingSource[]) const
{

View File

@ -13,11 +13,11 @@
#include <deque>
#include "PhraseTable.h"
#include "../Vector.h"
#include "../Phrase.h"
namespace Moses2
{
class Phrase;
class QueryEngine;
class target_text;
class MemPool;
@ -53,11 +53,11 @@ protected:
TargetPhrases *Lookup(const Manager &mgr, MemPool &pool,
InputPathBase &inputPath) const;
TargetPhrases *CreateTargetPhrase(MemPool &pool, const System &system,
const Phrase &sourcePhrase, uint64_t key) const;
const Phrase<Moses2::Word> &sourcePhrase, uint64_t key) const;
TargetPhrase *CreateTargetPhrase(MemPool &pool, const System &system,
const char *&offset) const;
void ConvertToProbingSourcePhrase(const Phrase &sourcePhrase, bool &ok,
void ConvertToProbingSourcePhrase(const Phrase<Moses2::Word> &sourcePhrase, bool &ok,
uint64_t probingSource[]) const;
inline const Factor *GetTargetFactor(uint32_t probingId) const
@ -69,7 +69,8 @@ protected:
}
std::pair<bool, uint64_t> GetSourceProbingId(
const Phrase &sourcePhrase) const;
const Phrase<Moses2::Word> &sourcePhrase) const;
inline uint64_t GetSourceProbingId(const Factor *factor) const
{
size_t factorId = factor->GetId();

View File

@ -99,7 +99,7 @@ TargetPhrases *UnknownWordPenalty::Lookup(const Manager &mgr, MemPool &pool,
}
void UnknownWordPenalty::EvaluateInIsolation(const System &system,
const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores,
const Phrase<Moses2::Word> &source, const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const
{

View File

@ -23,7 +23,7 @@ public:
InputPathBase &inputPath) const;
virtual void
EvaluateInIsolation(const System &system, const Phrase &source,
EvaluateInIsolation(const System &system, const Phrase<Moses2::Word> &source,
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;

View File

@ -58,8 +58,8 @@ LexicalReorderingTableCompact::~LexicalReorderingTableCompact()
delete m_scoreTrees[i];
}
std::vector<float> LexicalReorderingTableCompact::GetScore(const Phrase& f,
const Phrase& e, const Phrase& c)
std::vector<float> LexicalReorderingTableCompact::GetScore(const Phrase<Moses2::Word>& f,
const Phrase<Moses2::Word>& e, const Phrase<Moses2::Word>& c)
{
std::string key;
std::vector<float> scores;
@ -89,8 +89,8 @@ std::vector<float> LexicalReorderingTableCompact::GetScore(const Phrase& f,
return std::vector<float>();
}
std::string LexicalReorderingTableCompact::MakeKey(const Phrase& f,
const Phrase& e, const Phrase& c) const
std::string LexicalReorderingTableCompact::MakeKey(const Phrase<Moses2::Word>& f,
const Phrase<Moses2::Word>& e, const Phrase<Moses2::Word>& c) const
{
return MakeKey(Trim(f.GetString(m_FactorsF)), Trim(e.GetString(m_FactorsE)),
Trim(c.GetString(m_FactorsC)));

View File

@ -26,11 +26,10 @@
#include "CanonicalHuffman.h"
#include "StringVector.h"
#include "../../TypeDef.h"
//#include "../../Phrase.h"
#include "../../Phrase.h"
namespace Moses2
{
class Phrase;
//! additional types
class LexicalReorderingTable
@ -49,7 +48,7 @@ public:
public:
virtual std::vector<float>
GetScore(const Phrase& f, const Phrase& e, const Phrase& c) = 0;
GetScore(const Phrase<Moses2::Word>& f, const Phrase<Moses2::Word>& e, const Phrase<Moses2::Word>& c) = 0;
virtual
void InitializeForInput()
@ -59,7 +58,7 @@ public:
;
virtual
void InitializeForInputPhrase(const Phrase&)
void InitializeForInputPhrase(const Phrase<Moses2::Word>&)
{
}
@ -108,7 +107,7 @@ private:
StringVector<unsigned char, unsigned long, MmapAllocator> m_scoresMapped;
StringVector<unsigned char, unsigned long, std::allocator> m_scoresMemory;
std::string MakeKey(const Phrase& f, const Phrase& e, const Phrase& c) const;
std::string MakeKey(const Phrase<Moses2::Word>& f, const Phrase<Moses2::Word>& e, const Phrase<Moses2::Word>& c) const;
std::string MakeKey(const std::string& f, const std::string& e,
const std::string& c) const;
@ -126,7 +125,7 @@ public:
~LexicalReorderingTableCompact();
virtual std::vector<float>
GetScore(const Phrase& f, const Phrase& e, const Phrase& c);
GetScore(const Phrase<Moses2::Word>& f, const Phrase<Moses2::Word>& e, const Phrase<Moses2::Word>& c);
static LexicalReorderingTable*
CheckAndLoad(const std::string& filePath,