com.swabunga.spell.engine
Class GenericSpellDictionary

java.lang.Object
  extended by com.swabunga.spell.engine.SpellDictionaryASpell
      extended by com.swabunga.spell.engine.GenericSpellDictionary
All Implemented Interfaces:
SpellDictionary

public class GenericSpellDictionary
extends SpellDictionaryASpell

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).


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 permanantly to the dictionary (and the dictionary 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.
 
Methods inherited from class com.swabunga.spell.engine.SpellDictionaryASpell
getCode, getSuggestions
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericSpellDictionary

public GenericSpellDictionary(java.io.File wordList)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
Dictionary constructor that uses the DoubleMeta class with the english alphabet.

Throws:
java.io.FileNotFoundException
java.io.IOException

GenericSpellDictionary

public GenericSpellDictionary(java.io.File wordList,
                              java.io.File phonetic)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
Dictionary constructor that uses an aspell phonetic file to build the transformation table. If phonetic is null, then DoubleMeta is used with the english alphabet

Throws:
java.io.FileNotFoundException
java.io.IOException
Method Detail

addWord

public void addWord(java.lang.String word)
Add a word permanantly to the dictionary (and the dictionary file).

This needs to be made thread safe (synchronized)


getWords

public java.util.List getWords(java.lang.String code)
Returns a list of strings (words) for the code.


isCorrect

public boolean isCorrect(java.lang.String word)
Returns true if the word is correctly spelled against the current word list.

Specified by:
isCorrect in interface SpellDictionary
Overrides:
isCorrect in class SpellDictionaryASpell