diff --git a/OnDiskPt/TargetPhrase.cpp b/OnDiskPt/TargetPhrase.cpp index 058c413b9..c3586e213 100644 --- a/OnDiskPt/TargetPhrase.cpp +++ b/OnDiskPt/TargetPhrase.cpp @@ -244,7 +244,8 @@ Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vectorSetScoreChart(&phraseDict, m_scores, weightT, lmList, wpProducer); + ret->SetScore(&phraseDict, m_scores); + ret->Evaluate(); // alignments int index = 0; diff --git a/moses/TargetPhrase.cpp b/moses/TargetPhrase.cpp index 042f6b6b1..366e8e3e1 100644 --- a/moses/TargetPhrase.cpp +++ b/moses/TargetPhrase.cpp @@ -191,58 +191,7 @@ void TargetPhrase::SetScore(const FeatureFunction* translationScoreProducer, m_fullScore = transScore + totalFullScore + totalOOVScore; } -void TargetPhrase::SetScoreChart(const FeatureFunction* translationScoreProducer, - const Scores &scoreVector - ,const vector &weightT - ,const LMList &languageModels - ,const WordPenaltyProducer* wpProducer) -{ - //cerr << *this << endl; - CHECK(weightT.size() == scoreVector.size()); - - // calc average score if non-best - m_scoreBreakdown.PlusEquals(translationScoreProducer, scoreVector); - // Replicated from TranslationOptions.cpp - float totalNgramScore = 0; - float totalFullScore = 0; - float totalOOVScore = 0; - - LMList::const_iterator lmIter; - for (lmIter = languageModels.begin(); lmIter != languageModels.end(); ++lmIter) { - const LanguageModel &lm = **lmIter; - - if (lm.Useable(*this)) { - // contains factors used by this LM - const float weightLM = lm.GetWeight(); - const float oovWeightLM = lm.GetOOVWeight(); - float fullScore, nGramScore; - size_t oovCount; - - lm.CalcScore(*this, fullScore, nGramScore, oovCount); - - if (StaticData::Instance().GetLMEnableOOVFeature()) { - vector scores(2); - scores[0] = nGramScore; - scores[1] = oovCount; - m_scoreBreakdown.Assign(&lm, scores); - totalOOVScore += oovCount * oovWeightLM; - } else { - m_scoreBreakdown.Assign(&lm, nGramScore); - } - - // total LM score so far - totalNgramScore += nGramScore * weightLM; - totalFullScore += fullScore * weightLM; - } - } - - // word penalty - size_t wordCount = GetNumTerminals(); - m_scoreBreakdown.Assign(wpProducer, - wordCount); - - m_fullScore = m_scoreBreakdown.GetWeightedScore() - totalNgramScore + totalFullScore + totalOOVScore; -} void TargetPhrase::SetScore(const FeatureFunction* producer, const Scores &scoreVector) { diff --git a/moses/TargetPhrase.h b/moses/TargetPhrase.h index 8ab356f61..dced06de9 100644 --- a/moses/TargetPhrase.h +++ b/moses/TargetPhrase.h @@ -88,12 +88,6 @@ public: float weightWP, const LMList &languageModels); - void SetScoreChart(const FeatureFunction* translationScoreProducer - ,const Scores &scoreVector - ,const std::vector &weightT - ,const LMList &languageModels - ,const WordPenaltyProducer* wpProducer); - void SetSparseScore(const FeatureFunction* translationScoreProducer, const StringPiece &sparseString); // used by for unknown word proc in chart decoding diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp b/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp index 6187265d1..38365f676 100644 --- a/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp +++ b/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp @@ -242,7 +242,8 @@ namespace Moses std::transform(scoreVector.begin(),scoreVector.end(),scoreVector.begin(),TransformScore); std::transform(scoreVector.begin(),scoreVector.end(),scoreVector.begin(),FloorScore); - targetPhrase->SetScoreChart(this, scoreVector, *m_weight, *m_languageModels, m_wpProducer); + targetPhrase->SetScore(this, scoreVector); + targetPhrase->Evaluate(); TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(rootNode, sourcePhrase, *targetPhrase, sourceLHS); phraseColl.Add(targetPhrase);