xapian-letor refactoring
commit3d07e0f8b00b80ef2aac6ba2e0138a34e7513f8b
authorAyushP123 <f2012714@goa.bits-pilani.ac.in>
Fri, 17 Mar 2017 18:03:54 +0000 (17 23:33 +0530)
committerOlly Betts <olly@survex.com>
Thu, 22 Jun 2017 23:36:35 +0000 (23 11:36 +1200)
treec423aec396fcc7d581ccad03be07def89ad07559
parentf81ab865861300a935435c9cb88439f3c311848a
xapian-letor refactoring

Replace Feature::Internal with FeatureList::Internal and change the way
statistics are computed and stored for Features.

Initially Feature::Internal was being used by Feature subclasses to
compute statistics in the Feature::get_value() function to build the
Feature. The Feature was in turn used to build a FeatureVector in
FeatureList. There were two problems with this approach.

1. Presence of Internal in Feature was making it difficult to subclass
   Feature.
2. Statistics which were common to multiple Features were being computed
   unnecessarily by all of them instead of being computed once and being
   stored in a common location accessible to all the Features.

Since FeatureList was the common location accessible to all the Features
replacing Feature::Internal with FeatureList::Internal, which would be
used to compute and store statistics in FeatureList, solved both the
problems in one go.

FeatureList::Internal basically has two functions which are used by
FeatureList in building Vectors.

1. compute_statistics, to compute all the statistics being previous
   computed by Feature::Internal and store them in FeatureList.
2. populate_features, to populate a Feature with all the statistics it
   needs. To avoid populating a Feature with statistics it doesn't need
   a bit mask "stats_needed" was introduced which is used by the Feature
   to tell FeatureList which statistics it needs.

Since Feature::Internal's work was being done by FeatureList Internal
was removed from Feature. Feature::Internal's data members were added to
Features as it was easier for Features to access them there.
18 files changed:
xapian-letor/api/Makefile.mk
xapian-letor/api/featurelist.cc
xapian-letor/api/featurelist_internal.cc [new file with mode: 0644]
xapian-letor/api/featurelist_internal.h [new file with mode: 0644]
xapian-letor/api/featurevector.cc
xapian-letor/feature/Makefile.mk
xapian-letor/feature/colltfcolllenfeature.cc
xapian-letor/feature/feature.cc
xapian-letor/feature/feature_internal.cc [deleted file]
xapian-letor/feature/feature_internal.h [deleted file]
xapian-letor/feature/idffeature.cc
xapian-letor/feature/tfdoclencolltfcolllenfeature.cc
xapian-letor/feature/tfdoclenfeature.cc
xapian-letor/feature/tffeature.cc
xapian-letor/feature/tfidfdoclenfeature.cc
xapian-letor/include/xapian-letor/feature.h
xapian-letor/include/xapian-letor/featurelist.h
xapian-letor/ranker/ranker.cc