Xapian::Weight Class Reference

Abstract base class for weighting schemes. More...

#include <enquire.h>

Inheritance diagram for Xapian::Weight:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Weight ()
virtual ~Weight ()
Weightcreate (const Internal *internal_, Xapian::doclength querysize_, Xapian::termcount wqf_, const std::string &tname_) const
 Create a new weight object of the same type as this and initialise it with the specified statistics.
virtual std::string name () const=0
 Name of the weighting scheme.
virtual std::string serialise () const=0
 Serialise object parameters into a string.
virtual Weightunserialise (const std::string &s) const=0
 Create object given string serialisation returned by serialise().
virtual Xapian::weight get_sumpart (Xapian::termcount wdf, Xapian::doclength len) const=0
 Get a weight which is part of the sum over terms being performed.
virtual Xapian::weight get_maxpart () const=0
 Gets the maximum value that get_sumpart() may return.
virtual Xapian::weight get_sumextra (Xapian::doclength len) const=0
 Get an extra weight for a document to add to the sum calculated over the query terms.
virtual Xapian::weight get_maxextra () const=0
 Gets the maximum value that get_sumextra() may return.
virtual bool get_sumpart_needs_doclength () const
 return false if the weight object doesn't need doclength

Protected Member Functions

 Weight (const Weight &)

Protected Attributes

const Internalinternal
Xapian::doclength querysize
Xapian::termcount wqf
std::string tname

Private Member Functions

void operator= (Weight &)
virtual Weightclone () const=0
 Return a new weight object of this type.

Friends

class Enquire
class ::RemoteServer
class ::ScaleWeight

Classes

class  Internal
 Class to hold statistics for a given collection. More...

Detailed Description

Abstract base class for weighting schemes.

Definition at line 1051 of file enquire.h.


Constructor & Destructor Documentation

Xapian::Weight::Weight ( const Weight  )  [protected]

Xapian::Weight::Weight (  )  [inline]

Definition at line 1081 of file enquire.h.

Xapian::Weight::~Weight (  )  [virtual]

Definition at line 31 of file weight.cc.


Member Function Documentation

void Xapian::Weight::operator= ( Weight  )  [private]

virtual Weight* Xapian::Weight::clone (  )  const [private, pure 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); }

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, Xapian::TradWeight, ScaleWeight, and MyWeight.

Referenced by ScaleWeight::clone(), create(), RemoteServer::register_weighting_scheme(), and Xapian::Enquire::set_weighting_scheme().

Weight * Xapian::Weight::create ( const Internal internal_,
Xapian::doclength  querysize_,
Xapian::termcount  wqf_,
const std::string &  tname_ 
) const

Create a new weight object of the same type as this and initialise it with the specified statistics.

You shouldn't call this method yourself - it's called by Enquire.

Parameters:
internal_ Object to ask for collection statistics.
querysize_ Query size.
wqf_ Within query frequency of term this object is associated with.
tname_ Term which this object is associated with.

Definition at line 34 of file weight.cc.

References clone(), internal, querysize, tname, and wqf.

Referenced by LocalSubMatch::postlist_from_op_leaf_query().

virtual std::string Xapian::Weight::name (  )  const [pure virtual]

Name of the weighting scheme.

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

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, Xapian::TradWeight, ScaleWeight, and MyWeight.

Referenced by Xapian::Enquire::Internal::get_mset(), RemoteServer::register_weighting_scheme(), and RemoteDatabase::set_query().

virtual std::string Xapian::Weight::serialise (  )  const [pure virtual]

Serialise object parameters into a string.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, Xapian::TradWeight, ScaleWeight, and MyWeight.

Referenced by ScaleWeight::serialise(), and RemoteDatabase::set_query().

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

Create object given string serialisation returned by serialise().

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, Xapian::TradWeight, ScaleWeight, and MyWeight.

Referenced by DEFINE_TESTCASE(), and ScaleWeight::unserialise().

virtual Xapian::weight Xapian::Weight::get_sumpart ( Xapian::termcount  wdf,
Xapian::doclength  len 
) const [pure 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.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, Xapian::TradWeight, ScaleWeight, and MyWeight.

Referenced by ScaleWeight::get_sumpart(), and LeafPostList::get_weight().

virtual Xapian::weight Xapian::Weight::get_maxpart (  )  const [pure 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.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, Xapian::TradWeight, ScaleWeight, and MyWeight.

Referenced by ScaleWeight::get_maxpart(), and LeafPostList::get_maxweight().

virtual Xapian::weight Xapian::Weight::get_sumextra ( Xapian::doclength  len  )  const [pure 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.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, Xapian::TradWeight, ScaleWeight, and MyWeight.

Referenced by ScaleWeight::get_sumextra(), and ExtraWeightPostList::get_weight().

virtual Xapian::weight Xapian::Weight::get_maxextra (  )  const [pure virtual]

Gets the maximum value that get_sumextra() may return.

This is used in optimising searches.

Implemented in Xapian::BoolWeight, Xapian::BM25Weight, Xapian::TradWeight, ScaleWeight, and MyWeight.

Referenced by ScaleWeight::get_maxextra().

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

return false if the weight object doesn't need doclength

Reimplemented in Xapian::BoolWeight, Xapian::BM25Weight, Xapian::TradWeight, ScaleWeight, and MyWeight.

Definition at line 47 of file weight.cc.

Referenced by ScaleWeight::get_sumpart_needs_doclength(), and LeafPostList::set_termweight().


Friends And Related Function Documentation

friend class Enquire [friend]

Definition at line 1052 of file enquire.h.

friend class ::RemoteServer [friend]

Definition at line 1053 of file enquire.h.

friend class ::ScaleWeight [friend]

Definition at line 1054 of file enquire.h.


Member Data Documentation

const Internal* Xapian::Weight::internal [protected]

Definition at line 1074 of file enquire.h.

Referenced by Xapian::TradWeight::calc_termweight(), Xapian::BM25Weight::calc_termweight(), and create().

Xapian::doclength Xapian::Weight::querysize [protected]

Definition at line 1075 of file enquire.h.

Referenced by create(), Xapian::BM25Weight::get_maxextra(), and Xapian::BM25Weight::get_sumextra().

Xapian::termcount Xapian::Weight::wqf [protected]

Definition at line 1076 of file enquire.h.

Referenced by Xapian::BM25Weight::calc_termweight(), and create().

std::string Xapian::Weight::tname [protected]

Definition at line 1077 of file enquire.h.

Referenced by create().


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.