diff --git a/contrib/other-builds/moses2/FF/Distortion.cpp b/contrib/other-builds/moses2/FF/Distortion.cpp index fe8105d23..94ec31b5e 100644 --- a/contrib/other-builds/moses2/FF/Distortion.cpp +++ b/contrib/other-builds/moses2/FF/Distortion.cpp @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const { } diff --git a/contrib/other-builds/moses2/FF/Distortion.h b/contrib/other-builds/moses2/FF/Distortion.h index a126e2594..b1f069293 100644 --- a/contrib/other-builds/moses2/FF/Distortion.h +++ b/contrib/other-builds/moses2/FF/Distortion.h @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; diff --git a/contrib/other-builds/moses2/FF/FeatureFunction.h b/contrib/other-builds/moses2/FF/FeatureFunction.h index 35e49b68e..8e31c5f80 100644 --- a/contrib/other-builds/moses2/FF/FeatureFunction.h +++ b/contrib/other-builds/moses2/FF/FeatureFunction.h @@ -11,12 +11,12 @@ #include #include #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 &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 &sourcePhrase) const { } diff --git a/contrib/other-builds/moses2/FF/FeatureFunctions.cpp b/contrib/other-builds/moses2/FF/FeatureFunctions.cpp index 2f9ed0f8e..b790d3bbe 100644 --- a/contrib/other-builds/moses2/FF/FeatureFunctions.cpp +++ b/contrib/other-builds/moses2/FF/FeatureFunctions.cpp @@ -164,7 +164,7 @@ const PhraseTable *FeatureFunctions::GetPhraseTablesExcludeUnknownWordPenalty( } void FeatureFunctions::EvaluateInIsolation(MemPool &pool, const System &system, - const Phrase &source, TargetPhrase &targetPhrase) const + const Phrase &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 &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); - } - */ } diff --git a/contrib/other-builds/moses2/FF/FeatureFunctions.h b/contrib/other-builds/moses2/FF/FeatureFunctions.h index 0af000a22..239f6513f 100644 --- a/contrib/other-builds/moses2/FF/FeatureFunctions.h +++ b/contrib/other-builds/moses2/FF/FeatureFunctions.h @@ -12,6 +12,7 @@ #include #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 &source, TargetPhrase &targetPhrase) const; void EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, - const Phrase &sourcePhrase) const; + const Phrase &sourcePhrase) const; - /* - void EvaluateInIsolation(MemPool &pool, const System &system, - const Phrase &source, SCFG::TargetPhrase &targetPhrase) const; - */ protected: std::vector m_featureFunctions; std::vector m_statefulFeatureFunctions; diff --git a/contrib/other-builds/moses2/FF/LexicalReordering/LexicalReordering.cpp b/contrib/other-builds/moses2/FF/LexicalReordering/LexicalReordering.cpp index b2135bab6..384f34618 100644 --- a/contrib/other-builds/moses2/FF/LexicalReordering/LexicalReordering.cpp +++ b/contrib/other-builds/moses2/FF/LexicalReordering/LexicalReordering.cpp @@ -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 &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 &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 &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 &source, const Phrase &target) const { Key key(&source, &target); Coll::const_iterator iter; diff --git a/contrib/other-builds/moses2/FF/LexicalReordering/LexicalReordering.h b/contrib/other-builds/moses2/FF/LexicalReordering/LexicalReordering.h index 06e363af9..2d6eb0d1b 100644 --- a/contrib/other-builds/moses2/FF/LexicalReordering/LexicalReordering.h +++ b/contrib/other-builds/moses2/FF/LexicalReordering/LexicalReordering.h @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; virtual void EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, - const Phrase &sourcePhrase) const; + const Phrase &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 &sourcePhrase) const; // PROPERTY IN PT int m_propertyInd; // COMPACT MODEL LexicalReorderingTableCompact *m_compactModel; - Phrase *m_blank; + Phrase *m_blank; // MEMORY MODEL - typedef std::pair Key; + typedef std::pair*, const Phrase* > Key; typedef std::vector Values; struct KeyComparer @@ -99,7 +99,7 @@ protected: typedef boost::unordered_map Coll; Coll *m_coll; - const Values *GetValues(const Phrase &source, const Phrase &target) const; + const Values *GetValues(const Phrase &source, const Phrase &target) const; }; } /* namespace Moses2 */ diff --git a/contrib/other-builds/moses2/FF/PhrasePenalty.cpp b/contrib/other-builds/moses2/FF/PhrasePenalty.cpp index e4105259b..486f8e12b 100644 --- a/contrib/other-builds/moses2/FF/PhrasePenalty.cpp +++ b/contrib/other-builds/moses2/FF/PhrasePenalty.cpp @@ -23,7 +23,7 @@ PhrasePenalty::~PhrasePenalty() } void PhrasePenalty::EvaluateInIsolation(MemPool &pool, const System &system, - const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores, + const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const { scores.PlusEquals(system, *this, 1); diff --git a/contrib/other-builds/moses2/FF/PhrasePenalty.h b/contrib/other-builds/moses2/FF/PhrasePenalty.h index a7d70cb27..faa16aaff 100644 --- a/contrib/other-builds/moses2/FF/PhrasePenalty.h +++ b/contrib/other-builds/moses2/FF/PhrasePenalty.h @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; diff --git a/contrib/other-builds/moses2/FF/SkeletonStatefulFF.cpp b/contrib/other-builds/moses2/FF/SkeletonStatefulFF.cpp index aa2925c7b..a3a85a480 100644 --- a/contrib/other-builds/moses2/FF/SkeletonStatefulFF.cpp +++ b/contrib/other-builds/moses2/FF/SkeletonStatefulFF.cpp @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const { diff --git a/contrib/other-builds/moses2/FF/SkeletonStatefulFF.h b/contrib/other-builds/moses2/FF/SkeletonStatefulFF.h index eb588cdd3..16e39d47c 100644 --- a/contrib/other-builds/moses2/FF/SkeletonStatefulFF.h +++ b/contrib/other-builds/moses2/FF/SkeletonStatefulFF.h @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; diff --git a/contrib/other-builds/moses2/FF/SkeletonStatelessFF.cpp b/contrib/other-builds/moses2/FF/SkeletonStatelessFF.cpp index 8340fb3b2..a04d0bdb7 100644 --- a/contrib/other-builds/moses2/FF/SkeletonStatelessFF.cpp +++ b/contrib/other-builds/moses2/FF/SkeletonStatelessFF.cpp @@ -24,7 +24,7 @@ SkeletonStatelessFF::~SkeletonStatelessFF() } void SkeletonStatelessFF::EvaluateInIsolation(MemPool &pool, - const System &system, const Phrase &source, + const System &system, const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const { diff --git a/contrib/other-builds/moses2/FF/SkeletonStatelessFF.h b/contrib/other-builds/moses2/FF/SkeletonStatelessFF.h index 68f2179de..99fff34bd 100644 --- a/contrib/other-builds/moses2/FF/SkeletonStatelessFF.h +++ b/contrib/other-builds/moses2/FF/SkeletonStatelessFF.h @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; diff --git a/contrib/other-builds/moses2/FF/WordPenalty.cpp b/contrib/other-builds/moses2/FF/WordPenalty.cpp index 0fe8523ff..9be57d43c 100644 --- a/contrib/other-builds/moses2/FF/WordPenalty.cpp +++ b/contrib/other-builds/moses2/FF/WordPenalty.cpp @@ -25,7 +25,7 @@ WordPenalty::~WordPenalty() } void WordPenalty::EvaluateInIsolation(MemPool &pool, const System &system, - const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores, + const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const { SCORE score = -(SCORE) targetPhrase.GetSize(); diff --git a/contrib/other-builds/moses2/FF/WordPenalty.h b/contrib/other-builds/moses2/FF/WordPenalty.h index 2fe06ed88..b36afd08b 100644 --- a/contrib/other-builds/moses2/FF/WordPenalty.h +++ b/contrib/other-builds/moses2/FF/WordPenalty.h @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; diff --git a/contrib/other-builds/moses2/LM/KENLM.cpp b/contrib/other-builds/moses2/LM/KENLM.cpp index 9610018c2..01061ca04 100644 --- a/contrib/other-builds/moses2/LM/KENLM.cpp +++ b/contrib/other-builds/moses2/LM/KENLM.cpp @@ -130,7 +130,7 @@ void KENLM::EmptyHypothesisState(FFState &state, const ManagerBase &mgr, template void KENLM::EvaluateInIsolation(MemPool &pool, const System &system, - const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores, + const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const { // contains factors used by this LM @@ -231,7 +231,7 @@ void KENLM::EvaluateWhenApplied(const ManagerBase &mgr, } template -void KENLM::CalcScore(const Phrase &phrase, float &fullScore, +void KENLM::CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore, std::size_t &oovCount) const { fullScore = 0; diff --git a/contrib/other-builds/moses2/LM/KENLM.h b/contrib/other-builds/moses2/LM/KENLM.h index 406a0727e..1a6463af5 100644 --- a/contrib/other-builds/moses2/LM/KENLM.h +++ b/contrib/other-builds/moses2/LM/KENLM.h @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; @@ -60,7 +60,7 @@ protected: boost::shared_ptr m_ngram; - void CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore, + void CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore, std::size_t &oovCount) const; inline lm::WordIndex TranslateID(const Word &word) const diff --git a/contrib/other-builds/moses2/LM/LanguageModel.cpp b/contrib/other-builds/moses2/LM/LanguageModel.cpp index e5875e4fa..b1f3c269d 100644 --- a/contrib/other-builds/moses2/LM/LanguageModel.cpp +++ b/contrib/other-builds/moses2/LM/LanguageModel.cpp @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const { if (targetPhrase.GetSize() == 0) { diff --git a/contrib/other-builds/moses2/LM/LanguageModel.h b/contrib/other-builds/moses2/LM/LanguageModel.h index fc6872361..c4358d063 100644 --- a/contrib/other-builds/moses2/LM/LanguageModel.h +++ b/contrib/other-builds/moses2/LM/LanguageModel.h @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; diff --git a/contrib/other-builds/moses2/Phrase.cpp b/contrib/other-builds/moses2/Phrase.cpp index 78360db0f..ebbe85fb1 100644 --- a/contrib/other-builds/moses2/Phrase.cpp +++ b/contrib/other-builds/moses2/Phrase.cpp @@ -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 &) obj << " SCORES:" << obj.GetScores(); return out; } diff --git a/contrib/other-builds/moses2/Phrase.h b/contrib/other-builds/moses2/Phrase.h index e65bd9898..a5d8e5d53 100644 --- a/contrib/other-builds/moses2/Phrase.h +++ b/contrib/other-builds/moses2/Phrase.h @@ -24,6 +24,7 @@ class PhraseTable; class MemPool; class System; +template 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 &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 +inline std::ostream& operator<<(std::ostream &out, const Phrase &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 { friend std::ostream& operator<<(std::ostream &, const TargetPhrase &); @@ -170,10 +184,11 @@ struct CompareFutureScore }; //////////////////////////////////////////////////////////////////////// +template class PhraseOrdererLexical { public: - bool operator()(const Phrase &a, const Phrase &b) const + bool operator()(const Phrase &a, const Phrase &b) const { size_t minSize = std::min(a.GetSize(), b.GetSize()); for (size_t i = 0; i < minSize; ++i) { diff --git a/contrib/other-builds/moses2/PhraseBased/Hypothesis.cpp b/contrib/other-builds/moses2/PhraseBased/Hypothesis.cpp index 7bc76d7bc..c5b5672ff 100644 --- a/contrib/other-builds/moses2/PhraseBased/Hypothesis.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Hypothesis.cpp @@ -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 &phrase = GetTargetPhrase(); out << phrase << " "; } diff --git a/contrib/other-builds/moses2/PhraseBased/Hypothesis.h b/contrib/other-builds/moses2/PhraseBased/Hypothesis.h index 3bba0f18a..1fa6830f1 100644 --- a/contrib/other-builds/moses2/PhraseBased/Hypothesis.h +++ b/contrib/other-builds/moses2/PhraseBased/Hypothesis.h @@ -108,7 +108,7 @@ class HypothesisTargetPhraseOrderer public: bool operator()(const Hypothesis* a, const Hypothesis* b) const { - PhraseOrdererLexical phraseCmp; + PhraseOrdererLexical phraseCmp; bool ret = phraseCmp(a->GetTargetPhrase(), b->GetTargetPhrase()); /* std::cerr << (const Phrase&) a->GetTargetPhrase() << " ||| " diff --git a/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.cpp b/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.cpp index bf5ddb9dd..21f14eafb 100644 --- a/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.cpp +++ b/contrib/other-builds/moses2/PhraseBased/TargetPhraseImpl.cpp @@ -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&) obj << " SCORES:" << obj.GetScores(); return out; } diff --git a/contrib/other-builds/moses2/PhraseImpl.h b/contrib/other-builds/moses2/PhraseImpl.h index 1a125dd96..e1f4f674f 100644 --- a/contrib/other-builds/moses2/PhraseImpl.h +++ b/contrib/other-builds/moses2/PhraseImpl.h @@ -5,7 +5,7 @@ namespace Moses2 { -class PhraseImpl: public Phrase, public PhraseImplTemplate +class PhraseImpl: public Phrase, public PhraseImplTemplate { public: static PhraseImpl *CreateFromString(MemPool &pool, FactorCollection &vocab, diff --git a/contrib/other-builds/moses2/SCFG/PhraseImpl.h b/contrib/other-builds/moses2/SCFG/PhraseImpl.h index 73c80e05f..6bce2dd7d 100644 --- a/contrib/other-builds/moses2/SCFG/PhraseImpl.h +++ b/contrib/other-builds/moses2/SCFG/PhraseImpl.h @@ -8,7 +8,7 @@ namespace Moses2 namespace SCFG { -class PhraseImpl: public Phrase, public PhraseImplTemplate +class PhraseImpl: public Phrase, public PhraseImplTemplate { 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; } }; diff --git a/contrib/other-builds/moses2/SubPhrase.cpp b/contrib/other-builds/moses2/SubPhrase.cpp index b307dff2a..5635e59b3 100644 --- a/contrib/other-builds/moses2/SubPhrase.cpp +++ b/contrib/other-builds/moses2/SubPhrase.cpp @@ -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 { diff --git a/contrib/other-builds/moses2/SubPhrase.h b/contrib/other-builds/moses2/SubPhrase.h index a6e2eda7d..e6dccd710 100644 --- a/contrib/other-builds/moses2/SubPhrase.h +++ b/contrib/other-builds/moses2/SubPhrase.h @@ -4,11 +4,16 @@ namespace Moses2 { -class SubPhrase: public Phrase +class SubPhrase: public Phrase { friend std::ostream& operator<<(std::ostream &, const SubPhrase &); public: - SubPhrase(const Phrase &origPhrase, size_t start, size_t size); + SubPhrase(const Phrase &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 diff --git a/contrib/other-builds/moses2/TranslationModel/Memory/Node.h b/contrib/other-builds/moses2/TranslationModel/Memory/Node.h index e5f12967f..5da13ad21 100644 --- a/contrib/other-builds/moses2/TranslationModel/Memory/Node.h +++ b/contrib/other-builds/moses2/TranslationModel/Memory/Node.h @@ -9,6 +9,7 @@ #include #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 &source, TargetPhrase *target) { AddRule(source, target, 0); } - TargetPhrases *Find(const Phrase &source, size_t pos = 0) const + TargetPhrases *Find(const Phrase &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 *m_source; std::vector *m_unsortedTPS; - Node &AddRule(Phrase &source, TargetPhrase *target, size_t pos) + Node &AddRule(Phrase &source, TargetPhrase *target, size_t pos) { if (pos == source.GetSize()) { if (m_unsortedTPS == NULL) { diff --git a/contrib/other-builds/moses2/TranslationModel/Memory/PhraseTableMemory.cpp b/contrib/other-builds/moses2/TranslationModel/Memory/PhraseTableMemory.cpp index 4bf6f4401..4dbffa9d3 100644 --- a/contrib/other-builds/moses2/TranslationModel/Memory/PhraseTableMemory.cpp +++ b/contrib/other-builds/moses2/TranslationModel/Memory/PhraseTableMemory.cpp @@ -67,7 +67,7 @@ void PhraseTableMemory::Load(System &system) UTIL_THROW_IF2(toks.size() < 3, "Wrong format"); //cerr << "line=" << line << endl; - Phrase *source; + Phrase *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, diff --git a/contrib/other-builds/moses2/TranslationModel/PhraseTable.cpp b/contrib/other-builds/moses2/TranslationModel/PhraseTable.cpp index b21c0e463..e5a31983c 100644 --- a/contrib/other-builds/moses2/TranslationModel/PhraseTable.cpp +++ b/contrib/other-builds/moses2/TranslationModel/PhraseTable.cpp @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const { } diff --git a/contrib/other-builds/moses2/TranslationModel/PhraseTable.h b/contrib/other-builds/moses2/TranslationModel/PhraseTable.h index 62c111ca3..22941bde5 100644 --- a/contrib/other-builds/moses2/TranslationModel/PhraseTable.h +++ b/contrib/other-builds/moses2/TranslationModel/PhraseTable.h @@ -49,7 +49,7 @@ public: } virtual void - EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, + EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; diff --git a/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp b/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp index d93e178c4..d53e0f3f4 100644 --- a/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp +++ b/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp @@ -116,7 +116,7 @@ TargetPhrases* ProbingPT::Lookup(const Manager &mgr, MemPool &pool, return tpsAndKey.first; } */ - const Phrase &sourcePhrase = inputPath.subPhrase; + const Phrase &sourcePhrase = inputPath.subPhrase; // get hash for source phrase std::pair keyStruct = GetSourceProbingId(sourcePhrase); @@ -138,7 +138,7 @@ TargetPhrases* ProbingPT::Lookup(const Manager &mgr, MemPool &pool, } std::pair ProbingPT::GetSourceProbingId( - const Phrase &sourcePhrase) const + const Phrase &sourcePhrase) const { std::pair ret; @@ -161,7 +161,7 @@ std::pair ProbingPT::GetSourceProbingId( } TargetPhrases *ProbingPT::CreateTargetPhrase(MemPool &pool, - const System &system, const Phrase &sourcePhrase, uint64_t key) const + const System &system, const Phrase &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 &sourcePhrase, bool &ok, uint64_t probingSource[]) const { diff --git a/contrib/other-builds/moses2/TranslationModel/ProbingPT.h b/contrib/other-builds/moses2/TranslationModel/ProbingPT.h index 2b9f7950c..68d15263c 100644 --- a/contrib/other-builds/moses2/TranslationModel/ProbingPT.h +++ b/contrib/other-builds/moses2/TranslationModel/ProbingPT.h @@ -13,11 +13,11 @@ #include #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 &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 &sourcePhrase, bool &ok, uint64_t probingSource[]) const; inline const Factor *GetTargetFactor(uint32_t probingId) const @@ -69,7 +69,8 @@ protected: } std::pair GetSourceProbingId( - const Phrase &sourcePhrase) const; + const Phrase &sourcePhrase) const; + inline uint64_t GetSourceProbingId(const Factor *factor) const { size_t factorId = factor->GetId(); diff --git a/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp b/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp index ca165393e..3865a706e 100644 --- a/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp +++ b/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp @@ -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 &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const { diff --git a/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.h b/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.h index 0c8192a35..f981d79e0 100644 --- a/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.h +++ b/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.h @@ -23,7 +23,7 @@ public: InputPathBase &inputPath) const; virtual void - EvaluateInIsolation(const System &system, const Phrase &source, + EvaluateInIsolation(const System &system, const Phrase &source, const TargetPhrase &targetPhrase, Scores &scores, SCORE *estimatedScore) const; diff --git a/contrib/other-builds/moses2/legacy/CompactPT/LexicalReorderingTableCompact.cpp b/contrib/other-builds/moses2/legacy/CompactPT/LexicalReorderingTableCompact.cpp index c6a435010..4c8dfcdef 100644 --- a/contrib/other-builds/moses2/legacy/CompactPT/LexicalReorderingTableCompact.cpp +++ b/contrib/other-builds/moses2/legacy/CompactPT/LexicalReorderingTableCompact.cpp @@ -58,8 +58,8 @@ LexicalReorderingTableCompact::~LexicalReorderingTableCompact() delete m_scoreTrees[i]; } -std::vector LexicalReorderingTableCompact::GetScore(const Phrase& f, - const Phrase& e, const Phrase& c) +std::vector LexicalReorderingTableCompact::GetScore(const Phrase& f, + const Phrase& e, const Phrase& c) { std::string key; std::vector scores; @@ -89,8 +89,8 @@ std::vector LexicalReorderingTableCompact::GetScore(const Phrase& f, return std::vector(); } -std::string LexicalReorderingTableCompact::MakeKey(const Phrase& f, - const Phrase& e, const Phrase& c) const +std::string LexicalReorderingTableCompact::MakeKey(const Phrase& f, + const Phrase& e, const Phrase& c) const { return MakeKey(Trim(f.GetString(m_FactorsF)), Trim(e.GetString(m_FactorsE)), Trim(c.GetString(m_FactorsC))); diff --git a/contrib/other-builds/moses2/legacy/CompactPT/LexicalReorderingTableCompact.h b/contrib/other-builds/moses2/legacy/CompactPT/LexicalReorderingTableCompact.h index e73ee3ecf..90abf4197 100644 --- a/contrib/other-builds/moses2/legacy/CompactPT/LexicalReorderingTableCompact.h +++ b/contrib/other-builds/moses2/legacy/CompactPT/LexicalReorderingTableCompact.h @@ -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 - GetScore(const Phrase& f, const Phrase& e, const Phrase& c) = 0; + GetScore(const Phrase& f, const Phrase& e, const Phrase& c) = 0; virtual void InitializeForInput() @@ -59,7 +58,7 @@ public: ; virtual - void InitializeForInputPhrase(const Phrase&) + void InitializeForInputPhrase(const Phrase&) { } @@ -108,7 +107,7 @@ private: StringVector m_scoresMapped; StringVector m_scoresMemory; - std::string MakeKey(const Phrase& f, const Phrase& e, const Phrase& c) const; + std::string MakeKey(const Phrase& f, const Phrase& e, const Phrase& 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 - GetScore(const Phrase& f, const Phrase& e, const Phrase& c); + GetScore(const Phrase& f, const Phrase& e, const Phrase& c); static LexicalReorderingTable* CheckAndLoad(const std::string& filePath,