-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithm.lua
More file actions
46 lines (42 loc) · 1.13 KB
/
algorithm.lua
File metadata and controls
46 lines (42 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
------------------------------------------------------------
---@class StringDistanceAlgorithm
---
---@field name string
---@field distance fun(a: string, b: string): number
---@field similarity? fun(a: string, b: string): number
---
------------------------------------------------------------
local Algorithm = {}
------------------------------------------------------------
---
---Define an algorithm with a name
---
---@param name string
---@param module table
---
---@return StringDistanceAlgorithm
---
------------------------------------------------------------
local function define(name, module)
module.name = name
return module
end
Algorithm.LEVENSHTEIN = define(
"LEVENSHTEIN",
require("algorithms.levenshtein")
)
-- TODO: Implement rest of the party
-- Placeholder for future algorithms
-- Algorithm.DAMERAU_LEVENSHTEIN = define(
-- "DAMERAU_LEVENSHTEIN",
-- require("strsim.algorithms.damerau")
-- )
-- Algorithm.JARO_WINKLER = define(
-- "JARO_WINKLER",
-- require("strsim.algorithms.jaro_winkler")
-- )
return setmetatable(Algorithm, {
__newindex = function()
error("strsim.Algorithm is read-only", 2)
end
})