Class Hunspell
java.lang.Object
org.languagetool.rules.spelling.hunspell.Hunspell
The simple hunspell library frontend which takes care of creating
and singleton'ing the library instance (no need to load it more than once
per process).
The Hunspell java bindings are licensed under the same terms as Hunspell itself (GPL/LGPL/MPL tri-license),
see the file COPYING.txt in the root of the distribution for the exact terms.
- Author:
- Flemming Frandsen (flfr at stibo dot com)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassClass representing a single dictionary. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroyDictionary(String baseFileName) Removes a dictionary from the internal cachegetDictionary(String baseFileName) Gets an instance of the dictionary.static HunspellThe instance of the HunspellManager, looks for the native lib in the default directoriesstatic HunspellgetInstance(String libDir) The instance of the HunspellManager, looks for the native lib in the directory specified.static StringlibName()Calculate the filename of the native hunspell lib.static Stringprotected void
-
Constructor Details
-
Hunspell
Constructor for the library, loads the native lib. Loading is done in the first of the following three ways that works: 1) Unmodified load in the provided directory. 2) libFile stripped back to the base name (^lib(.*)\.so on unix) 3) The library is searched for in the classpath, extracted to disk and loaded.- Parameters:
libDir- Optional absolute directory where the native lib can be found.- Throws:
UnsupportedOperationException- if the OS or architecture is simply not supported.UnsatisfiedLinkError
-
-
Method Details
-
getInstance
The instance of the HunspellManager, looks for the native lib in the default directories -
getInstance
public static Hunspell getInstance(String libDir) throws UnsatisfiedLinkError, UnsupportedOperationException The instance of the HunspellManager, looks for the native lib in the directory specified.- Parameters:
libDir- Optional absolute directory where the native lib can be found.- Throws:
UnsatisfiedLinkErrorUnsupportedOperationException
-
tryLoad
- Throws:
UnsupportedOperationException
-
getLibFile
-
libName
Calculate the filename of the native hunspell lib. The files have completely different names to allow them to live in the same directory and avoid confusion.- Throws:
UnsupportedOperationException
-
libNameBare
- Throws:
UnsupportedOperationException
-
getDictionary
Gets an instance of the dictionary.- Parameters:
baseFileName- the base name of the dictionary, passing /dict/da_DK means that the files /dict/da_DK.dic and /dict/da_DK.aff get loaded- Throws:
IOException
-
destroyDictionary
Removes a dictionary from the internal cache- Parameters:
baseFileName- the base name of the dictionary, as passed to getDictionary()
-