FirteX-高性能全文索引和检索平台API Documentation |
00001 // 00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 00003 // All rights reserved. 00004 // This file is part of FirteX (www.firtex.org) 00005 // 00006 // Use of the FirteX is subject to the terms of the software license set forth in 00007 // the LICENSE file included with this software, and also available at 00008 // http://www.firtex.org/license.html 00009 // 00010 // Author : 郭瑞杰(GuoRuijie) 00011 // Email : ruijieguo@software.ict.ac.cn,ruijieguo@gmail.com 00012 // Created : 2006/5/9 00013 // 00014 #ifndef _BOOLEANSCORER_H 00015 #define _BOOLEANSCORER_H 00016 00017 #include <list> 00018 #include "Scorer.h" 00019 using namespace std; 00020 00021 namespace firtex 00022 { 00023 namespace search 00024 { 00025 typedef list<CScorer*> ScorerList; 00026 class CSimilarity; 00027 class CBooleanScorer : public CScorer 00028 { 00029 class CSingleMatchScorer:public CScorer 00030 { 00031 public: 00032 CSingleMatchScorer(CScorer* pScorer):m_pScorer(pScorer) 00033 { 00034 } 00035 ~CSingleMatchScorer(){delete m_pScorer;} 00036 public: 00037 count_t nextDocs(){return m_pScorer->nextDocs();} 00038 count_t scores(docid_t*& docs,score_t*& scores){return m_pScorer->scores(docs,scores);}; 00039 bool skipTo(docid_t target,docid_t& nearTarget){return m_pScorer->skipTo(target,nearTarget);} 00040 bool next(){return m_pScorer->next();} 00041 docid_t doc(){return m_pScorer->doc();} 00042 score_t score(){return m_pScorer->score();} 00043 protected: 00044 CScorer* m_pScorer; 00045 }; 00046 00047 public: 00048 CBooleanScorer(CSimilarity* pSimilarity,int minNrShouldMatch=1); 00049 virtual ~CBooleanScorer(void); 00050 public: 00051 count_t nextDocs(); 00052 count_t scores(docid_t*& docs,score_t*& scores); 00053 bool skipTo(docid_t target,docid_t& nearTarget); 00054 bool next(); 00055 docid_t doc(); 00056 score_t score(); 00057 00058 void add(CScorer* pScorer,bool bRequired,bool bProhibited); 00059 protected: 00060 CScorer* makeScorer(); 00061 CScorer* makeScorerNoReq(); 00062 CScorer* makeScorerSomeReq(); 00063 CScorer* makeConjunctionScorer(ScorerList* scorerList); 00064 CScorer* makeDisjunctionScorer(ScorerList* scorerList,int minNrShouldMatch); 00065 CScorer* addProhibitedScorers(CScorer* requiredScorer); 00066 CScorer* dualConjunctionScorer(CScorer* req1, CScorer* req2); 00067 protected: 00068 int m_minNrShouldMatch; 00069 00070 ScorerList m_requiredScorers; 00071 ScorerList m_optionalScorers; 00072 ScorerList m_prohibitedScorers; 00073 00074 CScorer* m_pScorer; 00075 }; 00076 } 00077 } 00078 00079 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex