1
0

Fixed crashes in certain error situations.

This commit is contained in:
Jon Michael Aanes 2018-07-21 14:15:21 +02:00
parent 1106669e34
commit cdb1d90140

View File

@ -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)
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,
}