diff --git a/contrib/other-builds/moses2/FF/FeatureFunction.h b/contrib/other-builds/moses2/FF/FeatureFunction.h index ea2ffd279..31411377b 100644 --- a/contrib/other-builds/moses2/FF/FeatureFunction.h +++ b/contrib/other-builds/moses2/FF/FeatureFunction.h @@ -53,7 +53,7 @@ public: Scores *estimatedScores) const = 0; virtual void - EvaluateAfterTablePruning(const TargetPhrases &tps) const + EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, const Phrase &sourcePhrase) const {} // clean up temporary memory, called after processing each sentence diff --git a/contrib/other-builds/moses2/FF/FeatureFunctions.cpp b/contrib/other-builds/moses2/FF/FeatureFunctions.cpp index b9ce0d131..c08578544 100644 --- a/contrib/other-builds/moses2/FF/FeatureFunctions.cpp +++ b/contrib/other-builds/moses2/FF/FeatureFunctions.cpp @@ -189,10 +189,11 @@ FeatureFunctions::EvaluateInIsolation(MemPool &pool, const System &system, targetPhrase.SetEstimatedScore(estimatedScores.GetTotalScore()); } -void FeatureFunctions::EvaluateAfterTablePruning(const TargetPhrases &tps) const +void FeatureFunctions::EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, const Phrase &sourcePhrase) const { BOOST_FOREACH(const FeatureFunction *ff, m_featureFunctions) { - ff->EvaluateAfterTablePruning(tps); } + ff->EvaluateAfterTablePruning(pool, tps, sourcePhrase); + } } diff --git a/contrib/other-builds/moses2/FF/FeatureFunctions.h b/contrib/other-builds/moses2/FF/FeatureFunctions.h index bcd70bf44..be0f5b35e 100644 --- a/contrib/other-builds/moses2/FF/FeatureFunctions.h +++ b/contrib/other-builds/moses2/FF/FeatureFunctions.h @@ -54,7 +54,7 @@ public: // the pool here must be the system pool if the rule was loaded during load, or the mgr if it was loaded on demand void EvaluateInIsolation(MemPool &pool, const System &system, const Phrase &source, TargetPhrase &targetPhrase) const; - void EvaluateAfterTablePruning(const TargetPhrases &tps) const; + void EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, const Phrase &sourcePhrase) const; protected: std::vector m_featureFunctions; diff --git a/contrib/other-builds/moses2/FF/LexicalReordering.cpp b/contrib/other-builds/moses2/FF/LexicalReordering.cpp index a8c075c0c..bc7d4d725 100644 --- a/contrib/other-builds/moses2/FF/LexicalReordering.cpp +++ b/contrib/other-builds/moses2/FF/LexicalReordering.cpp @@ -140,18 +140,22 @@ void LexicalReordering::EvaluateInIsolation(MemPool &pool, { } -void LexicalReordering::EvaluateAfterTablePruning(const TargetPhrases &tps) const +void LexicalReordering::EvaluateAfterTablePruning(MemPool &pool, + const TargetPhrases &tps, + const Phrase &sourcePhrase) const { BOOST_FOREACH(const TargetPhrase *tp, tps) { - EvaluateAfterTablePruning(*tp); + EvaluateAfterTablePruning(pool, *tp, sourcePhrase); } } -void LexicalReordering::EvaluateAfterTablePruning(const TargetPhrase &targetPhrase) const +void LexicalReordering::EvaluateAfterTablePruning(MemPool &pool, + const TargetPhrase &targetPhrase, + const Phrase &sourcePhrase) const { /* if (m_compactModel) { - const Values values = m_compactModel->GetScore(source, targetPhrase, *m_blank); + const Values values = m_compactModel->GetScore(sourcePhrase, targetPhrase, *m_blank); if (values.size()) { assert(values.size() == 6); SCORE *scoreArr = pool.Allocate(6); @@ -168,7 +172,7 @@ void LexicalReordering::EvaluateAfterTablePruning(const TargetPhrase &targetPhra assert(m_coll); // cache data in target phrase - const Values *values = GetValues(source, targetPhrase); + const Values *values = GetValues(sourcePhrase, targetPhrase); if (values) { SCORE *scoreArr = pool.Allocate(6); for (size_t i = 0; i < 6; ++i) { diff --git a/contrib/other-builds/moses2/FF/LexicalReordering.h b/contrib/other-builds/moses2/FF/LexicalReordering.h index c33a9ac12..b7385100b 100644 --- a/contrib/other-builds/moses2/FF/LexicalReordering.h +++ b/contrib/other-builds/moses2/FF/LexicalReordering.h @@ -45,7 +45,9 @@ public: Scores *estimatedScores) const; virtual void - EvaluateAfterTablePruning(const TargetPhrases &tps) const; + EvaluateAfterTablePruning(MemPool &pool, + const TargetPhrases &tps, + const Phrase &sourcePhrase) const; virtual void EvaluateWhenApplied(const Manager &mgr, const Hypothesis &hypo, @@ -60,7 +62,9 @@ protected: FactorList m_FactorsC; virtual void - EvaluateAfterTablePruning(const TargetPhrase &targetPhrase) const; + EvaluateAfterTablePruning(MemPool &pool, + const TargetPhrase &targetPhrase, + const Phrase &sourcePhrase) const; // COMPACT MODEL LexicalReorderingTableCompact *m_compactModel; diff --git a/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp b/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp index 43a2cac06..8110ae32e 100644 --- a/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp +++ b/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp @@ -39,6 +39,7 @@ PhraseTableMemory::Node &PhraseTableMemory::Node::AddRule(PhraseImpl &source, Ta if (pos == source.GetSize()) { if (m_unsortedTPS == NULL) { m_unsortedTPS = new std::vector(); + m_source = &source; } m_unsortedTPS->push_back(target); @@ -88,7 +89,7 @@ void PhraseTableMemory::Node::SortAndPrune(size_t tableLimit, MemPool &pool, Sys } m_targetPhrases->SortAndPrune(tableLimit); - system.featureFunctions.EvaluateAfterTablePruning(*m_targetPhrases); + system.featureFunctions.EvaluateAfterTablePruning(system.systemPool, *m_targetPhrases, *m_source); delete m_unsortedTPS; } diff --git a/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.h b/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.h index 271187cd4..1a303909e 100644 --- a/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.h +++ b/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.h @@ -30,6 +30,7 @@ class PhraseTableMemory : public PhraseTable typedef boost::unordered_map, UnorderedComparer > Children; Children m_children; TargetPhrases *m_targetPhrases; + PhraseImpl *m_source; std::vector *m_unsortedTPS; Node &AddRule(PhraseImpl &source, TargetPhrase *target, size_t pos); diff --git a/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp b/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp index 1990cea69..fcfa9e69f 100644 --- a/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp +++ b/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp @@ -126,7 +126,7 @@ TargetPhrases* ProbingPT::CreateTargetPhrase(MemPool &pool, const System &system } tps->SortAndPrune(m_tableLimit); - system.featureFunctions.EvaluateAfterTablePruning(*tps); + system.featureFunctions.EvaluateAfterTablePruning(pool, *tps, sourcePhrase); } else { assert(query_result.second.size() == 0); diff --git a/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp b/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp index bd3889e09..508918ae2 100644 --- a/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp +++ b/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp @@ -78,7 +78,7 @@ TargetPhrases *UnknownWordPenalty::Lookup(const Manager &mgr, MemPool &pool, Inp system.featureFunctions.EvaluateInIsolation(memPool, system, source, *target); tps->AddTargetPhrase(*target); - system.featureFunctions.EvaluateAfterTablePruning(*tps); + system.featureFunctions.EvaluateAfterTablePruning(memPool, *tps, source); return tps; }