matcher/phrasepostlist.h

Go to the documentation of this file.
00001 /* phrasepostlist.h: Return only items where terms are near or form a phrase
00002  *
00003  * ----START-LICENCE----
00004  * Copyright 1999,2000,2001 BrightStation PLC
00005  * Copyright 2003,2004,2005 Olly Betts
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of the
00010  * License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020  * USA
00021  * -----END-LICENCE-----
00022  */
00023 
00024 #ifndef OM_HGUARD_PHRASEPOSTLIST_H
00025 #define OM_HGUARD_PHRASEPOSTLIST_H
00026 
00027 #include "selectpostlist.h"
00028 #include <vector>
00029 
00030 typedef Xapian::PositionIterator::Internal PositionList;
00031 
00039 class NearPostList : public SelectPostList {
00040     private:
00041         Xapian::termpos window;
00042         std::vector<PostList *> terms;
00043 
00044         bool test_doc();
00045         bool do_test(std::vector<PositionList *> &plists, Xapian::termcount i,
00046                      Xapian::termcount min, Xapian::termcount max);
00047     public:
00048         std::string get_description() const;
00049         Xapian::termcount get_wdf() const;
00050 
00051         Xapian::doccount get_termfreq_est() const
00052         {
00053             // No idea how to estimate this - FIXME
00054             return source->get_termfreq_est() / 2;
00055         }
00056 
00057         NearPostList(PostList *source_, Xapian::termpos window_,
00058                      std::vector<PostList *> terms_)
00059                 : SelectPostList(source_)
00060         {
00061             window = window_;
00062             terms = terms_;
00063         }
00064 };
00065 
00073 class PhrasePostList : public SelectPostList {
00074     private:
00075         Xapian::termpos window;
00076         std::vector<PostList *> terms;
00077 
00078         bool test_doc();
00079         bool do_test(std::vector<PositionList *> &plists, Xapian::termcount i,
00080                      Xapian::termcount min, Xapian::termcount max);
00081     public:
00082         std::string get_description() const;
00083         Xapian::termcount get_wdf() const;
00084 
00085         Xapian::doccount get_termfreq_est() const
00086         {
00087             // No idea how to estimate this - FIXME
00088             return source->get_termfreq_est() / 3;
00089         }
00090 
00091         PhrasePostList(PostList *source_, Xapian::termpos window_,
00092                        std::vector<PostList *> terms_) : SelectPostList(source_)
00093         {
00094             window = window_;
00095             terms = terms_;
00096         }
00097 };
00098 
00099 #endif /* OM_HGUARD_PHRASEPOSTLIST_H */
00100 

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.