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/3/9 00013 // 00014 00015 #ifndef _PHRASEQUERY_H 00016 #define _PHRASEQUERY_H 00017 00018 #include "Query.h" 00019 #include "Weight.h" 00020 #include <vector> 00021 using namespace std; 00022 00023 namespace firtex 00024 { 00025 namespace search 00026 { 00027 class CTermQuery; 00028 typedef vector<CTerm*>::iterator TermIterator; 00029 class CPhraseQuery : public CQuery 00030 { 00031 class CPhraseWeight: public CWeight 00032 { 00033 public: 00034 CPhraseWeight(CSearcher* pSearcher,CPhraseQuery* pQuery); 00035 virtual ~CPhraseWeight(); 00036 public: 00037 weight_t squaredWeight(); 00038 weight_t getValue(); 00039 void normalize(float fQueryNorm); 00040 protected: 00041 CSearcher* m_pSearcher; 00042 00043 score_t m_fWeight; 00044 score_t m_idf; 00045 }; 00046 public: 00047 CPhraseQuery(void); 00048 CPhraseQuery(const CPhraseQuery& clone); 00049 virtual ~CPhraseQuery(void); 00050 public: 00051 void addTerm(CTerm* term); 00052 CScorer* scorer(CSearcher* pSearcher); 00053 CQuery* clone(); 00054 00055 void setSlop(int nSlop){m_nSlop = nSlop;} 00056 int getSlop(){return m_nSlop;} 00057 00058 static const char* getClassName(){return "PhraseQuery";} 00059 const char* getQueryName() const{return getClassName();} 00060 protected: 00061 CWeight* createWeight(CSearcher* pSearcher); 00062 protected: 00063 vector<CTerm*>m_terms; 00064 CTermQuery* m_pTermQuery; 00065 int m_nSlop; 00066 00067 friend class CPhraseQuery::CPhraseWeight; 00068 }; 00069 } 00070 } 00071 00072 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex