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/7/15 00013 // 00014 #ifndef _WORDPOSITIONVECTOR_H 00015 #define _WORDPOSITIONVECTOR_H 00016 00017 #include "TermFreqVector.h" 00018 00019 #if _MSC_VER > 1000 00020 #pragma once 00021 #endif // _MSC_VER > 1000 00022 00023 #include "TermPositionVector.h" 00024 #include "../store/IndexInput.h" 00025 #include "../utility/DynamicArray.h" 00026 using namespace firtex::store; 00027 using namespace firtex::utility; 00028 00029 namespace firtex 00030 { 00031 namespace index 00032 { 00033 class CWordPositionVector : public CTermPositionVector 00034 { 00035 00036 class loc_t_nullvalue 00037 { 00038 public: 00039 inline operator loc_t()const {return -1;} 00040 }; 00041 typedef struct _FREQ_POS 00042 { 00043 freq_t freq; 00044 CDynamicArray<loc_t,loc_t_nullvalue> positions; 00045 }FREQ_POS; 00046 public: 00047 CWordPositionVector(); 00048 CWordPositionVector(const tchar* field,CIndexInput* pTVVInput); 00049 virtual ~CWordPositionVector(void); 00050 public: 00056 void open(const tchar* field,CIndexInput* pInput); 00060 count_t numTerms(); 00061 00065 count_t numDistinctTerms(); 00066 00072 const CTerm* getTerms(); 00073 00079 const termid_t* getTermIDs(); 00080 00086 const freq_t* getTermFrequencies(); 00087 00094 void getTermFreqVector(termid_t*& tids,freq_t*& freqs,count_t& size); 00095 00101 int indexOf(termid_t tid); 00102 00104 00110 const loc_t* getTermPositions(const CTerm* term); 00111 00118 const loc_t* getTermPositions(termid_t tid); 00119 00126 const loc_t* getTermPositions(size_t index); 00127 protected: 00133 void addField(CIndexOutput* pOutput,CField* pField); 00134 00135 private: 00136 CDynamicArray<FREQ_POS*,Const_NullValue<FREQ_POS*> >* m_pTermDictionary; 00137 }; 00138 } 00139 } 00140 00141 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex