-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.lua
More file actions
50 lines (44 loc) · 1.98 KB
/
types.lua
File metadata and controls
50 lines (44 loc) · 1.98 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
47
48
49
50
--------------------------------------------------------------------------------------
---@meta
---@class StringDistanceAlgorithm
---@field name string The algorithm name
---@field distance fun(a: string, b: string): number Calculate edit distance
---@field similarity fun(a: string, b: string): number Calculate similarity
---@class strsim.AlgorithmEnum
---@field LEVENSHTEIN StringDistanceAlgorithm Levenshtein edit distance
---@field DAMERAU_LEVENSHTEIN StringDistanceAlgorithm Damerau-Levenshtein distance
---@field JARO_WINKLER StringDistanceAlgorithm Jaro-Winkler similarity
---@field HAMMING StringDistanceAlgorithm Hamming distance
---@field LCS StringDistanceAlgorithm Longest Common Subsequence
---@field OSA StringDistanceAlgorithm Optimal String Alignment
---@field JARO StringDistanceAlgorithm Jaro similarity
---@class strsim
---
---@field Algorithm strsim.AlgorithmEnum Available algorithms
--------------------------------------------------------------------------------------
local strsim = {}
--------------------------------------------------------------------------------------
---
---Calculate the edit distance between two strings
---
---@param a string First string
---@param b string Second string
---@param algorithm? StringDistanceAlgorithm Algorithm to use (default: LEVENSHTEIN)
---
---@return number distance The edit distance
---
--------------------------------------------------------------------------------------
function strsim.distance(a, b, algorithm) end
--------------------------------------------------------------------------------------
---
---Calculate the similarity between two strings (0.0 to 1.0)
---
---@param a string First string
---@param b string Second string
---@param algorithm? StringDistanceAlgorithm Algorithm to use (default: LEVENSHTEIN)
---
---@return number similarity Similarity score between 0.0 and 1.0
---
--------------------------------------------------------------------------------------
function strsim.similarity(a, b, algorithm) end
return strsim