View Source README
Welcome to Leven, an efficient, tabulated implementation of the Levenshtein distance algorithm in Elixir. The Levenshtein distance, also known as edit distance, measures the difference between two strings in terms of the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other.
installation
Installation
The package can be installed by adding leven
to your list of dependencies in
mix.exs
:
def deps do
[
{:leven, "~> 1.0.0"}
]
end
example
Example
iex(1)> Leven.distance("house", "horses")
2
Two single-character edits are required to get from "house" to "horses":
- Substitute "u" for "r", resulting in "horse"
- Appens "s", resulting in "horses"
benchmarks
Benchmarks
These benchmarks show how many operations per second Leven can perform for two
random strings of length N
on my machine (Ryzen 7 / 16 Core / 32 GB).
String Length | ops/sec |
---|---|
Empty LHS | 2.5 M |
Empty RHS | 2.47 M |
N=4 | 244.5 K |
N=8 | 86.57 K |
N=16 | 22.51 K |
N=32 | 4.67 K |
N=64 | 863 |
N=128 | 152 |
N=256 | 23 |
To benchmark Leven on your own machine, clone the repo and mix bench
.
license
License
Leven is released under the Apache License 2.0
.
about
About
This package was written by Elliot Jackson.
- Blog: https://elliotekj.com
- Email: elliot@elliotekj.com