Class HunspellDictionary


  • public class HunspellDictionary
    extends java.lang.Object
    In-memory structure for the dictionary (.dic) and affix (.aff) data of a hunspell dictionary.
    • Constructor Summary

      Constructors 
      Constructor Description
      HunspellDictionary​(java.io.InputStream affix, java.io.InputStream dictionary, Version version)
      Creates a new HunspellDictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files.
      HunspellDictionary​(java.io.InputStream affix, java.io.InputStream dictionary, Version version, boolean ignoreCase)
      Creates a new HunspellDictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files.
      HunspellDictionary​(java.io.InputStream affix, java.util.List<java.io.InputStream> dictionaries, Version version, boolean ignoreCase)
      Creates a new HunspellDictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files.
      HunspellDictionary​(java.io.InputStream affix, java.util.List<java.io.InputStream> dictionaries, Version version, boolean ignoreCase, boolean strictAffixParsing)
      Creates a new HunspellDictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Version getVersion()  
      boolean isIgnoreCase()  
      java.util.List<HunspellAffix> lookupPrefix​(char[] word, int offset, int length)
      Looks up HunspellAffix prefixes that have an append that matches the String created from the given char array, offset and length
      java.util.List<HunspellAffix> lookupSuffix​(char[] word, int offset, int length)
      Looks up HunspellAffix suffixes that have an append that matches the String created from the given char array, offset and length
      java.util.List<HunspellWord> lookupWord​(char[] word, int offset, int length)
      Looks up HunspellWords that match the String created from the given char array, offset and length
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HunspellDictionary

        public HunspellDictionary​(java.io.InputStream affix,
                                  java.io.InputStream dictionary,
                                  Version version)
                           throws java.io.IOException,
                                  java.text.ParseException
        Creates a new HunspellDictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files. You have to close the provided InputStreams yourself.
        Parameters:
        affix - InputStream for reading the hunspell affix file (won't be closed).
        dictionary - InputStream for reading the hunspell dictionary file (won't be closed).
        version - Lucene Version
        Throws:
        java.io.IOException - Can be thrown while reading from the InputStreams
        java.text.ParseException - Can be thrown if the content of the files does not meet expected formats
      • HunspellDictionary

        public HunspellDictionary​(java.io.InputStream affix,
                                  java.io.InputStream dictionary,
                                  Version version,
                                  boolean ignoreCase)
                           throws java.io.IOException,
                                  java.text.ParseException
        Creates a new HunspellDictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files. You have to close the provided InputStreams yourself.
        Parameters:
        affix - InputStream for reading the hunspell affix file (won't be closed).
        dictionary - InputStream for reading the hunspell dictionary file (won't be closed).
        version - Lucene Version
        ignoreCase - If true, dictionary matching will be case insensitive
        Throws:
        java.io.IOException - Can be thrown while reading from the InputStreams
        java.text.ParseException - Can be thrown if the content of the files does not meet expected formats
      • HunspellDictionary

        public HunspellDictionary​(java.io.InputStream affix,
                                  java.util.List<java.io.InputStream> dictionaries,
                                  Version version,
                                  boolean ignoreCase)
                           throws java.io.IOException,
                                  java.text.ParseException
        Creates a new HunspellDictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files. You have to close the provided InputStreams yourself.
        Parameters:
        affix - InputStream for reading the hunspell affix file (won't be closed).
        dictionaries - InputStreams for reading the hunspell dictionary file (won't be closed).
        version - Lucene Version
        ignoreCase - If true, dictionary matching will be case insensitive
        Throws:
        java.io.IOException - Can be thrown while reading from the InputStreams
        java.text.ParseException - Can be thrown if the content of the files does not meet expected formats
      • HunspellDictionary

        public HunspellDictionary​(java.io.InputStream affix,
                                  java.util.List<java.io.InputStream> dictionaries,
                                  Version version,
                                  boolean ignoreCase,
                                  boolean strictAffixParsing)
                           throws java.io.IOException,
                                  java.text.ParseException
        Creates a new HunspellDictionary containing the information read from the provided InputStreams to hunspell affix and dictionary files. You have to close the provided InputStreams yourself.
        Parameters:
        affix - InputStream for reading the hunspell affix file (won't be closed).
        dictionaries - InputStreams for reading the hunspell dictionary file (won't be closed).
        version - Lucene Version
        ignoreCase - If true, dictionary matching will be case insensitive
        strictAffixParsing - Affix strict parsing enabled or not (an error while reading a rule causes exception or is ignored)
        Throws:
        java.io.IOException - Can be thrown while reading from the InputStreams
        java.text.ParseException - Can be thrown if the content of the files does not meet expected formats
    • Method Detail

      • lookupWord

        public java.util.List<HunspellWord> lookupWord​(char[] word,
                                                       int offset,
                                                       int length)
        Looks up HunspellWords that match the String created from the given char array, offset and length
        Parameters:
        word - Char array to generate the String from
        offset - Offset in the char array that the String starts at
        length - Length from the offset that the String is
        Returns:
        List of HunspellWords that match the generated String, or null if none are found
      • lookupPrefix

        public java.util.List<HunspellAffix> lookupPrefix​(char[] word,
                                                          int offset,
                                                          int length)
        Looks up HunspellAffix prefixes that have an append that matches the String created from the given char array, offset and length
        Parameters:
        word - Char array to generate the String from
        offset - Offset in the char array that the String starts at
        length - Length from the offset that the String is
        Returns:
        List of HunspellAffix prefixes with an append that matches the String, or null if none are found
      • lookupSuffix

        public java.util.List<HunspellAffix> lookupSuffix​(char[] word,
                                                          int offset,
                                                          int length)
        Looks up HunspellAffix suffixes that have an append that matches the String created from the given char array, offset and length
        Parameters:
        word - Char array to generate the String from
        offset - Offset in the char array that the String starts at
        length - Length from the offset that the String is
        Returns:
        List of HunspellAffix suffixes with an append that matches the String, or null if none are found
      • getVersion

        public Version getVersion()
      • isIgnoreCase

        public boolean isIgnoreCase()