You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/07/20 14:02:55 UTC

(commons-text) branch master updated (3a9488e4 -> 5fea6e21)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git


    from 3a9488e4 Fix Javadoc on Java 8
     new 3d100309 Javadoc
     new 4d585ce9 Javadoc
     new a43c1378 Javadoc
     new 0f08e877 Javadoc
     new 38a7ae8d Javadoc
     new 90eb6293 Javadoc
     new a28b9fa3 Javadoc
     new bd008ff5 Javadoc
     new 4f9ac340 Javadoc
     new 1d7b5cae Javadoc
     new a1f3288a Javadoc
     new 74e54eec Javadoc
     new c819ed70 Javadoc
     new 2afc2363 Javadoc
     new 2f50c4f4 Javadoc
     new 5fea6e21 Javadoc

The 16 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/text/similarity/CosineSimilarity.java  |  20 +-
 .../commons/text/similarity/EditDistanceFrom.java  |   8 +-
 .../apache/commons/text/similarity/FuzzyScore.java |  18 +-
 .../text/similarity/IntersectionResult.java        |   8 +-
 .../text/similarity/IntersectionSimilarity.java    |  40 +--
 .../commons/text/similarity/JaccardDistance.java   |   4 +-
 .../commons/text/similarity/JaccardSimilarity.java |   4 +-
 .../text/similarity/JaroWinklerDistance.java       |   2 +-
 .../similarity/LevenshteinDetailedDistance.java    | 275 +++++++++------------
 .../text/similarity/LevenshteinDistance.java       |  24 +-
 .../text/similarity/LevenshteinResults.java        |  14 +-
 .../text/similarity/LongestCommonSubsequence.java  |  38 +--
 .../LongestCommonSubsequenceDistance.java          |  15 +-
 .../commons/text/similarity/RegexTokenizer.java    |   2 +-
 .../text/similarity/SimilarityScoreFrom.java       |   8 +-
 15 files changed, 211 insertions(+), 269 deletions(-)


(commons-text) 03/16: Javadoc

Posted by gg...@apache.org.
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

commit a43c1378a6a58b6d8ed9a8b1e0de9db9e890a3ee
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:00:44 2025 -0400

    Javadoc
---
 .../text/similarity/LongestCommonSubsequenceDistance.java | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequenceDistance.java b/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequenceDistance.java
index f6ce1e53..ed33437a 100644
--- a/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequenceDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequenceDistance.java
@@ -44,15 +44,14 @@ public class LongestCommonSubsequenceDistance implements EditDistance<Integer> {
     }
 
     /**
-     * Calculates an edit distance between two {@code CharSequence}'s {@code left} and
-     * {@code right} as: {@code left.length() + right.length() - 2 * LCS(left, right)}, where
-     * {@code LCS} is given in {@link LongestCommonSubsequence#apply(CharSequence, CharSequence)}.
+     * Calculates an edit distance between two {@code CharSequence}'s {@code left} and {@code right} as:
+     * {@code left.length() + right.length() - 2 * LCS(left, right)}, where {@code LCS} is given in
+     * {@link LongestCommonSubsequence#apply(CharSequence, CharSequence)}.
      *
-     * @param left first character sequence
-     * @param right second character sequence
-     * @return distance
-     * @throws IllegalArgumentException
-     *             if either String input {@code null}
+     * @param left  first character sequence.
+     * @param right second character sequence.
+     * @return distance.
+     * @throws IllegalArgumentException if either String input {@code null}.
      */
     @Override
     public Integer apply(final CharSequence left, final CharSequence right) {


(commons-text) 04/16: Javadoc

Posted by gg...@apache.org.
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

commit 0f08e877a9fa83e5a3de3ecfcf1ddbe45df7e5a5
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:00:54 2025 -0400

    Javadoc
---
 .../text/similarity/LongestCommonSubsequence.java  | 38 ++++++++++++----------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java b/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java
index 86288d48..04ec48e9 100644
--- a/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java
+++ b/src/main/java/org/apache/commons/text/similarity/LongestCommonSubsequence.java
@@ -65,7 +65,7 @@ public class LongestCommonSubsequence implements SimilarityScore<Integer> {
      *
      * @param left first input sequence.
      * @param right second input sequence.
-     * @return last row of the dynamic-programming (DP) table for calculating the LCS of {@code left} and {@code right}
+     * @return last row of the dynamic-programming (DP) table for calculating the LCS of {@code left} and {@code right}.
      * @since 1.10.0
      */
     private static int[] algorithmB(final CharSequence left, final CharSequence right) {
@@ -104,7 +104,7 @@ public class LongestCommonSubsequence implements SimilarityScore<Integer> {
      *
      * @param left first input sequence.
      * @param right second input sequence.
-     * @return the LCS of {@code left} and {@code right}
+     * @return the LCS of {@code left} and {@code right}.
      * @since 1.10.0
      */
     private static String algorithmC(final CharSequence left, final CharSequence right) {
@@ -144,7 +144,9 @@ public class LongestCommonSubsequence implements SimilarityScore<Integer> {
         return out.toString();
     }
 
-    // An auxiliary method for CharSequence reversal
+    /*
+     *  A method for CharSequence reversal.
+     */
     private static String reverse(final CharSequence s) {
         return new StringBuilder(s).reverse().toString();
     }
@@ -170,10 +172,10 @@ public class LongestCommonSubsequence implements SimilarityScore<Integer> {
      * An evaluation using JMH revealed that this method is almost two times faster than its previous version.
      * </p>
      *
-     * @param left first character sequence
-     * @param right second character sequence
-     * @return length of the longest common subsequence of {@code left} and {@code right}
-     * @throws IllegalArgumentException if either String input {@code null}
+     * @param left first character sequence.
+     * @param right second character sequence.
+     * @return length of the longest common subsequence of {@code left} and {@code right}.
+     * @throws IllegalArgumentException if either String input {@code null}.
      */
     @Override
     public Integer apply(final CharSequence left, final CharSequence right) {
@@ -211,10 +213,10 @@ public class LongestCommonSubsequence implements SimilarityScore<Integer> {
      * elements.
      * </p>
      *
-     * @param left first character sequence
-     * @param right second character sequence
-     * @return the longest common subsequence found
-     * @throws IllegalArgumentException if either String input {@code null}
+     * @param left first character sequence.
+     * @param right second character sequence.
+     * @return the longest common subsequence found.
+     * @throws IllegalArgumentException if either String input {@code null}.
      * @deprecated Deprecated as of 1.2 due to a typo in the method name.
      * Use {@link #longestCommonSubsequence(CharSequence, CharSequence)} instead.
      * This method will be removed in 2.0.
@@ -247,10 +249,10 @@ public class LongestCommonSubsequence implements SimilarityScore<Integer> {
      * elements.
      * </p>
      *
-     * @param left first character sequence
-     * @param right second character sequence
-     * @return the longest common subsequence found
-     * @throws IllegalArgumentException if either String input {@code null}
+     * @param left first character sequence.
+     * @param right second character sequence.
+     * @return the longest common subsequence found.
+     * @throws IllegalArgumentException if either String input {@code null}.
      * @since 1.2
      */
     public CharSequence longestCommonSubsequence(final CharSequence left, final CharSequence right) {
@@ -279,9 +281,9 @@ public class LongestCommonSubsequence implements SimilarityScore<Integer> {
      * dynamic programming portion of the algorithm, and is the reason for the runtime complexity being
      * O(m*n), where m=left.length() and n=right.length().
      *
-     * @param left first character sequence
-     * @param right second character sequence
-     * @return lcsLengthArray
+     * @param left first character sequence.
+     * @param right second character sequence.
+     * @return longest common substring length array.
      * @deprecated Deprecated as of 1.10. A more efficient implementation for calculating LCS is now available.
      * Use {@link #longestCommonSubsequence(CharSequence, CharSequence)} instead to directly calculate the LCS.
      * This method will be removed in 2.0.


(commons-text) 07/16: Javadoc

Posted by gg...@apache.org.
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

commit a28b9fa39bf83b6e1499493210eb8288a35dba1b
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:03 2025 -0400

    Javadoc
---
 .../similarity/LevenshteinDetailedDistance.java    | 275 +++++++++------------
 1 file changed, 110 insertions(+), 165 deletions(-)

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 0e241efd..78505991 100644
--- a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.commons.text.similarity;
 
 import java.util.Arrays;
@@ -22,9 +23,8 @@ import java.util.Arrays;
  * An algorithm for measuring the difference between two character sequences.
  *
  * <p>
- * This is the number of changes needed to change one sequence into another,
- * where each change is a single character modification (deletion, insertion
- * or substitution).
+ * This is the number of changes needed to change one sequence into another, where each change is a single character modification (deletion, insertion or
+ * substitution).
  * </p>
  *
  * @since 1.0
@@ -37,39 +37,29 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
     private static final LevenshteinDetailedDistance INSTANCE = new LevenshteinDetailedDistance();
 
     /**
-     * Finds count for each of the three [insert, delete, substitute] operations
-     * needed. This is based on the matrix formed based on the two character
-     * sequence.
+     * Finds count for each of the three [insert, delete, substitute] operations needed. This is based on the matrix formed based on the two character sequence.
      *
-     * @param <E> The type of similarity score unit.
-     * @param left character sequence which need to be converted from
-     * @param right character sequence which need to be converted to
-     * @param matrix two dimensional array containing
-     * @param swapped tells whether the value for left character sequence and right
-     *            character sequence were swapped to save memory
-     * @return result object containing the count of insert, delete and substitute and total count needed
+     * @param <E>     The type of similarity score unit.
+     * @param left    character sequence which need to be converted from.
+     * @param right   character sequence which need to be converted to.
+     * @param matrix  two dimensional array containing.
+     * @param swapped tells whether the value for left character sequence and right character sequence were swapped to save memory.
+     * @return result object containing the count of insert, delete and substitute and total count needed.
      */
-    private static <E> LevenshteinResults findDetailedResults(final SimilarityInput<E> left,
-                                                          final SimilarityInput<E> right,
-                                                          final int[][] matrix,
-                                                          final boolean swapped) {
-
+    private static <E> LevenshteinResults findDetailedResults(final SimilarityInput<E> left, final SimilarityInput<E> right, final int[][] matrix,
+            final boolean swapped) {
         int delCount = 0;
         int addCount = 0;
         int subCount = 0;
-
         int rowIndex = right.length();
         int columnIndex = left.length();
-
         int dataAtLeft = 0;
         int dataAtTop = 0;
         int dataAtDiagonal = 0;
         int data = 0;
         boolean deleted = false;
         boolean added = false;
-
         while (rowIndex >= 0 && columnIndex >= 0) {
-
             if (columnIndex == 0) {
                 dataAtLeft = -1;
             } else {
@@ -89,7 +79,6 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
                 break;
             }
             data = matrix[rowIndex][columnIndex];
-
             // case in which the character at left and right are the same,
             // in this case none of the counters will be incremented.
             if (columnIndex > 0 && rowIndex > 0 && left.at(columnIndex - 1).equals(right.at(rowIndex - 1))) {
@@ -97,12 +86,10 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
                 rowIndex--;
                 continue;
             }
-
             // handling insert and delete cases.
             deleted = false;
             added = false;
-            if (data - 1 == dataAtLeft && data <= dataAtDiagonal && data <= dataAtTop
-                    || dataAtDiagonal == -1 && dataAtTop == -1) { // NOPMD
+            if (data - 1 == dataAtLeft && data <= dataAtDiagonal && data <= dataAtTop || dataAtDiagonal == -1 && dataAtTop == -1) { // NOPMD
                 columnIndex--;
                 if (swapped) {
                     addCount++;
@@ -111,8 +98,7 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
                     delCount++;
                     deleted = true;
                 }
-            } else if (data - 1 == dataAtTop && data <= dataAtDiagonal && data <= dataAtLeft
-                    || dataAtDiagonal == -1 && dataAtLeft == -1) { // NOPMD
+            } else if (data - 1 == dataAtTop && data <= dataAtDiagonal && data <= dataAtLeft || dataAtDiagonal == -1 && dataAtLeft == -1) { // NOPMD
                 rowIndex--;
                 if (swapped) {
                     delCount++;
@@ -122,7 +108,6 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
                     added = true;
                 }
             }
-
             // substituted case
             if (!added && !deleted) {
                 subCount++;
@@ -143,15 +128,11 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
     }
 
     /**
-     * Finds the Levenshtein distance between two CharSequences if it's less than or
-     * equal to a given threshold.
+     * Finds the Levenshtein distance between two CharSequences if it's less than or equal to a given threshold.
      *
      * <p>
-     * This implementation follows from Algorithms on Strings, Trees and
-     * Sequences by Dan Gusfield and Chas Emerick's implementation of the
-     * Levenshtein distance algorithm from <a
-     * href="http://www.merriampark.com/ld.htm"
-     * >http://www.merriampark.com/ld.htm</a>
+     * This implementation follows from Algorithms on Strings, Trees and Sequences by Dan Gusfield and Chas Emerick's implementation of the Levenshtein distance
+     * algorithm from <a href="http://www.merriampark.com/ld.htm" >http://www.merriampark.com/ld.htm</a>
      * </p>
      *
      * <pre>
@@ -168,73 +149,46 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
      * limitedCompare("hippo", "elephant", 6) = -1
      * </pre>
      *
-     * @param <E> The type of similarity score unit.
-     * @param left the first CharSequence, must not be null
-     * @param right the second CharSequence, must not be null
-     * @param threshold the target threshold, must not be negative
-     * @return result distance, or -1
+     * @param <E>       The type of similarity score unit.
+     * @param left      the first CharSequence, must not be null.
+     * @param right     the second CharSequence, must not be null.
+     * @param threshold the target threshold, must not be negative.
+     * @return result distance, or -1.
      */
-    private static <E> LevenshteinResults limitedCompare(SimilarityInput<E> left, SimilarityInput<E> right, final int threshold) { //NOPMD
+    private static <E> LevenshteinResults limitedCompare(SimilarityInput<E> left, SimilarityInput<E> right, final int threshold) { // NOPMD
         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 of the cost table. It is also possible to use
-         * this to compute the unbounded Levenshtein distance by starting the
-         * threshold at 1 and doubling each time until the distance is found;
-         * this is O(dm), where d is the distance.
+         * 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
+         * of the cost table. It is also possible to use this to compute the unbounded Levenshtein distance by starting the threshold at 1 and doubling each
+         * time until the distance is found; this is O(dm), where d is the distance.
          *
-         * One subtlety comes from needing to ignore entries on the border of
-         * our stripe eg. p[] = |#|#|#|* d[] = *|#|#|#| We must ignore the entry
-         * to the left of the leftmost member We must ignore the entry above the
-         * rightmost member
+         * One subtlety comes from needing to ignore entries on the border of our stripe eg. p[] = |#|#|#|* d[] = *|#|#|#| We must ignore the entry to the left
+         * of the leftmost member We must ignore the entry above the rightmost member
          *
-         * Another subtlety comes from our stripe running off the matrix if the
-         * strings aren't of the same size. Since string s is always swapped to
-         * be the shorter of the two, the stripe will always run off to the
-         * upper right instead of the lower left of the matrix.
+         * Another subtlety comes from our stripe running off the matrix if the strings aren't of the same size. Since string s is always swapped to be the
+         * shorter of the two, the stripe will always run off to the upper right instead of the lower left of the matrix.
          *
-         * As a concrete example, suppose s is of length 5, t is of length 7,
-         * and our threshold is 1. In this case we're going to walk a stripe of
-         * length 3. The matrix would look like so:
+         * As a concrete example, suppose s is of length 5, t is of length 7, and our threshold is 1. In this case we're going to walk a stripe of length 3. The
+         * matrix would look like so:
          *
-         * <pre>
-         *    1 2 3 4 5
-         * 1 |#|#| | | |
-         * 2 |#|#|#| | |
-         * 3 | |#|#|#| |
-         * 4 | | |#|#|#|
-         * 5 | | | |#|#|
-         * 6 | | | | |#|
-         * 7 | | | | | |
-         * </pre>
+         * <pre> 1 2 3 4 5 1 |#|#| | | | 2 |#|#|#| | | 3 | |#|#|#| | 4 | | |#|#|#| 5 | | | |#|#| 6 | | | | |#| 7 | | | | | | </pre>
          *
-         * Note how the stripe leads off the table as there is no possible way
-         * to turn a string of length 5 into one of length 7 in edit distance of
-         * 1.
+         * Note how the stripe leads off the table as there is no possible way to turn a string of length 5 into one of length 7 in edit distance of 1.
          *
-         * Additionally, this implementation decreases memory usage by using two
-         * single-dimensional arrays and swapping them back and forth instead of
-         * allocating an entire n by m matrix. This requires a few minor
-         * changes, such as immediately returning when it's detected that the
-         * stripe has run off the matrix and initially filling the arrays with
-         * large values so that entries we don't compute are ignored.
+         * Additionally, this implementation decreases memory usage by using two single-dimensional arrays and swapping them back and forth instead of
+         * allocating an entire n by m matrix. This requires a few minor changes, such as immediately returning when it's detected that the stripe has run off
+         * the matrix and initially filling the arrays with large values so that entries we don't compute are ignored.
          *
-         * See Algorithms on Strings, Trees and Sequences by Dan Gusfield for
-         * some discussion.
+         * See Algorithms on Strings, Trees and Sequences by Dan Gusfield for some discussion.
          */
-
         int n = left.length(); // length of left
         int m = right.length(); // length of right
-
         // if one string is empty, the edit distance is necessarily the length of the other
         if (n == 0) {
             return m <= threshold ? new LevenshteinResults(m, m, 0, 0) : new LevenshteinResults(-1, 0, 0, 0);
@@ -242,7 +196,6 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
         if (m == 0) {
             return n <= threshold ? new LevenshteinResults(n, 0, n, 0) : new LevenshteinResults(-1, 0, 0, 0);
         }
-
         boolean swapped = false;
         if (n > m) {
             // swap the two strings to consume less memory
@@ -253,20 +206,17 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
             m = right.length();
             swapped = true;
         }
-
         int[] p = new int[n + 1]; // 'previous' cost array, horizontally
         int[] d = new int[n + 1]; // cost array, horizontally
         int[] tempD; // placeholder to assist in swapping p and d
         final int[][] matrix = new int[m + 1][n + 1];
-
-        //filling the first row and first column values in the matrix
+        // filling the first row and first column values in the matrix
         for (int index = 0; index <= n; index++) {
             matrix[0][index] = index;
         }
         for (int index = 0; index <= m; index++) {
             matrix[index][0] = index;
         }
-
         // fill in starting table values
         final int boundary = Math.min(n, threshold) + 1;
         for (int i = 0; i < boundary; i++) {
@@ -276,27 +226,21 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
         // stripe will be ignored in following loop iterations
         Arrays.fill(p, boundary, p.length, Integer.MAX_VALUE);
         Arrays.fill(d, Integer.MAX_VALUE);
-
         // iterates through t
         for (int j = 1; j <= m; j++) {
             final E rightJ = right.at(j - 1); // jth character of right
             d[0] = j;
-
             // compute stripe indices, constrain to array size
             final int min = Math.max(1, j - threshold);
-            final int max = j > Integer.MAX_VALUE - threshold ? n : Math.min(
-                    n, j + threshold);
-
+            final int max = j > Integer.MAX_VALUE - threshold ? n : Math.min(n, j + threshold);
             // the stripe may lead off of the table if s and t are of different sizes
             if (min > max) {
                 return new LevenshteinResults(-1, 0, 0, 0);
             }
-
             // ignore entry left of leftmost
             if (min > 1) {
                 d[min - 1] = Integer.MAX_VALUE;
             }
-
             // iterates through [min, max] in s
             for (int i = min; i <= max; i++) {
                 if (left.at(i - 1).equals(rightJ)) {
@@ -308,13 +252,11 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
                 }
                 matrix[j][i] = d[i];
             }
-
             // copy current distance counts to 'previous row' distance counts
             tempD = p;
             p = d;
             d = tempD;
         }
-
         // if p[n] is greater than the threshold, there's no guarantee on it being the correct distance
         if (p[n] <= threshold) {
             return findDetailedResults(left, right, matrix, swapped);
@@ -325,15 +267,21 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
     /**
      * Finds the Levenshtein distance between two Strings.
      *
-     * <p>A higher score indicates a greater distance.</p>
+     * <p>
+     * A higher score indicates a greater distance.
+     * </p>
      *
-     * <p>The previous implementation of the Levenshtein distance algorithm
-     * was from <a href="http://www.merriampark.com/ld.htm">http://www.merriampark.com/ld.htm</a></p>
+     * <p>
+     * The previous implementation of the Levenshtein distance algorithm was from
+     * <a href="http://www.merriampark.com/ld.htm">http://www.merriampark.com/ld.htm</a>
+     * </p>
      *
-     * <p>Chas Emerick has written an implementation in Java, which avoids an OutOfMemoryError
-     * which can occur when my Java implementation is used with very large strings.<br>
-     * This implementation of the Levenshtein distance algorithm
-     * is from <a href="http://www.merriampark.com/ldjava.htm">http://www.merriampark.com/ldjava.htm</a></p>
+     * <p>
+     * Chas Emerick has written an implementation in Java, which avoids an OutOfMemoryError which can occur when my Java implementation is used with very large
+     * strings.<br>
+     * This implementation of the Levenshtein distance algorithm is from
+     * <a href="http://www.merriampark.com/ldjava.htm">http://www.merriampark.com/ldjava.htm</a>
+     * </p>
      *
      * <pre>
      * unlimitedCompare(null, *)             = IllegalArgumentException
@@ -349,37 +297,29 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
      * unlimitedCompare("hello", "hallo")    = 1
      * </pre>
      *
-     * @param <E> The type of similarity score unit.
-     * @param left the first CharSequence, must not be null
-     * @param right the second CharSequence, must not be null
-     * @return result distance, or -1
-     * @throws IllegalArgumentException if either CharSequence input is {@code null}
+     * @param <E>   The type of similarity score unit.
+     * @param left  the first CharSequence, must not be null.
+     * @param right the second CharSequence, must not be null.
+     * @return result distance, or -1.
+     * @throws IllegalArgumentException if either CharSequence input is {@code null}.
      */
     private static <E> LevenshteinResults unlimitedCompare(SimilarityInput<E> left, SimilarityInput<E> right) {
         if (left == null || right == null) {
             throw new IllegalArgumentException("CharSequences must not be null");
         }
-
         /*
-           The difference between this impl. and the previous is that, rather
-           than creating and retaining a matrix of size s.length() + 1 by t.length() + 1,
-           we maintain two single-dimensional arrays of length s.length() + 1.  The first, d,
-           is the 'current working' distance array that maintains the newest distance cost
-           counts as we iterate through the characters of String s.  Each time we increment
-           the index of String t we are comparing, d is copied to p, the second int[].  Doing so
-           allows us to retain the previous cost counts as required by the algorithm (taking
-           the minimum of the cost count to the left, up one, and diagonally up and to the left
-           of the current cost count being calculated).  (Note that the arrays aren't really
-           copied anymore, just switched...this is clearly much better than cloning an array
-           or doing a System.arraycopy() each time  through the outer loop.)
-
-           Effectively, the difference between the two implementations is this one does not
-           cause an out of memory condition when calculating the LD over two very large strings.
+         * The difference between this impl. and the previous is that, rather than creating and retaining a matrix of size s.length() + 1 by t.length() + 1, we
+         * maintain two single-dimensional arrays of length s.length() + 1. The first, d, is the 'current working' distance array that maintains the newest
+         * distance cost counts as we iterate through the characters of String s. Each time we increment the index of String t we are comparing, d is copied to
+         * p, the second int[]. Doing so allows us to retain the previous cost counts as required by the algorithm (taking the minimum of the cost count to the
+         * left, up one, and diagonally up and to the left of the current cost count being calculated). (Note that the arrays aren't really copied anymore, just
+         * switched...this is clearly much better than cloning an array or doing a System.arraycopy() each time through the outer loop.)
+         * 
+         * Effectively, the difference between the two implementations is this one does not cause an out of memory condition when calculating the LD over two
+         * very large strings.
          */
-
         int n = left.length(); // length of left
         int m = right.length(); // length of right
-
         if (n == 0) {
             return new LevenshteinResults(m, m, 0, 0);
         }
@@ -396,12 +336,10 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
             m = right.length();
             swapped = true;
         }
-
         int[] p = new int[n + 1]; // 'previous' cost array, horizontally
         int[] d = new int[n + 1]; // cost array, horizontally
-        int[] tempD; //placeholder to assist in swapping p and d
+        int[] tempD; // placeholder to assist in swapping p and d
         final int[][] matrix = new int[m + 1][n + 1];
-
         // filling the first row and first column values in the matrix
         for (int index = 0; index <= n; index++) {
             matrix[0][index] = index;
@@ -409,30 +347,24 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
         for (int index = 0; index <= m; index++) {
             matrix[index][0] = index;
         }
-
         // indexes into strings left and right
         int i; // iterates through left
         int j; // iterates through right
-
         E rightJ; // jth character of right
-
         int cost; // cost
         for (i = 0; i <= n; i++) {
             p[i] = i;
         }
-
         for (j = 1; j <= m; j++) {
             rightJ = right.at(j - 1);
             d[0] = j;
-
             for (i = 1; i <= n; i++) {
                 cost = left.at(i - 1).equals(rightJ) ? 0 : 1;
                 // minimum of cell to the left+1, to the top+1, diagonally left and up +cost
                 d[i] = Math.min(Math.min(d[i - 1] + 1, p[i] + 1), p[i - 1] + cost);
-                //filling the matrix
+                // filling the matrix
                 matrix[j][i] = d[i];
             }
-
             // copy current distance counts to 'previous row' distance counts
             tempD = p;
             p = d;
@@ -448,8 +380,7 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
 
     /**
      * <p>
-     * This returns the default instance that uses a version
-     * of the algorithm that does not use a threshold parameter.
+     * This returns the default instance that uses a version of the algorithm that does not use a threshold parameter.
      * </p>
      *
      * @see LevenshteinDetailedDistance#getDefaultInstance()
@@ -463,7 +394,9 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
     /**
      * If the threshold is not null, distance calculations will be limited to a maximum length.
      *
-     * <p>If the threshold is null, the unlimited version of the algorithm will be used.</p>
+     * <p>
+     * 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.
      */
@@ -477,15 +410,21 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
     /**
      * Computes the Levenshtein distance between two Strings.
      *
-     * <p>A higher score indicates a greater distance.</p>
+     * <p>
+     * A higher score indicates a greater distance.
+     * </p>
      *
-     * <p>The previous implementation of the Levenshtein distance algorithm
-     * was from <a href="http://www.merriampark.com/ld.htm">http://www.merriampark.com/ld.htm</a></p>
+     * <p>
+     * The previous implementation of the Levenshtein distance algorithm was from
+     * <a href="http://www.merriampark.com/ld.htm">http://www.merriampark.com/ld.htm</a>
+     * </p>
      *
-     * <p>Chas Emerick has written an implementation in Java, which avoids an OutOfMemoryError
-     * which can occur when my Java implementation is used with very large strings.<br>
-     * This implementation of the Levenshtein distance algorithm
-     * is from <a href="http://www.merriampark.com/ldjava.htm">http://www.merriampark.com/ldjava.htm</a></p>
+     * <p>
+     * Chas Emerick has written an implementation in Java, which avoids an OutOfMemoryError which can occur when my Java implementation is used with very large
+     * strings.<br>
+     * This implementation of the Levenshtein distance algorithm is from
+     * <a href="http://www.merriampark.com/ldjava.htm">http://www.merriampark.com/ldjava.htm</a>
+     * </p>
      *
      * <pre>
      * distance.apply(null, *)             = IllegalArgumentException
@@ -501,10 +440,10 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
      * distance.apply("hello", "hallo")    = 1
      * </pre>
      *
-     * @param left the first input, must not be null
-     * @param right the second input, must not be null
-     * @return result distance, or -1
-     * @throws IllegalArgumentException if either String input {@code null}
+     * @param left  the first input, must not be null.
+     * @param right the second input, must not be null.
+     * @return result distance, or -1.
+     * @throws IllegalArgumentException if either String input {@code null}.
      */
     @Override
     public LevenshteinResults apply(final CharSequence left, final CharSequence right) {
@@ -514,15 +453,21 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
     /**
      * Computes the Levenshtein distance between two Strings.
      *
-     * <p>A higher score indicates a greater distance.</p>
+     * <p>
+     * A higher score indicates a greater distance.
+     * </p>
      *
-     * <p>The previous implementation of the Levenshtein distance algorithm
-     * was from <a href="http://www.merriampark.com/ld.htm">http://www.merriampark.com/ld.htm</a></p>
+     * <p>
+     * The previous implementation of the Levenshtein distance algorithm was from
+     * <a href="http://www.merriampark.com/ld.htm">http://www.merriampark.com/ld.htm</a>
+     * </p>
      *
-     * <p>Chas Emerick has written an implementation in Java, which avoids an OutOfMemoryError
-     * which can occur when my Java implementation is used with very large strings.<br>
-     * This implementation of the Levenshtein distance algorithm
-     * is from <a href="http://www.merriampark.com/ldjava.htm">http://www.merriampark.com/ldjava.htm</a></p>
+     * <p>
+     * Chas Emerick has written an implementation in Java, which avoids an OutOfMemoryError which can occur when my Java implementation is used with very large
+     * strings.<br>
+     * This implementation of the Levenshtein distance algorithm is from
+     * <a href="http://www.merriampark.com/ldjava.htm">http://www.merriampark.com/ldjava.htm</a>
+     * </p>
      *
      * <pre>
      * distance.apply(null, *)             = IllegalArgumentException
@@ -538,11 +483,11 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
      * distance.apply("hello", "hallo")    = 1
      * </pre>
      *
-     * @param <E> The type of similarity score unit.
-     * @param left the first input, must not be null
-     * @param right the second input, must not be null
-     * @return result distance, or -1
-     * @throws IllegalArgumentException if either String input {@code null}
+     * @param <E>   The type of similarity score unit.
+     * @param left  the first input, must not be null.
+     * @param right the second input, must not be null.
+     * @return result distance, or -1.
+     * @throws IllegalArgumentException if either String input {@code null}.
      * @since 1.13.0
      */
     public <E> LevenshteinResults apply(final SimilarityInput<E> left, final SimilarityInput<E> right) {
@@ -555,7 +500,7 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
     /**
      * Gets the distance threshold.
      *
-     * @return The distance threshold
+     * @return The distance threshold.
      */
     public Integer getThreshold() {
         return threshold;


(commons-text) 05/16: Javadoc

Posted by gg...@apache.org.
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

commit 38a7ae8d751c20e1f4055ebe15a649f003050bcb
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:00:57 2025 -0400

    Javadoc
---
 .../apache/commons/text/similarity/LevenshteinResults.java | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/LevenshteinResults.java b/src/main/java/org/apache/commons/text/similarity/LevenshteinResults.java
index 79601907..37b54779 100644
--- a/src/main/java/org/apache/commons/text/similarity/LevenshteinResults.java
+++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinResults.java
@@ -54,9 +54,9 @@ public class LevenshteinResults {
      * Constructs the results for a detailed Levenshtein distance.
      *
      * @param distance distance between two character sequences.
-     * @param insertCount insert character count
-     * @param deleteCount delete character count
-     * @param substituteCount substitute character count
+     * @param insertCount insert character count.
+     * @param deleteCount delete character count.
+     * @param substituteCount substitute character count.
      */
     public LevenshteinResults(final Integer distance, final Integer insertCount, final Integer deleteCount,
             final Integer substituteCount) {
@@ -83,7 +83,7 @@ public class LevenshteinResults {
     /**
      * Gets the number of character deletion needed to change one character sequence to other.
      *
-     * @return delete character count
+     * @return delete character count.
      */
     public Integer getDeleteCount() {
         return deleteCount;
@@ -92,7 +92,7 @@ public class LevenshteinResults {
     /**
      * Gets the distance between two character sequences.
      *
-     * @return distance between two character sequence
+     * @return distance between two character sequence.
      */
     public Integer getDistance() {
         return distance;
@@ -101,7 +101,7 @@ public class LevenshteinResults {
     /**
      * Gets the number of insertion needed to change one character sequence into another.
      *
-     * @return insert character count
+     * @return insert character count.
      */
     public Integer getInsertCount() {
         return insertCount;
@@ -110,7 +110,7 @@ public class LevenshteinResults {
     /**
      * Gets the number of character substitution needed to change one character sequence into another.
      *
-     * @return substitute character count
+     * @return substitute character count.
      */
     public Integer getSubstituteCount() {
         return substituteCount;


(commons-text) 14/16: Javadoc

Posted by gg...@apache.org.
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

commit 2afc236395968c1bf262f8f3f320bbd20b58da95
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:26 2025 -0400

    Javadoc
---
 .../java/org/apache/commons/text/similarity/EditDistanceFrom.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/EditDistanceFrom.java b/src/main/java/org/apache/commons/text/similarity/EditDistanceFrom.java
index 008ea39c..ef021dcd 100644
--- a/src/main/java/org/apache/commons/text/similarity/EditDistanceFrom.java
+++ b/src/main/java/org/apache/commons/text/similarity/EditDistanceFrom.java
@@ -80,8 +80,8 @@ public class EditDistanceFrom<R> {
      * Compares "left" field against the "right" parameter
      * using the "edit distance" implementation.
      *
-     * @param right the second CharSequence
-     * @return The similarity score between two CharSequences
+     * @param right the second CharSequence.
+     * @return The similarity score between two CharSequences.
      */
     public R apply(final CharSequence right) {
         return editDistance.apply(left, right);
@@ -90,7 +90,7 @@ public class EditDistanceFrom<R> {
     /**
      * Gets the edit distance.
      *
-     * @return The edit distance
+     * @return The edit distance.
      */
     public EditDistance<R> getEditDistance() {
         return editDistance;
@@ -99,7 +99,7 @@ public class EditDistanceFrom<R> {
     /**
      * Gets the left parameter.
      *
-     * @return The left parameter
+     * @return The left parameter.
      */
     public CharSequence getLeft() {
         return left;


(commons-text) 16/16: Javadoc

Posted by gg...@apache.org.
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

commit 5fea6e2183e0832ea332a28228bc1fc773b4c647
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:51 2025 -0400

    Javadoc
---
 .../org/apache/commons/text/similarity/LevenshteinDetailedDistance.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 78505991..f5f80ad1 100644
--- a/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinDetailedDistance.java
@@ -314,7 +314,7 @@ public class LevenshteinDetailedDistance implements EditDistance<LevenshteinResu
          * p, the second int[]. Doing so allows us to retain the previous cost counts as required by the algorithm (taking the minimum of the cost count to the
          * left, up one, and diagonally up and to the left of the current cost count being calculated). (Note that the arrays aren't really copied anymore, just
          * switched...this is clearly much better than cloning an array or doing a System.arraycopy() each time through the outer loop.)
-         * 
+         *
          * Effectively, the difference between the two implementations is this one does not cause an out of memory condition when calculating the LD over two
          * very large strings.
          */


(commons-text) 10/16: Javadoc

Posted by gg...@apache.org.
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

commit 1d7b5caeadeeff3329cce283411876fa92315d25
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:14 2025 -0400

    Javadoc
---
 src/main/java/org/apache/commons/text/similarity/JaccardDistance.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/JaccardDistance.java b/src/main/java/org/apache/commons/text/similarity/JaccardDistance.java
index 51c64f4e..d2042e06 100644
--- a/src/main/java/org/apache/commons/text/similarity/JaccardDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/JaccardDistance.java
@@ -40,7 +40,7 @@ public class JaccardDistance implements EditDistance<Double> {
      *
      * @param left  first input sequence.
      * @param right second input sequence.
-     * @return index
+     * @return The Jaccard distance.
      * @throws IllegalArgumentException if either String input {@code null}.
      */
     @Override
@@ -54,7 +54,7 @@ public class JaccardDistance implements EditDistance<Double> {
      * @param <E>   The type of similarity score unit.
      * @param left  first input sequence.
      * @param right second input sequence.
-     * @return index
+     * @return index.
      * @throws IllegalArgumentException if either String input {@code null}.
      */
     public <E> Double apply(final SimilarityInput<E> left, final SimilarityInput<E> right) {


(commons-text) 12/16: Javadoc

Posted by gg...@apache.org.
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

commit 74e54eece9d5e77fe7a95bb8f498ce4179420995
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:21 2025 -0400

    Javadoc
---
 .../org/apache/commons/text/similarity/IntersectionResult.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/IntersectionResult.java b/src/main/java/org/apache/commons/text/similarity/IntersectionResult.java
index 155a772f..01f4f09a 100644
--- a/src/main/java/org/apache/commons/text/similarity/IntersectionResult.java
+++ b/src/main/java/org/apache/commons/text/similarity/IntersectionResult.java
@@ -49,11 +49,11 @@ public class IntersectionResult {
     /**
      * Constructs the results for an intersection between two sets.
      *
-     * @param sizeA the size of set A ({@code |A|})
-     * @param sizeB the size of set B ({@code |B|})
-     * @param intersection the size of the intersection of A and B ({@code |A &#8745; B|})
+     * @param sizeA the size of set A ({@code |A|}).
+     * @param sizeB the size of set B ({@code |B|}).
+     * @param intersection the size of the intersection of A and B ({@code |A &#8745; B|}).
      * @throws IllegalArgumentException if the sizes are negative or the intersection is greater
-     * than the minimum of the two set sizes
+     * than the minimum of the two set sizes.
      */
     public IntersectionResult(final int sizeA, final int sizeB, final int intersection) {
         if (sizeA < 0) {


(commons-text) 11/16: Javadoc

Posted by gg...@apache.org.
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

commit a1f3288ac72897d511b04734eb82bbae121bf0d2
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:18 2025 -0400

    Javadoc
---
 .../text/similarity/IntersectionSimilarity.java    | 40 +++++++++++-----------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java b/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java
index 71a31a00..370b00a2 100644
--- a/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java
+++ b/src/main/java/org/apache/commons/text/similarity/IntersectionSimilarity.java
@@ -82,7 +82,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe
         /**
          * Adds a new element to the bag, incrementing its count in the underlying map.
          *
-         * @param object the object to add
+         * @param object the object to add.
          */
         private void add(final T object) {
             map.computeIfAbsent(object, k -> new BagCount()).count++;
@@ -91,7 +91,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe
         /**
          * Returns a Set view of the mappings contained in this bag.
          *
-         * @return The Set view
+         * @return The Set view.
          */
         private Set<Entry<T, BagCount>> entrySet() {
             return map.entrySet();
@@ -101,8 +101,8 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe
          * Returns the number of occurrence of the given element in this bag by
          * looking up its count in the underlying map.
          *
-         * @param object the object to search for
-         * @return The number of occurrences of the object, zero if not found
+         * @param object the object to search for.
+         * @return The number of occurrences of the object, zero if not found.
          */
         private int getCount(final Object object) {
             return map.getOrDefault(object, BagCount.ZERO).count;
@@ -111,7 +111,7 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe
         /**
          * Gets the number of unique elements in the bag.
          *
-         * @return The unique element size
+         * @return The unique element size.
          */
         private int uniqueElementSize() {
             return map.size();
@@ -122,10 +122,10 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe
      * Computes the intersection between two sets. This is the count of all the elements
      * that are within both sets.
      *
-     * @param <T> the type of the elements in the set
-     * @param setA the set A
-     * @param setB the set B
-     * @return The intersection
+     * @param <T> the type of the elements in the set.
+     * @param setA the set A.
+     * @param setB the set B.
+     * @return The intersection of A and B.
      */
     private static <T> int getIntersection(final Set<T> setA, final Set<T> setB) {
         int intersection = 0;
@@ -149,8 +149,8 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe
      * that will include duplicates in the intersect and union.
      * </p>
      *
-     * @param converter the converter used to create the elements from the characters
-     * @throws IllegalArgumentException if the converter is null
+     * @param converter the converter used to create the elements from the characters.
+     * @throws IllegalArgumentException if the converter is null.
      */
     public IntersectionSimilarity(final Function<CharSequence, Collection<T>> converter) {
         if (converter == null) {
@@ -162,10 +162,10 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe
     /**
      * Calculates the intersection of two character sequences passed as input.
      *
-     * @param left first character sequence
-     * @param right second character sequence
-     * @return The intersection result
-     * @throws IllegalArgumentException if either input sequence is {@code null}
+     * @param left first character sequence.
+     * @param right second character sequence.
+     * @return The intersection result.
+     * @throws IllegalArgumentException if either input sequence is {@code null}.
      */
     @Override
     public IntersectionResult apply(final CharSequence left, final CharSequence right) {
@@ -210,9 +210,9 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe
      * Computes the intersection between two bags. This is the sum of the minimum
      * count of each element that is within both sets.
      *
-     * @param bagA the bag A
-     * @param bagB the bag B
-     * @return The intersection
+     * @param bagA the bag A.
+     * @param bagB the bag B.
+     * @return The intersection of A and B.
      */
     private int getIntersection(final TinyBag bagA, final TinyBag bagB) {
         int intersection = 0;
@@ -229,8 +229,8 @@ public class IntersectionSimilarity<T> implements SimilarityScore<IntersectionRe
      * Converts the collection to a bag. The bag will contain the count of each element
      * in the collection.
      *
-     * @param objects the objects
-     * @return The bag
+     * @param objects the objects.
+     * @return The bag.
      */
     private TinyBag toBag(final Collection<T> objects) {
         final TinyBag bag = new TinyBag(objects.size());


(commons-text) 08/16: Javadoc

Posted by gg...@apache.org.
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

commit bd008ff5e5f852e6979c9b5800f24f6a2db0e530
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:08 2025 -0400

    Javadoc
---
 .../java/org/apache/commons/text/similarity/JaroWinklerDistance.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
index f1554987..5564b07b 100644
--- a/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/JaroWinklerDistance.java
@@ -81,7 +81,7 @@ public class JaroWinklerDistance implements EditDistance<Double> {
      * @param left the first input, must not be null.
      * @param right the second input, must not be null.
      * @return result distance.
-     * @throws IllegalArgumentException if either CharSequence input is {@code null}
+     * @throws IllegalArgumentException if either CharSequence input is {@code null}.
      */
     @Override
     public Double apply(final CharSequence left, final CharSequence right) {


(commons-text) 06/16: Javadoc

Posted by gg...@apache.org.
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

commit 90eb6293905066fd1e26c3768c4e88c2ccab8b1c
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:00 2025 -0400

    Javadoc
---
 .../text/similarity/LevenshteinDistance.java       | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

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 3aad1d8d..787279c6 100644
--- a/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/LevenshteinDistance.java
@@ -44,7 +44,7 @@ public class LevenshteinDistance implements EditDistance<Integer> {
     /**
      * Gets the default instance.
      *
-     * @return The default instance
+     * @return The default instance.
      */
     public static LevenshteinDistance getDefaultInstance() {
         return INSTANCE;
@@ -72,9 +72,9 @@ public class LevenshteinDistance implements EditDistance<Integer> {
      * limitedCompare("hippo", "elephant", 6) = -1
      * </pre>
      *
-     * @param left      the first SimilarityInput, must not be null
-     * @param right     the second SimilarityInput, must not be null
-     * @param threshold the target threshold, must not be negative
+     * @param left      the first SimilarityInput, must not be null.
+     * @param right     the second SimilarityInput, must not be null.
+     * @param threshold the target threshold, must not be negative.
      * @return result distance, or -1
      */
     private static <E> int limitedCompare(SimilarityInput<E> left, SimilarityInput<E> right, final int threshold) { // NOPMD
@@ -229,10 +229,10 @@ public class LevenshteinDistance implements EditDistance<Integer> {
      * unlimitedCompare("hello", "hallo")    = 1
      * </pre>
      *
-     * @param left  the first CharSequence, must not be null
-     * @param right the second CharSequence, must not be null
-     * @return result distance, or -1
-     * @throws IllegalArgumentException if either CharSequence input is {@code null}
+     * @param left  the first CharSequence, must not be null.
+     * @param right the second CharSequence, must not be null.
+     * @return result distance, or -1.
+     * @throws IllegalArgumentException if either CharSequence input is {@code null}.
      */
     private static <E> int unlimitedCompare(SimilarityInput<E> left, SimilarityInput<E> right) {
         if (left == null || right == null) {
@@ -347,10 +347,10 @@ public class LevenshteinDistance implements EditDistance<Integer> {
      * distance.apply("hello", "hallo")    = 1
      * </pre>
      *
-     * @param left  the first input, must not be null
-     * @param right the second input, must not be null
-     * @return result distance, or -1
-     * @throws IllegalArgumentException if either String input {@code null}
+     * @param left  the first input, must not be null.
+     * @param right the second input, must not be null.
+     * @return result distance, or -1.
+     * @throws IllegalArgumentException if either String input {@code null}.
      */
     @Override
     public Integer apply(final CharSequence left, final CharSequence right) {


(commons-text) 01/16: Javadoc

Posted by gg...@apache.org.
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

commit 3d100309e422d4aa8a7f52415c440f523565e7f4
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:00:37 2025 -0400

    Javadoc
---
 .../org/apache/commons/text/similarity/SimilarityScoreFrom.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/SimilarityScoreFrom.java b/src/main/java/org/apache/commons/text/similarity/SimilarityScoreFrom.java
index 341f9d9d..470bb713 100644
--- a/src/main/java/org/apache/commons/text/similarity/SimilarityScoreFrom.java
+++ b/src/main/java/org/apache/commons/text/similarity/SimilarityScoreFrom.java
@@ -81,8 +81,8 @@ public class SimilarityScoreFrom<R> {
      * This compares "left" field against the "right" parameter
      * using the "similarity score" implementation.
      *
-     * @param right the second CharSequence
-     * @return The similarity score between two CharSequences
+     * @param right the second CharSequence.
+     * @return The similarity score between two CharSequences.
      */
     public R apply(final CharSequence right) {
         return similarityScore.apply(left, right);
@@ -91,7 +91,7 @@ public class SimilarityScoreFrom<R> {
     /**
      * Gets the left parameter.
      *
-     * @return The left parameter
+     * @return The left parameter.
      */
     public CharSequence getLeft() {
         return left;
@@ -100,7 +100,7 @@ public class SimilarityScoreFrom<R> {
     /**
      * Gets the edit distance.
      *
-     * @return The edit distance
+     * @return The edit distance.
      */
     public SimilarityScore<R> getSimilarityScore() {
         return similarityScore;


(commons-text) 02/16: Javadoc

Posted by gg...@apache.org.
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

commit 4d585ce9b72cfcb33ccb04285c55915067f87d57
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:00:41 2025 -0400

    Javadoc
---
 src/main/java/org/apache/commons/text/similarity/RegexTokenizer.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/RegexTokenizer.java b/src/main/java/org/apache/commons/text/similarity/RegexTokenizer.java
index b633d786..e566cbaf 100644
--- a/src/main/java/org/apache/commons/text/similarity/RegexTokenizer.java
+++ b/src/main/java/org/apache/commons/text/similarity/RegexTokenizer.java
@@ -47,7 +47,7 @@ final class RegexTokenizer implements CharSequenceTokenizer<CharSequence> {
     /**
      * {@inheritDoc}
      *
-     * @throws IllegalArgumentException if the input text is blank
+     * @throws IllegalArgumentException if the input text is blank.
      */
     @Override
     public CharSequence[] apply(final CharSequence text) {


(commons-text) 13/16: Javadoc

Posted by gg...@apache.org.
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

commit c819ed70bae8cbfebd402d31324caa26faa6f341
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:24 2025 -0400

    Javadoc
---
 .../org/apache/commons/text/similarity/FuzzyScore.java | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/FuzzyScore.java b/src/main/java/org/apache/commons/text/similarity/FuzzyScore.java
index 8355fdba..78c96aff 100644
--- a/src/main/java/org/apache/commons/text/similarity/FuzzyScore.java
+++ b/src/main/java/org/apache/commons/text/similarity/FuzzyScore.java
@@ -43,10 +43,8 @@ public class FuzzyScore {
     /**
      * This returns a {@link Locale}-specific {@link FuzzyScore}.
      *
-     * @param locale The string matching logic is case insensitive.
-                     A {@link Locale} is necessary to normalize both Strings to lower case.
-     * @throws IllegalArgumentException
-     *         This is thrown if the {@link Locale} parameter is {@code null}.
+     * @param locale The string matching logic is case insensitive. A {@link Locale} is necessary to normalize both Strings to lower case.
+     * @throws IllegalArgumentException This is thrown if the {@link Locale} parameter is {@code null}.
      */
     public FuzzyScore(final Locale locale) {
         if (locale == null) {
@@ -56,8 +54,7 @@ public class FuzzyScore {
     }
 
     /**
-     * Find the Fuzzy Score which indicates the similarity score between two
-     * Strings.
+     * Find the Fuzzy Score which indicates the similarity score between two Strings.
      *
      * <pre>
      * score.fuzzyScore(null, null)                          = IllegalArgumentException
@@ -72,11 +69,10 @@ public class FuzzyScore {
      * score.fuzzyScore("Apache Software Foundation", "asf") = 3
      * </pre>
      *
-     * @param term a full term that should be matched against, must not be null
-     * @param query the query that will be matched against a term, must not be
-     *            null
-     * @return result score
-     * @throws IllegalArgumentException if the term or query is {@code null}
+     * @param term  a full term that should be matched against, must not be null.
+     * @param query the query that will be matched against a term, must not be null.
+     * @return result score.
+     * @throws IllegalArgumentException if the term or query is {@code null}.
      */
     public Integer fuzzyScore(final CharSequence term, final CharSequence query) {
         if (term == null || query == null) {


(commons-text) 15/16: Javadoc

Posted by gg...@apache.org.
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

commit 2f50c4f412612865494ba91cfa42008d3084022e
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:31 2025 -0400

    Javadoc
---
 .../commons/text/similarity/CosineSimilarity.java    | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/CosineSimilarity.java b/src/main/java/org/apache/commons/text/similarity/CosineSimilarity.java
index d1adbf25..dfbfe25b 100644
--- a/src/main/java/org/apache/commons/text/similarity/CosineSimilarity.java
+++ b/src/main/java/org/apache/commons/text/similarity/CosineSimilarity.java
@@ -48,9 +48,9 @@ public class CosineSimilarity {
     /**
      * Calculates the cosine similarity for two given vectors.
      *
-     * @param leftVector left vector
-     * @param rightVector right vector
-     * @return cosine similarity between the two vectors
+     * @param leftVector left vector.
+     * @param rightVector right vector.
+     * @return cosine similarity between the two vectors.
      */
     public Double cosineSimilarity(final Map<CharSequence, Integer> leftVector,
                                    final Map<CharSequence, Integer> rightVector) {
@@ -83,10 +83,10 @@ public class CosineSimilarity {
      * that if a vector is longer than other, then a smaller part of it will be used to compute
      * the dot product.
      *
-     * @param leftVector left vector
-     * @param rightVector right vector
-     * @param intersection common elements
-     * @return The dot product
+     * @param leftVector left vector.
+     * @param rightVector right vector.
+     * @param intersection common elements.
+     * @return The dot product.
      */
     private double dot(final Map<CharSequence, Integer> leftVector, final Map<CharSequence, Integer> rightVector,
             final Set<CharSequence> intersection) {
@@ -100,9 +100,9 @@ public class CosineSimilarity {
     /**
      * Returns a set with keys common to the two given maps.
      *
-     * @param leftVector left vector map
-     * @param rightVector right vector map
-     * @return common strings
+     * @param leftVector left vector map.
+     * @param rightVector right vector map.
+     * @return common strings.
      */
     private Set<CharSequence> getIntersection(final Map<CharSequence, Integer> leftVector,
             final Map<CharSequence, Integer> rightVector) {


(commons-text) 09/16: Javadoc

Posted by gg...@apache.org.
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

commit 4f9ac340d2a5bc67f7f722cfdde820c411102913
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Jul 20 10:01:11 2025 -0400

    Javadoc
---
 .../java/org/apache/commons/text/similarity/JaccardSimilarity.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/similarity/JaccardSimilarity.java b/src/main/java/org/apache/commons/text/similarity/JaccardSimilarity.java
index 2630728a..c5291486 100644
--- a/src/main/java/org/apache/commons/text/similarity/JaccardSimilarity.java
+++ b/src/main/java/org/apache/commons/text/similarity/JaccardSimilarity.java
@@ -48,7 +48,7 @@ public class JaccardSimilarity implements SimilarityScore<Double> {
      *
      * @param left  first input sequence.
      * @param right second input sequence.
-     * @return index.
+     * @return The Jaccard Similarity of two set character sequence passed as input.
      * @throws IllegalArgumentException if either String input {@code null}.
      */
     @Override
@@ -63,7 +63,7 @@ public class JaccardSimilarity implements SimilarityScore<Double> {
      * @param <E>   The type of similarity score unit.
      * @param left  first input sequence.
      * @param right second input sequence.
-     * @return index.
+     * @return The Jaccard Similarity of two set character sequence passed as input.
      * @since 1.13.0
      */
     public <E> Double apply(final SimilarityInput<E> left, final SimilarityInput<E> right) {