22 #ifndef XAPIAN_INCLUDED_WEIGHTINTERNAL_H
23 #define XAPIAN_INCLUDED_WEIGHTINTERNAL_H
42 #include <string_view>
43 #ifdef HAVE_STD_FROM_CHARS_DOUBLE
64 double max_part_ = 0.0)
107 #ifdef XAPIAN_ASSERTIONS
115 mutable bool finalised =
false;
151 std::map<std::string, TermFreqs, std::less<>>
termfreqs;
188 #ifdef XAPIAN_ASSERTIONS
202 termfreq = reltermfreq = collfreq = 0;
206 termfreq = i->second.termfreq;
207 reltermfreq = i->second.reltermfreq;
208 collfreq = i->second.collfreq;
222 #ifdef XAPIAN_ASSERTIONS
235 termweight = i->second.max_part;
245 while (i !=
termfreqs.end() && i->second.max_part == 0.0) ++i;
247 min_tw = max_tw = 0.0;
250 min_tw = max_tw = i->second.max_part;
252 double max_part = i->second.max_part;
253 if (max_part > max_tw) {
255 }
else if (max_part < min_tw && max_part != 0.0) {
267 double& val = i->second.max_part;
268 val = std::max(val, max_part);
273 #ifdef XAPIAN_ASSERTIONS
286 #ifdef HAVE_STD_FROM_CHARS_DOUBLE
287 const char* startptr = *
p;
290 const char* endptr = startptr + std::strlen(startptr);
292 const auto& r = std::from_chars(startptr, endptr, v);
293 if (r.ec != std::errc()) {
301 double v = strtod(*
p, &end);
302 if (*
p == end || errno)
return false;
312 if (*q ==
'\0')
break;
315 if (q == *
p)
return false;
323 const std::string& scheme,
324 const char* params) {
Virtual base class for Database internals.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Class representing a query.
Class representing a set of documents judged as relevant.
Class to hold statistics for a given collection.
static void parameter_error(const char *msg, const std::string &scheme, const char *params)
Xapian::totallength total_length
Total length of all documents in the collection.
Xapian::Query query
The query.
bool get_stats(std::string_view term, Xapian::doccount &termfreq, Xapian::doccount &reltermfreq, Xapian::termcount &collfreq) const
Get the frequencies for the given term.
std::string get_description() const
Return a std::string describing this object.
static bool param_name(const char **p, std::string &name)
Xapian::termcount db_doclength_upper_bound
An upper bound on the maximum length of any document in the database.
bool have_max_part
Has max_part been set for any term?
bool get_termweight(std::string_view term, double &termweight) const
Get the termweight.
Xapian::termcount db_doclength_lower_bound
A lower bound on the minimum length of any document in the database.
void get_max_termweight(double &min_tw, double &max_tw)
Get the minimum and maximum termweights.
void merge(const Weight::Internal &o)
Xapian::termcount db_unique_terms_lower_bound
A lower bound on the number of unique terms in any document.
Xapian::doccount rset_size
Number of relevant documents in the collection.
Xapian::doccount collection_size
Number of documents in the collection.
static bool double_param(const char **p, double *ptr_val)
bool get_stats(std::string_view term, Xapian::doccount &termfreq) const
Get just the termfreq.
Xapian::doclength get_average_length() const
void set_max_part(const std::string &term, double max_part)
Set max_part for a term.
void accumulate_stats(const Xapian::Database::Internal &sub_db, const Xapian::RSet &rset)
Accumulate the rtermfreqs for terms in the query.
std::map< std::string, TermFreqs, std::less<> > termfreqs
Map of term frequencies and relevant term frequencies for the collection.
Internal & operator+=(const Internal &inc)
Add in the supplied statistics from a sub-database.
void set_query(const Xapian::Query &query_)
Xapian::termcount db_unique_terms_upper_bound
An upper bound on the number of unique terms in any document.
An indexed database of documents.
Virtual base class for Database internals.
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.
double doclength
A normalised document length.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
Various assertion macros.
Various handy string-related helpers.
The frequencies for a term.
Xapian::doccount reltermfreq
Xapian::doccount termfreq
void operator+=(const TermFreqs &other)
std::string get_description() const
Return a std::string describing this object.
TermFreqs(Xapian::doccount termfreq_, Xapian::doccount reltermfreq_, Xapian::termcount collfreq_, double max_part_=0.0)
void operator*=(double factor)
void operator/=(unsigned x)
Xapian::termcount collfreq