public class Levenshtein extends Object implements StringMetric, StringDistance
Insert/delete and substitute operations can be weighted. When the cost for substitution is zero Levenshtein does not satisfy the coincidence property.
This class is immutable and thread-safe.
| Constructor and Description |
|---|
Levenshtein()
Constructs a new Levenshtein metric.
|
Levenshtein(float insertDelete,
float substitute)
Constructs a new weighted Levenshtein metric.
|
| Modifier and Type | Method and Description |
|---|---|
float |
compare(String a,
String b)
Measures the similarity between strings a and b.
|
float |
distance(String s,
String t)
Measures the distance between string a and b.
|
String |
toString() |
public Levenshtein(float insertDelete,
float substitute)
insertDelete - positive non-zero cost of an insert or deletion operationsubstitute - positive cost of a substitute operationpublic Levenshtein()
public float compare(String a, String b)
StringMetriccompare in interface Metric<String>compare in interface StringMetrica - string a to compareb - string b to comparepublic float distance(String s, String t)
StringDistance0.0 indicates that a and
b are similar.distance in interface Distance<String>distance in interface StringDistances - string a to comparet - string b to compareCopyright © 2014–2018. All rights reserved.