1
0

Luacheck fixes
Some checks failed
Lua Library / Lua-Testing (push) Failing after 6s
Lua Library / Static-Analysis (push) Successful in 3s

This commit is contained in:
Jon Michael Aanes 2024-04-28 12:43:55 +02:00
parent 31ef3ade89
commit ef9c34b7cd
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 6 additions and 6 deletions

View File

@ -92,7 +92,7 @@ local function correct_error (self, module_suffix, format_msg, gotten_string, po
assert(type(lvl) == 'number')
-- 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 ""
-- Format
error(('[%s%s]: '..format_msg):format(self.module_name, module_suffix, gotten_string, list_string), lvl + 1)

View File

@ -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
-- Do work
local str1, str2 = str1:lower(), str2:lower()
str1, str2 = str1:lower(), str2:lower()
local len1, len2 = #str1, #str2
-- Quick cut-offs to save time
@ -65,9 +65,9 @@ local function levenshtein (str1, str2)
-- Algorithm
for x = 1, len2 do
column[0] = x
local lastdiag, olddiag = x - 1, nil
local lastdiag = x - 1
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))
lastdiag = olddiag
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
-- Do work
local str1, str2 = str1:lower(), str2:lower()
str1, str2 = str1:lower(), str2:lower()
local len1, len2 = #str1, #str2
-- Quick cut-offs to save time
@ -139,7 +139,7 @@ local function jaccard_similarity_of_words (str1, str2)
end
-- Work work
local words1, words2, all = {}, {}, {}, {}
local words1, words2, all = {}, {}, {}
for _, word in ipairs(split_string_into_words(str1)) do
words1[word], all[word] = true, true
end