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

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

reranker::Candidate::Candidate ( int  index,
double  loss,
double  baseline_score,
int  num_words,
const string &  raw_data 
)
inline

Constructor for a candidate without features.

Parameters
indexthe index of this candidate within its set
lossthe loss of this candidate
baseline_scorethe baseline score of this candidate
num_wordsthe number of words of this candidate
raw_datathe original string for this candidate

Definition at line 71 of file candidate.H.

reranker::Candidate::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 
)
inline

Constructor for a candidate with "compiled" features.

Parameters
indexthe index of this candidate within its set
lossthe loss of this candidate
baseline_scorethe baseline score of this candidate
num_wordsthe number of words of this candidate
raw_datathe original string for this candidate
featuresthe features for this candidate
symbolic_featuresthe symbolic features for this candidate

Definition at line 90 of file candidate.H.

virtual reranker::Candidate::~Candidate ( )
inlinevirtual

Destroys this candidate.

Definition at line 105 of file candidate.H.

Member Function Documentation

double reranker::Candidate::baseline_score ( ) const
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.

Parameters
symbolsthe map from symbols (string instances) to unique integer id’s
clear_featureswhether to clear the “normal” feature vector prior to compiling symbolic features
clear_symbolic_featureswhether to clear the symbolic feature vector after updating the “regular” feature vector (to save space)
forceforces feature compilation, even if this method has been previously invoked
Returns
whether any symbolic features were actually compiled by this method invocation

Definition at line 42 of file candidate.C.

bool reranker::Candidate::compiled ( ) const
inline

Returns whether this candidate’s symbolic features have been compiled.

See Also
Compile

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.

Parameters
symbolsthe map from symbols (string instances) to unique integer id’s
clear_symbolic_featureswhether to clear the symbolic feature vector prior to decompiling features
clear_featureswhether to clear the “normal” feature vector after updating the symbolic feature vector (to save space)
forceforces feature decompilation, even if this method has been previously invoked

Definition at line 67 of file candidate.C.

const FeatureVector<int,double>& reranker::Candidate::features ( ) const
inline

Returns the feature vector for this candidate.

Definition at line 137 of file candidate.H.

int reranker::Candidate::index ( ) const
inline

Returns the index of this candidate relative to the other candidates.

Definition at line 121 of file candidate.H.

double reranker::Candidate::loss ( ) const
inline

Returns the loss of this candidate.

Definition at line 129 of file candidate.H.

int reranker::Candidate::num_correct ( ) const
inline

Returns the number of correct words of this candidate relative to a reference string.

Definition at line 127 of file candidate.H.

int reranker::Candidate::num_errors ( ) const
inline

Returns the number of word errors of this candidate relative to a reference string.

Definition at line 124 of file candidate.H.

int reranker::Candidate::num_words ( ) const
inline

Returns the number of words in this candidate.

Definition at line 135 of file candidate.H.

const string& reranker::Candidate::raw_data ( ) const
inline

Returns the raw data (typically the sentence) for this candidate.

Definition at line 143 of file candidate.H.

double reranker::Candidate::score ( ) const
inline

Returns the reranker’s score for this candidate.

Definition at line 131 of file candidate.H.

void reranker::Candidate::set_baseline_score ( double  baseline_score)
inline

Sets the score of this candidate.

Parameters
baseline_scorethe new baseline_score of this candidate

Definition at line 161 of file candidate.H.

void reranker::Candidate::set_loss ( double  loss)
inline

Sets the loss of this candidate.

Parameters
lossthe new loss of this candidate.

Definition at line 168 of file candidate.H.

void reranker::Candidate::set_raw_data ( const string &  raw_data)
inline

Sets the raw data (typically the sentence) for this candidate).

Definition at line 151 of file candidate.H.

void reranker::Candidate::set_score ( double  score)
inline

Sets the score of this candidate.

Parameters
scorethe new score of this candidate

Definition at line 156 of file candidate.H.

const FeatureVector<string,double>& reranker::Candidate::symbolic_features ( ) const
inline

Returns the symbolic feature vector for this candidate.

Definition at line 139 of file candidate.H.

string reranker::Candidate::to_string ( )
inline

Returns a the string that would be output by operator<<.

Definition at line 232 of file candidate.H.

Friends And Related Function Documentation

Definition at line 63 of file candidate.H.

friend class FeatureExtractor
friend

Definition at line 62 of file candidate.H.

ostream& operator<< ( ostream &  os,
const Candidate c 
)
friend

Outputs a human-readable string version of this Candidate instance to the specified ostream.

Parameters
osthe output stream to which to output a human-readable version of this candidate
cthe candidate to be output to the specified output stream

Definition at line 220 of file candidate.H.


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