00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef XAPIAN_INCLUDED_EXPANDWEIGHT_H
00022 #define XAPIAN_INCLUDED_EXPANDWEIGHT_H
00023
00024 #include <xapian/database.h>
00025
00026 #include "termlist.h"
00027
00028 #include <string>
00029 #include <vector>
00030
00031 namespace Xapian {
00032 namespace Internal {
00033
00035 class ExpandStats {
00036
00037 std::vector<bool> dbs_seen;
00038
00039
00040 Xapian::doclength avlen;
00041
00043 double expand_k;
00044
00045 public:
00047 Xapian::doccount dbsize;
00048
00050 Xapian::doccount termfreq;
00051
00053 Xapian::weight multiplier;
00054
00056 Xapian::doccount rtermfreq;
00057
00059 size_t db_index;
00060
00061 ExpandStats(Xapian::doclength avlen_, double expand_k_)
00062 : avlen(avlen_), expand_k(expand_k_),
00063 dbsize(0), termfreq(0), multiplier(0), rtermfreq(0), db_index(0) {
00064 }
00065
00066 void accumulate(Xapian::termcount wdf, Xapian::doclength doclen, Xapian::doccount subtf, Xapian::doccount subdbsize) {
00067
00068
00069 if (wdf == 0) wdf = 1;
00070
00071 multiplier += (expand_k + 1) * wdf / (expand_k * doclen / avlen + wdf);
00072 ++rtermfreq;
00073
00074
00075
00076 if (db_index >= dbs_seen.size() || !dbs_seen[db_index]) {
00077 dbsize += subdbsize;
00078 termfreq += subtf;
00079 if (db_index >= dbs_seen.size()) dbs_seen.resize(db_index + 1);
00080 dbs_seen[db_index] = true;
00081 }
00082 }
00083 };
00084
00086 class ExpandWeight {
00088 const Xapian::Database db;
00089
00091 Xapian::doccount rsize;
00092
00103 bool use_exact_termfreq;
00104
00106 double expand_k;
00107
00108 public:
00109 ExpandWeight(const Xapian::Database &db_,
00110 Xapian::doccount rsize_,
00111 bool use_exact_termfreq_,
00112 double expand_k_);
00113
00114 Xapian::weight get_weight(TermList * merger,
00115 const std::string & tname) const;
00116 };
00117
00118 }
00119 }
00120
00121 #endif // XAPIAN_INCLUDED_EXPANDWEIGHT_H