⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 booleanscorer.h

📁 clucene是c++版的全文检索引擎,完全移植于lucene,采用 stl 编写.
💻 H
字号:
/*------------------------------------------------------------------------------
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
* 
* Distributable under the terms of either the Apache License (Version 2.0) or 
* the GNU Lesser General Public License, as specified in the COPYING file.
------------------------------------------------------------------------------*/
#ifndef _lucene_search_BooleanScorer_
#define _lucene_search_BooleanScorer_

#if defined(_LUCENE_PRAGMA_ONCE)
# pragma once
#endif

#include "Scorer.h"

CL_NS_DEF(search)
	
	class BooleanScorer: public Scorer {
	private:
			
		class Bucket: LUCENE_BASE {
		public:
			int32_t	doc;				  // tells if bucket is valid
			float_t	score;				  // incremental score
			int32_t	bits;					  // used for bool constraints
			int32_t	coord;					  // count of terms in score
			Bucket*	next;				  // next valid bucket

			Bucket();
			~Bucket();
		};

		class SubScorer: LUCENE_BASE {
		public:
			bool done;
			Scorer* scorer;
			bool required;
			bool prohibited;
			HitCollector* collector;
			SubScorer* next;
			SubScorer(Scorer* scr, const bool r, const bool p, HitCollector* c, SubScorer* nxt);
			~SubScorer();
		};

		class BucketTable:LUCENE_BASE {		
		private:
			BooleanScorer* scorer;
		public:
			Bucket* buckets;
			Bucket* first;			  // head of valid list

			BucketTable(BooleanScorer* scr);
			int32_t size() const;
			HitCollector* newCollector(const int32_t mask);
			void clear();
			~BucketTable();
	      
		};

		class Collector: public HitCollector {
		private:
			BucketTable* bucketTable;
			int32_t mask;
		public:
			Collector(const int32_t mask, BucketTable* bucketTable);
			
			void collect(const int32_t doc, const float_t score);
		};

		SubScorer* scorers;
		BucketTable* bucketTable;

		int32_t maxCoord;
		int32_t nextMask;

      	int32_t end;
		Bucket* current;
	public:
		LUCENE_STATIC_CONSTANT(int32_t,BucketTable_SIZE=1024);
		int32_t requiredMask;
		int32_t prohibitedMask;
		float_t* coordFactors;

    	BooleanScorer(Similarity* similarity);
		~BooleanScorer();
		void add(Scorer* scorer, const bool required, const bool prohibited);
		int32_t doc() const { return current->doc; }
		bool next();
		float_t score() const;
		bool skipTo(int32_t target);
		Explanation* explain(int32_t doc);
		TCHAR* toString();
		void computeCoordFactors();
	};







CL_NS_END
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -