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 | Protected Member Functions | Protected Attributes | List of all members
reranker::AbstractFileBackedFeatureExtractor Class Referenceabstract

This class makes it easy for concrete subclasses to extract features based on input from a file. More...

#include <abstract-file-backed-feature-extractor.H>

Inheritance diagram for reranker::AbstractFileBackedFeatureExtractor:
reranker::FeatureExtractor reranker::FactoryConstructible reranker::BasicFileBackedFeatureExtractor reranker::FileBackedLossSetter reranker::FileBackedNgramFeatureExtractor

Public Member Functions

 AbstractFileBackedFeatureExtractor ()
 Constructs an instance. More...
 
virtual ~AbstractFileBackedFeatureExtractor ()
 Destroys this instance. More...
 
virtual void RegisterInitializers (Initializers &initializers)
 Registers the data member to be initialized when an instance of this class is constructed by a Factory. More...
 
virtual void Init (const Environment *env, const string &arg)
 This method is guaranteed to be inokved by a Factory after invoking the RegisterInitializers method just after construction. 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...
 
virtual long line_number () const
 Returns the current number of lines read by this feature extractor from the underlying stream. More...
 
- Public Member Functions inherited from reranker::FeatureExtractor
 FeatureExtractor ()
 Constructs an empty feature vector. More...
 
virtual ~FeatureExtractor ()
 Destroys this vector. More...
 
- Public Member Functions inherited from reranker::FactoryConstructible
virtual ~FactoryConstructible ()
 

Protected Member Functions

virtual void ReadFromStream ()
 Reads from the stream. More...
 

Protected Attributes

string filename_
 The name of the file backing this feature extractor. More...
 
istream * is_
 The stream created from the file backing this feature extractor. More...
 
string line_
 The last line read by this feature extractor. More...
 
long line_number_
 The number of lines read so far by this feature extractor. More...
 
Tokenizer tokenizer_
 A simple whitespace tokenizer for use by concrete subclasses. More...
 

Detailed Description

This class makes it easy for concrete subclasses to extract features based on input from a file.

Definition at line 57 of file abstract-file-backed-feature-extractor.H.

Constructor & Destructor Documentation

reranker::AbstractFileBackedFeatureExtractor::AbstractFileBackedFeatureExtractor ( )
inline

Constructs an instance.

Definition at line 60 of file abstract-file-backed-feature-extractor.H.

virtual reranker::AbstractFileBackedFeatureExtractor::~AbstractFileBackedFeatureExtractor ( )
inlinevirtual

Destroys this instance.

Definition at line 63 of file abstract-file-backed-feature-extractor.H.

Member Function Documentation

virtual void reranker::AbstractFileBackedFeatureExtractor::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

Implements reranker::FeatureExtractor.

Implemented in reranker::FileBackedNgramFeatureExtractor, reranker::FileBackedLossSetter, and reranker::BasicFileBackedFeatureExtractor.

virtual void reranker::AbstractFileBackedFeatureExtractor::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 from reranker::FeatureExtractor.

Definition at line 127 of file abstract-file-backed-feature-extractor.H.

virtual void reranker::AbstractFileBackedFeatureExtractor::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

Implements reranker::FeatureExtractor.

Implemented in reranker::FileBackedNgramFeatureExtractor, reranker::FileBackedLossSetter, and reranker::BasicFileBackedFeatureExtractor.

virtual void reranker::AbstractFileBackedFeatureExtractor::Init ( const Environment env,
const string &  arg 
)
inlinevirtual

This method is guaranteed to be inokved by a Factory after invoking the RegisterInitializers method just after construction.

Parameters
envthe environment just after initializing this object
argthe string parsed by the Factory
See Also
Factory::CreateOrDie

Reimplemented from reranker::FactoryConstructible.

Reimplemented in reranker::FileBackedLossSetter.

Definition at line 99 of file abstract-file-backed-feature-extractor.H.

virtual long reranker::AbstractFileBackedFeatureExtractor::line_number ( ) const
inlinevirtual

Returns the current number of lines read by this feature extractor from the underlying stream.

Definition at line 140 of file abstract-file-backed-feature-extractor.H.

virtual void reranker::AbstractFileBackedFeatureExtractor::ReadFromStream ( )
inlineprotectedvirtual

Reads from the stream.

The default implementation here reads a single line and puts it into the protected line_ member.

Definition at line 145 of file abstract-file-backed-feature-extractor.H.

virtual void reranker::AbstractFileBackedFeatureExtractor::RegisterInitializers ( Initializers initializers)
inlinevirtual

Registers the data member to be initialized when an instance of this class is constructed by a Factory.

Variable name Type Required Description Default value
filename string Yes The name of the file backing this feature extractor. n/a

Reimplemented from reranker::FactoryConstructible.

Reimplemented in reranker::FileBackedNgramFeatureExtractor, and reranker::FileBackedLossSetter.

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

virtual void reranker::AbstractFileBackedFeatureExtractor::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 from reranker::FeatureExtractor.

Definition at line 113 of file abstract-file-backed-feature-extractor.H.

Member Data Documentation

string reranker::AbstractFileBackedFeatureExtractor::filename_
protected

The name of the file backing this feature extractor.

Definition at line 160 of file abstract-file-backed-feature-extractor.H.

istream* reranker::AbstractFileBackedFeatureExtractor::is_
protected

The stream created from the file backing this feature extractor.

Definition at line 162 of file abstract-file-backed-feature-extractor.H.

string reranker::AbstractFileBackedFeatureExtractor::line_
protected

The last line read by this feature extractor.

Definition at line 164 of file abstract-file-backed-feature-extractor.H.

long reranker::AbstractFileBackedFeatureExtractor::line_number_
protected

The number of lines read so far by this feature extractor.

Definition at line 166 of file abstract-file-backed-feature-extractor.H.

Tokenizer reranker::AbstractFileBackedFeatureExtractor::tokenizer_
protected

A simple whitespace tokenizer for use by concrete subclasses.

Definition at line 168 of file abstract-file-backed-feature-extractor.H.


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