39 TradWeight::clone()
const 45 TradWeight::init(
double factor)
56 if (get_rset_size() != 0) {
65 AssertRel(reltermfreq,<=,get_rset_size());
71 AssertRel(reldocs_not_indexed,<=,get_collection_size() - tf);
76 double numerator = (reltermfreq + 0.5) * (Q - tf + 0.5);
77 double denom = (reldocs_not_indexed + 0.5) * (nonreldocs_indexed + 0.5);
78 tw = numerator / denom;
80 tw = (get_collection_size() - tf + 0.5) / (tf + 0.5);
101 if (
rare(tw <= 1.0)) {
104 termweight = log(tw) * factor;
107 if (tw < 2) tw = tw * 0.5 + 1;
108 termweight = log(tw) * factor;
117 len_factor = get_average_length();
120 if (len_factor != 0) len_factor = param_k / len_factor;
129 return "Xapian::TradWeight";
133 TradWeight::serialise()
const 139 TradWeight::unserialise(
const string & s)
const 141 const char *ptr = s.data();
142 const char *end = ptr + s.size();
144 if (
rare(ptr != end))
153 double wdf_double = wdf;
154 return termweight * (wdf_double / (len * len_factor + wdf_double));
158 TradWeight::get_maxpart()
const 160 double wdf_max = get_wdf_upper_bound();
162 return termweight * (wdf_max / (doclen_lb * len_factor + wdf_max));
172 TradWeight::get_maxextra()
const The Xapian namespace contains public interfaces for the Xapian library.
#define AssertRel(A, REL, B)
Hierarchy of classes which Xapian can throw as exceptions.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
functions to serialise and unserialise a double
double unserialise_double(const char **p, const char *end)
Unserialise a double serialised by serialise_double.
Indicates an error in the std::string serialisation of an object.
Xapian::Weight subclass implementing the traditional probabilistic formula.
std::string serialise_double(double v)
Serialise a double to a string.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Various assertion macros.