Class LatticeTokenizer
- All Implemented Interfaces:
Tokenizer
MecabDictionary, minimizing the sum of
word costs and connection costs. This is the segmentation approach behind Japanese
and Korean morphological analysis. A single decoder serves both because the supplied
dictionary provides the language-specific data.
Unknown text is handled through the dictionary's character categories: where the lexicon has no entry, or a category always invokes them, unknown-word candidates are generated per category template, grouping runs of same-category characters when the category requests it. A multi-category run continues while successive assignments overlap. Whitespace cannot join or appear as a morpheme. Every reported span is in original text coordinates.
analyze(String) returns full morphemes with their dictionary features;
the Tokenizer view reports just the surfaces and spans.
The tokenizer reads only immutable dictionary state and is safe to share between threads.
- Since:
- 3.0.0
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
LatticeTokenizer
Initializes the tokenizer.- Parameters:
dictionary- The dictionary to segment with. Must not benull.- Throws:
IllegalArgumentException- Thrown ifdictionaryisnull.
-
-
Method Details
-
analyze
Segments a text into morphemes with their dictionary features.- Parameters:
text- The text to segment. Must not benull.- Returns:
- The morphemes in text order, spans in original coordinates, whitespace
omitted. Never
null; empty for empty or all-whitespace input. - Throws:
IllegalArgumentException- Thrown iftextisnull.IllegalStateException- Thrown if the dictionary offers no candidate at some position, which aunk.defwithout aDEFAULTtemplate does.
-
tokenize
Splits a string into its atomic parts.Reports the segmented surfaces, whitespace omitted.
- Specified by:
tokenizein interfaceTokenizer- Parameters:
text- The string to be tokenized.- Returns:
- The String[] with the individual tokens as the array elements.
- Throws:
IllegalArgumentException- Thrown iftextisnull.IllegalStateException- Thrown if the dictionary offers no candidate at some position; seeanalyze(String).
-
tokenizePos
Finds the boundaries of atomic parts in a string.Reports the segmented spans in original text coordinates, whitespace omitted.
- Specified by:
tokenizePosin interfaceTokenizer- Parameters:
text- The string to be tokenized.- Returns:
- The
spans (offsets intofor each token as the individuals array elements.s) - Throws:
IllegalArgumentException- Thrown iftextisnull.IllegalStateException- Thrown if the dictionary offers no candidate at some position; seeanalyze(String).
-