mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-20 07:42:21 +03:00
allow num of features to be specified as an argument, rather than need to be passed into constructor
This commit is contained in:
parent
4caffffe7b
commit
4ca673df8e
@ -75,6 +75,12 @@ std::vector<FeatureFunction*> FeatureFunction::m_producers;
|
||||
std::vector<const StatelessFeatureFunction*> StatelessFeatureFunction::m_statelessFFs;
|
||||
std::vector<const StatefulFeatureFunction*> StatefulFeatureFunction::m_statefulFFs;
|
||||
|
||||
FeatureFunction::FeatureFunction(const std::string& description, const std::string &line)
|
||||
: ScoreProducer(description, line)
|
||||
{
|
||||
m_producers.push_back(this);
|
||||
}
|
||||
|
||||
FeatureFunction::FeatureFunction(const std::string& description, size_t numScoreComponents, const std::string &line)
|
||||
: ScoreProducer(description, numScoreComponents, line)
|
||||
{
|
||||
@ -100,6 +106,12 @@ bool StatelessFeatureFunction::ComputeValueInTranslationOption() const
|
||||
return false;
|
||||
}
|
||||
|
||||
StatefulFeatureFunction::StatefulFeatureFunction(const std::string& description, const std::string &line)
|
||||
: FeatureFunction(description, line)
|
||||
{
|
||||
m_statefulFFs.push_back(this);
|
||||
}
|
||||
|
||||
StatefulFeatureFunction::StatefulFeatureFunction(const std::string& description, size_t numScoreComponents, const std::string &line)
|
||||
: FeatureFunction(description,numScoreComponents, line)
|
||||
{
|
||||
|
@ -82,6 +82,7 @@ class FeatureFunction: public ScoreProducer
|
||||
public:
|
||||
static const std::vector<FeatureFunction*>& GetFeatureFunctions() { return m_producers; }
|
||||
|
||||
FeatureFunction(const std::string& description, const std::string &line);
|
||||
FeatureFunction(const std::string& description, size_t numScoreComponents, const std::string &line);
|
||||
virtual bool IsStateless() const = 0;
|
||||
virtual ~FeatureFunction();
|
||||
@ -135,7 +136,9 @@ class StatefulFeatureFunction: public FeatureFunction
|
||||
public:
|
||||
static const std::vector<const StatefulFeatureFunction*>& GetStatefulFeatureFunctions() {return m_statefulFFs;}
|
||||
|
||||
StatefulFeatureFunction(const std::string& description, const std::string &line);
|
||||
StatefulFeatureFunction(const std::string& description, size_t numScoreComponents, const std::string &line);
|
||||
|
||||
/**
|
||||
* \brief This interface should be implemented.
|
||||
* Notes: When evaluating the value of this feature function, you should avoid
|
||||
|
@ -10,7 +10,7 @@ using namespace std;
|
||||
namespace Moses
|
||||
{
|
||||
LexicalReordering::LexicalReordering(const std::string &line)
|
||||
: StatefulFeatureFunction("LexicalReordering", 6, line)
|
||||
: StatefulFeatureFunction("LexicalReordering", line)
|
||||
{
|
||||
std::cerr << "Initializing LexicalReordering.." << std::endl;
|
||||
|
||||
|
@ -14,6 +14,26 @@ namespace Moses
|
||||
multiset<string> ScoreProducer::description_counts;
|
||||
const size_t ScoreProducer::unlimited = -1;
|
||||
|
||||
ScoreProducer::ScoreProducer(const std::string& description, const std::string &line)
|
||||
: m_reportSparseFeatures(false)
|
||||
{
|
||||
ParseLine(line);
|
||||
m_numScoreComponents = FindNumFeatures();
|
||||
size_t index = description_counts.count(description);
|
||||
|
||||
ostringstream dstream;
|
||||
dstream << description;
|
||||
dstream << index;
|
||||
|
||||
description_counts.insert(description);
|
||||
|
||||
m_description = dstream.str();
|
||||
if (m_numScoreComponents != unlimited)
|
||||
{
|
||||
ScoreComponentCollection::RegisterScoreProducer(this);
|
||||
}
|
||||
}
|
||||
|
||||
ScoreProducer::ScoreProducer(const std::string& description, size_t numScoreComponents, const std::string &line)
|
||||
: m_reportSparseFeatures(false), m_numScoreComponents(numScoreComponents)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ protected:
|
||||
static std::multiset<std::string> description_counts;
|
||||
|
||||
ScoreProducer(const ScoreProducer&); // don't implement
|
||||
ScoreProducer(const std::string& description, const std::string &line);
|
||||
ScoreProducer(const std::string& description, size_t numScoreComponents, const std::string &line);
|
||||
|
||||
void ParseLine(const std::string &line);
|
||||
|
Loading…
Reference in New Issue
Block a user