|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.folt.similarity.LevenshteinSimilarity
public class LevenshteinSimilarity
Class computes the Levenshtein distance and similarity. The main function to be used is
int levenshteinSimilarity(String sKey, String sPattern).
It returns a % value where 100 (%) means identical strings.
Code is partially based on merriampark.
| Constructor Summary | |
|---|---|
LevenshteinSimilarity()
|
|
| Method Summary | |
|---|---|
static boolean |
bCharValueDifference(java.lang.String source,
java.lang.String match,
int percent)
bCharValueDifference returns true if the character sum difference between the two strings is > then percent given. |
static int |
getLevenshteinDistance(java.lang.String string1,
java.lang.String string2)
getLevenshteinDistance computes the Levenshtein distance. |
static int |
getLevenshteinDistance(java.lang.String string1,
java.lang.String string2,
int minPercent)
getLevenshteinDistance computes the Levenshtein distance. |
static int |
levenshteinSimilarity(java.lang.String compareString1,
java.lang.String compareString2)
levenSimilarity computes the Levenshtein similarity of two strings |
static int |
levenshteinSimilarity(java.lang.String compareString1,
java.lang.String compareString2,
int minPercent)
levenSimilarity computes the Levenshtein similarity of two strings The similarity in % is computed by using: percent = 100 - (dlw * 100) / maxlwlm; where dlw is Levenshtein edit distance and maxlwlm the maximum of the length of the two strings |
static int |
levenshteinWordBasedSimilarity(java.lang.String compareString1,
java.lang.String compareString2,
int minPercent)
levenshteinWordBasedSimilarity computes the Levenshtein similarity of two strings on a word basis. |
static void |
main(java.lang.String[] args)
Function LevenTest Description test function Parameter Type Comment Returns print test Annotation: |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LevenshteinSimilarity()
| Method Detail |
|---|
public static boolean bCharValueDifference(java.lang.String source,
java.lang.String match,
int percent)
source - string 1match - string 2percent - the difference between the two strings
public static int getLevenshteinDistance(java.lang.String string1,
java.lang.String string2)
string1 - String 1string2 - String
public static int getLevenshteinDistance(java.lang.String string1,
java.lang.String string2,
int minPercent)
string1 - String 1string2 - StringminPercent - minimul percentage to be used 100% = Strings have to be identical, -1 ignore this parameter
public static int levenshteinSimilarity(java.lang.String compareString1,
java.lang.String compareString2)
compareString1 - String 1compareString2 - String 2
public static int levenshteinSimilarity(java.lang.String compareString1,
java.lang.String compareString2,
int minPercent)
percent = 100 - (dlw * 100) / maxlwlm;where dlw is Levenshtein edit distance and maxlwlm the maximum of the length of the two strings
compareString1 - String 1compareString2 - String 2minPercent - the minimum percentage to be used; can be used to optimize the similarity computations
public static int levenshteinWordBasedSimilarity(java.lang.String compareString1,
java.lang.String compareString2,
int minPercent)
compareString1 - String 1compareString2 - String 2minPercent - the minimum percentage to be used; can be used to optimize the similarity computations
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||