22 #ifndef XAPIAN_INCLUDED_WEIGHTINTERNAL_H 23 #define XAPIAN_INCLUDED_WEIGHTINTERNAL_H 44 TermFreqs() : termfreq(0), reltermfreq(0), collfreq(0), max_part(0.0) {}
48 double max_part_ = 0.0)
49 : termfreq(termfreq_),
50 reltermfreq(reltermfreq_),
52 max_part(max_part_) {}
71 #ifdef XAPIAN_ASSERTIONS 79 mutable bool finalised =
false;
96 bool have_max_part =
false;
143 #ifdef XAPIAN_ASSERTIONS 149 termfreq = collection_size;
150 collfreq = collection_size;
151 reltermfreq = rset_size;
155 auto i = termfreqs.find(term);
156 if (i == termfreqs.end()) {
157 termfreq = reltermfreq = collfreq = 0;
161 termfreq = i->second.termfreq;
162 reltermfreq = i->second.reltermfreq;
163 collfreq = i->second.collfreq;
172 return get_stats(term, termfreq, dummy1, dummy2);
177 #ifdef XAPIAN_ASSERTIONS 185 auto i = termfreqs.find(term);
186 if (i == termfreqs.end()) {
190 termweight = i->second.max_part;
199 auto i = termfreqs.begin();
200 while (i != termfreqs.end() && i->second.max_part == 0.0) ++i;
201 if (
rare(i == termfreqs.end())) {
202 min_tw = max_tw = 0.0;
205 min_tw = max_tw = i->second.max_part;
206 while (++i != termfreqs.end()) {
207 double max_part = i->second.max_part;
208 if (max_part > max_tw) {
210 }
else if (max_part < min_tw && max_part != 0.0) {
218 have_max_part =
true;
220 auto i = termfreqs.find(term);
221 if (i != termfreqs.end())
222 i->second.max_part += max_part;
226 #ifdef XAPIAN_ASSERTIONS 229 if (
rare(collection_size == 0))
return 0;
245 #endif // XAPIAN_INCLUDED_WEIGHTINTERNAL_H The Xapian namespace contains public interfaces for the Xapian library.
size_t sub_db(Xapian::docid did, size_t n_dbs)
This class is used to access a database, or a group of databases.
Xapian::Database db
Database to get the bounds on doclength and wdf from.
void operator+=(const TermFreqs &other)
std::string get_description() const
Return a std::string describing this object.
Base class for databases.
XAPIAN_TOTALLENGTH_TYPE totallength
The total length of all documents in a database.
void set_query(const Xapian::Query &query_)
bool get_stats(const std::string &term, Xapian::doccount &termfreq, Xapian::doccount &reltermfreq, Xapian::termcount &collfreq) const
Get the frequencies for the given term.
Xapian::doccount termfreq
std::map< std::string, TermFreqs > termfreqs
Map of term frequencies and relevant term frequencies for the collection.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Xapian::Query query
The query.
double doclength
A normalised document length.
Class to hold statistics for a given collection.
TermFreqs(Xapian::doccount termfreq_, Xapian::doccount reltermfreq_, Xapian::termcount collfreq_, double max_part_=0.0)
API for working with Xapian databases.
void get_max_termweight(double &min_tw, double &max_tw)
Get the minimum and maximum termweights.
Xapian::termcount collfreq
bool get_termweight(const std::string &term, double &termweight) const
Get the termweight.
void set_bounds_from_db(const Xapian::Database &db_)
Set the "bounds" stats from Database db.
Xapian::doclength get_average_length() const
The frequencies for a term.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
bool get_stats(const std::string &term, Xapian::doccount &termfreq) const
Get just the termfreq.
void set_max_part(const std::string &term, double max_part)
Set max_part for a term.
Various assertion macros.
Class representing a query.
Xapian::doccount reltermfreq