<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Xapian: API Documentation: xapian-core: Xapian::BM25Weight Class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#ffffff"> <!-- Generated by Doxygen 1.5.2 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="classes.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="classes.html"><span>Alphabetical List</span></a></li> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="nav"> <a class="el" href="namespaceXapian.html">Xapian</a>::<a class="el" href="classXapian_1_1BM25Weight.html">BM25Weight</a></div> <h1>Xapian::BM25Weight Class Reference</h1><!-- doxytag: class="Xapian::BM25Weight" --><!-- doxytag: inherits="Xapian::Weight" -->BM25 weighting scheme. <a href="#_details">More...</a> <p> Inheritance diagram for Xapian::BM25Weight:<p><center><img src="classXapian_1_1BM25Weight__inherit__graph.png" border="0" usemap="#Xapian_1_1BM25Weight__inherit__map" alt="Inheritance graph"></center> <map name="Xapian_1_1BM25Weight__inherit__map"> <area shape="rect" href="classXapian_1_1Weight.html" title="Abstract base class for weighting schemes." alt="" coords="23,7,137,33"></map> <center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center><a href="classXapian_1_1BM25Weight-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> <tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#58aa8ee25f7e8309de1655d83347560a">BM25Weight</a> (double k1_, double k2_, double k3_, double b_, double min_normlen_)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Construct a BM25 weight. <a href="#58aa8ee25f7e8309de1655d83347560a"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classXapian_1_1BM25Weight.html">BM25Weight</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#afaa762651eba7eb3e516ba553d902af">clone</a> () const</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Return a new weight object of this type. <a href="#afaa762651eba7eb3e516ba553d902af"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#97584d9336aecc0316978aafdf463a3b">name</a> () const</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Name of the weighting scheme. <a href="#97584d9336aecc0316978aafdf463a3b"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#98394bf1ed0024762c88b22d3dcf7b40">serialise</a> () const</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Serialise object parameters into a string. <a href="#98394bf1ed0024762c88b22d3dcf7b40"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classXapian_1_1BM25Weight.html">BM25Weight</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#0f550b0f4d27348fb69aa198af7b4770">unserialise</a> (const std::string &s) const</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Create object given string serialisation returned by <a class="el" href="classXapian_1_1BM25Weight.html#98394bf1ed0024762c88b22d3dcf7b40" title="Serialise object parameters into a string.">serialise()</a>. <a href="#0f550b0f4d27348fb69aa198af7b4770"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="namespaceXapian.html#ee1bece7207c349621963d7f584dd98b">Xapian::weight</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#20644c0662caec5ff4fe65b039cb1386">get_sumpart</a> (<a class="el" href="namespaceXapian.html#3261017447607738e49eae6a2a4f5eec">Xapian::termcount</a> wdf, <a class="el" href="namespaceXapian.html#6c1c4bfd0b540caccbb5179976ebf792">Xapian::doclength</a> len) const</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get a weight which is part of the sum over terms being performed. <a href="#20644c0662caec5ff4fe65b039cb1386"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="namespaceXapian.html#ee1bece7207c349621963d7f584dd98b">Xapian::weight</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#c2055deab9c2532949ec229fa11c1ee2">get_maxpart</a> () const</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Gets the maximum value that <a class="el" href="classXapian_1_1BM25Weight.html#20644c0662caec5ff4fe65b039cb1386" title="Get a weight which is part of the sum over terms being performed.">get_sumpart()</a> may return. <a href="#c2055deab9c2532949ec229fa11c1ee2"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="namespaceXapian.html#ee1bece7207c349621963d7f584dd98b">Xapian::weight</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#989abcfbed9b5406583297c705b51888">get_sumextra</a> (<a class="el" href="namespaceXapian.html#6c1c4bfd0b540caccbb5179976ebf792">Xapian::doclength</a> len) const</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get an extra weight for a document to add to the sum calculated over the query terms. <a href="#989abcfbed9b5406583297c705b51888"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="namespaceXapian.html#ee1bece7207c349621963d7f584dd98b">Xapian::weight</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#c8b41f2715e49d6a8ef52e3373396073">get_maxextra</a> () const</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Gets the maximum value that <a class="el" href="classXapian_1_1BM25Weight.html#989abcfbed9b5406583297c705b51888" title="Get an extra weight for a document to add to the sum calculated over the query terms...">get_sumextra()</a> may return. <a href="#c8b41f2715e49d6a8ef52e3373396073"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classXapian_1_1BM25Weight.html#0f37ccfe48b94457303896803e621090">get_sumpart_needs_doclength</a> () const</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">return false if the weight object doesn't need doclength <a href="#0f37ccfe48b94457303896803e621090"></a><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> BM25 weighting scheme. <p> BM25 weighting options : The BM25 formula is <p class="formulaDsp"> <img class="formulaDsp" alt="\[ \frac{k_{2}.n_{q}}{1+L_{d}}+\sum_{t}\frac{(k_{3}+1)q_{t}}{k_{3}+q_{t}}.\frac{(k_{1}+1)f_{t,d}}{k_{1}((1-b)+bL_{d})+f_{t,d}}.w_{t} \]" src="form_0.png"> <p> where<ul> <li><img class="formulaInl" alt="$w_{t}$" src="form_1.png"> is the termweight of term t</li><li><img class="formulaInl" alt="$f_{t,d}$" src="form_2.png"> is the within document frequency of term t in document d</li><li><img class="formulaInl" alt="$q_{t}$" src="form_3.png"> is the within query frequency of term t</li><li><img class="formulaInl" alt="$L_{d}$" src="form_4.png"> is the normalised length of document d</li><li><img class="formulaInl" alt="$n_{q}$" src="form_5.png"> is the size of the query</li><li><img class="formulaInl" alt="$k_{1}$" src="form_6.png">, <img class="formulaInl" alt="$k_{2}$" src="form_7.png">, <img class="formulaInl" alt="$k_{3}$" src="form_8.png"> and <img class="formulaInl" alt="$b$" src="form_9.png"> are user specified parameters </li></ul> <p> <hr><h2>Constructor & Destructor Documentation</h2> <a class="anchor" name="58aa8ee25f7e8309de1655d83347560a"></a><!-- doxytag: member="Xapian::BM25Weight::BM25Weight" ref="58aa8ee25f7e8309de1655d83347560a" args="(double k1_, double k2_, double k3_, double b_, double min_normlen_)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Xapian::BM25Weight::BM25Weight </td> <td>(</td> <td class="paramtype">double </td> <td class="paramname"> <em>k1_</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">double </td> <td class="paramname"> <em>k2_</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">double </td> <td class="paramname"> <em>k3_</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">double </td> <td class="paramname"> <em>b_</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">double </td> <td class="paramname"> <em>min_normlen_</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Construct a BM25 weight. <p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>k1</em> </td><td>governs the importance of within document frequency. Must be >= 0. 0 means ignore wdf. Default is 1. </td></tr> <tr><td valign="top"></td><td valign="top"><em>k2</em> </td><td>compensation factor for the high wdf values in large documents. Must be >= 0. 0 means no compensation. Default is 0. </td></tr> <tr><td valign="top"></td><td valign="top"><em>k3</em> </td><td>governs the importance of within query frequency. Must be >= 0. 0 means ignore wqf. Default is 1. </td></tr> <tr><td valign="top"></td><td valign="top"><em>b</em> </td><td>Relative importance of within document frequency and document length. Must be >= 0 and <= 1. Default is 0.5. </td></tr> <tr><td valign="top"></td><td valign="top"><em>min_normlen</em> </td><td>specifies a cutoff on the minimum value that can be used for a normalised document length - smaller values will be forced up to this cutoff. This prevents very small documents getting a huge bonus weight. Default is 0.5. </td></tr> </table> </dl> </div> </div><p> <hr><h2>Member Function Documentation</h2> <a class="anchor" name="afaa762651eba7eb3e516ba553d902af"></a><!-- doxytag: member="Xapian::BM25Weight::clone" ref="afaa762651eba7eb3e516ba553d902af" args="() const" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classXapian_1_1BM25Weight.html">BM25Weight</a>* Xapian::BM25Weight::clone </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td width="100%"> const<code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Return a new weight object of this type. <p> A subclass called FooWeight taking parameters param1 and param2 should implement this as:<p> virtual FooWeight * <a class="el" href="classXapian_1_1BM25Weight.html#afaa762651eba7eb3e516ba553d902af" title="Return a new weight object of this type.">clone() const</a> { return new FooWeight(param1, param2); } <p> Implements <a class="el" href="classXapian_1_1Weight.html">Xapian::Weight</a>. </div> </div><p> <a class="anchor" name="97584d9336aecc0316978aafdf463a3b"></a><!-- doxytag: member="Xapian::BM25Weight::name" ref="97584d9336aecc0316978aafdf463a3b" args="() const" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">std::string Xapian::BM25Weight::name </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td width="100%"> const<code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Name of the weighting scheme. <p> If the subclass is called FooWeight, this should return "Foo". <p> Implements <a class="el" href="classXapian_1_1Weight.html#b0a873c16f02bcf9ea54b632b7c8600a">Xapian::Weight</a>. </div> </div><p> <a class="anchor" name="98394bf1ed0024762c88b22d3dcf7b40"></a><!-- doxytag: member="Xapian::BM25Weight::serialise" ref="98394bf1ed0024762c88b22d3dcf7b40" args="() const" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">std::string Xapian::BM25Weight::serialise </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td width="100%"> const<code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Serialise object parameters into a string. <p> <p> Implements <a class="el" href="classXapian_1_1Weight.html#b2ff0584c32e9db9f52dafed9e4e2bcf">Xapian::Weight</a>. </div> </div><p> <a class="anchor" name="0f550b0f4d27348fb69aa198af7b4770"></a><!-- doxytag: member="Xapian::BM25Weight::unserialise" ref="0f550b0f4d27348fb69aa198af7b4770" args="(const std::string &s) const" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classXapian_1_1BM25Weight.html">BM25Weight</a>* Xapian::BM25Weight::unserialise </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"> <em>s</em> </td> <td> ) </td> <td width="100%"> const<code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Create object given string serialisation returned by <a class="el" href="classXapian_1_1BM25Weight.html#98394bf1ed0024762c88b22d3dcf7b40" title="Serialise object parameters into a string.">serialise()</a>. <p> <p> Implements <a class="el" href="classXapian_1_1Weight.html#c6948bf58e52443ca6c8d5547bf14d14">Xapian::Weight</a>. </div> </div><p> <a class="anchor" name="20644c0662caec5ff4fe65b039cb1386"></a><!-- doxytag: member="Xapian::BM25Weight::get_sumpart" ref="20644c0662caec5ff4fe65b039cb1386" args="(Xapian::termcount wdf, Xapian::doclength len) const" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="namespaceXapian.html#ee1bece7207c349621963d7f584dd98b">Xapian::weight</a> Xapian::BM25Weight::get_sumpart </td> <td>(</td> <td class="paramtype"><a class="el" href="namespaceXapian.html#3261017447607738e49eae6a2a4f5eec">Xapian::termcount</a> </td> <td class="paramname"> <em>wdf</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="namespaceXapian.html#6c1c4bfd0b540caccbb5179976ebf792">Xapian::doclength</a> </td> <td class="paramname"> <em>len</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td width="100%"> const<code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Get a weight which is part of the sum over terms being performed. <p> This returns a weight for a given term and document. These weights are summed to give a total weight for the document.<p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>wdf</em> </td><td>the within document frequency of the term. </td></tr> <tr><td valign="top"></td><td valign="top"><em>len</em> </td><td>the (unnormalised) document length. </td></tr> </table> </dl> <p> Implements <a class="el" href="classXapian_1_1Weight.html#35ac7463961ccfcfa7ff6abc170135f8">Xapian::Weight</a>. </div> </div><p> <a class="anchor" name="c2055deab9c2532949ec229fa11c1ee2"></a><!-- doxytag: member="Xapian::BM25Weight::get_maxpart" ref="c2055deab9c2532949ec229fa11c1ee2" args="() const" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="namespaceXapian.html#ee1bece7207c349621963d7f584dd98b">Xapian::weight</a> Xapian::BM25Weight::get_maxpart </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td width="100%"> const<code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Gets the maximum value that <a class="el" href="classXapian_1_1BM25Weight.html#20644c0662caec5ff4fe65b039cb1386" title="Get a weight which is part of the sum over terms being performed.">get_sumpart()</a> may return. <p> This is used in optimising searches, by having the postlist tree decay appropriately when parts of it can have limited, or no, further effect. <p> Implements <a class="el" href="classXapian_1_1Weight.html#029bd952184c78f75126227de336f3f6">Xapian::Weight</a>. </div> </div><p> <a class="anchor" name="989abcfbed9b5406583297c705b51888"></a><!-- doxytag: member="Xapian::BM25Weight::get_sumextra" ref="989abcfbed9b5406583297c705b51888" args="(Xapian::doclength len) const" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="namespaceXapian.html#ee1bece7207c349621963d7f584dd98b">Xapian::weight</a> Xapian::BM25Weight::get_sumextra </td> <td>(</td> <td class="paramtype"><a class="el" href="namespaceXapian.html#6c1c4bfd0b540caccbb5179976ebf792">Xapian::doclength</a> </td> <td class="paramname"> <em>len</em> </td> <td> ) </td> <td width="100%"> const<code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Get an extra weight for a document to add to the sum calculated over the query terms. <p> This returns a weight for a given document, and is used by some weighting schemes to account for influence such as document length.<p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>len</em> </td><td>the (unnormalised) document length. </td></tr> </table> </dl> <p> Implements <a class="el" href="classXapian_1_1Weight.html#9fec5777ea998c2925b0960e3d9ca31c">Xapian::Weight</a>. </div> </div><p> <a class="anchor" name="c8b41f2715e49d6a8ef52e3373396073"></a><!-- doxytag: member="Xapian::BM25Weight::get_maxextra" ref="c8b41f2715e49d6a8ef52e3373396073" args="() const" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="namespaceXapian.html#ee1bece7207c349621963d7f584dd98b">Xapian::weight</a> Xapian::BM25Weight::get_maxextra </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td width="100%"> const<code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Gets the maximum value that <a class="el" href="classXapian_1_1BM25Weight.html#989abcfbed9b5406583297c705b51888" title="Get an extra weight for a document to add to the sum calculated over the query terms...">get_sumextra()</a> may return. <p> This is used in optimising searches. <p> Implements <a class="el" href="classXapian_1_1Weight.html#158796278206334879e4861d7ebc1040">Xapian::Weight</a>. </div> </div><p> <a class="anchor" name="0f37ccfe48b94457303896803e621090"></a><!-- doxytag: member="Xapian::BM25Weight::get_sumpart_needs_doclength" ref="0f37ccfe48b94457303896803e621090" args="() const" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool Xapian::BM25Weight::get_sumpart_needs_doclength </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td width="100%"> const<code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> return false if the weight object doesn't need doclength <p> <p> Reimplemented from <a class="el" href="classXapian_1_1Weight.html#057ce24c2d3a54dc6a6b3127d064ce9f">Xapian::Weight</a>. </div> </div><p> <hr>The documentation for this class was generated from the following file:<ul> <li>xapian/<a class="el" href="enquire_8h.html">enquire.h</a></ul> <hr> <address><small> Documentation for Xapian (version 1.0.21).<br> Generated on 18 Jun 2010 by <a href="http://www.doxygen.org/">Doxygen 1.5.2</a>. </small></address> </body> </html>