from https://en.wikipedia.org/wiki/Levenshtein_distance "It is always at least the difference of the sizes of the two strings." "It is at most the length of the longer string."
(String s, String t)
| 111 | * "It is at most the length of the longer string." |
| 112 | */ |
| 113 | public static float normalizedLevenshteinDistance(String s, String t) { |
| 114 | float d = levenshteinDistance(s, t); |
| 115 | int max = Math.max(s.length(), t.length()); |
| 116 | return d / (float)max; |
| 117 | } |
| 118 | |
| 119 | public static float levenshteinDistance(String s, String t) { |
| 120 | // degenerate cases |
no test coverage detected