garydgregory commented on code in PR #737:
URL: https://github.com/apache/commons-text/pull/737#discussion_r2936650826


##########
src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java:
##########
@@ -294,48 +397,90 @@ public LevenshteinDistance() {
     }
 
     /**
-     * Constructs a new instance. If the threshold is not null, distance 
calculations will be limited to a maximum length. If the threshold is null, the
-     * unlimited version of the algorithm will be used.
+     * Constructs a new instance with the given threshold and all operation 
costs set to 1.
      *
-     * @param threshold If this is null then distances calculations will not 
be limited. This may not be negative.
+     * <p>
+     * If the threshold is not null, distance calculations will be limited to 
a maximum length. If
+     * the threshold is null, the unlimited version of the algorithm will be 
used.
+     * </p>
+     *
+     * @param threshold If this is null then distances calculations will not 
be limited.
+     *                  This may not be negative.
      */
     public LevenshteinDistance(final Integer threshold) {
+        this(threshold, DEFAULT_INSERT_COST, DEFAULT_DELETE_COST, 
DEFAULT_REPLACE_COST);
+    }
+
+    /**
+     * Constructs a new instance with the given threshold and custom operation 
costs.
+     *
+     * <p>
+     * If the threshold is not null, distance calculations will be limited to 
a maximum value.
+     * If the threshold is null, the unlimited version of the algorithm will 
be used.
+     * </p>
+     *
+     * <p>
+     * All cost parameters must be non-negative integers. Passing 0 for a cost 
makes that
+     * operation free; passing values greater than 1 makes it more expensive 
relative to
+     * the other operations.
+     * </p>
+     *
+     * @param threshold   If this is null then distance calculations will not 
be limited.
+     *                    This may not be negative.
+     * @param insertCost  the cost of inserting a character, must not be 
negative.
+     * @param deleteCost  the cost of deleting a character, must not be 
negative.
+     * @param replaceCost the cost of replacing (substituting) a character, 
must not be negative.
+     * @throws IllegalArgumentException if threshold is negative, or any cost 
is negative.
+     * @since 1.13.0
+     */
+    public LevenshteinDistance(final Integer threshold, final int insertCost, 
final int deleteCost,

Review Comment:
   Use a builder instead, this will avoid constructor inflation and 
deprecations in the future. You should end upt with a private constructor that 
takes the Builder as its input.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to