Reranker Framework (ReFr)
Reranking framework for structure prediction and discriminative language modeling
|
A class to represent a candidate in a set of candidates that constitutes a training instance for a reranker. More...
#include <candidate.H>
Classes | |
class | Comparator |
An inner interface specifying comparison between two Candidate instances. More... | |
Public Member Functions | |
Candidate (int index, double loss, double baseline_score, int num_words, const string &raw_data) | |
Constructor for a candidate without features. More... | |
Candidate (int index, double loss, double baseline_score, int num_words, const string &raw_data, const FeatureVector< int, double > &features, const FeatureVector< string, double > &symbolic_features) | |
Constructor for a candidate with "compiled" features. More... | |
virtual | ~Candidate () |
Destroys this candidate. More... | |
int | index () const |
Returns the index of this candidate relative to the other candidates. More... | |
int | num_errors () const |
Returns the number of word errors of this candidate relative to a reference string. More... | |
int | num_correct () const |
Returns the number of correct words of this candidate relative to a reference string. More... | |
double | loss () const |
Returns the loss of this candidate. More... | |
double | score () const |
Returns the reranker’s score for this candidate. More... | |
double | baseline_score () const |
Returns the baseline model score for this candidate. More... | |
int | num_words () const |
Returns the number of words in this candidate. More... | |
const FeatureVector< int, double > & | features () const |
Returns the feature vector for this candidate. More... | |
const FeatureVector< string, double > & | symbolic_features () const |
Returns the symbolic feature vector for this candidate. More... | |
const string & | raw_data () const |
Returns the raw data (typically the sentence) for this candidate. More... | |
bool | compiled () const |
Returns whether this candidate’s symbolic features have been compiled. More... | |
void | set_raw_data (const string &raw_data) |
Sets the raw data (typically the sentence) for this candidate). More... | |
void | set_score (double score) |
Sets the score of this candidate. More... | |
void | set_baseline_score (double baseline_score) |
Sets the score of this candidate. More... | |
void | set_loss (double loss) |
Sets the loss of this candidate. More... | |
bool | Compile (Symbols *symbols, bool clear_features=false, bool clear_symbolic_features=true, bool force=false) |
Compiles any symbolic features in this candidate. More... | |
void | Decompile (Symbols *symbols, bool clear_symbolic_features=false, bool clear_features=true, bool force=false) |
Decompiles any non-symbolic features in this candidate. More... | |
string | to_string () |
Returns a the string that would be output by operator<<. More... | |
Friends | |
class | FeatureExtractor |
class | AbstractFileBackedFeatureExtractor |
ostream & | operator<< (ostream &os, const Candidate &c) |
Outputs a human-readable string version of this Candidate instance to the specified ostream. More... | |
A class to represent a candidate in a set of candidates that constitutes a training instance for a reranker.
Definition at line 60 of file candidate.H.
|
inline |
Constructor for a candidate without features.
index | the index of this candidate within its set |
loss | the loss of this candidate |
baseline_score | the baseline score of this candidate |
num_words | the number of words of this candidate |
raw_data | the original string for this candidate |
Definition at line 71 of file candidate.H.
|
inline |
Constructor for a candidate with "compiled" features.
index | the index of this candidate within its set |
loss | the loss of this candidate |
baseline_score | the baseline score of this candidate |
num_words | the number of words of this candidate |
raw_data | the original string for this candidate |
features | the features for this candidate |
symbolic_features | the symbolic features for this candidate |
Definition at line 90 of file candidate.H.
|
inlinevirtual |
Destroys this candidate.
Definition at line 105 of file candidate.H.
|
inline |
Returns the baseline model score for this candidate.
Definition at line 133 of file candidate.H.
bool reranker::Candidate::Compile | ( | Symbols * | symbols, |
bool | clear_features = false , |
||
bool | clear_symbolic_features = true , |
||
bool | force = false |
||
) |
Compiles any symbolic features in this candidate.
Feature weights for symbolic features will be added to those for any features already specified with int
uid’s.
symbols | the map from symbols (string instances) to unique integer id’s |
clear_features | whether to clear the “normal” feature vector prior to compiling symbolic features |
clear_symbolic_features | whether to clear the symbolic feature vector after updating the “regular” feature vector (to save space) |
force | forces feature compilation, even if this method has been previously invoked |
Definition at line 42 of file candidate.C.
|
inline |
Returns whether this candidate’s symbolic features have been compiled.
Definition at line 147 of file candidate.H.
void reranker::Candidate::Decompile | ( | Symbols * | symbols, |
bool | clear_symbolic_features = false , |
||
bool | clear_features = true , |
||
bool | force = false |
||
) |
Decompiles any non-symbolic features in this candidate.
Feature weights for non-symbolic features will be added to those for any features already specified with string
uid’s.
symbols | the map from symbols (string instances) to unique integer id’s |
clear_symbolic_features | whether to clear the symbolic feature vector prior to decompiling features |
clear_features | whether to clear the “normal” feature vector after updating the symbolic feature vector (to save space) |
force | forces feature decompilation, even if this method has been previously invoked |
Definition at line 67 of file candidate.C.
|
inline |
Returns the feature vector for this candidate.
Definition at line 137 of file candidate.H.
|
inline |
Returns the index of this candidate relative to the other candidates.
Definition at line 121 of file candidate.H.
|
inline |
Returns the loss of this candidate.
Definition at line 129 of file candidate.H.
|
inline |
Returns the number of correct words of this candidate relative to a reference string.
Definition at line 127 of file candidate.H.
|
inline |
Returns the number of word errors of this candidate relative to a reference string.
Definition at line 124 of file candidate.H.
|
inline |
Returns the number of words in this candidate.
Definition at line 135 of file candidate.H.
|
inline |
Returns the raw data (typically the sentence) for this candidate.
Definition at line 143 of file candidate.H.
|
inline |
Returns the reranker’s score for this candidate.
Definition at line 131 of file candidate.H.
|
inline |
Sets the score of this candidate.
baseline_score | the new baseline_score of this candidate |
Definition at line 161 of file candidate.H.
|
inline |
Sets the loss of this candidate.
loss | the new loss of this candidate. |
Definition at line 168 of file candidate.H.
|
inline |
Sets the raw data (typically the sentence) for this candidate).
Definition at line 151 of file candidate.H.
|
inline |
Sets the score of this candidate.
score | the new score of this candidate |
Definition at line 156 of file candidate.H.
|
inline |
Returns the symbolic feature vector for this candidate.
Definition at line 139 of file candidate.H.
|
inline |
Returns a the string that would be output by operator<<.
Definition at line 232 of file candidate.H.
|
friend |
Definition at line 63 of file candidate.H.
|
friend |
Definition at line 62 of file candidate.H.
|
friend |
Outputs a human-readable string version of this Candidate instance to the specified ostream.
os | the output stream to which to output a human-readable version of this candidate |
c | the candidate to be output to the specified output stream |
Definition at line 220 of file candidate.H.