Class Hunspell.Dictionary

  • Enclosing class:
    Hunspell

    public class Hunspell.Dictionary
    extends java.lang.Object
    Class representing a single dictionary.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String encoding
      The encoding used by this dictionary
      private com.sun.jna.Pointer hunspellDict
      The pointer to the hunspell object as returned by the hunspell constructor.
      private java.lang.String wordChars  
    • Constructor Summary

      Constructors 
      Constructor Description
      Dictionary​(java.lang.String baseFileName)
      Creates an instance of the dictionary.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addWord​(java.lang.String word)
      Adds a word to the runtime dictionary.
      void destroy()
      Deallocate the dictionary.
      java.lang.String getWordChars()
      Used to query what are word-characters
      private java.lang.String getWordCharsFromFile​(java.io.File affixFile)  
      boolean misspelled​(java.lang.String word)
      Check if a word is spelled correctly
      protected byte[] stringToBytes​(java.lang.String str)
      Convert a Java string to a zero terminated byte array, in the encoding of the dictionary, as expected by the hunspell functions.
      java.util.List<java.lang.String> suggest​(java.lang.String word)
      Returns a list of suggestions
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • hunspellDict

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

        private java.lang.String encoding
        The encoding used by this dictionary
      • wordChars

        private final java.lang.String wordChars
    • Constructor Detail

      • Dictionary

        Dictionary​(java.lang.String baseFileName)
            throws java.io.IOException
        Creates an instance of the dictionary.
        Parameters:
        baseFileName - the base name of the dictionary,
        Throws:
        java.io.IOException
    • Method Detail

      • destroy

        public void destroy()
        Deallocate the dictionary.
      • getWordChars

        public java.lang.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​(java.lang.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​(java.lang.String str)
                                throws java.io.UnsupportedEncodingException
        Convert a Java string to a zero terminated byte array, in the encoding of the dictionary, as expected by the hunspell functions.
        Throws:
        java.io.UnsupportedEncodingException
      • suggest

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

        private java.lang.String getWordCharsFromFile​(java.io.File affixFile)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • addWord

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