searchengine/cpix/cpix/inc/private/analyzer.h
changeset 1 6f2c1c46032b
parent 0 671dee74050a
child 8 6547bf8ca13a
--- a/searchengine/cpix/cpix/inc/private/analyzer.h	Mon Apr 19 14:40:16 2010 +0300
+++ b/searchengine/cpix/cpix/inc/private/analyzer.h	Mon May 03 13:33:22 2010 +0300
@@ -56,6 +56,39 @@
 // Class definitions
 namespace Cpix
 {
+
+	/**
+	 * This is a special filter that is used to generate prefixes
+	 * of the searched words.
+	 * 
+	 * For example token "chapter" will be split into tokens "ch" and "c"
+	 * if maxPrefixLength is set as 2. 
+	 */
+	class PrefixGenerator : public lucene::analysis::TokenFilter {
+	
+	public: 
+	
+		PrefixGenerator(lucene::analysis::TokenStream* in, 
+						bool deleteTS, 
+						size_t maxPrefixLength);
+
+		virtual ~PrefixGenerator();
+		
+		/**
+		 * Returns
+		 */
+		virtual bool next(lucene::analysis::Token* token);
+		
+	private: 
+		
+		lucene::analysis::Token token_; 
+		
+		size_t prefixLength_;
+	
+		size_t maxPrefixLength_; 
+	
+	};
+
     /**
      * Aggregates token streams from all fields marked from aggregation. 
      * Used to generate the contents of the _aggregate field.