mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 14:05:29 +03:00
move code from LoadPhraseLengthFeature() to constructor in class PhraseLengthFeature
This commit is contained in:
parent
add63c23a7
commit
b71d6c9b24
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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> ¶meters = m_parameter->GetParam("word-translation-feature");
|
||||
|
@ -252,7 +252,6 @@ protected:
|
||||
bool LoadReferences();
|
||||
bool LoadDiscrimLMFeature();
|
||||
bool LoadPhrasePairFeature();
|
||||
bool LoadPhraseLengthFeature();
|
||||
bool LoadWordTranslationFeature();
|
||||
|
||||
void ReduceTransOptCache() const;
|
||||
|
Loading…
Reference in New Issue
Block a user