OSDN Git Service

58577f4b7e83f7a4c0fc846fc9db0de211300a25
[neighbornote/NeighborNote.git] / src / com / swabunga / spell / engine / SpellDictionary.java
1 /*\r
2 Jazzy - a Java library for Spell Checking\r
3 Copyright (C) 2001 Mindaugas Idzelis\r
4 Full text of license can be found in LICENSE.txt\r
5 \r
6 This library is free software; you can redistribute it and/or\r
7 modify it under the terms of the GNU Lesser General Public\r
8 License as published by the Free Software Foundation; either\r
9 version 2.1 of the License, or (at your option) any later version.\r
10 \r
11 This library is distributed in the hope that it will be useful,\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
14 Lesser General Public License for more details.\r
15 \r
16 You should have received a copy of the GNU Lesser General Public\r
17 License along with this library; if not, write to the Free Software\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
19 */\r
20 package com.swabunga.spell.engine;\r
21 \r
22 import java.util.List;\r
23 \r
24 /**\r
25  * An interface for all dictionary implementations. It defines the most basic\r
26  * operations on a dictionary: adding words, checking if a word is correct, and getting a list\r
27  * of suggestions for misspelled words.\r
28  */\r
29 public interface SpellDictionary {\r
30 \r
31   /**\r
32    * Add a word permanently to the dictionary.\r
33    * @param word The word to add to the dictionary\r
34    */\r
35   public void addWord(String word);\r
36 \r
37   /**\r
38    * Evaluates if the word is correctly spelled against the dictionary.\r
39    * @param word The word to verify if it's spelling is OK.\r
40    * @return Indicates if the word is present in the dictionary.\r
41    */\r
42   public boolean isCorrect(String word);\r
43 \r
44   /**\r
45    * Returns a list of Word objects that are the suggestions to any word.\r
46    * If the word is correctly spelled, then this method\r
47    * could return just that one word, or it could still return a list\r
48    * of words with similar spellings.\r
49    * <br/>\r
50    * Each suggested word has a score, which is an integer\r
51    * that represents how different the suggested word is from the sourceWord.\r
52    * If the words are the exactly the same, then the score is 0.\r
53    * You can get the dictionary to only return the most similar words by setting\r
54    * an appropriately low threshold value.\r
55    * If you set the threshold value too low, you may get no suggestions for a given word.\r
56    * <p>\r
57    * This method is only needed to provide backward compatibility. \r
58    * @see #getSuggestions(String, int, int[][])\r
59    * \r
60    * @param sourceWord the string that we want to get a list of spelling suggestions for\r
61    * @param scoreThreshold Any words that have score less than this number are returned.\r
62    * @return List a List of suggested words\r
63    * @see com.swabunga.spell.engine.Word\r
64    * \r
65    */\r
66   @SuppressWarnings("unchecked")\r
67 public List getSuggestions(String sourceWord, int scoreThreshold);\r
68 \r
69   /**\r
70    * Returns a list of Word objects that are the suggestions to any word.\r
71    * If the word is correctly spelled, then this method\r
72    * could return just that one word, or it could still return a list\r
73    * of words with similar spellings.\r
74    * <br/>\r
75    * Each suggested word has a score, which is an integer\r
76    * that represents how different the suggested word is from the sourceWord.\r
77    * If the words are the exactly the same, then the score is 0.\r
78    * You can get the dictionary to only return the most similar words by setting\r
79    * an appropriately low threshold value.\r
80    * If you set the threshold value too low, you may get no suggestions for a given word.\r
81    * <p>\r
82    * @param sourceWord the string that we want to get a list of spelling suggestions for\r
83    * @param scoreThreshold Any words that have score less than this number are returned.\r
84    * @param Two dimensional int array used to calculate edit distance. Allocating \r
85    * this memory outside of the function will greatly improve efficiency.   \r
86    * @return List a List of suggested words\r
87    * @see com.swabunga.spell.engine.Word\r
88    */\r
89   @SuppressWarnings("unchecked")\r
90 public List getSuggestions(String sourceWord, int scoreThreshold , int[][] matrix);\r
91 \r
92 }\r