Class Levenshtein

java.lang.Object
io.github.connellite.util.Levenshtein

public class Levenshtein extends Object
Levenshtein (edit) distance: minimum single-character insertions, deletions, and substitutions needed to turn one CharSequence into another. Uses UTF-16 code units, like String.

Time O(m·n), space O(n) for lengths m and n (two rows).

  • Constructor Details

    • Levenshtein

      public Levenshtein()
  • Method Details

    • dist

      public static int dist(CharSequence word1, CharSequence word2)
      Parameters:
      word1 - first sequence; not null
      word2 - second sequence; not null
      Returns:
      edit distance between word1 and word2 (non-negative)