diff --git a/string_distance.lua b/string_distance.lua index f0bd122..fb36603 100644 --- a/string_distance.lua +++ b/string_distance.lua @@ -186,12 +186,10 @@ local function strings_with_highest_similarity (str, list_of_other_str) -- Calculate similarity metrics for _, other_str in ipairs(list_of_other_str) do local total_sim = 0 - --print(other_str) for _, similarity_func in ipairs(SIMILARITY_METRICS) do - local sim, max_sim, min_sim = similarity_func(str, other_str) - assert(max_sim ~= min_sim) + local sim, max_sim, min_sim = similarity_func(str, other_str) + assert(min_sim <= max_sim) total_sim = total_sim + (sim-min_sim)/(max_sim-min_sim) - --print('', sim, (sim-min_sim)/(max_sim-min_sim)) end possible[#possible+1] = {other_str, total_sim} --print('\tTotal: '.. total_sim) @@ -213,3 +211,4 @@ return { jaccard_similarity_of_words = jaccard_similarity_of_words, strings_with_highest_similarity = strings_with_highest_similarity, } +