Class HunspellStemmer
- All Implemented Interfaces:
opennlp.tools.stemmer.Stemmer
Stemmer over a HunspellDictionary: a surface form
is reduced to the dictionary words it can be derived from by removing one suffix, one
prefix, a cross-product combination of both, or an additional suffix licensed by a
continuation class.
stem(CharSequence) returns the first analysis, preferring the word's own
dictionary entry; stemAll(CharSequence) returns every distinct analysis. A
word with no analysis is returned unchanged, so the stemmer degrades to identity on
unknown vocabulary. A form containing uppercase characters is also analyzed in its
lowercase variant, so sentence-initial capitalization does not hide an entry.
Entries the dictionary marks as virtual stems (NEEDAFFIX), compound-only
parts (ONLYINCOMPOUND), or forbidden words (FORBIDDENWORD) never
count as standalone analyses, matching how hunspell reads those flags.
Compound part search is capped at 2048 part-licensing
attempts per input word; beyond that budget further compound analyses are skipped.
The Stemmer interface leaves thread safety to the implementation. This
implementation reads only the immutable dictionary state, so a single instance is
safe to share between threads.
- Since:
- 3.0.0
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
HunspellStemmer
Initializes the stemmer.- Parameters:
dictionary- The dictionary to analyze against. Must not benull.- Throws:
IllegalArgumentException- Thrown ifdictionaryisnull.
-
-
Method Details
-
stem
Returns the first analysis, which prefers the word's own dictionary entry.
- Specified by:
stemin interfaceopennlp.tools.stemmer.Stemmer
-
stemAll
Returns every distinct analysis, or a single-element list of the unchanged word when it has none.
- Specified by:
stemAllin interfaceopennlp.tools.stemmer.Stemmer
-