Skip to content

Commit

Permalink
Keep track of original index of document in MSet.
Browse files Browse the repository at this point in the history
Store original index of document in MSet in FeatureVector.
  • Loading branch information
VcamX committed Jul 14, 2014
1 parent 16ad87f commit 7e28b8f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions xapian-letor/feature.cc
Expand Up @@ -367,6 +367,8 @@ Feature::generate_feature_vector(const Xapian::MSetIterator & met_it_) {

fvector.set_did( get_did(doc) );

fvector.set_index( mset_it_->get_rank() );

vector<double> feature_values( get_features_num() );
for (int i=0; i<get_features_num(); i++) {
feature_values[i] = get_feature(features[i], mset_it_);
Expand Down
10 changes: 10 additions & 0 deletions xapian-letor/feature_vector.cc
Expand Up @@ -70,6 +70,11 @@ FeatureVector::set_label(double label_) {
label = label_;
}

void
FeatureVector::set_index(Xapian::doccount index_) {
index = index_;
}

void
FeatureVector::set_feature_values(vector<double> feature_values_) {
feature_values = feature_values_;
Expand All @@ -90,6 +95,11 @@ FeatureVector::get_label() {
return label;
}

Xapian::doccount
FeatureVector::get_index() {
return index;
}

int
FeatureVector::get_feature_num() {
return feature_values.size();
Expand Down
8 changes: 7 additions & 1 deletion xapian-letor/feature_vector.h
Expand Up @@ -41,7 +41,7 @@ class XAPIAN_VISIBILITY_DEFAULT FeatureVector {
double label; // the tagged relavance label
double score; // the calculated score
vector<double> fvals; // feature values
double normalization_factor; // the normalization factor
Xapian::doccount index; // the original index in MSet

public:
FeatureVector();
Expand All @@ -58,6 +58,9 @@ class XAPIAN_VISIBILITY_DEFAULT FeatureVector {

// Set the label
void set_label(double label_);

// Set the original index in MSet
void set_index(Xapian::doccount index_);

// Set feature values
void set_feature_values(vector<double> feature_values_);
Expand All @@ -70,6 +73,9 @@ class XAPIAN_VISIBILITY_DEFAULT FeatureVector {

// Get the label
double get_label();

// Get the original index in MSet
Xapian::doccount get_index();

// Get the number of features
int get_feature_num();
Expand Down

0 comments on commit 7e28b8f

Please sign in to comment.