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: