Reranker Framework (ReFr)
Reranking framework for structure prediction and discriminative language modeling
|
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>
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... | |
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.
|
inline |
Constructs an instance.
Definition at line 60 of file abstract-file-backed-feature-extractor.H.
|
inlinevirtual |
Destroys this instance.
Definition at line 63 of file abstract-file-backed-feature-extractor.H.
|
pure virtual |
Extracts features for the specified candidate, where each feature is represented by an int for its unique identifier.
[in] | candidate | the candidate for which to extract features |
[out] | features | the features extracted for the specified candidate |
Implements reranker::FeatureExtractor.
Implemented in reranker::FileBackedNgramFeatureExtractor, reranker::FileBackedLossSetter, and reranker::BasicFileBackedFeatureExtractor.
|
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.
candidate_set | the set of candidates for which to extract features. |
Reimplemented from reranker::FeatureExtractor.
Definition at line 127 of file abstract-file-backed-feature-extractor.H.
|
pure virtual |
Extracts symbolic features for the specified candidate, where each feature is represented by a string for its unique identifier.
[in] | candidate | the candidate for which to extract features |
[out] | symbolic_features | the features extracted for the specified candidate |
Implements reranker::FeatureExtractor.
Implemented in reranker::FileBackedNgramFeatureExtractor, reranker::FileBackedLossSetter, and reranker::BasicFileBackedFeatureExtractor.
|
inlinevirtual |
This method is guaranteed to be inokved by a Factory after invoking the RegisterInitializers method just after construction.
env | the environment just after initializing this object |
arg | the string parsed by the Factory |
Reimplemented from reranker::FactoryConstructible.
Reimplemented in reranker::FileBackedLossSetter.
Definition at line 99 of file abstract-file-backed-feature-extractor.H.
|
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.
|
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.
|
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.
|
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.
|
protected |
The name of the file backing this feature extractor.
Definition at line 160 of file abstract-file-backed-feature-extractor.H.
|
protected |
The stream created from the file backing this feature extractor.
Definition at line 162 of file abstract-file-backed-feature-extractor.H.
|
protected |
The last line read by this feature extractor.
Definition at line 164 of file abstract-file-backed-feature-extractor.H.
|
protected |
The number of lines read so far by this feature extractor.
Definition at line 166 of file abstract-file-backed-feature-extractor.H.
|
protected |
A simple whitespace tokenizer for use by concrete subclasses.
Definition at line 168 of file abstract-file-backed-feature-extractor.H.