public class SpellDictionaryHashMap extends SpellDictionaryASpell
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Hashtable |
mainDictionary
The hashmap that contains the word dictionary.
|
tf| Constructor and Description |
|---|
SpellDictionaryHashMap()
Dictionary Constructor.
|
SpellDictionaryHashMap(java.io.File wordList)
Dictionary convenience Constructor.
|
SpellDictionaryHashMap(java.io.File wordList,
java.io.File phonetic)
Dictionary constructor that uses an aspell phonetic file to
build the transformation table.
|
SpellDictionaryHashMap(java.io.File wordList,
java.io.File phonetic,
java.lang.String phoneticEncoding)
Dictionary constructor that uses an aspell phonetic file to
build the transformation table.
|
SpellDictionaryHashMap(java.io.Reader wordList)
Dictionary Constructor.
|
SpellDictionaryHashMap(java.io.Reader wordList,
java.io.Reader phonetic)
Dictionary constructor that uses an aspell phonetic file to
build the transformation table.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDictionary(java.io.File wordList)
Add words from a file to existing dictionary hashmap.
|
void |
addDictionary(java.io.Reader wordList)
Add words from a Reader to existing dictionary hashmap.
|
protected void |
addDictionaryHelper(java.io.BufferedReader in)
Adds to the existing dictionary from a word list file.
|
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 |
getWords(java.lang.String code)
Returns a list of strings (words) for the code.
|
boolean |
isCorrect(java.lang.String word)
Returns true if the word is correctly spelled against the current word list.
|
protected void |
putWord(java.lang.String word)
Allocates a word in the dictionary
|
protected void |
putWordUnique(java.lang.String word)
Allocates a word, if it is not already present in the dictionary.
|
getCode, getSuggestions, getSuggestionsprotected java.util.Hashtable mainDictionary
public SpellDictionaryHashMap()
throws java.io.IOException
java.io.IOException - indicates a problem with the file systempublic SpellDictionaryHashMap(java.io.Reader wordList)
throws java.io.IOException
wordList - The file containing the words list for the dictionaryjava.io.IOException - indicates problems reading the words list
filepublic SpellDictionaryHashMap(java.io.File wordList)
throws java.io.FileNotFoundException,
java.io.IOException
wordList - The file containing the words list for the dictionaryjava.io.FileNotFoundException - indicates problems locating the
words list file on the systemjava.io.IOException - indicates problems reading the words list
filepublic SpellDictionaryHashMap(java.io.File wordList,
java.io.File phonetic)
throws java.io.FileNotFoundException,
java.io.IOException
wordList - The file containing the words list for the dictionaryphonetic - The file to use for phonetic transformation of the
wordlist.java.io.FileNotFoundException - indicates problems locating the
file on the systemjava.io.IOException - indicates problems reading the words list
filepublic SpellDictionaryHashMap(java.io.File wordList,
java.io.File phonetic,
java.lang.String phoneticEncoding)
throws java.io.FileNotFoundException,
java.io.IOException
wordList - The file containing the words list for the dictionaryphonetic - The file to use for phonetic transformation of the
wordlist.phoneticEncoding - Uses the character set encoding specifiedjava.io.FileNotFoundException - indicates problems locating the
file on the systemjava.io.IOException - indicates problems reading the words list
or phonetic informationpublic SpellDictionaryHashMap(java.io.Reader wordList,
java.io.Reader phonetic)
throws java.io.IOException
wordList - The file containing the words list for the dictionaryphonetic - The reader to use for phonetic transformation of the
wordlist.java.io.IOException - indicates problems reading the words list
or phonetic informationpublic void addDictionary(java.io.File wordList)
throws java.io.FileNotFoundException,
java.io.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()
wordList - a File object that contains the words, on word per line.java.io.FileNotFoundExceptionjava.io.IOExceptionpublic void addDictionary(java.io.Reader wordList)
throws java.io.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()
wordList - a Reader object that contains the words, on word per line.java.io.IOExceptionpublic void addWord(java.lang.String word)
This needs to be made thread safe (synchronized)
word - The word to add to the dictionaryprotected void createDictionary(java.io.BufferedReader in)
throws java.io.IOException
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.
java.io.IOExceptionprotected void addDictionaryHelper(java.io.BufferedReader in)
throws java.io.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.
java.io.IOExceptionprotected void putWord(java.lang.String word)
word - The word to addprotected void putWordUnique(java.lang.String word)
word - The word to addpublic java.util.List getWords(java.lang.String code)
getWords in class SpellDictionaryASpellcode - The phonetic code common to the list of wordspublic boolean isCorrect(java.lang.String word)
isCorrect in interface SpellDictionaryisCorrect in class SpellDictionaryASpellword - The word to verify if it's spelling is OK.