Class MorfologikMultiSpeller

java.lang.Object
org.languagetool.rules.spelling.morfologik.MorfologikMultiSpeller

public class MorfologikMultiSpeller extends Object
Morfologik speller that merges results from binary (.dict) and plain text (.txt) dictionaries.
Since:
2.9
  • Field Details

  • 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 file
      plainTextPaths - 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 file
      plainTextReader - 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

      @NotNull private static @NotNull BufferedReader getBufferedReader(List<String> plainTextPaths)
    • getUserDictSpellerOrNull

      private MorfologikSpeller getUserDictSpellerOrNull(List<String> userWords, String dictPath, int maxEditDistance) throws IOException
      Throws:
      IOException
    • getBinaryDict

      private MorfologikSpeller getBinaryDict(String binaryDictPath, int maxEditDistance)
    • 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

      public boolean isMisspelled(String word)
      Accept the word if at least one of the dictionaries accepts it as not misspelled.
    • getFrequency

      public int getFrequency(String word)
      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

      public List<String> getSuggestions(String word)
      The suggestions from all dictionaries (without duplicates).
    • getSuggestionsFromUserDicts

      @Experimental public List<String> getSuggestionsFromUserDicts(String word)
      Parameters:
      word - misspelled word
      Returns:
      suggestions from users personal dictionary
      Since:
      4.5
    • getSuggestionsFromDefaultDicts

      @Experimental public List<String> getSuggestionsFromDefaultDicts(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