22 #ifndef XAPIAN_INCLUDED_WEIGHTINTERNAL_H 23 #define XAPIAN_INCLUDED_WEIGHTINTERNAL_H 50 double max_part_ = 0.0)
51 : termfreq(termfreq_),
52 reltermfreq(reltermfreq_),
54 max_part(max_part_) {}
75 #ifdef XAPIAN_ASSERTIONS 83 mutable bool finalised =
false;
100 bool have_max_part =
false;
147 #ifdef XAPIAN_ASSERTIONS 153 termfreq = collection_size;
154 collfreq = collection_size;
155 reltermfreq = rset_size;
159 auto i = termfreqs.find(term);
160 if (i == termfreqs.end()) {
161 termfreq = reltermfreq = collfreq = 0;
165 termfreq = i->second.termfreq;
166 reltermfreq = i->second.reltermfreq;
167 collfreq = i->second.collfreq;
176 return get_stats(term, termfreq, dummy1, dummy2);
181 #ifdef XAPIAN_ASSERTIONS 189 auto i = termfreqs.find(term);
190 if (i == termfreqs.end()) {
194 termweight = i->second.max_part;
203 auto i = termfreqs.begin();
204 while (i != termfreqs.end() && i->second.max_part == 0.0) ++i;
205 if (
rare(i == termfreqs.end())) {
206 min_tw = max_tw = 0.0;
209 min_tw = max_tw = i->second.max_part;
210 while (++i != termfreqs.end()) {
211 double max_part = i->second.max_part;
212 if (max_part > max_tw) {
214 }
else if (max_part < min_tw && max_part != 0.0) {
223 auto i = termfreqs.find(term);
224 if (i != termfreqs.end()) {
225 have_max_part =
true;
226 double& val = i->second.max_part;
227 val = std::max(val, max_part);
232 #ifdef XAPIAN_ASSERTIONS 235 if (
rare(collection_size == 0))
return 0;
251 #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