owsei / levenshtein.js
0 likes
0 forks
1 files
Last active
1 | function lev(a, b) { |
2 | if (!a.length) return b.length; |
3 | if (!b.length) return a.length; |
4 | const arr = []; |
5 | for (let i = 0; i <= b.length; i++) { |
6 | arr[i] = [i]; |
7 | for (let j = 1; j <= a.length; j++) { |
8 | arr[i][j] = i === 0 ? |
9 | j : Math.min( |
10 | arr[i - 1][j] + 1, |
Newer
Older