Luacheck fixes
This commit is contained in:
parent
31ef3ade89
commit
ef9c34b7cd
|
@ -92,7 +92,7 @@ local function correct_error (self, module_suffix, format_msg, gotten_string, po
|
||||||
assert(type(lvl) == 'number')
|
assert(type(lvl) == 'number')
|
||||||
|
|
||||||
-- Do stuff
|
-- Do stuff
|
||||||
local possible_strings = string_dist.strings_with_highest_similarity(gotten_string, possible_strings)
|
possible_strings = string_dist.strings_with_highest_similarity(gotten_string, possible_strings)
|
||||||
local list_string = #possible_strings > 0 and format_probable_strings(possible_strings, 3) or ""
|
local list_string = #possible_strings > 0 and format_probable_strings(possible_strings, 3) or ""
|
||||||
-- Format
|
-- Format
|
||||||
error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, gotten_string, list_string), lvl + 1)
|
error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, gotten_string, list_string), lvl + 1)
|
||||||
|
|
|
@ -46,7 +46,7 @@ local function levenshtein (str1, str2)
|
||||||
if type(str2) ~= 'string' then error(('[errors/internal]: Bad argument #1 to levenshtein, expected string, got %s (%s)'):format(str2, type(str2))) end
|
if type(str2) ~= 'string' then error(('[errors/internal]: Bad argument #1 to levenshtein, expected string, got %s (%s)'):format(str2, type(str2))) end
|
||||||
|
|
||||||
-- Do work
|
-- Do work
|
||||||
local str1, str2 = str1:lower(), str2:lower()
|
str1, str2 = str1:lower(), str2:lower()
|
||||||
local len1, len2 = #str1, #str2
|
local len1, len2 = #str1, #str2
|
||||||
|
|
||||||
-- Quick cut-offs to save time
|
-- Quick cut-offs to save time
|
||||||
|
@ -65,9 +65,9 @@ local function levenshtein (str1, str2)
|
||||||
-- Algorithm
|
-- Algorithm
|
||||||
for x = 1, len2 do
|
for x = 1, len2 do
|
||||||
column[0] = x
|
column[0] = x
|
||||||
local lastdiag, olddiag = x - 1, nil
|
local lastdiag = x - 1
|
||||||
for y = 1, len1 do
|
for y = 1, len1 do
|
||||||
olddiag = column[y]
|
local olddiag = column[y]
|
||||||
column[y] = math.min(column[y] + 1, column[y-1] + 1, lastdiag + (str1:byte(y-1) == str2:byte(x-1) and 0 or 1))
|
column[y] = math.min(column[y] + 1, column[y-1] + 1, lastdiag + (str1:byte(y-1) == str2:byte(x-1) and 0 or 1))
|
||||||
lastdiag = olddiag
|
lastdiag = olddiag
|
||||||
end
|
end
|
||||||
|
@ -93,7 +93,7 @@ local function longest_common_subsequence (str1, str2)
|
||||||
if type(str2) ~= 'string' then error(('[errors/internal]: Bad argument #1 to longest_common_subsequence, expected string, got %s (%s)'):format(str2, type(str2))) end
|
if type(str2) ~= 'string' then error(('[errors/internal]: Bad argument #1 to longest_common_subsequence, expected string, got %s (%s)'):format(str2, type(str2))) end
|
||||||
|
|
||||||
-- Do work
|
-- Do work
|
||||||
local str1, str2 = str1:lower(), str2:lower()
|
str1, str2 = str1:lower(), str2:lower()
|
||||||
local len1, len2 = #str1, #str2
|
local len1, len2 = #str1, #str2
|
||||||
|
|
||||||
-- Quick cut-offs to save time
|
-- Quick cut-offs to save time
|
||||||
|
@ -139,7 +139,7 @@ local function jaccard_similarity_of_words (str1, str2)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Work work
|
-- Work work
|
||||||
local words1, words2, all = {}, {}, {}, {}
|
local words1, words2, all = {}, {}, {}
|
||||||
for _, word in ipairs(split_string_into_words(str1)) do
|
for _, word in ipairs(split_string_into_words(str1)) do
|
||||||
words1[word], all[word] = true, true
|
words1[word], all[word] = true, true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user