Class Levenshtein

java.lang.Object
dev.getelements.elements.sdk.util.Levenshtein

public class Levenshtein extends Object
Utility class for calculating the Levenshtein distance between two CharSequences. Additionally, this has some utility method which can be used to generate strings with specific edit operations.
  • Method Details

    • distance

      public static int distance(CharSequence source, CharSequence target)
      Calculates the Levenshtein distance between two CharSequences.
      Parameters:
      source - the source CharSequence
      target - the target CharSequence
      Returns:
      the Levenshtein distance
    • insertAt

      public static String insertAt(String source, int index, char ch)
      Inserts a character at the given index in the source string.
    • deleteAt

      public static String deleteAt(String source, int index)
      Deletes the character at the given index from the source string.
    • substituteAt

      public static String substituteAt(String source, int index, char newChar)
      Substitutes the character at the given index with a new character.