Skip to content

Commit 4dec5ab

Browse files
committed
deprecated double-cost constructor
1 parent b1780fb commit 4dec5ab

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/main/java/org/cicirello/sequences/distance/EditDistance.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* JavaPermutationTools: A Java library for computation on permutations and sequences
3-
* Copyright 2005-2022 Vincent A. Cicirello, <https://www.cicirello.org/>.
3+
* Copyright 2005-2023 Vincent A. Cicirello, <https://www.cicirello.org/>.
44
*
55
* This file is part of JavaPermutationTools (https://jpt.cicirello.org/).
66
*
@@ -29,17 +29,13 @@
2929
*
3030
* <p>Edit distance is the minimum cost to transform one string (or sequence) into the other, which
3131
* is the sum of the costs of the edit operations necessary to do so. This edit distance considers 3
32-
* edit operations: Inserts which insert a new element into the sequence, Deletes which remove an
32+
* edit operations: Inserts which inserts a new element into the sequence, Deletes which removes an
3333
* element from the sequence, and Changes which replace an element with a different element.
3434
*
35-
* <p>The edit distance is parameterized by costs for the edit operations. We provide two
36-
* constructors which enable you to specify 3 costs, 1 for each type of edit operation. One of the
37-
* constructors expects integer costs, and the other double valued costs. If you specify costs as
38-
* integers, then all of the distance and distancef methods from the {@link
39-
* org.cicirello.sequences.distance.SequenceDistanceMeasurer SequenceDistanceMeasurer} and {@link
40-
* org.cicirello.sequences.distance.SequenceDistanceMeasurerDouble SequenceDistanceMeasurerDouble}
41-
* interfaces are available. If costs are specified as doubles, then only the distancef methods will
42-
* function, while the distance methods will throw exceptions.
35+
* <p>The edit distance is parameterized by costs for the edit operations. The class provides a
36+
* constructor which enables you to specify 3 costs as ints, 1 for each type of edit operation. If
37+
* your application requires non-integer costs, then use the {@link EditDistanceDouble} class which
38+
* defines the costs as doubles, but is otherwise an implementation of the same algorithm.
4339
*
4440
* <p>This class supports computing EditDistance for Java String objects or arrays of any of the
4541
* primitive types, or arrays of objects. It makes no assumptions about the contents of the Strings
@@ -80,7 +76,9 @@ public class EditDistance extends EditDistanceDouble implements SequenceDistance
8076
* @param deleteCost Cost of an deletion operation. Must be non-negative.
8177
* @param changeCost Cost of an change operation. Must be non-negative.
8278
* @throws IllegalArgumentException if any of the costs are negative.
79+
* @deprecated For double-valued costs, use the {@link EditDistanceDouble} class instead.
8380
*/
81+
@Deprecated
8482
public EditDistance(double insertCost, double deleteCost, double changeCost) {
8583
super(insertCost, deleteCost, changeCost);
8684
if (isIntAsDouble(insertCost) && isIntAsDouble(deleteCost) && isIntAsDouble(changeCost)) {
@@ -95,8 +93,7 @@ public EditDistance(double insertCost, double deleteCost, double changeCost) {
9593
}
9694

9795
/**
98-
* Constructs an edit distance measure with the specified edit operation costs. With integer
99-
* costs, all of the distance and distancef methods are available.
96+
* Constructs an edit distance measure with the specified edit operation costs.
10097
*
10198
* @param insertCost Cost of an insertion operation. Must be non-negative.
10299
* @param deleteCost Cost of an deletion operation. Must be non-negative.

src/test/java/org/cicirello/sequences/distance/EditDistanceTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2022 Vincent A. Cicirello, <https://www.cicirello.org/>.
2+
* Copyright 2018-2023 Vincent A. Cicirello, <https://www.cicirello.org/>.
33
*
44
* This file is part of JavaPermutationTools (https://jpt.cicirello.org/).
55
*
@@ -30,6 +30,7 @@
3030
public class EditDistanceTests extends InternalTestHelpersSequenceDistance {
3131

3232
@Test
33+
@SuppressWarnings("deprecation")
3334
public void testEditDistanceExceptions() {
3435
final EditDistance d = new EditDistance(1.5, 1.5, 1.5);
3536
UnsupportedOperationException thrown =
@@ -118,6 +119,7 @@ public void testEditObjectSequences() {
118119
}
119120

120121
@Test
122+
@SuppressWarnings("deprecation")
121123
public void testIdentical() {
122124
EditDistance d = new EditDistance(1, 2, 10);
123125
identicalSequences(d);
@@ -145,6 +147,7 @@ public void testIdentical() {
145147
}
146148

147149
@Test
150+
@SuppressWarnings("deprecation")
148151
public void testEditDistance() {
149152
int cost_i = 1;
150153
int cost_d = 1;

0 commit comments

Comments
 (0)