refactor WordPenaltyProducer

This commit is contained in:
Hieu Hoang 2013-02-04 16:04:17 +00:00
parent 0aca60c4e7
commit 96e3468912
2 changed files with 8 additions and 7 deletions

View File

@ -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()

View File

@ -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<float> &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<float> &weights = m_parameter->GetWeights(feature, featureIndex);
SetWeights(model, weights);
m_wpProducer = model;
}
#ifdef HAVE_SYNLM
else if (feature == "SyntacticLanguageModel") {