public class DamerauLevenshtein extends Object implements StringMetric, StringDistance
Insert/delete, substitute and transpose operations can be weighted. When the cost for substitution and/or transposition are zero Damerau-Levenshtein does not satisfy the coincidence property.
This class is immutable and thread-safe.
Constructor and Description |
---|
DamerauLevenshtein()
Constructs a new Damerau-Levenshtein metric.
|
DamerauLevenshtein(float insertDelete,
float substitute,
float transpose)
Constructs a new weighted Damerau-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 DamerauLevenshtein()
public DamerauLevenshtein(float insertDelete, float substitute, float transpose)
insertDelete
- positive non-zero cost of an insert or deletion operationsubstitute
- positive cost of a substitute operationtranspose
- positive cost of a transpose operationpublic float compare(String a, String b)
StringMetric
compare
in interface Metric<String>
compare
in interface StringMetric
a
- string a to compareb
- string b to comparepublic float distance(String s, String t)
StringDistance
0.0
indicates that a
and
b
are similar.distance
in interface Distance<String>
distance
in interface StringDistance
s
- string a to comparet
- string b to compareCopyright © 2014–2018. All rights reserved.