CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_search_PhraseScorer_ 00008 #define _lucene_search_PhraseScorer_ 00009 00010 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 #include "PhraseQueue.h" 00015 #include "PhrasePositions.h" 00016 #include "Scorer.h" 00017 #include "Similarity.h" 00018 00019 CL_NS_DEF(search) 00020 00021 class PhraseScorer: public Scorer { 00022 private: 00023 Weight* weight; 00024 float_t freq; 00025 bool firstTime; 00026 bool more; 00027 00028 protected: 00029 uint8_t* norms; 00030 float_t value; 00031 00032 PhraseQueue* pq; //is used to order the list point to by first and last 00033 PhrasePositions* first; //Points to the first in the list of PhrasePositions 00034 PhrasePositions* last; //Points to the last in the list of PhrasePositions 00035 00036 public: 00037 //Constructor 00038 PhraseScorer(Weight* weight, CL_NS(index)::TermPositions** tps, 00039 int32_t* positions, Similarity* similarity, uint8_t* norms); 00040 virtual ~PhraseScorer(); 00041 00042 int32_t doc() const { return first->doc; } 00043 bool next(); 00044 float_t score(); 00045 bool skipTo(int32_t target); 00046 00047 00048 void explain(int32_t doc, Explanation* ret); 00049 TCHAR* toString(); 00050 protected: 00051 virtual float_t phraseFreq() =0; 00052 00053 //Transfers the PhrasePositions from the PhraseQueue pq to 00054 //the PhrasePositions list with first as its first element 00055 void pqToList(); 00056 00057 //Moves first to the end of the list 00058 void firstToLast(); 00059 private: 00060 bool doNext(); 00061 void init(); 00062 void sort(); 00063 }; 00064 CL_NS_END 00065 #endif