Package com.swabunga.spell.engine
Class SpellDictionaryASpell
- java.lang.Object
-
- com.swabunga.spell.engine.SpellDictionaryASpell
-
- All Implemented Interfaces:
SpellDictionary
- Direct Known Subclasses:
GenericSpellDictionary
,SpellDictionaryDichoDisk
,SpellDictionaryDisk
,SpellDictionaryHashMap
public abstract class SpellDictionaryASpell extends java.lang.Object implements SpellDictionary
Container for various methods that anySpellDictionary
will use. This class is based on the original Jazzy aspell port. Derived classes will need words list files as spell checking reference. Words list file is a dictionary with one word per line. There are many open source dictionary files, see: http://wordlist.sourceforge.net/ You can choose words lists form aspell many differents languages dictionaries. To grab some, installaspell
and the dictionaries you require. Then run aspell specifying the name of the dictionary and the words list file to dump it into, for example:aspell --master=fr-40 dump master > fr-40.txt
Note: the number following the language is the size indicator. A bigger number gives a more extensive language coverage. Size 40 is more than adequate for many usages. For some languages, Aspell can also supply you with the phonetic file. On Windows, go into aspelldata
directory and copy the phonetic file corresponding to your language, for example thefr_phonet.dat
for thefr
language. The phonetic file should be in directory/usr/share/aspell
on Unix.
-
-
Field Summary
Fields Modifier and Type Field Description protected Transformator
tf
The reference to a Transformator, used to transform a word into it's phonetic code.
-
Constructor Summary
Constructors Constructor Description SpellDictionaryASpell(java.io.File phonetic)
Constructs a new SpellDictionaryASpellSpellDictionaryASpell(java.io.File phonetic, java.lang.String encoding)
Constructs a new SpellDictionaryASpellSpellDictionaryASpell(java.io.Reader phonetic)
Constructs a new SpellDictionaryASpell
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
getCode(java.lang.String word)
Returns the phonetic code representing the word.java.util.List
getSuggestions(java.lang.String word, int threshold)
Returns a list of Word objects that are the suggestions to an incorrect word.java.util.List
getSuggestions(java.lang.String word, int threshold, int[][] matrix)
Returns a list of Word objects that are the suggestions to an incorrect word.protected abstract java.util.List
getWords(java.lang.String phoneticCode)
Returns a list of words that have the same phonetic code.boolean
isCorrect(java.lang.String word)
Returns true if the word is correctly spelled against the current word list.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.swabunga.spell.engine.SpellDictionary
addWord
-
-
-
-
Field Detail
-
tf
protected Transformator tf
The reference to a Transformator, used to transform a word into it's phonetic code.
-
-
Constructor Detail
-
SpellDictionaryASpell
public SpellDictionaryASpell(java.io.File phonetic) throws java.io.IOException
Constructs a new SpellDictionaryASpell- Parameters:
phonetic
- The file to use for phonetic transformation of the words list. Ifphonetic
is null, the the transformation usesDoubleMeta
transformation.- Throws:
java.io.IOException
- indicates problems reading the phonetic information
-
SpellDictionaryASpell
public SpellDictionaryASpell(java.io.File phonetic, java.lang.String encoding) throws java.io.IOException
Constructs a new SpellDictionaryASpell- Parameters:
phonetic
- The file to use for phonetic transformation of the words list. Ifphonetic
is null, the the transformation usesDoubleMeta
transformation.encoding
- Uses the character set encoding specified- Throws:
java.io.IOException
- indicates problems reading the phonetic information
-
SpellDictionaryASpell
public SpellDictionaryASpell(java.io.Reader phonetic) throws java.io.IOException
Constructs a new SpellDictionaryASpell- Parameters:
phonetic
- The Reader to use for phonetic transformation of the words list. Ifphonetic
is null, the the transformation usesDoubleMeta
transformation.- Throws:
java.io.IOException
- indicates problems reading the phonetic information
-
-
Method Detail
-
getSuggestions
public java.util.List getSuggestions(java.lang.String word, int threshold)
Returns a list of Word objects that are the suggestions to an incorrect word.This method is only needed to provide backward compatibility.
- Specified by:
getSuggestions
in interfaceSpellDictionary
- Parameters:
word
- Suggestions for given misspelt wordthreshold
- The lower boundary of similarity to misspelt word- Returns:
- Vector a List of suggestions
- See Also:
getSuggestions(String, int, int[][])
-
getSuggestions
public java.util.List getSuggestions(java.lang.String word, int threshold, int[][] matrix)
Returns a list of Word objects that are the suggestions to an incorrect word.- Specified by:
getSuggestions
in interfaceSpellDictionary
- Parameters:
word
- Suggestions for given misspelt wordthreshold
- The lower boundary of similarity to misspelt wordmatrix
- Two dimensional int array used to calculate edit distance. Allocating this memory outside of the function will greatly improve efficiency.- Returns:
- Vector a List of suggestions
- See Also:
Word
-
getCode
public java.lang.String getCode(java.lang.String word)
Returns the phonetic code representing the word.- Parameters:
word
- The word we want the phonetic code.- Returns:
- The value of the phonetic code for the word.
-
getWords
protected abstract java.util.List getWords(java.lang.String phoneticCode)
Returns a list of words that have the same phonetic code.- Parameters:
phoneticCode
- The phonetic code common to the list of words- Returns:
- A list of words having the same phonetic 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 interfaceSpellDictionary
- Parameters:
word
- The word to verify if it's spelling is OK.- Returns:
- Indicates if the word is present in the dictionary.
-
-