Calculates edit distance using Damerau-Levenshtein algorithm