move code from LoadPhraseLengthFeature() to constructor in class PhraseLengthFeature

This commit is contained in:
Hieu Hoang 2013-01-02 16:54:38 +00:00
parent add63c23a7
commit b71d6c9b24
4 changed files with 12 additions and 17 deletions

View File

@ -8,6 +8,12 @@ namespace Moses {
using namespace std;
PhraseLengthFeature::PhraseLengthFeature(const std::string &line)
:StatelessFeatureFunction("pl", ScoreProducer::unlimited)
{
}
void PhraseLengthFeature::Evaluate(
const PhraseBasedFeatureContext& context,
ScoreComponentCollection* accumulator) const

View File

@ -17,9 +17,7 @@ namespace Moses
*/
class PhraseLengthFeature : public StatelessFeatureFunction {
public:
PhraseLengthFeature():
StatelessFeatureFunction("pl", ScoreProducer::unlimited)
{}
PhraseLengthFeature(const std::string &line);
void Evaluate(const PhraseBasedFeatureContext& context,
ScoreComponentCollection* accumulator) const;

View File

@ -580,6 +580,11 @@ SetWeight(m_unknownWordPenaltyProducer, weightUnknownWord);
const vector<float> &weights = m_parameter->GetWeights(feature, featureIndex);
//SetWeights(model, weights);
}
else if (feature == "pl") {
PhraseLengthFeature *model = new PhraseLengthFeature(line);
const vector<float> &weights = m_parameter->GetWeights(feature, featureIndex);
//SetWeights(model, weights);
}
}
@ -597,7 +602,6 @@ SetWeight(m_unknownWordPenaltyProducer, weightUnknownWord);
if (!LoadReferences()) return false;
if (!LoadDiscrimLMFeature()) return false;
if (!LoadPhrasePairFeature()) return false;
if (!LoadPhraseLengthFeature()) return false;
if (!LoadWordTranslationFeature()) return false;
// report individual sparse features in n-best list
@ -1420,18 +1424,6 @@ bool StaticData::LoadPhrasePairFeature()
return true;
}
bool StaticData::LoadPhraseLengthFeature()
{
if (m_parameter->isParamSpecified("phrase-length-feature")) {
PhraseLengthFeature *phraseLengthFeature = new PhraseLengthFeature();
if (m_parameter->GetParam("report-sparse-features").size() > 0) {
phraseLengthFeature->SetSparseFeatureReporting();
}
}
return true;
}
bool StaticData::LoadWordTranslationFeature()
{
const vector<string> &parameters = m_parameter->GetParam("word-translation-feature");

View File

@ -252,7 +252,6 @@ protected:
bool LoadReferences();
bool LoadDiscrimLMFeature();
bool LoadPhrasePairFeature();
bool LoadPhraseLengthFeature();
bool LoadWordTranslationFeature();
void ReduceTransOptCache() const;