com.swabunga.spell.engine
public class SpellDictionaryHashMap extends SpellDictionaryASpell
Field Summary | |
---|---|
protected Hashtable | mainDictionary
The hashmap that contains the word dictionary. |
Constructor Summary | |
---|---|
SpellDictionaryHashMap()
Dictionary Constructor. | |
SpellDictionaryHashMap(Reader wordList)
Dictionary Constructor. | |
SpellDictionaryHashMap(File wordList)
Dictionary convenience Constructor. | |
SpellDictionaryHashMap(File wordList, File phonetic)
Dictionary constructor that uses an aspell phonetic file to
build the transformation table. | |
SpellDictionaryHashMap(File wordList, File phonetic, String phoneticEncoding)
Dictionary constructor that uses an aspell phonetic file to
build the transformation table. | |
SpellDictionaryHashMap(Reader wordList, Reader phonetic)
Dictionary constructor that uses an aspell phonetic file to
build the transformation table. |
Method Summary | |
---|---|
void | addDictionary(File wordList)
Add words from a file to existing dictionary hashmap.
|
void | addDictionary(Reader wordList)
Add words from a Reader to existing dictionary hashmap.
|
protected void | addDictionaryHelper(BufferedReader in)
Adds to the existing dictionary from a word list file. |
void | addWord(String word)
Add a word permanently to the dictionary (and the dictionary file).
|
protected void | createDictionary(BufferedReader in)
Constructs the dictionary from a word list file.
|
List | getWords(String code)
Returns a list of strings (words) for the code. |
boolean | isCorrect(String word)
Returns true if the word is correctly spelled against the current word list. |
protected void | putWord(String word)
Allocates a word in the dictionary |
protected void | putWordUnique(String word)
Allocates a word, if it is not already present in the dictionary. |
Throws: java.io.IOException indicates a problem with the file system
Parameters: wordList The file containing the words list for the dictionary
Throws: java.io.IOException indicates problems reading the words list file
Parameters: wordList The file containing the words list for the dictionary
Throws: java.io.FileNotFoundException indicates problems locating the words list file on the system java.io.IOException indicates problems reading the words list file
Parameters: wordList The file containing the words list for the dictionary phonetic The file to use for phonetic transformation of the wordlist.
Throws: java.io.FileNotFoundException indicates problems locating the file on the system java.io.IOException indicates problems reading the words list file
Parameters: wordList The file containing the words list for the dictionary phonetic The file to use for phonetic transformation of the wordlist. phoneticEncoding Uses the character set encoding specified
Throws: java.io.FileNotFoundException indicates problems locating the file on the system java.io.IOException indicates problems reading the words list or phonetic information
Parameters: wordList The file containing the words list for the dictionary phonetic The reader to use for phonetic transformation of the wordlist.
Throws: java.io.IOException indicates problems reading the words list or phonetic information
Note that adding a dictionary does not affect the target dictionary file for the addWord method. That is, addWord() continues to make additions to the dictionary file specified in createDictionary()
Parameters: wordList a File object that contains the words, on word per line.
Throws: FileNotFoundException IOException
Note that adding a dictionary does not affect the target dictionary file for the addWord method. That is, addWord() continues to make additions to the dictionary file specified in createDictionary()
Parameters: wordList a Reader object that contains the words, on word per line.
Throws: IOException
Each word in the reader should be on a separate line.
Note: for whatever reason that I haven't yet looked into, the phonetic codes for a particular word map to a vector of words rather than a hash table. This is a drag since in order to check for duplicates you have to iterate through all the words that use the phonetic code. If the vector-based implementation is important, it may be better to subclass for the cases where duplicates are bad.
This needs to be made thread safe (synchronized)
Each word in the reader should be on a separate line.
This is a very slow function. On my machine it takes quite a while to load the data in. I suspect that we could speed this up quite allot.
Parameters: word The word to add
Parameters: word The word to add