Class HunspellDictionary
.aff and .dic files. OpenNLP includes no dictionary data.
Supported affix features are PFX and SFX rules with strip
strings, character-class conditions, cross-product combinations, and a double suffix
connected by continuation classes; FLAG modes char, UTF-8,
long, and num; the AF alias table; and the SET
encoding declaration. Compound decomposition supports COMPOUNDFLAG,
COMPOUNDBEGIN, COMPOUNDMIDDLE, COMPOUNDEND,
COMPOUNDMIN, COMPOUNDWORDMAX, COMPOUNDPERMITFLAG,
COMPOUNDFORBIDFLAG, CHECKCOMPOUNDDUP,
CHECKCOMPOUNDCASE, and CHECKCOMPOUNDTRIPLE. The blocking flags
NEEDAFFIX (also named PSEUDOROOT), ONLYINCOMPOUND, and
FORBIDDENWORD, plus CIRCUMFIX and FULLSTRIP, are also
applied.
Other directives are skipped. Their spelling, conversion, suggestion, or advanced compound behavior is not applied by this affix stemmer. Dictionary morphology fields are also ignored.
Instances are immutable and safe to share between threads.
- Since:
- 3.0.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe file suffix for a Hunspell affix file.static final StringThe file suffix for a Hunspell word-list file.static final intInclusive upper bound on bytes buffered from one affix or dictionary stream duringload(InputStream, InputStream). -
Method Summary
Modifier and TypeMethodDescriptionstatic HunspellDictionaryload(InputStream affixStream, InputStream dictionaryStream) Loads a dictionary from its two streams.static HunspellDictionaryLoads a dictionary from its two files.
-
Field Details
-
AFFIX_FILE_SUFFIX
-
DICTIONARY_FILE_SUFFIX
The file suffix for a Hunspell word-list file.- See Also:
-
MAX_STREAM_BYTES
public static final int MAX_STREAM_BYTESInclusive upper bound on bytes buffered from one affix or dictionary stream duringload(InputStream, InputStream). The limit is 64 MiB. Larger streams fail withIOException.- See Also:
-
-
Method Details
-
load
Loads a dictionary from its two files.- Parameters:
affixFile- The.affaffix file. Must not benull.dictionaryFile- The.dicword list. Must not benull.- Returns:
- The loaded dictionary. Never
null. - Throws:
IOException- Thrown if reading fails or a file is malformed.IllegalArgumentException- Thrown if a parameter isnull.
-
load
public static HunspellDictionary load(InputStream affixStream, InputStream dictionaryStream) throws IOException Loads a dictionary from its two streams. Each stream is buffered up toMAX_STREAM_BYTESbytes; a larger stream fails withIOException.- Parameters:
affixStream- The.affaffix content. Must not benull. Not closed.dictionaryStream- The.dicword list content. Must not benull. Not closed.- Returns:
- The loaded dictionary. Never
null. - Throws:
IOException- Thrown if reading fails, a stream exceedsMAX_STREAM_BYTES, or the content is malformed.IllegalArgumentException- Thrown if a parameter isnull.
-