Class Hunspell.Dictionary

java.lang.Object
org.languagetool.rules.spelling.hunspell.Hunspell.Dictionary
Enclosing class:
Hunspell

public class Hunspell.Dictionary extends Object
Class representing a single dictionary.
  • Field Details

    • hunspellDict

      private com.sun.jna.Pointer hunspellDict
      The pointer to the hunspell object as returned by the hunspell constructor.
    • encoding

      private String encoding
      The encoding used by this dictionary
    • wordChars

      private final String wordChars
  • Constructor Details

    • Dictionary

      Dictionary(String baseFileName) throws IOException
      Creates an instance of the dictionary.
      Parameters:
      baseFileName - the base name of the dictionary,
      Throws:
      IOException
  • Method Details

    • destroy

      public void destroy()
      Deallocate the dictionary.
    • getWordChars

      public String getWordChars()
      Used to query what are word-characters
      Returns:
      A string composed of characters that are parts of words, even if they are not alphabetic.
    • misspelled

      public boolean misspelled(String word)
      Check if a word is spelled correctly
      Parameters:
      word - The word to check.
      Returns:
      true if the word is not correctly spelled
    • stringToBytes

      protected byte[] stringToBytes(String str) throws UnsupportedEncodingException
      Convert a Java string to a zero terminated byte array, in the encoding of the dictionary, as expected by the hunspell functions.
      Throws:
      UnsupportedEncodingException
    • suggest

      public List<String> suggest(String word) throws CharacterCodingException
      Returns a list of suggestions
      Parameters:
      word - The word to check and offer suggestions for
      Throws:
      CharacterCodingException
    • getWordCharsFromFile

      private String getWordCharsFromFile(File affixFile) throws IOException
      Throws:
      IOException
    • addWord

      public void addWord(String word) throws UnsupportedEncodingException
      Adds a word to the runtime dictionary.
      Parameters:
      word - Word to be added.
      Throws:
      UnsupportedEncodingException