Class WikipediaTokenizer
java.lang.Object
org.apache.lucene.util.AttributeSource
org.apache.lucene.analysis.TokenStream
org.apache.lucene.analysis.Tokenizer
org.apache.lucene.analysis.wikipedia.WikipediaTokenizer
- All Implemented Interfaces:
Closeable
,AutoCloseable
Extension of StandardTokenizer that is aware of Wikipedia syntax. It is based off of the
Wikipedia tutorial available at http://en.wikipedia.org/wiki/Wikipedia:Tutorial, but it may not
be complete.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource
AttributeSource.State
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final String
static final int
static final String
static final int
static final int
Output the both the untokenized token and the splitsstatic final String
static final int
static final String
static final int
static final int
static final int
static final int
static final String
static final int
static final String
static final int
static final String
static final int
static final int
static final String
static final int
static final String
static final int
static final int
static final String
static final int
static final String[]
String token types that correspond to token type int constantsstatic final int
Only output tokensstatic final int
Only output untokenized tokens, which are tokens that would normally be split into several tokensstatic final int
This flag is used to indicate that the produced "Token" would, ifTOKENS_ONLY
was used, produce multiple tokens.Fields inherited from class org.apache.lucene.analysis.TokenStream
DEFAULT_TOKEN_ATTRIBUTE_FACTORY
-
Constructor Summary
ConstructorDescriptionCreates a new instance of theWikipediaTokenizer
.WikipediaTokenizer
(int tokenOutput, Set<String> untokenizedTypes) Creates a new instance of theWikipediaTokenizer
.WikipediaTokenizer
(AttributeFactory factory, int tokenOutput, Set<String> untokenizedTypes) Creates a new instance of theWikipediaTokenizer
. -
Method Summary
Methods inherited from class org.apache.lucene.analysis.Tokenizer
correctOffset, setReader, setReaderTestPoint
Methods 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
-
INTERNAL_LINK
- See Also:
-
EXTERNAL_LINK
- See Also:
-
EXTERNAL_LINK_URL
- See Also:
-
CITATION
- See Also:
-
CATEGORY
- See Also:
-
BOLD
- See Also:
-
ITALICS
- See Also:
-
BOLD_ITALICS
- See Also:
-
HEADING
- See Also:
-
SUB_HEADING
- See Also:
-
ALPHANUM_ID
public static final int ALPHANUM_ID- See Also:
-
APOSTROPHE_ID
public static final int APOSTROPHE_ID- See Also:
-
ACRONYM_ID
public static final int ACRONYM_ID- See Also:
-
COMPANY_ID
public static final int COMPANY_ID- See Also:
-
EMAIL_ID
public static final int EMAIL_ID- See Also:
-
HOST_ID
public static final int HOST_ID- See Also:
-
NUM_ID
public static final int NUM_ID- See Also:
-
CJ_ID
public static final int CJ_ID- See Also:
-
INTERNAL_LINK_ID
public static final int INTERNAL_LINK_ID- See Also:
-
EXTERNAL_LINK_ID
public static final int EXTERNAL_LINK_ID- See Also:
-
CITATION_ID
public static final int CITATION_ID- See Also:
-
CATEGORY_ID
public static final int CATEGORY_ID- See Also:
-
BOLD_ID
public static final int BOLD_ID- See Also:
-
ITALICS_ID
public static final int ITALICS_ID- See Also:
-
BOLD_ITALICS_ID
public static final int BOLD_ITALICS_ID- See Also:
-
HEADING_ID
public static final int HEADING_ID- See Also:
-
SUB_HEADING_ID
public static final int SUB_HEADING_ID- See Also:
-
EXTERNAL_LINK_URL_ID
public static final int EXTERNAL_LINK_URL_ID- See Also:
-
TOKEN_TYPES
String token types that correspond to token type int constants -
TOKENS_ONLY
public static final int TOKENS_ONLYOnly output tokens- See Also:
-
UNTOKENIZED_ONLY
public static final int UNTOKENIZED_ONLYOnly output untokenized tokens, which are tokens that would normally be split into several tokens- See Also:
-
BOTH
public static final int BOTHOutput the both the untokenized token and the splits- See Also:
-
UNTOKENIZED_TOKEN_FLAG
public static final int UNTOKENIZED_TOKEN_FLAGThis flag is used to indicate that the produced "Token" would, ifTOKENS_ONLY
was used, produce multiple tokens.- See Also:
-
-
Constructor Details
-
WikipediaTokenizer
public WikipediaTokenizer()Creates a new instance of theWikipediaTokenizer
. Attaches theinput
to a newly created JFlex scanner. -
WikipediaTokenizer
Creates a new instance of theWikipediaTokenizer
. Attaches theinput
to the newly created JFlex scanner.- Parameters:
tokenOutput
- One ofTOKENS_ONLY
,UNTOKENIZED_ONLY
,BOTH
-
WikipediaTokenizer
Creates a new instance of theWikipediaTokenizer
. Attaches theinput
to the newly created JFlex scanner. Uses the givenAttributeFactory
.- Parameters:
tokenOutput
- One ofTOKENS_ONLY
,UNTOKENIZED_ONLY
,BOTH
-
-
Method Details
-
incrementToken
- Specified by:
incrementToken
in classTokenStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classTokenizer
- Throws:
IOException
-
reset
- Overrides:
reset
in classTokenizer
- Throws:
IOException
-
end
- Overrides:
end
in classTokenStream
- Throws:
IOException
-