public class GenericSpellingDictionary extends ASpellSpellingDictionary
This class is thread safe. Derived classes should ensure that this preserved.
There are many open source dictionary files. For just a few see: http://wordlist.sourceforge.net/
This dictionary class reads words one per line. Make sure that your word list is formatted in this way (most are).
| Modifier and Type | Field and Description |
|---|---|
protected java.util.HashMap<java.lang.String,java.util.LinkedList<java.lang.String>> |
mainDictionary
The hashmap that contains the word dictionary.
|
transformator| Constructor and Description |
|---|
GenericSpellingDictionary(java.io.File wordList)
Dictionary constructor that uses the DoubleMetaphone class with the
English alphabet.
|
GenericSpellingDictionary(java.io.File wordList,
java.io.File phonetic)
Dictionary constructor that uses an aspell phonetic file to build the
transformation table.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addWord(java.lang.String word)
Add a word permanently to the dictionary (and the dictionary file).
|
protected void |
createDictionary(java.io.BufferedReader in)
Constructs the dictionary from a word list file.
|
java.util.List<java.lang.String> |
getWords(java.lang.String code)
Returns a list of strings (words) for the code.
|
protected void |
putWord(java.lang.String word)
Stores a word in the dictionary.
|
getPhoneticCode, getSuggestions, getSuggestions, isCorrectprotected java.util.HashMap<java.lang.String,java.util.LinkedList<java.lang.String>> mainDictionary
public GenericSpellingDictionary(java.io.File wordList)
throws java.io.FileNotFoundException,
java.io.IOException
wordList - The file containing dictionary as a words list.java.io.FileNotFoundException - when the words list file could not
be located on the system.java.io.IOException - when problems occurs while reading the words
list filepublic GenericSpellingDictionary(java.io.File wordList,
java.io.File phonetic)
throws java.io.FileNotFoundException,
java.io.IOException
wordList - The file containing dictionary as a words list.phonetic - The file containing the phonetic transformation
information.java.io.FileNotFoundException - when the words list or phonetic
file could not be located on the systemjava.io.IOException - when problems occurs while reading the words
list or phonetic filepublic void addWord(java.lang.String word)
This needs to be made thread safe (synchronized)
word - The word to add to the dictionaryprotected final void createDictionary(java.io.BufferedReader in)
throws java.io.IOException
Each word in the reader should be on a separate line.
in - a buffered reader pointing to the word list filejava.io.IOException - if a problem is encountered reading the fileprotected void putWord(java.lang.String word)
word - a word to be stored in the dictionarypublic java.util.List<java.lang.String> getWords(java.lang.String code)
getWords in class ASpellSpellingDictionarycode - The phonetic code we want to find words for