|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.incava.text.SpellChecker
public class SpellChecker
Calculates the edit distance between two strings.
Field Summary | |
---|---|
protected static int |
ARR_SIZE
|
protected static int |
COMP_LEN
|
static int |
DEFAULT_MAX_DISTANCE
|
Constructor Summary | |
---|---|
SpellChecker()
|
Method Summary | |
---|---|
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_MAX_DISTANCE
protected static final int COMP_LEN
protected static final int ARR_SIZE
Constructor Detail |
---|
public SpellChecker()
Method Detail |
---|
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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |