41 BM25PlusWeight::clone()
const
44 param_min_normlen, param_delta);
48 BM25PlusWeight::init(
double factor)
56 termweight = log(
double(get_collection_size() + 1) / tf);
59 double wqf_double = get_wqf();
60 termweight *= (param_k3 + 1) * wqf_double / (param_k3 + wqf_double);
66 if (param_k2 == 0 && (param_b == 0 || param_k1 == 0)) {
71 len_factor = get_average_length();
74 if (len_factor != 0) len_factor = 1 / len_factor;
87 BM25PlusWeight::serialise()
const
99 BM25PlusWeight::unserialise(
const string & s)
const
101 const char *ptr = s.data();
102 const char *end = ptr + s.size();
109 if (
rare(ptr != end))
118 LOGCALL(WTCALC,
double,
"BM25PlusWeight::get_sumpart", wdf | len);
121 double wdf_double = wdf;
122 double denom = param_k1 * (normlen * param_b + (1 - param_b)) + wdf_double;
127 RETURN(termweight * ((param_k1 + 1) * wdf_double / denom + param_delta));
131 BM25PlusWeight::get_maxpart()
const
133 LOGCALL(WTCALC,
double,
"BM25PlusWeight::get_maxpart", NO_ARGS);
134 double denom = param_k1;
136 if (param_k1 != 0.0) {
137 if (param_b != 0.0) {
147 max(max(wdf_max, get_doclength_lower_bound()) * len_factor,
149 denom *= (normlen_lb * param_b + (1 - param_b));
154 RETURN(termweight * ((param_k1 + 1) * wdf_max / denom + param_delta));
174 LOGCALL(WTCALC,
double,
"BM25PlusWeight::get_sumextra", len);
175 double num = (2.0 * param_k2 * get_query_length());
176 RETURN(num / (1.0 + max(len * len_factor, param_min_normlen)));
180 BM25PlusWeight::get_maxextra()
const
182 LOGCALL(WTCALC,
double,
"BM25PlusWeight::get_maxextra", NO_ARGS);
185 double num = (2.0 * param_k2 * get_query_length());
186 RETURN(num / (1.0 + max(get_doclength_lower_bound() * len_factor,
187 param_min_normlen)));
198 BM25PlusWeight::create_from_parameters(
const char* params)
const
200 const char*
p = params;
207 double min_normlen = 0.5;
Xapian::Weight subclass implementing the BM25+ probabilistic formula.
Indicates an error in the std::string serialisation of an object.
static void parameter_error(const char *msg, const std::string &scheme, const char *params)
static bool double_param(const char **p, double *ptr_val)
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
Hierarchy of classes which Xapian can throw as exceptions.
static void parameter_error(const char *message, const std::string &scheme, const char *params)
The Xapian namespace contains public interfaces for the Xapian library.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
double doclength
A normalised document length.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Various assertion macros.
#define AssertRel(A, REL, B)
string serialise_double(double v)
Serialise a double to a string.
double unserialise_double(const char **p, const char *end)
Unserialise a double serialised by serialise_double.
functions to serialise and unserialise a double
Xapian::Weight::Internal class, holding database and term statistics.