Interface EditDistance

All Known Implementing Classes:
DamerauOSADistance, LevenshteinDistance

public interface EditDistance
Computes the edit distance between two character sequences with an upper bound.

Implementations must be Unicode-aware and operate on code points rather than UTF-16 char units so that supplementary characters are handled correctly.

  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Computes the edit distance between a and b, giving up early once it is certain the distance exceeds max.
  • Method Details

    • distance

      int distance(CharSequence a, CharSequence b, int max)
      Computes the edit distance between a and b, giving up early once it is certain the distance exceeds max.

      A max of 0 is permitted and meaningful: it asks only whether the two sequences are equal, returning 0 when they are and -1 as soon as any difference is found. It is the natural lower bound of the contract, not a degenerate case.

      Parameters:
      a - the first sequence; must not be null
      b - the second sequence; must not be null
      max - the maximum acceptable distance; must not be negative (>= 0)
      Returns:
      the edit distance, or -1 if it is strictly greater than max
      Throws:
      IllegalArgumentException - if a or b is null, or if max is negative