DivergenceMeter
DivergenceMeter is Levenshtein distance(レーベンシュタイン距離) tool and Library.
Installation
Add this line to your application's Gemfile:
gem 'divergence_meter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install divergence_meter
Usage
use command line.
calculate Levenshtein distance.
$ divergence_meter retire tire
2
$ divergence_meter retire retare
1
$ divergence_meter retire hoge
5
did you mean?
retare
is typo. tire retire hoge
is dictionary words.
$ divergence_meter retare tire retire hoge
retare
use library
calculate Levenshtein distance.
require 'divergence_meter'
puts DivergenceMeter.distance('retire', 'tire')
# => 2
did you mean?
retare
is typo. tire retire hoge
is dictionary words.
require 'divergence_meter'
puts DivergenceMeter.did_you_mean('retare', %w(tire retire hoge))
# => retire
Contributing
- Fork it ( https://github.com/[my-github-username]/divergence_meter/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request