1
/*------------------------------------------------------------------------------
2
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
4
* Distributable under the terms of either the Apache License (Version 2.0) or
5
* the GNU Lesser General Public License, as specified in the COPYING file.
6
------------------------------------------------------------------------------*/
7
#ifndef _lucene_analysis_cjk_cjkanalyzer_
8
#define _lucene_analysis_cjk_cjkanalyzer_
10
#include "CLucene/analysis/AnalysisHeader.h"
12
CL_NS_DEF2(analysis,cjk)
15
* CJKTokenizer was modified from StopTokenizer which does a decent job for
16
* most European languages. It performs other token methods for double-byte
17
* Characters: the token will return at each two charactors with overlap match.<br>
18
* Example: "java C1C2C3C4" will be segment to: "java" "C1C2" "C2C3" "C3C4" it
19
* also need filter filter zero length token ""<br>
20
* for Digit: digit, '+', '#' will token as letter<br>
21
* for more info on Asia language(Chinese Japanese Korean) text segmentation:
23
* href="http://www.google.com/search?q=word+chinese+segment">google</a>
27
class CLUCENE_CONTRIBS_EXPORT CJKTokenizer: public CL_NS(analysis)::Tokenizer {
29
/** word offset, used to imply which character(in ) is parsed */
32
/** the index used only for ioBuffer */
39
* character buffer, store the characters which are used to compose <br>
42
TCHAR buffer[LUCENE_MAX_WORD_LEN];
45
* I/O buffer, used to store the content of the input(one of the <br>
46
* members of Tokenizer)
48
const TCHAR* ioBuffer;
50
/** word type: single=>ASCII double=>non-ASCII word=>default */
51
const TCHAR* tokenType;
53
static const TCHAR* tokenTypeSingle;
54
static const TCHAR* tokenTypeDouble;
57
* tag: previous character is a cached double-byte character "C1C2C3C4"
58
* ----(set the C1 isTokened) C1C2 "C2C3C4" ----(set the C2 isTokened)
59
* C1C2 C2C3 "C3C4" ----(set the C3 isTokened) "C1C2 C2C3 C3C4"
64
bool ignoreSurrogates;
68
* Construct a token stream processing the given input.
70
* @param in I/O reader
72
CJKTokenizer(CL_NS(util)::Reader* in);
75
* Returns the next token in the stream, or null at EOS.
76
* See http://java.sun.com/j2se/1.3/docs/api/java/lang/Character.UnicodeBlock.html
81
* @throws java.io.IOException - throw IOException when read error <br>
82
* hanppened in the InputStream
85
CL_NS(analysis)::Token* next(CL_NS(analysis)::Token* token);
87
bool getIgnoreSurrogates(){ return ignoreSurrogates; };
88
void setIgnoreSurrogates(bool ignoreSurrogates){ this->ignoreSurrogates = ignoreSurrogates; };