This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push:
new 61ec6fd6 Removed unreachable threshold verification code from
Levenshtein algorithm implementation classes (#730)
61ec6fd6 is described below
commit 61ec6fd6ec37c73e576d8af84679421a2701964c
Author: Michael Hausegger <[email protected]>
AuthorDate: Mon Dec 1 20:09:19 2025 +0100
Removed unreachable threshold verification code from Levenshtein algorithm
implementation classes (#730)
Co-authored-by: TheRealHaui <[email protected]>
---
.../apache/commons/text/similarity/DamerauLevenshteinDistance.java | 4 ----
.../apache/commons/text/similarity/LevenshteinDetailedDistance.java | 4 +---
.../java/org/apache/commons/text/similarity/LevenshteinDistance.java | 3 ---
3 files changed, 1 insertion(+), 10 deletions(-)
diff --git
a/src/main/java/org/apache/commons/text/similarity/DamerauLevenshteinDistance.java
b/src/main/java/org/apache/commons/text/similarity/DamerauLevenshteinDistance.java
index 0aa39acc..4e0b9c65 100644
---
a/src/main/java/org/apache/commons/text/similarity/DamerauLevenshteinDistance.java
+++
b/src/main/java/org/apache/commons/text/similarity/DamerauLevenshteinDistance.java
@@ -54,10 +54,6 @@ public class DamerauLevenshteinDistance implements
EditDistance<Integer> {
throw new IllegalArgumentException("Left/right inputs must not be
null");
}
- if (threshold < 0) {
- throw new IllegalArgumentException("Threshold can not be
negative");
- }
-
// Implementation based on
https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance#Optimal_string_alignment_distance
int leftLength = left.length();
diff --git
a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
index d4148de4..ac7b4018 100644
---
a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
+++
b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
@@ -159,9 +159,7 @@ public class LevenshteinDetailedDistance implements
EditDistance<LevenshteinResu
if (left == null || right == null) {
throw new IllegalArgumentException("CharSequences must not be
null");
}
- if (threshold < 0) {
- throw new IllegalArgumentException("Threshold must not be
negative");
- }
+
/*
* This implementation only computes the distance if it's less than or
equal to the threshold value, returning -1 if it's greater. The advantage is
* performance: unbounded distance is O(nm), but a bound of k allows
us to reduce it to O(km) time by only computing a diagonal stripe of width 2k +
1
diff --git
a/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
b/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
index cb2e2729..8ab60eee 100644
--- a/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
@@ -81,9 +81,6 @@ public class LevenshteinDistance implements
EditDistance<Integer> {
if (left == null || right == null) {
throw new IllegalArgumentException("CharSequences must not be
null");
}
- if (threshold < 0) {
- throw new IllegalArgumentException("Threshold must not be
negative");
- }
/*
* This implementation only computes the distance if it's less than or
equal to the threshold value, returning -1 if it's greater. The advantage is