Class JapaneseTokenizerFactory
- All Implemented Interfaces:
ResourceLoaderAware
JapaneseTokenizer
.
<fieldType name="text_ja" class="solr.TextField"> <analyzer> <tokenizer class="solr.JapaneseTokenizerFactory" mode="NORMAL" userDictionary="user.txt" userDictionaryEncoding="UTF-8" discardPunctuation="true" discardCompoundToken="false" /> <filter class="solr.JapaneseBaseFormFilterFactory"/> </analyzer> </fieldType>
Additional expert user parameters nBestCost and nBestExamples can be used to include additional searchable tokens that those most likely according to the statistical model. A typical use-case for this is to improve recall and make segmentation more resilient to mistakes. The feature can also be used to get a decompounding effect.
The nBestCost parameter specifies an additional Viterbi cost, and when used, JapaneseTokenizer will include all tokens in Viterbi paths that are within the nBestCost value of the best path.
Finding a good value for nBestCost can be difficult to do by hand. The nBestExamples parameter can be used to find an nBestCost value based on examples with desired segmentation outcomes.
For example, a value of /箱根山-箱根/成田空港-成田/ indicates that in the texts, 箱根山 (Mt. Hakone) and 成田空港 (Narita Airport) we'd like a cost that gives is us 箱根 (Hakone) and 成田 (Narita). Notice that costs are estimated for each example individually, and the maximum nBestCost found across all examples is used.
If both nBestCost and nBestExamples is used in a configuration, the largest value of the two is used.
Parameters nBestCost and nBestExamples work with all tokenizer modes, but it makes the most sense to use them with NORMAL mode.
- Since:
- 3.6.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private final boolean
private final boolean
private final JapaneseTokenizer.Mode
private static final String
static final String
SPI nameprivate static final String
private static final String
private int
private final String
private static final String
private static final String
private UserDictionary
private final String
private final String
Fields inherited from class org.apache.lucene.analysis.AbstractAnalysisFactory
LUCENE_MATCH_VERSION_PARAM, luceneMatchVersion
-
Constructor Summary
ConstructorsConstructorDescriptionDefault ctor for compatibility with SPIJapaneseTokenizerFactory
(Map<String, String> args) Creates a new JapaneseTokenizerFactory -
Method Summary
Modifier and TypeMethodDescriptioncreate
(AttributeFactory factory) Creates a TokenStream of the specified input using the given AttributeFactoryvoid
inform
(ResourceLoader loader) Initializes this component with the provided ResourceLoader (used for loading classes, files, etc).Methods inherited from class org.apache.lucene.analysis.TokenizerFactory
availableTokenizers, create, findSPIName, forName, lookupClass, reloadTokenizers
Methods inherited from class org.apache.lucene.analysis.AbstractAnalysisFactory
defaultCtorException, get, get, get, get, get, getBoolean, getChar, getClassArg, getFloat, getInt, getLines, getLuceneMatchVersion, getOriginalArgs, getPattern, getSet, getSnowballWordSet, getWordSet, isExplicitLuceneMatchVersion, require, require, require, requireBoolean, requireChar, requireFloat, requireInt, setExplicitLuceneMatchVersion, splitAt, splitFileNames
-
Field Details
-
NAME
SPI name- See Also:
-
MODE
- See Also:
-
USER_DICT_PATH
- See Also:
-
USER_DICT_ENCODING
- See Also:
-
DISCARD_PUNCTUATION
- See Also:
-
DISCARD_COMPOUND_TOKEN
- See Also:
-
NBEST_COST
- See Also:
-
NBEST_EXAMPLES
- See Also:
-
userDictionary
-
mode
-
discardPunctuation
private final boolean discardPunctuation -
discardCompoundToken
private final boolean discardCompoundToken -
userDictionaryPath
-
userDictionaryEncoding
-
nbestExamples
-
nbestCost
private int nbestCost
-
-
Constructor Details
-
JapaneseTokenizerFactory
Creates a new JapaneseTokenizerFactory -
JapaneseTokenizerFactory
public JapaneseTokenizerFactory()Default ctor for compatibility with SPI
-
-
Method Details
-
inform
Description copied from interface:ResourceLoaderAware
Initializes this component with the provided ResourceLoader (used for loading classes, files, etc).- Specified by:
inform
in interfaceResourceLoaderAware
- Throws:
IOException
-
create
Description copied from class:TokenizerFactory
Creates a TokenStream of the specified input using the given AttributeFactory- Specified by:
create
in classTokenizerFactory
-