public abstract class ASpellSpellingDictionary extends java.lang.Object implements SpellingDictionary
SpellingDictionary 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 from aspell's
many different language dictionaries. To grab some, install
aspell 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.
data directory and copy the phonetic
file corresponding to your language, for example the
fr_phonet.dat for the fr language. The phonetic
file should be in directory /usr/share/aspell on Unix.| Modifier and Type | Field and Description |
|---|---|
protected Transformator |
transformator
The reference to a Transformator, used to transform a word into its
phonetic code.
|
| Constructor and Description |
|---|
ASpellSpellingDictionary(java.io.File phonetic)
Constructs a new SpellDictionaryASpell
|
ASpellSpellingDictionary(java.io.File phonetic,
java.lang.String encoding)
Constructs a new SpellDictionaryASpell
|
ASpellSpellingDictionary(java.io.Reader phonetic)
Constructs a new ASpellSpellingDictionary
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getPhoneticCode(java.lang.String word)
Returns the phonetic code representing the word.
|
java.util.List<Word> |
getSuggestions(java.lang.String word,
int threshold)
Returns a list of Word objects that are the suggestions to an incorrect
word.
|
java.util.List<Word> |
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<java.lang.String> |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddWordprotected Transformator transformator
public ASpellSpellingDictionary(java.io.File phonetic)
throws java.io.IOException
phonetic - The file to use for phonetic transformation of the words
list. If phonetic is null, the the transformation uses
DoubleMetaphoneTransformator transformation.java.io.IOException - indicates problems reading the phonetic
informationpublic ASpellSpellingDictionary(java.io.File phonetic,
java.lang.String encoding)
throws java.io.IOException
phonetic - The file to use for phonetic transformation of the words
list. If phonetic is null, the the transformation uses
DoubleMetaphoneTransformator transformation.encoding - Uses the character set encoding specifiedjava.io.IOException - indicates problems reading the phonetic
informationpublic ASpellSpellingDictionary(java.io.Reader phonetic)
throws java.io.IOException
phonetic - The Reader to use for phonetic transformation of the
words list. If phonetic is null, the the transformation uses
DoubleMetaphoneTransformator transformation.java.io.IOException - indicates problems reading the phonetic
informationpublic java.util.List<Word> getSuggestions(java.lang.String word, int threshold)
This method is only needed to provide backward compatibility.
getSuggestions in interface SpellingDictionaryword - Suggestions for given misspelt wordthreshold - The lower boundary of similarity to misspelt wordgetSuggestions(String, int, int[][])public java.util.List<Word> getSuggestions(java.lang.String word, int threshold, int[][] matrix)
getSuggestions in interface SpellingDictionaryword - 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.Wordpublic java.lang.String getPhoneticCode(java.lang.String word)
word - The word we want the phonetic code.protected abstract java.util.List<java.lang.String> getWords(java.lang.String phoneticCode)
phoneticCode - The phonetic code common to the list of wordspublic boolean isCorrect(java.lang.String word)
isCorrect in interface SpellingDictionaryword - The word to verify if its spelling is OK.