Xapian::TradWeight Class Reference

Traditional probabilistic weighting scheme. More...

#include <enquire.h>

Inheritance diagram for Xapian::TradWeight:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TradWeight (double k)
 Construct a TradWeight.
 TradWeight ()
TradWeightclone () const
 Return a new weight object of this type.
 ~TradWeight ()
std::string name () const
 Name of the weighting scheme.
std::string serialise () const
 Serialise object parameters into a string.
TradWeightunserialise (const std::string &s) const
 Create object given string serialisation returned by serialise().
Xapian::weight get_sumpart (Xapian::termcount wdf, Xapian::doclength len) const
 Get a weight which is part of the sum over terms being performed.
Xapian::weight get_maxpart () const
 Gets the maximum value that get_sumpart() may return.
Xapian::weight get_sumextra (Xapian::doclength len) const
 Get an extra weight for a document to add to the sum calculated over the query terms.
Xapian::weight get_maxextra () const
 Gets the maximum value that get_sumextra() may return.
bool get_sumpart_needs_doclength () const
 return false if the weight object doesn't need doclength

Private Member Functions

void calc_termweight () const

Private Attributes

Xapian::weight termweight
Xapian::doclength lenpart
double param_k
bool weight_calculated

Detailed Description

Traditional probabilistic weighting scheme.

This class implements the Traditional Probabilistic Weighting scheme, as described by the early papers on Probabilistic Retrieval. BM25 generally gives better results.

The Traditional weighting scheme formula is

\[ \sum_{t}\frac{f_{t,d}}{k.L_{d}+f_{t,d}}.w_{t} \]

where

TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that the latter returns weights (k+1) times larger.

Definition at line 1252 of file enquire.h.


Constructor & Destructor Documentation

Xapian::TradWeight::TradWeight ( double  k  )  [inline, explicit]

Construct a TradWeight.

Parameters:
k parameter governing the importance of within document frequency and document length - any non-negative number (0 meaning to ignore wdf and doc length when calculating weights). Default is 1.

Definition at line 1271 of file enquire.h.

Xapian::TradWeight::TradWeight (  )  [inline]

Definition at line 1275 of file enquire.h.

Referenced by clone().

Xapian::TradWeight::~TradWeight (  )  [inline]

Definition at line 1278 of file enquire.h.


Member Function Documentation

void Xapian::TradWeight::calc_termweight (  )  const [private]

Definition at line 59 of file tradweight.cc.

References Assert, Xapian::Weight::Internal::collection_size, DEBUGCALL, DEBUGLINE, Xapian::Weight::internal, lenpart, param_k, Xapian::Weight::Internal::rset_size, termweight, and weight_calculated.

Referenced by get_maxpart(), get_sumpart(), and get_sumpart_needs_doclength().

TradWeight * Xapian::TradWeight::clone (  )  const [virtual]

Return a new weight object of this type.

A subclass called FooWeight taking parameters param1 and param2 should implement this as:

virtual FooWeight * clone() const { return new FooWeight(param1, param2); }

Implements Xapian::Weight.

Definition at line 39 of file tradweight.cc.

References param_k, and TradWeight().

string Xapian::TradWeight::name (  )  const [virtual]

Name of the weighting scheme.

If the subclass is called FooWeight, this should return "Foo".

Implements Xapian::Weight.

Definition at line 43 of file tradweight.cc.

Referenced by DEFINE_TESTCASE().

string Xapian::TradWeight::serialise (  )  const [virtual]

Serialise object parameters into a string.

Implements Xapian::Weight.

Definition at line 45 of file tradweight.cc.

References param_k, and serialise_double().

Referenced by DEFINE_TESTCASE().

TradWeight* Xapian::TradWeight::unserialise ( const std::string &  s  )  const [virtual]

Create object given string serialisation returned by serialise().

Implements Xapian::Weight.

Xapian::weight Xapian::TradWeight::get_sumpart ( Xapian::termcount  wdf,
Xapian::doclength  len 
) const [virtual]

Get a weight which is part of the sum over terms being performed.

This returns a weight for a given term and document. These weights are summed to give a total weight for the document.

Parameters:
wdf the within document frequency of the term.
len the (unnormalised) document length.

Implements Xapian::Weight.

Definition at line 111 of file tradweight.cc.

References calc_termweight(), DEBUGCALL, lenpart, RETURN, termweight, and weight_calculated.

Xapian::weight Xapian::TradWeight::get_maxpart (  )  const [virtual]

Gets the maximum value that get_sumpart() may return.

This is used in optimising searches, by having the postlist tree decay appropriately when parts of it can have limited, or no, further effect.

Implements Xapian::Weight.

Definition at line 124 of file tradweight.cc.

References calc_termweight(), DEBUGCALL, RETURN, termweight, and weight_calculated.

Xapian::weight Xapian::TradWeight::get_sumextra ( Xapian::doclength  len  )  const [virtual]

Get an extra weight for a document to add to the sum calculated over the query terms.

This returns a weight for a given document, and is used by some weighting schemes to account for influence such as document length.

Parameters:
len the (unnormalised) document length.

Implements Xapian::Weight.

Definition at line 133 of file tradweight.cc.

References DEBUGCALL, and RETURN.

Xapian::weight Xapian::TradWeight::get_maxextra (  )  const [virtual]

Gets the maximum value that get_sumextra() may return.

This is used in optimising searches.

Implements Xapian::Weight.

Definition at line 140 of file tradweight.cc.

References DEBUGCALL, and RETURN.

bool Xapian::TradWeight::get_sumpart_needs_doclength (  )  const [virtual]

return false if the weight object doesn't need doclength

Reimplemented from Xapian::Weight.

Definition at line 146 of file tradweight.cc.

References calc_termweight(), lenpart, and weight_calculated.


Member Data Documentation

Xapian::weight Xapian::TradWeight::termweight [mutable, private]

Definition at line 1254 of file enquire.h.

Referenced by calc_termweight(), get_maxpart(), and get_sumpart().

Xapian::doclength Xapian::TradWeight::lenpart [mutable, private]

Definition at line 1255 of file enquire.h.

Referenced by calc_termweight(), get_sumpart(), and get_sumpart_needs_doclength().

double Xapian::TradWeight::param_k [private]

Definition at line 1257 of file enquire.h.

Referenced by calc_termweight(), clone(), and serialise().

bool Xapian::TradWeight::weight_calculated [mutable, private]

Definition at line 1259 of file enquire.h.

Referenced by calc_termweight(), get_maxpart(), get_sumpart(), and get_sumpart_needs_doclength().


The documentation for this class was generated from the following files:
Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.