Levenshtein distance (edit distance) library for Ruby, implemented in C++ with SWIG bindings. Supports multibyte characters (e.g. Japanese).
./build.shThis builds inside Docker and extracts lsd.so to the current directory.
Requires swig, ruby, and C++ build tools.
./build.sh --localrequire 'lsd'
l = Lsd::Lsd.new
l.dp("kitten", "sitting") # => 3
l.dp("あいうえお", "あいうえ") # => 1- SWIG generates Ruby bindings from
lsd.i+Lsd.h - extconf.rb generates a Makefile via
mkmf - make compiles
Lsd.ccand the SWIG wrapper intolsd.so
Internally, multibyte strings are converted to wide strings (wstring) so that each character is counted as one unit.
# Docker
./build.sh
docker run --rm lsd-builder
# Expected output: 3, 1