36 DLHWeight::clone()
const
42 DLHWeight::init(
double factor)
50 double wdf_upper = get_wdf_upper_bound();
56 const double wdf_lower = 1.0;
57 double len_upper = get_doclength_upper_bound();
58 double len_lower = get_doclength_lower_bound();
60 double F = get_collection_freq();
63 log_constant = get_total_length() / F;
64 wqf_product_factor = get_wqf() * factor;
69 double max_wdf_over_l = wdf_upper < len_lower ? wdf_upper / len_lower : 1.0;
78 double logged_expr = max_wdf_over_l * log_constant;
79 double w_for_A = logged_expr > 1.0 ? wdf_upper : wdf_lower;
80 double A = w_for_A / (w_for_A + 0.5) * log2(logged_expr);
94 if (len_lower > wdf_upper) {
121 double B1 = (len_lower - wdf_lower) * log2(1.0 - wdf_lower / len_lower);
122 double B2 = (len_lower - wdf_upper) * log2(1.0 - wdf_upper / len_lower);
136 double wdf_var = min(wdf_upper, len_upper / 2.0);
137 double max_product = wdf_var * (1.0 - wdf_var / len_upper);
143 double min_wdf_to_len = wdf_lower / len_upper;
144 double max_product_2 = wdf_upper * (1.0 - min_wdf_to_len);
146 max_product = min(max_product, max_product_2);
148 double C = 0.5 * log2(2.0 * M_PI * max_product) / (wdf_lower + 0.5);
149 upper_bound =
A +
B +
C;
151 if (
rare(upper_bound < 0.0))
154 upper_bound *= wqf_product_factor;
164 DLHWeight::serialise()
const
170 DLHWeight::unserialise(
const string& s)
const
172 if (
rare(!s.empty()))
181 if (wdf == 0 || wdf == len)
return 0.0;
183 double wdf_to_len = double(wdf) / len;
184 double one_minus_wdf_to_len = 1.0 - wdf_to_len;
186 double wt = wdf * log2(wdf_to_len * log_constant) +
187 (len - wdf) * log2(one_minus_wdf_to_len) +
188 0.5 * log2(2.0 * M_PI * wdf * one_minus_wdf_to_len);
189 if (
rare(wt <= 0.0))
return 0.0;
191 return wqf_product_factor * wt / (wdf + 0.5);
195 DLHWeight::get_maxpart()
const
201 DLHWeight::create_from_parameters(
const char *
p)
const
This class implements the DLH weighting scheme, which is a representative scheme of the Divergence fr...
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Indicates an error in the std::string serialisation of an object.
Hierarchy of classes which Xapian can throw as exceptions.
The Xapian namespace contains public interfaces for the Xapian library.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.