|
|||||||||
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.GenericSpellDictionary
public class GenericSpellDictionary
The SpellDictionary class holds the instance of 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.HashMap |
mainDictionary
The hashmap that contains the word dictionary. |
Fields inherited from class com.swabunga.spell.engine.SpellDictionaryASpell |
---|
tf |
Constructor Summary | |
---|---|
GenericSpellDictionary(java.io.File wordList)
Dictionary constructor that uses the DoubleMeta class with the English alphabet. |
|
GenericSpellDictionary(java.io.File wordList,
java.io.File phonetic)
Dictionary constructor that uses an aspell phonetic file to build the transformation table. |
Method Summary | |
---|---|
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 |
Methods inherited from class com.swabunga.spell.engine.SpellDictionaryASpell |
---|
getCode, getSuggestions, getSuggestions |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.HashMap mainDictionary
Constructor Detail |
---|
public GenericSpellDictionary(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 GenericSpellDictionary(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 system
java.io.IOException
- when problems occurs while reading the
words list or phonetic fileMethod Detail |
---|
public 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.IOException
protected void putWord(java.lang.String word)
public java.util.List getWords(java.lang.String code)
getWords
in class SpellDictionaryASpell
code
- The phonetic code we want to find words for
public boolean isCorrect(java.lang.String word)
isCorrect
in interface SpellDictionary
isCorrect
in class SpellDictionaryASpell
word
- The word to checked in the dictionary
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |