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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final Stringstatic final intstatic final Stringstatic final intstatic final intOutput the both the untokenized token and the splitsstatic final Stringstatic final intstatic final Stringstatic final intstatic final intstatic final intstatic final intstatic final Stringstatic final intstatic final Stringstatic final intstatic final Stringstatic final intstatic final intstatic final Stringstatic final intstatic final Stringstatic final intstatic final intstatic final Stringstatic final intstatic final String[]String token types that correspond to token type int constantsstatic final intOnly output tokensstatic final intOnly output untokenized tokens, which are tokens that would normally be split into several tokensstatic final intThis flag is used to indicate that the produced "Token" would, ifTOKENS_ONLYwas used, produce multiple tokens.Fields inherited from class org.apache.lucene.analysis.TokenStream
DEFAULT_TOKEN_ATTRIBUTE_FACTORY -
Constructor Summary
ConstructorsConstructorDescriptionCreates 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, 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
-
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_ONLYwas used, produce multiple tokens.- See Also:
-
-
Constructor Details
-
WikipediaTokenizer
public WikipediaTokenizer()Creates a new instance of theWikipediaTokenizer. Attaches theinputto a newly created JFlex scanner. -
WikipediaTokenizer
Creates a new instance of theWikipediaTokenizer. Attaches theinputto the newly created JFlex scanner.- Parameters:
tokenOutput- One ofTOKENS_ONLY,UNTOKENIZED_ONLY,BOTH
-
WikipediaTokenizer
Creates a new instance of theWikipediaTokenizer. Attaches theinputto the newly created JFlex scanner. Uses the givenAttributeFactory.- Parameters:
tokenOutput- One ofTOKENS_ONLY,UNTOKENIZED_ONLY,BOTH
-
-
Method Details
-
incrementToken
- Specified by:
incrementTokenin classTokenStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classTokenizer- Throws:
IOException
-
reset
- Overrides:
resetin classTokenizer- Throws:
IOException
-
end
- Overrides:
endin classTokenStream- Throws:
IOException
-