Package com.jalios.jcms.search.analysis
Class JcmsTokenizer
java.lang.Object
org.apache.lucene.util.AttributeSource
org.apache.lucene.analysis.TokenStream
org.apache.lucene.analysis.Tokenizer
com.jalios.jcms.search.analysis.JcmsTokenizer
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class JcmsTokenizer
extends org.apache.lucene.analysis.Tokenizer
A grammar-based tokenizer constructed with JFlex, based on lucene default ClassicTokenizer.
This should be a good tokenizer for most European-language documents:
- Splits words at punctuation characters, removing punctuation. However, a dot that's not followed by whitespace is considered part of a token.
- Splits words at hyphens, underscore and dash, unless there's a number in the token.
- Recognizes email addresses and internet hostnames as one token.
-
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 intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic 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 theJcmsTokenizer.JcmsTokenizer(org.apache.lucene.util.AttributeFactory factory) Creates a new JcmsTokenizer with a givenAttributeFactory -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()final voidend()intRetrieve the max allowed token lengthfinal booleanvoidreset()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 ALPHANUM- See Also:
-
APOSTROPHE
public static final int APOSTROPHE- See Also:
-
ACRONYM
public static final int ACRONYM- See Also:
-
COMPANY
public static final int COMPANY- See Also:
-
EMAIL
public static final int EMAIL- See Also:
-
HOST
public static final int HOST- See Also:
-
NUM
public static final int NUM- See Also:
-
CJ
public static final int CJ- See Also:
-
ACRONYM_DEP
public static final int ACRONYM_DEP- See Also:
-
TOKEN_TYPES
String token types that correspond to token type int constants
-
-
Constructor Details
-
JcmsTokenizer
public JcmsTokenizer()Creates a new instance of theJcmsTokenizer. Attaches theinputto the newly created JFlex scanner. See http://issues.apache.org/jira/browse/LUCENE-1068 -
JcmsTokenizer
public JcmsTokenizer(org.apache.lucene.util.AttributeFactory factory) Creates a new JcmsTokenizer with a givenAttributeFactory- Parameters:
factory- the attribute factory to use
-
-
Method Details
-
setMaxTokenLength
public void setMaxTokenLength(int length) Set the max allowed token length. Any token longer than this is skipped.- Parameters:
length- a length, must be greated than zero, default is 255
-
getMaxTokenLength
public int getMaxTokenLength()Retrieve the max allowed token length- Returns:
- a length greater than 0, default is 255
- 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
-