Class Hunspell.Dictionary
- java.lang.Object
-
- org.languagetool.rules.spelling.hunspell.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 dictionaryprivate 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-charactersprivate java.lang.String
getWordCharsFromFile(java.io.File affixFile)
boolean
misspelled(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
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
-
-