diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-04-25 21:24:02 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-04-25 21:24:02 +0400 |
commit | 75c85acd5e81e741345a41371010b25769b9f4b2 (patch) | |
tree | 0f249d7d40d85a8dd394381132d6da5457b38476 /moses/TranslationOption.cpp | |
parent | b53b93f09f589abddecc9e563eca46b9c1c67c06 (diff) |
delete PhraseDictionaryMemory. Use PhraseDictionarySCFG
Diffstat (limited to 'moses/TranslationOption.cpp')
-rw-r--r-- | moses/TranslationOption.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/moses/TranslationOption.cpp b/moses/TranslationOption.cpp index 6c8781caf..f2532aa44 100644 --- a/moses/TranslationOption.cpp +++ b/moses/TranslationOption.cpp @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "LexicalReordering.h" #include "StaticData.h" #include "InputType.h" +#include "DummyScoreProducers.h" using namespace std; @@ -51,13 +52,8 @@ TranslationOption::TranslationOption(const WordsRange &wordsRange : m_targetPhrase(targetPhrase) , m_sourceWordsRange (wordsRange) , m_futureScore(0) + ,m_scoreBreakdown(targetPhrase.GetScoreBreakdown()) { - if (up) { - const FeatureFunction *scoreProducer = (const FeatureFunction *)up; // not sure why none of the c++ cast works - vector<float> score(1); - score[0] = FloorScore(-numeric_limits<float>::infinity()); - m_scoreBreakdown.Assign(scoreProducer, score); - } } TranslationOption::TranslationOption(const TranslationOption ©, const WordsRange &sourceWordsRange) @@ -80,6 +76,9 @@ void TranslationOption::MergeNewFeatures(const Phrase& phrase, const ScoreCompon m_targetPhrase.MergeFactors(phrase, featuresToAdd); } m_scoreBreakdown.PlusEquals(score); + + // override word penalty, otherwise it doubles up when there are >1 translation models + m_scoreBreakdown.Assign(StaticData::Instance().GetWordPenaltyProducer(), -m_targetPhrase.GetSize()); } bool TranslationOption::IsCompatible(const Phrase& phrase, const std::vector<FactorType>& featuresToCheck) const @@ -110,13 +109,10 @@ void TranslationOption::CalcScore(const TranslationSystem* system) const LMList &lmList = StaticData::Instance().GetLMList(); lmList.CalcScore(GetTargetPhrase(), retFullScore, ngramScore, oovScore, &m_scoreBreakdown); - - size_t phraseSize = GetTargetPhrase().GetSize(); // future score m_futureScore = retFullScore - ngramScore + oovScore - + m_scoreBreakdown.InnerProduct(StaticData::Instance().GetAllWeights()) - phraseSize * - StaticData::Instance().GetWeightWordPenalty(); + + m_scoreBreakdown.GetWeightedScore(); } TO_STRING_BODY(TranslationOption); |