Skip to content

Instantly share code, notes, and snippets.

View TobiasKrok's full-sized avatar

Tobias Kroknes Kristiansen TobiasKrok

  • Norway
  • 13:41 (UTC +02:00)
View GitHub Profile
@TobiasKrok
TobiasKrok / Levenshtein.java
Created December 7, 2021 17:55
Java Levenshtein implementation that accepts a map of string to compare and calculates deviation
public static Map<String, Double> levenshtein(String value, List<String> otherValues, boolean caseSensitive) {
Map<String, Double> result = new HashMap<>();
char[] sourceArr = value.toCharArray();
int soureArrLength = sourceArr.length;
if(soureArrLength == 0) return result;
for (String otherValue : otherValues) {
char[] targetVal = otherValue.toCharArray();
int targetValLength = targetVal.length;
if (targetValLength == 0) {