Reranker Framework (ReFr)
Reranking framework for structure prediction and discriminative language modeling
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
reranker::FeatureExtractor Class Referenceabstract

An abstract base class/interface for all feature extractors. More...

#include <feature-extractor.H>

Inheritance diagram for reranker::FeatureExtractor:
reranker::FactoryConstructible reranker::AbstractFileBackedFeatureExtractor reranker::ExampleFeatureExtractor reranker::NgramFeatureExtractor reranker::RankFeatureExtractor reranker::BasicFileBackedFeatureExtractor reranker::FileBackedLossSetter reranker::FileBackedNgramFeatureExtractor

Public Member Functions

 FeatureExtractor ()
 Constructs an empty feature vector. More...
 
virtual ~FeatureExtractor ()
 Destroys this vector. More...
 
virtual void Extract (Candidate &candidate, FeatureVector< int, double > &features)=0
 Extracts features for the specified candidate, where each feature is represented by an int for its unique identifier. More...
 
virtual void ExtractSymbolic (Candidate &candidate, FeatureVector< string, double > &symbolic_features)=0
 Extracts symbolic features for the specified candidate, where each feature is represented by a string for its unique identifier. More...
 
virtual void Reset ()
 Indicates to this instance that iteration over candidate sets on which features are being extracted has been reset. More...
 
virtual void Extract (CandidateSet &candidate_set)
 Extracts features for all the candidates in the specified CandidateSet. More...
 
- Public Member Functions inherited from reranker::FactoryConstructible
virtual ~FactoryConstructible ()
 
virtual void RegisterInitializers (Initializers &initializers)
 
virtual void Init (const Environment *env, const string &arg)
 

Detailed Description

An abstract base class/interface for all feature extractors.

Concrete subclasses need to register themselves with the FeatureExtractor Factory via the REGISTER_FEATURE_EXTRACTOR(MyDerivedClassName) macro.

Example:

my-feature-extractor.H:
class MyFeatureExtractor : public FeatureExtractor {
public:
...
};
my-feature-extractor.C:
REGISTER_FEATURE_EXTRACTOR(MyFeatureExtractor)
See Also
ExampleFeatureExtractor for a fully functional, if not quite useful, example FeatureExtractor implementation
feature-extractor-test.C for a working example employing a FeatureExtractor
ExecutiveFeatureExtractor for a class that can “execute” a suite of FeatureExtractor instances on a CandidateSet

Definition at line 86 of file feature-extractor.H.

Constructor & Destructor Documentation

reranker::FeatureExtractor::FeatureExtractor ( )
inline

Constructs an empty feature vector.

Definition at line 89 of file feature-extractor.H.

virtual reranker::FeatureExtractor::~FeatureExtractor ( )
inlinevirtual

Destroys this vector.

Definition at line 91 of file feature-extractor.H.

Member Function Documentation

virtual void reranker::FeatureExtractor::Extract ( Candidate candidate,
FeatureVector< int, double > &  features 
)
pure virtual

Extracts features for the specified candidate, where each feature is represented by an int for its unique identifier.

Implementation advice:
Please play nice with others! For efficiency, the feature vector you are modifying is the actual feature vector inside the specified Candidate. Please use FeatureVector::IncrementWeight wherever possible; only use FeatureVector::SetWeight if you truly want to blow away any existing weight for a feature.
Parameters
[in]candidatethe candidate for which to extract features
[out]featuresthe features extracted for the specified candidate

Implemented in reranker::ExampleFeatureExtractor, reranker::NgramFeatureExtractor, reranker::AbstractFileBackedFeatureExtractor, reranker::FileBackedNgramFeatureExtractor, reranker::FileBackedLossSetter, reranker::BasicFileBackedFeatureExtractor, and reranker::RankFeatureExtractor.

virtual void reranker::FeatureExtractor::Extract ( CandidateSet candidate_set)
inlinevirtual

Extracts features for all the candidates in the specified CandidateSet.

The default implementation here uses the concrete implementations of the Extract(Candidate&,FeatureVector<int,double>&) and ExtractSymbolic methods.

Parameters
candidate_setthe set of candidates for which to extract features.

Reimplemented in reranker::AbstractFileBackedFeatureExtractor, and reranker::RankFeatureExtractor.

Definition at line 139 of file feature-extractor.H.

virtual void reranker::FeatureExtractor::ExtractSymbolic ( Candidate candidate,
FeatureVector< string, double > &  symbolic_features 
)
pure virtual

Extracts symbolic features for the specified candidate, where each feature is represented by a string for its unique identifier.

Implementation advice:
Please play nice with others! For efficiency, the feature vector you are modifying is the actual feature vector inside the specified Candidate. Please use FeatureVector::IncrementWeight wherever possible; only use FeatureVector::SetWeight if you truly want to blow away any existing weight for a feature.
Parameters
[in]candidatethe candidate for which to extract features
[out]symbolic_featuresthe features extracted for the specified candidate

Implemented in reranker::ExampleFeatureExtractor, reranker::NgramFeatureExtractor, reranker::FileBackedNgramFeatureExtractor, reranker::AbstractFileBackedFeatureExtractor, reranker::FileBackedLossSetter, reranker::BasicFileBackedFeatureExtractor, and reranker::RankFeatureExtractor.

virtual void reranker::FeatureExtractor::Reset ( )
inlinevirtual

Indicates to this instance that iteration over candidate sets on which features are being extracted has been reset.

Concrete subclasses should override this method (which by default does nothing) if they need to do something special at the beginning of each iteration.

Reimplemented in reranker::AbstractFileBackedFeatureExtractor.

Definition at line 128 of file feature-extractor.H.


The documentation for this class was generated from the following file: