feature functions can be both sparse AND dense

This commit is contained in:
Hieu Hoang 2013-06-09 18:48:09 +01:00
parent d7ed014c5d
commit 82224a7a46
4 changed files with 21 additions and 10 deletions

View File

@ -1176,6 +1176,16 @@
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/FF/SourceWordDeletionFeature.h</locationURI>
</link>
<link>
<name>FF/SparsePhraseDictionaryFeature.cpp</name>
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/FF/SparsePhraseDictionaryFeature.cpp</locationURI>
</link>
<link>
<name>FF/SparsePhraseDictionaryFeature.h</name>
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/moses/FF/SparsePhraseDictionaryFeature.h</locationURI>
</link>
<link>
<name>FF/StatefulFeatureFunction.cpp</name>
<type>1</type>

View File

@ -439,10 +439,9 @@ void IOWrapper::OutputFeatureScores( std::ostream& out, const ScoreComponentColl
}
// sparse features
else {
const FVector scores = features.GetVectorForProducer( ff );
for(FVector::FNVmap::const_iterator i = scores.cbegin(); i != scores.cend(); i++)
out << " " << i->first << "= " << i->second;
const FVector scores = features.GetVectorForProducer( ff );
for(FVector::FNVmap::const_iterator i = scores.cbegin(); i != scores.cend(); i++) {
out << " " << i->first << "= " << i->second;
}
}

View File

@ -493,11 +493,9 @@ void OutputFeatureScores( std::ostream& out
}
// sparse features
else {
const FVector scores = features.GetVectorForProducer( ff );
for(FVector::FNVmap::const_iterator i = scores.cbegin(); i != scores.cend(); i++) {
out << " " << i->first << "= " << i->second;
}
const FVector scores = features.GetVectorForProducer( ff );
for(FVector::FNVmap::const_iterator i = scores.cbegin(); i != scores.cend(); i++) {
out << " " << i->first << "= " << i->second;
}
}

View File

@ -53,6 +53,7 @@ public:
virtual bool IsStateless() const = 0;
virtual ~FeatureFunction();
//! override to load model files
virtual void Load()
{}
@ -71,11 +72,13 @@ public:
return m_description;
}
//! if false, then this feature is not displayed in the n-best list.
// use with care
virtual bool IsTuneable() const {
return m_tuneable;
}
//!
//! Called before search and collecting of translation options
virtual void InitializeForInput(InputType const& source)
{}
@ -91,6 +94,7 @@ public:
// return true if the feature function can be evaluated
virtual bool IsUseable(const FactorMask &mask) const = 0;
// used by stateless ff. And stateful ff to make initial score estimate during loading of phrase table
virtual void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown