Skip to content

hisashi-ito/lsd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LSD - Levenshtein Distance

Levenshtein distance (edit distance) library for Ruby, implemented in C++ with SWIG bindings. Supports multibyte characters (e.g. Japanese).

Build

Docker (recommended)

./build.sh

This builds inside Docker and extracts lsd.so to the current directory.

Local

Requires swig, ruby, and C++ build tools.

./build.sh --local

Usage

require 'lsd'

l = Lsd::Lsd.new
l.dp("kitten", "sitting")     # => 3
l.dp("あいうえお", "あいうえ")  # => 1

How it works

  1. SWIG generates Ruby bindings from lsd.i + Lsd.h
  2. extconf.rb generates a Makefile via mkmf
  3. make compiles Lsd.cc and the SWIG wrapper into lsd.so

Internally, multibyte strings are converted to wide strings (wstring) so that each character is counted as one unit.

Verify

# Docker
./build.sh
docker run --rm lsd-builder
# Expected output: 3, 1

About

編集距離計算rubyライブラリ(c++実装)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors