public final class JapaneseTokenizer extends Tokenizer
This tokenizer sets a number of additional attributes:
BaseFormAttribute containing base form for inflected
adjectives and verbs.
PartOfSpeechAttribute containing part-of-speech.
ReadingAttribute containing reading and pronunciation.
InflectionAttribute containing additional part-of-speech
information for inflected forms.
This tokenizer uses a rolling Viterbi search to find the
least cost segmentation (path) of the incoming characters.
For tokens that appear to be compound (> length 2 for all
Kanji, or > length 7 for non-Kanji), we see if there is a
2nd best segmentation of that token after applying
penalties to the long tokens. If so, and the Mode is
JapaneseTokenizer.Mode.SEARCH, we output the alternate segmentation
as well.
| Modifier and Type | Class and Description |
|---|---|
static class |
JapaneseTokenizer.Mode
Tokenization mode: this determines how the tokenizer handles
compound and unknown words.
|
static class |
JapaneseTokenizer.Type
Token type reflecting the original source of this token
|
AttributeSource.State| Modifier and Type | Field and Description |
|---|---|
static JapaneseTokenizer.Mode |
DEFAULT_MODE
Default tokenization mode.
|
DEFAULT_TOKEN_ATTRIBUTE_FACTORY| Constructor and Description |
|---|
JapaneseTokenizer(AttributeFactory factory,
TokenInfoDictionary systemDictionary,
UnknownDictionary unkDictionary,
ConnectionCosts connectionCosts,
UserDictionary userDictionary,
boolean discardPunctuation,
boolean discardCompoundToken,
JapaneseTokenizer.Mode mode)
Create a new JapaneseTokenizer, supplying a custom system dictionary and unknown dictionary.
|
JapaneseTokenizer(AttributeFactory factory,
UserDictionary userDictionary,
boolean discardPunctuation,
boolean discardCompoundToken,
JapaneseTokenizer.Mode mode)
Create a new JapaneseTokenizer using the system and unknown dictionaries shipped with Lucene.
|
JapaneseTokenizer(AttributeFactory factory,
UserDictionary userDictionary,
boolean discardPunctuation,
JapaneseTokenizer.Mode mode)
Create a new JapaneseTokenizer using the system and unknown dictionaries shipped with Lucene.
|
JapaneseTokenizer(UserDictionary userDictionary,
boolean discardPunctuation,
boolean discardCompoundToken,
JapaneseTokenizer.Mode mode)
Create a new JapaneseTokenizer.
|
JapaneseTokenizer(UserDictionary userDictionary,
boolean discardPunctuation,
JapaneseTokenizer.Mode mode)
Create a new JapaneseTokenizer.
|
| Modifier and Type | Method and Description |
|---|---|
int |
calcNBestCost(String examples) |
void |
close() |
void |
end() |
boolean |
incrementToken() |
void |
reset() |
void |
setGraphvizFormatter(GraphvizFormatter dotOut)
Expert: set this to produce graphviz (dot) output of
the Viterbi lattice
|
void |
setNBestCost(int value) |
correctOffset, setReaderaddAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState, toStringpublic static final JapaneseTokenizer.Mode DEFAULT_MODE
JapaneseTokenizer.Mode.SEARCH.public JapaneseTokenizer(UserDictionary userDictionary, boolean discardPunctuation, JapaneseTokenizer.Mode mode)
Uses the default AttributeFactory.
userDictionary - Optional: if non-null, user dictionary.discardPunctuation - true if punctuation tokens should be dropped from the output.mode - tokenization mode.public JapaneseTokenizer(UserDictionary userDictionary, boolean discardPunctuation, boolean discardCompoundToken, JapaneseTokenizer.Mode mode)
Uses the default AttributeFactory.
userDictionary - Optional: if non-null, user dictionary.discardPunctuation - true if punctuation tokens should be dropped from the output.discardCompoundToken - true if compound tokens should be dropped from the output when tokenization mode is not NORMAL.mode - tokenization mode.public JapaneseTokenizer(AttributeFactory factory, UserDictionary userDictionary, boolean discardPunctuation, JapaneseTokenizer.Mode mode)
factory - the AttributeFactory to useuserDictionary - Optional: if non-null, user dictionary.discardPunctuation - true if punctuation tokens should be dropped from the output.mode - tokenization mode.public JapaneseTokenizer(AttributeFactory factory, UserDictionary userDictionary, boolean discardPunctuation, boolean discardCompoundToken, JapaneseTokenizer.Mode mode)
factory - the AttributeFactory to useuserDictionary - Optional: if non-null, user dictionary.discardPunctuation - true if punctuation tokens should be dropped from the output.discardCompoundToken - true if compound tokens should be dropped from the output when tokenization mode is not NORMAL.mode - tokenization mode.public JapaneseTokenizer(AttributeFactory factory, TokenInfoDictionary systemDictionary, UnknownDictionary unkDictionary, ConnectionCosts connectionCosts, UserDictionary userDictionary, boolean discardPunctuation, boolean discardCompoundToken, JapaneseTokenizer.Mode mode)
Create a new JapaneseTokenizer, supplying a custom system dictionary and unknown dictionary.
This constructor provides an entry point for users that want to construct custom language models
that can be used as input to DictionaryBuilder.
factory - the AttributeFactory to usesystemDictionary - a custom known token dictionaryunkDictionary - a custom unknown token dictionaryconnectionCosts - custom token transition costsuserDictionary - Optional: if non-null, user dictionary.discardPunctuation - true if punctuation tokens should be dropped from the output.discardCompoundToken - true if compound tokens should be dropped from the output when tokenization mode is not NORMAL.mode - tokenization mode.public void setGraphvizFormatter(GraphvizFormatter dotOut)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class TokenizerIOExceptionpublic void reset()
throws IOException
reset in class TokenizerIOExceptionpublic void end()
throws IOException
end in class TokenStreamIOExceptionpublic boolean incrementToken()
throws IOException
incrementToken in class TokenStreamIOExceptionpublic int calcNBestCost(String examples)
public void setNBestCost(int value)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.