[1014] | 1 | package com.swabunga.spell.engine; |
---|
| 2 | |
---|
| 3 | import java.util.List; |
---|
| 4 | |
---|
| 5 | /** |
---|
| 6 | * An interface for all dictionary implementations. It defines the most basic |
---|
| 7 | * operations on a dictionary: adding words, checking if a word is correct, and getting a list |
---|
| 8 | * of suggestions for misspelled words. |
---|
| 9 | */ |
---|
| 10 | public interface SpellDictionary { |
---|
| 11 | |
---|
| 12 | /** |
---|
| 13 | * Add a word permanently to the dictionary. |
---|
| 14 | */ |
---|
| 15 | public void addWord(String word); |
---|
| 16 | |
---|
| 17 | /** |
---|
| 18 | * Returns true if the word is correctly spelled against the dictionary. |
---|
| 19 | */ |
---|
| 20 | public boolean isCorrect(String word); |
---|
| 21 | |
---|
| 22 | /** |
---|
| 23 | * Returns a list of Word objects that are the suggestions to any word. |
---|
| 24 | * If the word is correctly spelled, then this method |
---|
| 25 | * could return just that one word, or it could still return a list |
---|
| 26 | * of words with similar spellings. |
---|
| 27 | * <br/> |
---|
| 28 | * Each suggested word has a score, which is an integer |
---|
| 29 | * that represents how different the suggested word is from the sourceWord. |
---|
| 30 | * If the words are the exactly the same, then the score is 0. |
---|
| 31 | * You can get the dictionary to only return the most similiar words by setting |
---|
| 32 | * an appropriately low threshold value. |
---|
| 33 | * If you set the threshold value too low, you may get no suggestions for a given word. |
---|
| 34 | * <p> |
---|
| 35 | * @param sourceWord the string that we want to get a list of spelling suggestions for |
---|
| 36 | * @param scoreThreshold Any words that have score less than this number are returned. |
---|
| 37 | * @return List a List of suggested words |
---|
| 38 | * @see com.swabunga.spell.engine.Word |
---|
| 39 | */ |
---|
| 40 | public List getSuggestions(String sourceWord, int scoreThreshold); |
---|
| 41 | } |
---|