Class Levenshtein

java.lang.Object
com.ubs.backend.util.Levenshtein

public class Levenshtein extends Object
Class to calculate the Levenshtein distance between two words
Since:
17.07.2021
Author:
Marc, Magnus
  • Constructor Details

    • Levenshtein

      public Levenshtein()
  • Method Details

    • costOfSubstitution

      public static int costOfSubstitution(char a, char b)
      Function for checking the cost of changing a character in the string
      Parameters:
      a - current character
      b - replacement character
      Returns:
      cost of changing the character
      Since:
      17.07.2021
    • min

      public static int min(int... numbers)
      Minimal number in array
      Parameters:
      numbers - all numbers which we want to check
      Returns:
      the lowest number from the numbers given
      Since:
      17.07.2021
    • calculate

      public static int calculate(String x, String y, boolean caseSensitive)
      Function to find the Levenshtein distance using a table approach
      Parameters:
      x - the string which is used to compare
      y - the string which is used as a comparison
      caseSensitive - is it case sensitive or not?
      Returns:
      the minimal amount of changes made to a string for it to be equal to the second one
      Since:
      17.07.2021
    • rsc

      private static String rsc(String s)
      Parameters:
      s -
      Returns:
      Since:
      17.07.2021