Xapian::MatchSpy Class Reference

Class for classifying matching documents by their values. More...

#include <matchspy.h>

Inheritance diagram for Xapian::MatchSpy:

Inheritance graph
[legend]
Collaboration diagram for Xapian::MatchSpy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MatchSpy ()
 Default constructor.
 MatchSpy (Xapian::valueno valno)
 Construct a MatchSpy which classifies documents by a particular value.
void add_category (Xapian::valueno valno)
 Add a value number to classify documents by.
bool operator() (const Xapian::Document &doc) const
 Implementation of virtual operator().
size_t get_total () const
 Return the total number of documents tallied.
const std::map< std::string,
size_t > & 
get_categories (Xapian::valueno valno) const
 Return the categorisation for value number valno.
double score_categorisation (Xapian::valueno valno, double desired_no_of_categories=0.0)
 Return a score reflecting how "good" a categorisation is.
bool build_numeric_ranges (Xapian::valueno valno, size_t max_ranges)
 Turn a category containing sort-encoded numeric values into a set of ranges.

Detailed Description

Class for classifying matching documents by their values.


Constructor & Destructor Documentation

Xapian::MatchSpy::MatchSpy (  )  [inline]

Default constructor.

Xapian::MatchSpy::MatchSpy ( Xapian::valueno  valno  )  [inline]

Construct a MatchSpy which classifies documents by a particular value.

Further values can be added by calling add_category().


Member Function Documentation

void Xapian::MatchSpy::add_category ( Xapian::valueno  valno  )  [inline]

Add a value number to classify documents by.

A MatchSpy can classify by one or more values.

bool Xapian::MatchSpy::operator() ( const Xapian::Document doc  )  const [virtual]

Implementation of virtual operator().

This implementation tallies values for a matching document.

Implements Xapian::MatchDecider.

size_t Xapian::MatchSpy::get_total (  )  const [inline]

Return the total number of documents tallied.

const std::map<std::string, size_t>& Xapian::MatchSpy::get_categories ( Xapian::valueno  valno  )  const [inline]

Return the categorisation for value number valno.

double Xapian::MatchSpy::score_categorisation ( Xapian::valueno  valno,
double  desired_no_of_categories = 0.0 
)

Return a score reflecting how "good" a categorisation is.

If you don't want to show a poor categorisation, or have multiple categories and only space in your user interface to show a few, you want to be able to decide how "good" a categorisation is. We define a good categorisation as one which offers a fairly even split, and (optionally) about a specified number of options.

Parameters:
valno Value number to look at the categorisation for.
desired_no_of_categories The desired number of categories - this is a floating point value, so you can ask for 5.5 if you'd like "about 5 or 6 categories". The default is to desire the number of categories that there actually are, so the score then only reflects how even the split is.
Returns:
A score for the categorisation for value valno - lower is better, with a perfectly even split across the right number of categories scoring 0.

bool Xapian::MatchSpy::build_numeric_ranges ( Xapian::valueno  valno,
size_t  max_ranges 
)

Turn a category containing sort-encoded numeric values into a set of ranges.

For "continuous" values (such as price, height, weight, etc), there will usually be too many different values to offer the user, and the user won't want to restrict to an exact value anyway.

This method produces a set of ranges for a particular value number. The ranges replace the category data for value valno - the keys are either empty (entry for "no value set"), <= 9 bytes long (a singleton encoded value), or > 9 bytes long (the first 9 bytes are the encoded range start, the rest the encoded range end).

Parameters:
valno Value number to produce ranges for.
max_ranges Group into at most this many ranges.
Returns:
true if ranges could be built; false if not (e.g. all values the same, no values set, or other reasons).


The documentation for this class was generated from the following file:
Documentation for Xapian (version 1.0.2).
Generated on 5 Jul 2007 by Doxygen 1.5.2.