include/xapian/matchspy.h

Go to the documentation of this file.
00001 
00004 /* Copyright (C) 2007 Olly Betts
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00019  */
00020 
00021 #ifndef XAPIAN_INCLUDED_MATCHSPY_H
00022 #define XAPIAN_INCLUDED_MATCHSPY_H
00023 
00024 #include <xapian/enquire.h>
00025 
00026 #include <map>
00027 #include <string>
00028 
00029 namespace Xapian {
00030 
00032 class XAPIAN_VISIBILITY_DEFAULT MatchSpy : public MatchDecider {
00033     mutable size_t total;
00034 
00035     mutable std::map<Xapian::valueno, std::map<std::string, size_t> > categories;
00036 
00037   public:
00039     MatchSpy() : total(0) { }
00040 
00045     MatchSpy(Xapian::valueno valno) : total(0) {
00046         add_category(valno);
00047     }
00048 
00053     void add_category(Xapian::valueno valno) {
00054         // Ensure that categories[valno] exists.
00055         (void)categories[valno];
00056     }
00057 
00062     bool operator()(const Xapian::Document &doc) const;
00063 
00065     size_t get_total() const {
00066         return total;
00067     }
00068 
00070     const std::map<std::string, size_t> &
00071             get_categories(Xapian::valueno valno) const {
00072         return categories[valno];
00073     }
00074 
00095     double score_categorisation(Xapian::valueno valno,
00096                                 double desired_no_of_categories = 0.0);
00097 
00117     bool build_numeric_ranges(Xapian::valueno valno, size_t max_ranges);
00118 };
00119 
00120 }
00121 
00122 #endif // XAPIAN_INCLUDED_MATCHSPY_H

Documentation for Xapian (version 1.0.2).
Generated on 5 Jul 2007 by Doxygen 1.5.2.