Class Dictionary
java.lang.Object
org.apache.lucene.analysis.hunspell.Dictionary
In-memory structure for the dictionary (.dic) and affix (.aff) data of a hunspell dictionary.
-
Constructor Summary
ConstructorsConstructorDescriptionDictionary
(InputStream affix, List<InputStream> dictionaries, boolean ignoreCase, SortingStrategy sortingStrategy) Creates a new Dictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files.Dictionary
(Directory tempDir, String tempFileNamePrefix, InputStream affix, InputStream dictionary) Creates a new Dictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files.Dictionary
(Directory tempDir, String tempFileNamePrefix, InputStream affix, List<InputStream> dictionaries, boolean ignoreCase) Creates a new Dictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if this dictionary was constructed with theignoreCase
optionprotected double
The factor determining the size of the internal hash table used for storing the entries.lookupEntries
(String root) protected boolean
Whether incorrect PFX/SFX rule counts should be silently ignored.
-
Constructor Details
-
Dictionary
public Dictionary(Directory tempDir, String tempFileNamePrefix, InputStream affix, InputStream dictionary) throws IOException, ParseException Creates a new Dictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files. You have to close the provided InputStreams yourself.- Parameters:
tempDir
- Directory to use for offline sortingtempFileNamePrefix
- prefix to use to generate temp file namesaffix
- InputStream for reading the hunspell affix file (won't be closed).dictionary
- InputStream for reading the hunspell dictionary file (won't be closed).- Throws:
IOException
- Can be thrown while reading from the InputStreamsParseException
- Can be thrown if the content of the files does not meet expected formats
-
Dictionary
public Dictionary(Directory tempDir, String tempFileNamePrefix, InputStream affix, List<InputStream> dictionaries, boolean ignoreCase) throws IOException, ParseException Creates a new Dictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files. You have to close the provided InputStreams yourself.- Parameters:
tempDir
- Directory to use for offline sortingtempFileNamePrefix
- prefix to use to generate temp file namesaffix
- InputStream for reading the hunspell affix file (won't be closed).dictionaries
- InputStream for reading the hunspell dictionary files (won't be closed).- Throws:
IOException
- Can be thrown while reading from the InputStreamsParseException
- Can be thrown if the content of the files does not meet expected formats
-
Dictionary
public Dictionary(InputStream affix, List<InputStream> dictionaries, boolean ignoreCase, SortingStrategy sortingStrategy) throws IOException, ParseException Creates a new Dictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files. You have to close the provided InputStreams yourself.- Parameters:
affix
- InputStream for reading the hunspell affix file (won't be closed).dictionaries
- InputStream for reading the hunspell dictionary files (won't be closed).sortingStrategy
- the entry strategy for the dictionary loading- Throws:
IOException
- Can be thrown while reading from the InputStreamsParseException
- Can be thrown if the content of the files does not meet expected formats
-
-
Method Details
-
lookupEntries
- Parameters:
root
- a string to look up in the dictionary. No case conversion or affix removal is performed. To get the possible roots of any word, you may callHunspell.getRoots(String)
- Returns:
- the dictionary entries for the given root, or
null
if there's none
-
hashFactor
protected double hashFactor()The factor determining the size of the internal hash table used for storing the entries. The table size isentry_count * hashFactor
. The default factor is 1.0. If there are too many hash collisions, the factor can be increased, resulting in faster access, but more memory usage. -
tolerateAffixRuleCountMismatches
protected boolean tolerateAffixRuleCountMismatches()Whether incorrect PFX/SFX rule counts should be silently ignored. False by default: aParseException
will happen. -
getIgnoreCase
public boolean getIgnoreCase()Returns true if this dictionary was constructed with theignoreCase
option
-