Class MorfologikMultiSpeller
- java.lang.Object
-
- org.languagetool.rules.spelling.morfologik.MorfologikMultiSpeller
-
public class MorfologikMultiSpeller extends java.lang.ObjectMorfologik speller that merges results from binary (.dict) and plain text (.txt) dictionaries.- Since:
- 2.9
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classMorfologikMultiSpeller.BufferedReaderWithSource
-
Field Summary
Fields Modifier and Type Field Description private booleanconvertsCaseprivate java.util.List<MorfologikSpeller>defaultDictSpellersprivate static java.util.Map<java.lang.String,morfologik.stemming.Dictionary>dicPathToDictprivate static com.google.common.cache.LoadingCache<MorfologikMultiSpeller.BufferedReaderWithSource,java.util.List<byte[]>>dictCacheprivate java.util.List<MorfologikSpeller>spellersprivate java.util.List<MorfologikSpeller>userDictSpellers
-
Constructor Summary
Constructors Constructor Description MorfologikMultiSpeller(java.lang.String binaryDictPath, java.io.BufferedReader plainTextReader, java.util.List<java.lang.String> plainTextReaderPath, java.io.BufferedReader languageVariantPlainTextReader, java.lang.String languageVariantPlainTextPath, java.util.List<java.lang.String> userWords, int maxEditDistance)MorfologikMultiSpeller(java.lang.String binaryDictPath, java.util.List<java.lang.String> plainTextPaths, java.lang.String languageVariantPlainTextPath, int maxEditDistance)MorfologikMultiSpeller(java.lang.String binaryDictPath, java.util.List<java.lang.String> plainTextPaths, java.lang.String languageVariantPlainTextPath, UserConfig userConfig, int maxEditDistance)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanconvertsCase()Determines whether the dictionary uses case conversions.private MorfologikSpellergetBinaryDict(java.lang.String binaryDictPath, int maxEditDistance)private static @NotNull java.io.BufferedReadergetBufferedReader(java.util.List<java.lang.String> plainTextPaths)private morfologik.stemming.DictionarygetDictionary(java.util.List<byte[]> lines, java.lang.String dictPath, java.lang.String infoPath, boolean allowCache)intgetFrequency(java.lang.String word)Get the frequency of use of a word (0-27) form the dictionaryprivate @Nullable MorfologikSpellergetPlainTextDictSpellerOrNull(java.io.BufferedReader plainTextReader, java.util.List<java.lang.String> plainTextReaderPaths, java.io.BufferedReader languageVariantPlainTextReader, java.lang.String languageVariantPlainTextPath, java.lang.String dictPath, int maxEditDistance)java.util.List<java.lang.String>getSuggestions(java.lang.String word)The suggestions from all dictionaries (without duplicates).java.util.List<java.lang.String>getSuggestionsFromDefaultDicts(java.lang.String word)private @NotNull java.util.List<java.lang.String>getSuggestionsFromSpellers(java.lang.String word, java.util.List<MorfologikSpeller> spellerList)java.util.List<java.lang.String>getSuggestionsFromUserDicts(java.lang.String word)private MorfologikSpellergetUserDictSpellerOrNull(java.util.List<java.lang.String> userWords, java.lang.String dictPath, int maxEditDistance)booleanisMisspelled(java.lang.String word)Accept the word if at least one of the dictionaries accepts it as not misspelled.
-
-
-
Field Detail
-
dictCache
private static final com.google.common.cache.LoadingCache<MorfologikMultiSpeller.BufferedReaderWithSource,java.util.List<byte[]>> dictCache
-
dicPathToDict
private static final java.util.Map<java.lang.String,morfologik.stemming.Dictionary> dicPathToDict
-
spellers
private final java.util.List<MorfologikSpeller> spellers
-
defaultDictSpellers
private final java.util.List<MorfologikSpeller> defaultDictSpellers
-
userDictSpellers
private final java.util.List<MorfologikSpeller> userDictSpellers
-
convertsCase
private final boolean convertsCase
-
-
Constructor Detail
-
MorfologikMultiSpeller
public MorfologikMultiSpeller(java.lang.String binaryDictPath, java.util.List<java.lang.String> plainTextPaths, java.lang.String languageVariantPlainTextPath, int maxEditDistance) throws java.io.IOException- Throws:
java.io.IOException
-
MorfologikMultiSpeller
@Experimental public MorfologikMultiSpeller(java.lang.String binaryDictPath, java.util.List<java.lang.String> plainTextPaths, java.lang.String languageVariantPlainTextPath, UserConfig userConfig, int maxEditDistance) throws java.io.IOException
- Parameters:
binaryDictPath- path in classpath to a.dictbinary Morfologik fileplainTextPaths- paths in classpath to plain text.txtfiles (like spelling.txt)maxEditDistance- maximum edit distance for accepting suggestions- Throws:
java.io.IOException- Since:
- 4.2
-
MorfologikMultiSpeller
public MorfologikMultiSpeller(java.lang.String binaryDictPath, java.io.BufferedReader plainTextReader, java.util.List<java.lang.String> plainTextReaderPath, java.io.BufferedReader languageVariantPlainTextReader, java.lang.String languageVariantPlainTextPath, java.util.List<java.lang.String> userWords, int maxEditDistance) throws java.io.IOException- Parameters:
binaryDictPath- path in classpath to a.dictbinary Morfologik fileplainTextReader- reader with to a plain text.txtfile (like from spelling.txt)maxEditDistance- maximum edit distance for accepting suggestions- Throws:
java.io.IOException- Since:
- 3.0
-
-
Method Detail
-
getBufferedReader
@NotNull private static @NotNull java.io.BufferedReader getBufferedReader(java.util.List<java.lang.String> plainTextPaths)
-
getUserDictSpellerOrNull
private MorfologikSpeller getUserDictSpellerOrNull(java.util.List<java.lang.String> userWords, java.lang.String dictPath, int maxEditDistance) throws java.io.IOException
- Throws:
java.io.IOException
-
getBinaryDict
private MorfologikSpeller getBinaryDict(java.lang.String binaryDictPath, int maxEditDistance)
-
getPlainTextDictSpellerOrNull
@Nullable private @Nullable MorfologikSpeller getPlainTextDictSpellerOrNull(java.io.BufferedReader plainTextReader, java.util.List<java.lang.String> plainTextReaderPaths, java.io.BufferedReader languageVariantPlainTextReader, java.lang.String languageVariantPlainTextPath, java.lang.String dictPath, int maxEditDistance) throws java.io.IOException
- Throws:
java.io.IOException
-
getDictionary
private morfologik.stemming.Dictionary getDictionary(java.util.List<byte[]> lines, java.lang.String dictPath, java.lang.String infoPath, boolean allowCache) throws java.io.IOException- Throws:
java.io.IOException
-
isMisspelled
public boolean isMisspelled(java.lang.String word)
Accept the word if at least one of the dictionaries accepts it as not misspelled.
-
getFrequency
public int getFrequency(java.lang.String word)
Get the frequency of use of a word (0-27) form the dictionary
-
getSuggestionsFromSpellers
@NotNull private @NotNull java.util.List<java.lang.String> getSuggestionsFromSpellers(java.lang.String word, java.util.List<MorfologikSpeller> spellerList)
-
getSuggestions
public java.util.List<java.lang.String> getSuggestions(java.lang.String word)
The suggestions from all dictionaries (without duplicates).
-
getSuggestionsFromUserDicts
@Experimental public java.util.List<java.lang.String> getSuggestionsFromUserDicts(java.lang.String word)
- Parameters:
word- misspelled word- Returns:
- suggestions from users personal dictionary
- Since:
- 4.5
-
getSuggestionsFromDefaultDicts
@Experimental public java.util.List<java.lang.String> getSuggestionsFromDefaultDicts(java.lang.String word)
- 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
-
-