Package com.ubs.backend.util
Class Levenshtein
java.lang.Object
com.ubs.backend.util.Levenshtein
Class to calculate the Levenshtein distance between two words
- Since:
- 17.07.2021
- Author:
- Marc, Magnus
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intFunction to find the Levenshtein distance using a table approachstatic intcostOfSubstitution(char a, char b)Function for checking the cost of changing a character in the stringstatic intmin(int... numbers)Minimal number in arrayprivate static String
-
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 characterb- 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
Function to find the Levenshtein distance using a table approach- Parameters:
x- the string which is used to comparey- the string which is used as a comparisoncaseSensitive- 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
- Parameters:
s-- Returns:
- Since:
- 17.07.2021
-