40 BM25PlusWeight::clone()
const 43 param_min_normlen, param_delta);
47 BM25PlusWeight::init(
double factor)
55 termweight = log(
double(get_collection_size() + 1) / tf);
58 double wqf_double = get_wqf();
59 termweight *= (param_k3 + 1) * wqf_double / (param_k3 + wqf_double);
65 if (param_k2 == 0 && (param_b == 0 || param_k1 == 0)) {
70 len_factor = get_average_length();
73 if (len_factor != 0) len_factor = 1 / len_factor;
82 return "Xapian::BM25PlusWeight";
86 BM25PlusWeight::serialise()
const 98 BM25PlusWeight::unserialise(
const string & s)
const 100 const char *ptr = s.data();
101 const char *end = ptr + s.size();
108 if (
rare(ptr != end))
117 LOGCALL(WTCALC,
double,
"BM25PlusWeight::get_sumpart", wdf | len);
120 double wdf_double = wdf;
121 double denom = param_k1 * (normlen * param_b + (1 - param_b)) + wdf_double;
126 RETURN(termweight * ((param_k1 + 1) * wdf_double / denom + param_delta));
130 BM25PlusWeight::get_maxpart()
const 132 LOGCALL(WTCALC,
double,
"BM25PlusWeight::get_maxpart", NO_ARGS);
133 double denom = param_k1;
135 if (param_k1 != 0.0) {
136 if (param_b != 0.0) {
146 max(max(wdf_max, get_doclength_lower_bound()) * len_factor,
148 denom *= (normlen_lb * param_b + (1 - param_b));
153 RETURN(termweight * ((param_k1 + 1) * wdf_max / denom + param_delta));
171 LOGCALL(WTCALC,
double,
"BM25PlusWeight::get_sumextra", len);
172 double num = (2.0 * param_k2 * get_query_length());
173 RETURN(num / (1.0 + max(len * len_factor, param_min_normlen)));
177 BM25PlusWeight::get_maxextra()
const 179 LOGCALL(WTCALC,
double,
"BM25PlusWeight::get_maxextra", NO_ARGS);
182 double num = (2.0 * param_k2 * get_query_length());
183 RETURN(num / (1.0 + max(get_doclength_lower_bound() * len_factor,
184 param_min_normlen)));
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.
double doclength
A normalised document length.
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.
Xapian::Weight subclass implementing the BM25+ probabilistic formula.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)