Class Hunspell
- java.lang.Object
-
- org.languagetool.rules.spelling.hunspell.Hunspell
-
public class Hunspell extends Object
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 Classes Modifier and Type Class Description class
Hunspell.Dictionary
Class representing a single dictionary.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroyDictionary(String baseFileName)
Removes a dictionary from the internal cacheHunspell.Dictionary
getDictionary(String baseFileName)
Gets an instance of the dictionary.static Hunspell
getInstance()
The instance of the HunspellManager, looks for the native lib in the default directoriesstatic Hunspell
getInstance(String libDir)
The instance of the HunspellManager, looks for the native lib in the directory specified.String
getLibFile()
static String
libName()
Calculate the filename of the native hunspell lib.static String
libNameBare()
protected void
tryLoad(String libFile)
-
-
-
Constructor Detail
-
Hunspell
protected Hunspell(String libDir) throws UnsatisfiedLinkError, UnsupportedOperationException
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 Detail
-
getInstance
public static Hunspell getInstance() throws UnsatisfiedLinkError, UnsupportedOperationException
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:
UnsatisfiedLinkError
UnsupportedOperationException
-
tryLoad
protected void tryLoad(String libFile) throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
-
getLibFile
public String getLibFile()
-
libName
public static String libName() throws UnsupportedOperationException
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
public static String libNameBare() throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
-
getDictionary
public Hunspell.Dictionary getDictionary(String baseFileName) throws IOException
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
public void destroyDictionary(String baseFileName)
Removes a dictionary from the internal cache- Parameters:
baseFileName
- the base name of the dictionary, as passed to getDictionary()
-
-