Package com.easydesk.lucene.analyzer
Class EasyDeskTokenizer
java.lang.Object
org.apache.lucene.util.AttributeSource
org.apache.lucene.analysis.TokenStream
org.apache.lucene.analysis.Tokenizer
com.easydesk.lucene.analyzer.EasyDeskTokenizer
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class EasyDeskTokenizer
extends org.apache.lucene.analysis.Tokenizer
JFlex 로 생성한 grammar 기반 tokenizer.
Lucene StandardTokenizer 와 같이 Unicode Standard Annex #29 의
Word Break rule 을 구현하며, 추가로 MathJax inline 수식 ($...$) 을 하나의 <MATH_EXPRESSION> token 으로
처리한다.
Token type 문자열은 StandardTokenizer.TOKEN_TYPES 의 instance 를 그대로 사용하므로
CJKBigramFilter 등 Lucene filter 와 함께 사용할 수 있다.
- Author:
- 조 영 호
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource
org.apache.lucene.util.AttributeSource.State -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAlpha/numeric token typestatic final intDefault maximum allowed token lengthstatic final intEmoji token typestatic final intHangul token typestatic final intHiragana token typestatic final intIdeographic token typestatic final intKatakana token typestatic final intMathJax Latex token typestatic final intNumeric token typestatic final intSoutheast Asian token typestatic final String[]String token types that correspond to token type int constantsFields inherited from class org.apache.lucene.analysis.Tokenizer
inputFields inherited from class org.apache.lucene.analysis.TokenStream
DEFAULT_TOKEN_ATTRIBUTE_FACTORY -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of theEasyDeskTokenizer.EasyDeskTokenizer(org.apache.lucene.util.AttributeFactory factory) Creates a new EasyDeskTokenizer with a givenAttributeFactory -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidend()intbooleanvoidreset()voidsetMaxTokenLength(int length) Set the max allowed token length.Methods inherited from class org.apache.lucene.analysis.Tokenizer
correctOffset, setReader, setReaderTestPointMethods inherited from class org.apache.lucene.util.AttributeSource
addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState, toString
-
Field Details
-
ALPHANUM
public static final int ALPHANUMAlpha/numeric token type- See Also:
-
NUM
public static final int NUMNumeric token type- See Also:
-
SOUTHEAST_ASIAN
public static final int SOUTHEAST_ASIANSoutheast Asian token type- See Also:
-
IDEOGRAPHIC
public static final int IDEOGRAPHICIdeographic token type- See Also:
-
HIRAGANA
public static final int HIRAGANAHiragana token type- See Also:
-
KATAKANA
public static final int KATAKANAKatakana token type- See Also:
-
HANGUL
public static final int HANGULHangul token type- See Also:
-
EMOJI
public static final int EMOJIEmoji token type- See Also:
-
MATH_EXPRESSION
public static final int MATH_EXPRESSIONMathJax Latex token type- See Also:
-
TOKEN_TYPES
String token types that correspond to token type int constants -
DEFAULT_MAX_TOKEN_LENGTH
public static final int DEFAULT_MAX_TOKEN_LENGTHDefault maximum allowed token length- See Also:
-
-
Constructor Details
-
EasyDeskTokenizer
public EasyDeskTokenizer()Creates a new instance of theEasyDeskTokenizer. -
EasyDeskTokenizer
public EasyDeskTokenizer(org.apache.lucene.util.AttributeFactory factory) Creates a new EasyDeskTokenizer with a givenAttributeFactory- Parameters:
factory- attribute factory
-
-
Method Details
-
setMaxTokenLength
public void setMaxTokenLength(int length) Set the max allowed token length. Any token longer than this is skipped.- Parameters:
length- max token length
-
getMaxTokenLength
public int getMaxTokenLength()- Returns:
- max token length
- See Also:
-
incrementToken
- Specified by:
incrementTokenin classorg.apache.lucene.analysis.TokenStream- Throws:
IOException
-
end
- Overrides:
endin classorg.apache.lucene.analysis.TokenStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classorg.apache.lucene.analysis.Tokenizer- Throws:
IOException
-
reset
- Overrides:
resetin classorg.apache.lucene.analysis.Tokenizer- Throws:
IOException
-