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 : 2005/12/28 00013 // 00014 #ifndef _TERMSCORER_H 00015 #define _TERMSCORER_H 00016 00017 00018 #include "Scorer.h" 00019 #include "../index/TermDocs.h" 00020 #include "../index/NormBytes.h" 00021 00022 using namespace firtex::index; 00023 00024 namespace firtex 00025 { 00026 namespace search 00027 { 00028 #define TERMSCORE_CACHESIZE 1024 00029 class CWeight; 00030 class CSearcher; 00031 class CSimilarity; 00032 class CTermScorer : public CScorer 00033 { 00034 public: 00035 CTermScorer(CWeight* pWeight,CTermDocs* pTermDocs,CSimilarity* pSimilarity,CNormBytes* norms); 00036 virtual ~CTermScorer(void); 00037 public: 00038 00043 count_t nextDocs(); 00044 00051 count_t scores(docid_t*& docs,score_t*& scores); 00052 00060 bool skipTo(docid_t target,docid_t& nearTarget); 00061 00066 bool next(); 00067 00068 /* 00069 * 返回当前位置文档的打分结果,必须配合{@link skipTo(docid_t,DOC_ID)}或{@link next()}使用,只有返回true后才有效 00070 */ 00071 score_t score(); 00072 00073 /* 00074 * 返回当前位置文档ID,必须配合{@link skipTo(docid_t,DOC_ID)}或{@link next()}使用,只有返回true后才有效 00075 */ 00076 docid_t doc(); 00077 protected: 00078 CWeight* m_pWeight; 00079 CTermDocs* m_pTermDocs; 00080 00081 score_t m_fWeights; 00082 docid_t* m_docs; //多个文档ID,内存由CTermDocs维护,调用nextDocs()时使用 00083 freq_t* m_freqs; //多个词频,内存由CTermDocs维护,调用nextDocs()时使用 00084 count_t m_numDocs; //文档数 00085 00086 docid_t m_doc; //单个文档ID,调用skipTo()时使用 00087 freq_t m_freq; //单个词频,调用skipTo()时使用 00088 00089 score_t* m_scores; //打分结果 00090 count_t m_pointer; //m_scores数组访问指针 00091 count_t m_pointerMax; //m_scores数组大小 00092 00093 score_t m_scoreCache[TERMSCORE_CACHESIZE]; //Score Cache 00094 CNormBytes* m_norms; 00095 }; 00096 } 00097 } 00098 00099 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex