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/10 00013 // 00014 #ifndef _SCORER_H 00015 #define _SCORER_H 00016 00017 #include "HitCollector.h" 00018 #include "../utility/typedefs.h" 00019 using namespace firtex; 00020 00021 namespace firtex 00022 { 00023 namespace search 00024 { 00025 class CSimilarity; 00026 class CScorer 00027 { 00028 public: 00029 CScorer():m_pSimilarity(NULL) 00030 { 00031 } 00032 CScorer(CSimilarity* pSimilarity):m_pSimilarity(pSimilarity) 00033 { 00034 } 00035 00036 virtual ~CScorer() 00037 { 00038 m_pSimilarity = NULL; 00039 } 00040 public: 00045 void score(CHitCollector* pCollector) 00046 { 00047 count_t num; 00048 docid_t* docs; 00049 score_t* ss; 00050 while (nextDocs() > 0) 00051 { 00052 num = scores(docs,ss); 00053 pCollector->collect(docs,ss,num); 00054 } 00055 } 00056 00057 CSimilarity* getSimilarity(){return m_pSimilarity;} 00058 00063 virtual count_t nextDocs()=0; 00064 00071 virtual count_t scores(docid_t*& docs,score_t*& scores)=0; 00072 00080 virtual bool skipTo(docid_t target,docid_t& nearTarget)=0; 00081 00086 virtual bool next() = 0; 00087 00088 /* 00089 * 返回当前位置文档的打分结果,必须配合{@link skipTo(docid_t,DOC_ID)}或{@link next()}使用,只有返回true后才有效 00090 */ 00091 virtual score_t score()=0; 00092 /* 00093 * 返回当前位置文档ID,必须配合{@link skipTo(docid_t,DOC_ID)}或{@link next()}使用,只有调用skipTo并返回true后才有效 00094 */ 00095 virtual docid_t doc()=0; 00096 protected: 00097 CSimilarity* m_pSimilarity; 00098 00099 }; 00100 } 00101 } 00102 00103 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex