Class MorfologikMultiSpeller
java.lang.Object
org.languagetool.rules.spelling.morfologik.MorfologikMultiSpeller
Morfologik speller that merges results from binary (.dict) and plain text (.txt) dictionaries.
- Since:
- 2.9
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final List
<MorfologikSpeller> private static final com.google.common.cache.LoadingCache
<MorfologikMultiSpeller.BufferedReaderWithSource, List<byte[]>> private final List
<MorfologikSpeller> private final List
<MorfologikSpeller> -
Constructor Summary
ConstructorsConstructorDescriptionMorfologikMultiSpeller
(String binaryDictPath, BufferedReader plainTextReader, List<String> plainTextReaderPath, BufferedReader languageVariantPlainTextReader, String languageVariantPlainTextPath, List<String> userWords, int maxEditDistance) MorfologikMultiSpeller
(String binaryDictPath, List<String> plainTextPaths, String languageVariantPlainTextPath, int maxEditDistance) MorfologikMultiSpeller
(String binaryDictPath, List<String> plainTextPaths, String languageVariantPlainTextPath, UserConfig userConfig, int maxEditDistance) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines whether the dictionary uses case conversions.private MorfologikSpeller
getBinaryDict
(String binaryDictPath, int maxEditDistance) private static @NotNull BufferedReader
getBufferedReader
(List<String> plainTextPaths) private morfologik.stemming.Dictionary
getDictionary
(List<byte[]> lines, String dictPath, String infoPath, boolean allowCache) int
getFrequency
(String word) Get the frequency of use of a word (0-27) form the dictionaryprivate @Nullable MorfologikSpeller
getPlainTextDictSpellerOrNull
(BufferedReader plainTextReader, List<String> plainTextReaderPaths, BufferedReader languageVariantPlainTextReader, String languageVariantPlainTextPath, String dictPath, int maxEditDistance) getSuggestions
(String word) The suggestions from all dictionaries (without duplicates).getSuggestionsFromSpellers
(String word, List<MorfologikSpeller> spellerList) private MorfologikSpeller
getUserDictSpellerOrNull
(List<String> userWords, String dictPath, int maxEditDistance) boolean
isMisspelled
(String word) Accept the word if at least one of the dictionaries accepts it as not misspelled.
-
Field Details
-
dictCache
private static final com.google.common.cache.LoadingCache<MorfologikMultiSpeller.BufferedReaderWithSource,List<byte[]>> dictCache -
dicPathToDict
-
spellers
-
defaultDictSpellers
-
userDictSpellers
-
convertsCase
private final boolean convertsCase
-
-
Constructor Details
-
MorfologikMultiSpeller
public MorfologikMultiSpeller(String binaryDictPath, List<String> plainTextPaths, String languageVariantPlainTextPath, int maxEditDistance) throws IOException - Throws:
IOException
-
MorfologikMultiSpeller
@Experimental public MorfologikMultiSpeller(String binaryDictPath, List<String> plainTextPaths, String languageVariantPlainTextPath, UserConfig userConfig, int maxEditDistance) throws IOException - Parameters:
binaryDictPath
- path in classpath to a.dict
binary Morfologik fileplainTextPaths
- paths in classpath to plain text.txt
files (like spelling.txt)maxEditDistance
- maximum edit distance for accepting suggestions- Throws:
IOException
- Since:
- 4.2
-
MorfologikMultiSpeller
public MorfologikMultiSpeller(String binaryDictPath, BufferedReader plainTextReader, List<String> plainTextReaderPath, BufferedReader languageVariantPlainTextReader, String languageVariantPlainTextPath, List<String> userWords, int maxEditDistance) throws IOException - Parameters:
binaryDictPath
- path in classpath to a.dict
binary Morfologik fileplainTextReader
- reader with to a plain text.txt
file (like from spelling.txt)maxEditDistance
- maximum edit distance for accepting suggestions- Throws:
IOException
- Since:
- 3.0
-
-
Method Details
-
getBufferedReader
-
getUserDictSpellerOrNull
private MorfologikSpeller getUserDictSpellerOrNull(List<String> userWords, String dictPath, int maxEditDistance) throws IOException - Throws:
IOException
-
getBinaryDict
-
getPlainTextDictSpellerOrNull
@Nullable private @Nullable MorfologikSpeller getPlainTextDictSpellerOrNull(BufferedReader plainTextReader, List<String> plainTextReaderPaths, BufferedReader languageVariantPlainTextReader, String languageVariantPlainTextPath, String dictPath, int maxEditDistance) throws IOException - Throws:
IOException
-
getDictionary
private morfologik.stemming.Dictionary getDictionary(List<byte[]> lines, String dictPath, String infoPath, boolean allowCache) throws IOException - Throws:
IOException
-
isMisspelled
Accept the word if at least one of the dictionaries accepts it as not misspelled. -
getFrequency
Get the frequency of use of a word (0-27) form the dictionary -
getSuggestionsFromSpellers
@NotNull private @NotNull List<String> getSuggestionsFromSpellers(String word, List<MorfologikSpeller> spellerList) -
getSuggestions
The suggestions from all dictionaries (without duplicates). -
getSuggestionsFromUserDicts
- Parameters:
word
- misspelled word- Returns:
- suggestions from users personal dictionary
- Since:
- 4.5
-
getSuggestionsFromDefaultDicts
- Parameters:
word
- misspelled word- Returns:
- suggestions from built-in dictionaries
- Since:
- 4.5
-
convertsCase
public boolean convertsCase()Determines whether the dictionary uses case conversions.- Returns:
- True when the speller uses spell conversions.
- Since:
- 2.5
-