public class SpellChecker
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static int |
ARR_SIZE |
protected static int |
COMP_LEN |
static int |
DEFAULT_MAX_DISTANCE |
Constructor and Description |
---|
SpellChecker() |
Modifier and Type | Method and Description |
---|---|
boolean |
addDictionary(java.lang.String dictionary)
Adds the given dictionary.
|
void |
addWord(java.lang.String word) |
protected int |
compare(java.lang.String str1,
int len1,
java.lang.String str2,
int len2)
Compares the two characters.
|
int |
editDistance(java.lang.String str1,
java.lang.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(java.lang.String str1,
java.lang.String str2,
int maximum)
Computes the Levenstein edit distance between the two words.
|
java.lang.String |
getKey(java.lang.String word) |
boolean |
hasWord(java.lang.String word) |
boolean |
isCorrect(java.lang.String word,
int maxEditDistance,
java.util.Map nearMatches) |
boolean |
isCorrect(java.lang.String word,
java.util.Map nearMatches) |
protected static int |
min3(int x,
int y,
int z) |
boolean |
nearMatch(java.lang.String str1,
java.lang.String str2) |
public static final int DEFAULT_MAX_DISTANCE
protected static final int COMP_LEN
protected static final int ARR_SIZE
public int editDistance(java.lang.String str1, java.lang.String str2)
public int editDistance(java.lang.String str1, java.lang.String str2, int maximum)
public boolean nearMatch(java.lang.String str1, java.lang.String str2)
public boolean addDictionary(java.lang.String dictionary)
public java.lang.String getKey(java.lang.String word)
public void addWord(java.lang.String word)
public boolean hasWord(java.lang.String word)
public boolean isCorrect(java.lang.String word, int maxEditDistance, java.util.Map nearMatches)
nearMatches
- a map from edit distances to matches.public boolean isCorrect(java.lang.String word, java.util.Map nearMatches)
protected int compare(java.lang.String str1, int len1, java.lang.String str2, int len2)
protected static int min3(int x, int y, int z)