|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.swabunga.spell.engine.SpellDictionaryASpell
com.swabunga.spell.engine.SpellDictionaryHashMap
The SpellDictionaryHashMap holds the dictionary
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).
Field Summary | |
protected java.util.Hashtable |
mainDictionary
The hashmap that contains the word dictionary. |
Fields inherited from class com.swabunga.spell.engine.SpellDictionaryASpell |
tf |
Constructor Summary | |
SpellDictionaryHashMap()
Dictionary Constructor. |
|
SpellDictionaryHashMap(java.io.File wordList)
Dictionary Convienence 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. |
Method Summary | |
void |
addDictionary(java.io.File wordList)
Add words from a file to existing dictionary hashmap. |
void |
addDictionary(java.io.Reader wordList)
|
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 permanantly 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)
|
Methods inherited from class com.swabunga.spell.engine.SpellDictionaryASpell |
getCode, getSuggestions |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Hashtable mainDictionary
Constructor Detail |
public SpellDictionaryHashMap() throws java.io.IOException
public SpellDictionaryHashMap(java.io.Reader wordList) throws java.io.IOException
public SpellDictionaryHashMap(java.io.File wordList) throws java.io.FileNotFoundException, java.io.IOException
public SpellDictionaryHashMap(java.io.File wordList, java.io.File phonetic) throws java.io.FileNotFoundException, java.io.IOException
public SpellDictionaryHashMap(java.io.File wordList, java.io.File phonetic, java.lang.String phoneticEncoding) throws java.io.FileNotFoundException, java.io.IOException
public SpellDictionaryHashMap(java.io.Reader wordList, java.io.Reader phonetic) throws java.io.IOException
Method Detail |
public 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.FileNotFoundException
java.io.IOException
public void addDictionary(java.io.Reader wordList) throws java.io.IOException
java.io.IOException
public void addWord(java.lang.String word)
This needs to be made thread safe (synchronized)
protected void createDictionary(java.io.BufferedReader in) throws java.io.IOException
Each word in the reader should be on a seperate 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 alot.
java.io.IOException
protected void addDictionaryHelper(java.io.BufferedReader in) throws java.io.IOException
Each word in the reader should be on a seperate 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.IOException
protected void putWord(java.lang.String word)
protected void putWordUnique(java.lang.String word)
public java.util.List getWords(java.lang.String code)
getWords
in class SpellDictionaryASpell
public boolean isCorrect(java.lang.String word)
isCorrect
in interface SpellDictionary
isCorrect
in class SpellDictionaryASpell
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |