From 96e3468912156f7a63a8a0ecfe74921eb627053e Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Mon, 4 Feb 2013 16:04:17 +0000 Subject: [PATCH] refactor WordPenaltyProducer --- moses/Parameter.cpp | 2 ++ moses/StaticData.cpp | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/moses/Parameter.cpp b/moses/Parameter.cpp index 158442ceb..9be6ca367 100644 --- a/moses/Parameter.cpp +++ b/moses/Parameter.cpp @@ -669,6 +669,8 @@ void Parameter::ConvertWeightArgs() ConvertWeightArgsSingleWeight("weight-e", "WordDeletion"); // TODO Can't find real name ConvertWeightArgsSingleWeight("weight-lex", "GlobalLexicalReordering"); // TODO Can't find real name + AddFeature("WordPenalty"); + } void Parameter::CreateWeightsMap() diff --git a/moses/StaticData.cpp b/moses/StaticData.cpp index 867b2aab3..c2aef3796 100644 --- a/moses/StaticData.cpp +++ b/moses/StaticData.cpp @@ -332,13 +332,6 @@ bool StaticData::LoadData(Parameter *parameter) } } - // word penalties - CHECK(m_parameter->GetWeights("WordPenalty", 0).size() == 1); - float weightWordPenalty = m_parameter->GetWeights("WordPenalty", 0)[0]; - m_wpProducer = new WordPenaltyProducer("WordPenalty"); - - SetWeight(m_wpProducer, weightWordPenalty); - const vector &weightsUnknownWord = m_parameter->GetWeights("UnknownWordPenalty", 0); float weightUnknownWord = weightsUnknownWord.size() ? weightsUnknownWord[0] : 1.0; @@ -641,6 +634,12 @@ SetWeight(m_unknownWordPenaltyProducer, weightUnknownWord); SetWeights(model, weights); m_distortionScoreProducer = model; } + else if (feature == "WordPenalty") { + WordPenaltyProducer *model = new WordPenaltyProducer(line); + const vector &weights = m_parameter->GetWeights(feature, featureIndex); + SetWeights(model, weights); + m_wpProducer = model; + } #ifdef HAVE_SYNLM else if (feature == "SyntacticLanguageModel") {