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 | List of all members
reranker::BasicFileBackedFeatureExtractor Class Reference

A class to read one line at a time from a backing file, and tokenize that line based on whitespace, and then interpret each token as a feature-value pair via a protected method ExtractFeatureValuePair (see the documentation for that method for details on how tokens are interpreted as feature-value pairs). More...

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

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

Public Member Functions

 BasicFileBackedFeatureExtractor ()
 Constructs an instance. More...
 
virtual ~BasicFileBackedFeatureExtractor ()
 Destroys this instance. More...
 
virtual void Extract (Candidate &candidate, FeatureVector< int, double > &features)
 Does nothing. More...
 
virtual void ExtractSymbolic (Candidate &candidate, FeatureVector< string, double > &symbolic_features)
 Extracts symbolic features based on the most recent line read from the file (or stream) that backs this feature extractor. More...
 
- Public Member Functions inherited from reranker::AbstractFileBackedFeatureExtractor
 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 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 ExtractFeatureValuePair (const string &s, string &feature, double &value)
 Extracts a symbolic feature and value from the specified string. More...
 
- Protected Member Functions inherited from reranker::AbstractFileBackedFeatureExtractor
virtual void ReadFromStream ()
 Reads from the stream. More...
 

Additional Inherited Members

- Protected Attributes inherited from reranker::AbstractFileBackedFeatureExtractor
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

A class to read one line at a time from a backing file, and tokenize that line based on whitespace, and then interpret each token as a feature-value pair via a protected method ExtractFeatureValuePair (see the documentation for that method for details on how tokens are interpreted as feature-value pairs).

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

Constructor & Destructor Documentation

reranker::BasicFileBackedFeatureExtractor::BasicFileBackedFeatureExtractor ( )
inline

Constructs an instance.

Definition at line 61 of file basic-file-backed-feature-extractor.H.

virtual reranker::BasicFileBackedFeatureExtractor::~BasicFileBackedFeatureExtractor ( )
inlinevirtual

Destroys this instance.

Definition at line 64 of file basic-file-backed-feature-extractor.H.

Member Function Documentation

virtual void reranker::BasicFileBackedFeatureExtractor::Extract ( Candidate candidate,
FeatureVector< int, double > &  features 
)
inlinevirtual
virtual void reranker::BasicFileBackedFeatureExtractor::ExtractFeatureValuePair ( const string &  s,
string &  feature,
double &  value 
)
inlineprotectedvirtual

Extracts a symbolic feature and value from the specified string.

The specified string may have one of three forms:

StringFeature nameFeature weight
foofoo1.0
foo=foo1.0
foo=value foo value

where value is the (string representation of) a floating-point value.

Parameters
[in]sthe string from which to extract a feature-value pair
[out]featurethe symbolic feature name extracted from the specified string s
[out]valuethe symbolic feature’s value extracted from the specified string s

Definition at line 97 of file basic-file-backed-feature-extractor.H.

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

Extracts symbolic features based on the most recent line read from the file (or stream) that backs this feature extractor.

The line is tokenized based on whitespace, and each token is transformed into a feature-value pair via the ExtractFeatureValuePair method.

Implements reranker::AbstractFileBackedFeatureExtractor.

Reimplemented in reranker::FileBackedNgramFeatureExtractor.

Definition at line 43 of file basic-file-backed-feature-extractor.C.


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