36 #ifndef RERANKER_RANK_FEATURE_EXTRACTOR_H_
37 #define RERANKER_RANK_FEATURE_EXTRACTOR_H_
46 using std::stringstream;
60 initializers.
Add(
"add_score_factor", &add_score_factor_);
61 initializers.
Add(
"add_score_difference", &add_score_difference_);
77 ss <<
"orig_rank:" << candidate.
index();
80 stringstream lg_rank_ss;
81 double lg_rank = floor(log((
double)candidate.
index() + 1.0) /
83 lg_rank_ss <<
"lg_rank:" << lg_rank;
86 if (add_score_factor_) {
87 double top_baseline_score =
88 top_baseline_score_ == 0.0 ? 1e-10 : top_baseline_score_;
89 double score_factor = candidate.
baseline_score() / top_baseline_score;
92 if (add_score_difference_) {
93 double score_difference =
95 symbolic_features.
IncrementWeight(
"score_difference", score_difference);
107 double top_baseline_score_;
108 bool add_score_factor_;
109 bool add_score_difference_;
double baseline_score() const
Returns the baseline model score for this candidate.
void Add(const string &name, T *member, bool required=false)
int index() const
Returns the index of this candidate relative to the other candidates.
A class to hold a set of candidates, either for training or test.
A class to represent a candidate in a set of candidates that constitutes a training instance for a re...
V IncrementWeight(const K &uid, V by)
Increments the weight of the specified feature by the specified amount.
Candidate & Get(size_t idx)
A container for all the member initializers for a particular Factory-constructible instance...