public final class LongestCommonSubsequence extends Object implements StringMetric, StringDistance
similarity(a,b) = ∣lcs(a,b)∣ / max{∣a∣, ∣b∣}
distance(a,b) = ∣a∣ + ∣b∣ - 2 * ∣lcs(a,b)∣
This class is immutable and thread-safe.
| Constructor and Description |
|---|
LongestCommonSubsequence() |
| Modifier and Type | Method and Description |
|---|---|
float |
compare(String a,
String b)
Measures the similarity between strings a and b.
|
float |
distance(String a,
String b)
Measures the distance between string a and b.
|
String |
toString() |
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 a, String b)
StringDistance0.0 indicates that a and
b are similar.distance in interface Distance<String>distance in interface StringDistancea - string a to compareb - string b to compareCopyright © 2014–2016. All rights reserved.