org.incava.text
Class SpellChecker
java.lang.Object
org.incava.text.SpellChecker
public class SpellChecker
extends java.lang.Object
Calculates the edit distance between two strings.
boolean | addDictionary(String dictionary) - Adds the given dictionary.
|
void | addWord(String word)
|
protected int | compare(String str1, int len1, String str2, int len2) - Compares the two characters.
|
int | editDistance(String str1, String str2) - Computes the Levenstein edit distance between the two words, with a
maximum of 3, at which point the distance is no longer computed.
|
int | editDistance(String str1, String str2, int maximum) - Computes the Levenstein edit distance between the two words.
|
String | getKey(String word)
|
boolean | hasWord(String word)
|
boolean | isCorrect(String word, Map nearMatches)
|
boolean | isCorrect(String word, int maxEditDistance, Map nearMatches)
|
protected static int | min3(int x, int y, int z)
|
boolean | nearMatch(String str1, String str2)
|
ARR_SIZE
protected static final int ARR_SIZE
COMP_LEN
protected static final int COMP_LEN
DEFAULT_MAX_DISTANCE
public static final int DEFAULT_MAX_DISTANCE
addDictionary
public boolean addDictionary(String dictionary)
Adds the given dictionary. Returns whether it could be read and had content.
addWord
public void addWord(String word)
compare
protected int compare(String str1,
int len1,
String str2,
int len2)
Compares the two characters. English words should probably be case
insensitive; code should not.
editDistance
public int editDistance(String str1,
String str2)
Computes the Levenstein edit distance between the two words, with a
maximum of 3, at which point the distance is no longer computed.
editDistance
public int editDistance(String str1,
String str2,
int maximum)
Computes the Levenstein edit distance between the two words.
getKey
public String getKey(String word)
hasWord
public boolean hasWord(String word)
isCorrect
public boolean isCorrect(String word,
Map nearMatches)
isCorrect
public boolean isCorrect(String word,
int maxEditDistance,
Map nearMatches)
nearMatches
- a map from edit distances to matches.
min3
protected static int min3(int x,
int y,
int z)
nearMatch
public boolean nearMatch(String str1,
String str2)