parent
1e4093d949
commit
42d2c3088e
12 changed files with 135 additions and 19 deletions
|
|
@ -13,10 +13,11 @@
|
|||
import unicode
|
||||
|
||||
proc editDistance*(a, b: string): int {.noSideEffect.} =
|
||||
## Returns the unicode-rune edit distance between ``a`` and ``b``.
|
||||
## Returns the **unicode-rune** edit distance between ``a`` and ``b``.
|
||||
##
|
||||
## This uses the `Levenshtein`:idx: distance algorithm with only a linear
|
||||
## memory overhead.
|
||||
runnableExamples: static: doAssert editdistance("Kitten", "Bitten") == 1
|
||||
if len(a) > len(b):
|
||||
# make ``b`` the longer string
|
||||
return editDistance(b, a)
|
||||
|
|
@ -181,6 +182,7 @@ proc editDistanceAscii*(a, b: string): int {.noSideEffect.} =
|
|||
##
|
||||
## This uses the `Levenshtein`:idx: distance algorithm with only a linear
|
||||
## memory overhead.
|
||||
runnableExamples: static: doAssert editDistanceAscii("Kitten", "Bitten") == 1
|
||||
var len1 = a.len
|
||||
var len2 = b.len
|
||||
if len1 > len2:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue