mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
FF registration is now in FeatureFactory::DefaultSetup, ...
... not in the FF constructor any more. This is related to a bug fix in Base.cpp, related to moving the LM OOV feature specification from the global space into the setup of individual LMs (to eliminate the dependence on StaticData in the LM constructors).
This commit is contained in:
parent
060a5f1b47
commit
bcb0212b5b
@ -153,6 +153,8 @@ void
|
||||
FeatureFactory
|
||||
::DefaultSetup(F *feature)
|
||||
{
|
||||
FeatureFunction::Register(feature);
|
||||
|
||||
StaticData &static_data = StaticData::InstanceNonConst();
|
||||
const std::string &featureName = feature->GetScoreProducerDescription();
|
||||
std::vector<float> weights = static_data.GetParameter()->GetWeights(featureName);
|
||||
|
@ -54,7 +54,8 @@ FeatureFunction(const std::string& line, bool registerNow)
|
||||
{
|
||||
m_numTuneableComponents = m_numScoreComponents;
|
||||
ParseLine(line);
|
||||
if (registerNow) Register();
|
||||
// if (registerNow) Register(); // now done in FeatureFactory::DefaultSetup()
|
||||
// TO DO: eliminate the registerNow parameter
|
||||
}
|
||||
|
||||
FeatureFunction::FeatureFunction(size_t numScoreComponents, const std::string& line, bool registerNow)
|
||||
@ -66,15 +67,16 @@ FeatureFunction::FeatureFunction(size_t numScoreComponents, const std::string& l
|
||||
{
|
||||
m_numTuneableComponents = m_numScoreComponents;
|
||||
ParseLine(line);
|
||||
if (registerNow) Register();
|
||||
// if (registerNow) Register(); // now done in FeatureFactory::DefaultSetup()
|
||||
// TO DO: eliminate the registerNow parameter
|
||||
}
|
||||
|
||||
void
|
||||
FeatureFunction::
|
||||
Register()
|
||||
Register(FeatureFunction* ff)
|
||||
{
|
||||
ScoreComponentCollection::RegisterScoreProducer(this);
|
||||
s_staticColl.push_back(this);
|
||||
ScoreComponentCollection::RegisterScoreProducer(ff);
|
||||
s_staticColl.push_back(ff);
|
||||
}
|
||||
|
||||
FeatureFunction::~FeatureFunction() {}
|
||||
|
@ -49,7 +49,8 @@ protected:
|
||||
//In case there's multiple producers with the same description
|
||||
static std::multiset<std::string> description_counts;
|
||||
|
||||
void Register();
|
||||
public:
|
||||
static void Register(FeatureFunction* ff);
|
||||
private:
|
||||
// void Initialize(const std::string &line);
|
||||
void ParseLine(const std::string &line);
|
||||
|
@ -75,7 +75,7 @@ LexicalReordering(const std::string &line)
|
||||
<< m_configuration->GetNumScoreComponents() << ")");
|
||||
|
||||
m_configuration->ConfigureSparse(sparseArgs, this);
|
||||
this->Register();
|
||||
// this->Register();
|
||||
}
|
||||
|
||||
LexicalReordering::
|
||||
|
@ -38,10 +38,10 @@ LanguageModel::LanguageModel(const std::string &line) :
|
||||
m_enableOOVFeature(false)
|
||||
{
|
||||
// load m_enableOOVFeature via SetParameter() first
|
||||
ReadParameters();
|
||||
// ReadParameters();
|
||||
this->m_numScoreComponents = this->m_numTuneableComponents = m_enableOOVFeature ? 2 : 1;
|
||||
// register with the correct m_numScoreComponents
|
||||
Register();
|
||||
// Register();
|
||||
}
|
||||
|
||||
|
||||
@ -112,6 +112,7 @@ void LanguageModel::SetParameter(const std::string& key, const std::string& valu
|
||||
{
|
||||
if(key == "oov-feature") {
|
||||
m_enableOOVFeature = Scan<bool>(value);
|
||||
this->m_numScoreComponents = this->m_numTuneableComponents = m_enableOOVFeature ? 2 : 1;
|
||||
} else {
|
||||
StatefulFeatureFunction::SetParameter(key, value);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ protected:
|
||||
public:
|
||||
virtual ~LanguageModelSingleFactor();
|
||||
bool IsUseable(const FactorMask &mask) const;
|
||||
void SetParameter(const std::string& key, const std::string& value);
|
||||
virtual void SetParameter(const std::string& key, const std::string& value);
|
||||
|
||||
const Factor *GetSentenceStart() const {
|
||||
return m_sentenceStart;
|
||||
|
@ -89,7 +89,12 @@ public:
|
||||
|
||||
|
||||
struct MockProducers {
|
||||
MockProducers() {}
|
||||
MockProducers()
|
||||
{
|
||||
FeatureFunction::Register(&single);
|
||||
FeatureFunction::Register(&multi);
|
||||
FeatureFunction::Register(&sparse);
|
||||
}
|
||||
|
||||
MockSingleFeature single;
|
||||
MockMultiFeature multi;
|
||||
|
@ -82,7 +82,7 @@ namespace Moses
|
||||
// * Don't use features that depend on generation steps that won't be run
|
||||
// yet at extract time
|
||||
SetFeaturesToApply();
|
||||
Register();
|
||||
// Register();
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user