Package com.swabunga.spell.engine
Interface SpellDictionary
-
- All Known Implementing Classes:
GenericSpellDictionary
,SpellDictionaryASpell
,SpellDictionaryCachedDichoDisk
,SpellDictionaryDichoDisk
,SpellDictionaryDisk
,SpellDictionaryHashMap
public interface SpellDictionary
An interface for all dictionary implementations. It defines the most basic operations on a dictionary: adding words, checking if a word is correct, and getting a list of suggestions for misspelled words.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addWord(java.lang.String word)
Add a word permanently to the dictionary.java.util.List
getSuggestions(java.lang.String sourceWord, int scoreThreshold)
Returns a list of Word objects that are the suggestions to any word.java.util.List
getSuggestions(java.lang.String sourceWord, int scoreThreshold, int[][] matrix)
Returns a list of Word objects that are the suggestions to any word.boolean
isCorrect(java.lang.String word)
Evaluates if the word is correctly spelled against the dictionary.
-
-
-
Method Detail
-
addWord
void addWord(java.lang.String word)
Add a word permanently to the dictionary.- Parameters:
word
- The word to add to the dictionary
-
isCorrect
boolean isCorrect(java.lang.String word)
Evaluates if the word is correctly spelled against the dictionary.- Parameters:
word
- The word to verify if it's spelling is OK.- Returns:
- Indicates if the word is present in the dictionary.
-
getSuggestions
java.util.List getSuggestions(java.lang.String sourceWord, int scoreThreshold)
Returns a list of Word objects that are the suggestions to any word. If the word is correctly spelled, then this method could return just that one word, or it could still return a list of words with similar spellings.
Each suggested word has a score, which is an integer that represents how different the suggested word is from the sourceWord. If the words are the exactly the same, then the score is 0. You can get the dictionary to only return the most similar words by setting an appropriately low threshold value. If you set the threshold value too low, you may get no suggestions for a given word.This method is only needed to provide backward compatibility.
- Parameters:
sourceWord
- the string that we want to get a list of spelling suggestions forscoreThreshold
- Any words that have score less than this number are returned.- Returns:
- List a List of suggested words
- See Also:
getSuggestions(String, int, int[][])
,Word
-
getSuggestions
java.util.List getSuggestions(java.lang.String sourceWord, int scoreThreshold, int[][] matrix)
Returns a list of Word objects that are the suggestions to any word. If the word is correctly spelled, then this method could return just that one word, or it could still return a list of words with similar spellings.
Each suggested word has a score, which is an integer that represents how different the suggested word is from the sourceWord. If the words are the exactly the same, then the score is 0. You can get the dictionary to only return the most similar words by setting an appropriately low threshold value. If you set the threshold value too low, you may get no suggestions for a given word.- Parameters:
sourceWord
- the string that we want to get a list of spelling suggestions forscoreThreshold
- Any words that have score less than this number are returned.Two
- dimensional int array used to calculate edit distance. Allocating this memory outside of the function will greatly improve efficiency.- Returns:
- List a List of suggested words
- See Also:
Word
-
-