Class Hunspell.Dictionary
- java.lang.Object
-
- org.languagetool.rules.spelling.hunspell.Hunspell.Dictionary
-
- Enclosing class:
- Hunspell
public class Hunspell.Dictionary extends java.lang.ObjectClass representing a single dictionary.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringencodingThe encoding used by this dictionaryprivate com.sun.jna.PointerhunspellDictThe pointer to the hunspell object as returned by the hunspell constructor.private java.lang.StringwordChars
-
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 voidaddWord(java.lang.String word)Adds a word to the runtime dictionary.voiddestroy()Deallocate the dictionary.java.lang.StringgetWordChars()Used to query what are word-charactersprivate java.lang.StringgetWordCharsFromFile(java.io.File affixFile)booleanmisspelled(java.lang.String word)Check if a word is spelled correctlyprotected 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
-
-
-
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
wordis not correctly spelled
-
stringToBytes
protected byte[] stringToBytes(java.lang.String str) throws java.io.UnsupportedEncodingExceptionConvert 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.CharacterCodingExceptionReturns 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.UnsupportedEncodingExceptionAdds a word to the runtime dictionary.- Parameters:
word- Word to be added.- Throws:
java.io.UnsupportedEncodingException
-
-