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 _BOOLEANQUERY_H 00015 #define _BOOLEANQUERY_H 00016 00017 #include <vector> 00018 #include "Query.h" 00019 #include "Weight.h" 00020 00021 using namespace std; 00022 00023 namespace firtex 00024 { 00025 namespace search 00026 { 00027 class CBooleanClause; 00028 typedef vector<CBooleanClause*> ClauseVector; 00029 typedef ClauseVector::const_iterator ClauseIterator; 00030 class CBooleanQuery : public CQuery 00031 { 00032 typedef vector<CWeight*> WeightVector; 00033 typedef WeightVector::iterator WeightIterator; 00034 class CBooleanWeight:public CWeight 00035 { 00036 public: 00037 CBooleanWeight(CSearcher* pSearcher,CBooleanQuery* pQuery); 00038 virtual ~CBooleanWeight(); 00039 public: 00040 weight_t squaredWeight(); 00041 void normalize(float fQueryNorm); 00042 00043 weight_t getValue(); 00044 protected: 00045 CSearcher* m_pSearcher; 00046 WeightVector m_weights; 00047 weight_t m_fWeight; 00048 }; 00049 public: 00050 CBooleanQuery(void); 00051 CBooleanQuery(const CBooleanQuery& clone); 00052 virtual ~CBooleanQuery(void); 00053 public: 00060 CQuery* optimize(firtex::index::CIndexReader* pReader); 00061 00067 CScorer* scorer(CSearcher* pSearcher); 00068 00073 CQuery* clone(); 00074 00075 int32_t getClaouseCount(){return (int32_t)m_clauses.size();} 00076 00082 void add(CQuery* query, const bool required, const bool prohibited); 00083 void add(CBooleanClause* pClause); 00084 00085 void clear(); 00086 public: 00087 static int getMaxClauseCount(); 00088 static void setMaxClauseCount(int maxCount); 00089 public: 00090 static const char* getClassName(){return "BooleanQuery";} 00091 const char* getQueryName() const{return getClassName();} 00092 protected: 00093 CWeight* createWeight(CSearcher* pSearcher); 00094 protected: 00095 ClauseVector m_clauses; 00096 00097 static int maxClauseCount; 00098 int m_minShouldMatch; 00099 00100 friend class CBooleanQuery::CBooleanWeight; 00101 }; 00102 } 00103 } 00104 00105 00106 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex