@Immutable public class Levenshtein extends Object implements MetricStringDistance
| Constructor and Description |
|---|
Levenshtein() |
| Modifier and Type | Method and Description |
|---|---|
double |
distance(String s1,
String s2)
Equivalent to distance(s1, s2, Integer.MAX_VALUE).
|
double |
distance(String s1,
String s2,
int limit)
The Levenshtein distance, or edit distance, between two words is the
minimum number of single-character edits (insertions, deletions or
substitutions) required to change one word into the other.
|
public final double distance(String s1, String s2)
distance in interface MetricStringDistancedistance in interface StringDistancepublic final double distance(String s1, String s2, int limit)
s1 - The first string to compare.s2 - The second string to compare.limit - The maximum result to compute before stopping. This
means that the calculation can terminate early if you
only care about strings with a certain similarity.
Set this to Integer.MAX_VALUE if you want to run the
calculation to completion in every case.NullPointerException - if s1 or s2 is null.Copyright © 2019. All rights reserved.