Class Levenshtein
java.lang.Object
dev.getelements.elements.sdk.util.Levenshtein
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 Summary
Modifier and TypeMethodDescriptionstatic StringDeletes the character at the given index from the source string.static intdistance(CharSequence source, CharSequence target) Calculates the Levenshtein distance between two CharSequences.static StringInserts a character at the given index in the source string.static StringsubstituteAt(String source, int index, char newChar) Substitutes the character at the given index with a new character.
-
Method Details
-
distance
Calculates the Levenshtein distance between two CharSequences.- Parameters:
source- the source CharSequencetarget- the target CharSequence- Returns:
- the Levenshtein distance
-
insertAt
Inserts a character at the given index in the source string. -
deleteAt
Deletes the character at the given index from the source string. -
substituteAt
Substitutes the character at the given index with a new character.
-