Class StemmerDictionaryParser
Each non-empty logical line uses a tab-separated values layout. The first column is interpreted as the canonical stem, and every following tab-separated column on the same line is interpreted as a variant belonging to that stem.
Input line case normalization is controlled by CaseProcessingMode.
Leading and trailing whitespace around each column is ignored.
The parser supports line remarks and trailing remarks. The remark markers
# and // terminate the logical content of the line, and the
remainder of that line is ignored.
Dictionary items containing any Unicode whitespace character are currently
not supported. Such items are ignored and reported through a single
warning-level log entry per physical line together with
the source line number, the normalized stem column, and the list of ignored
items from that line.
This class is intentionally stateless and allocation-light so it can be used both by runtime loading and by offline compilation tooling.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCallback receiving one parsed dictionary line.static final recordImmutable parsing statistics. -
Method Summary
Modifier and TypeMethodDescriptionparse(Reader reader, String sourceDescription, CaseProcessingMode caseProcessingMode, StemmerDictionaryParser.EntryHandler entryHandler) Parses a dictionary from a reader.parse(Reader reader, String sourceDescription, StemmerDictionaryParser.EntryHandler entryHandler) Parses a dictionary from a reader.parse(String fileName, CaseProcessingMode caseProcessingMode, StemmerDictionaryParser.EntryHandler entryHandler) Parses a dictionary file from a path string.parse(String fileName, StemmerDictionaryParser.EntryHandler entryHandler) Parses a dictionary file from a path string.parse(Path path, CaseProcessingMode caseProcessingMode, StemmerDictionaryParser.EntryHandler entryHandler) Parses a dictionary file from a filesystem path.parse(Path path, StemmerDictionaryParser.EntryHandler entryHandler) Parses a dictionary file from a filesystem path.
-
Method Details
-
parse
public static StemmerDictionaryParser.ParseStatistics parse(Path path, StemmerDictionaryParser.EntryHandler entryHandler) throws IOException Parses a dictionary file from a filesystem path.- Parameters:
path- dictionary file pathentryHandler- handler receiving parsed entries- Returns:
- parsing statistics
- Throws:
NullPointerException- if any argument isnullIOException- if reading fails
-
parse
public static StemmerDictionaryParser.ParseStatistics parse(Path path, CaseProcessingMode caseProcessingMode, StemmerDictionaryParser.EntryHandler entryHandler) throws IOException Parses a dictionary file from a filesystem path.- Parameters:
path- dictionary file pathcaseProcessingMode- case processing modeentryHandler- handler receiving parsed entries- Returns:
- parsing statistics
- Throws:
NullPointerException- if any argument isnullIOException- if reading fails
-
parse
public static StemmerDictionaryParser.ParseStatistics parse(String fileName, StemmerDictionaryParser.EntryHandler entryHandler) throws IOException Parses a dictionary file from a path string.- Parameters:
fileName- dictionary file name or path stringentryHandler- handler receiving parsed entries- Returns:
- parsing statistics
- Throws:
NullPointerException- if any argument isnullIOException- if reading fails
-
parse
public static StemmerDictionaryParser.ParseStatistics parse(String fileName, CaseProcessingMode caseProcessingMode, StemmerDictionaryParser.EntryHandler entryHandler) throws IOException Parses a dictionary file from a path string.- Parameters:
fileName- dictionary file name or path stringcaseProcessingMode- case processing modeentryHandler- handler receiving parsed entries- Returns:
- parsing statistics
- Throws:
NullPointerException- if any argument isnullIOException- if reading fails
-
parse
public static StemmerDictionaryParser.ParseStatistics parse(Reader reader, String sourceDescription, StemmerDictionaryParser.EntryHandler entryHandler) throws IOException Parses a dictionary from a reader.- Parameters:
reader- source readersourceDescription- logical source description for diagnosticsentryHandler- handler receiving parsed entries- Returns:
- parsing statistics
- Throws:
NullPointerException- if any argument isnullIOException- if reading or handler processing fails
-
parse
public static StemmerDictionaryParser.ParseStatistics parse(Reader reader, String sourceDescription, CaseProcessingMode caseProcessingMode, StemmerDictionaryParser.EntryHandler entryHandler) throws IOException Parses a dictionary from a reader.- Parameters:
reader- source readersourceDescription- logical source description for diagnosticscaseProcessingMode- case processing modeentryHandler- handler receiving parsed entries- Returns:
- parsing statistics
- Throws:
NullPointerException- if any argument isnullIOException- if reading or handler processing fails
-