Darts-clone.rb provides Ruby bindings for the Darts-clone.
Add this line to your application's Gemfile:
gem 'dartsclone'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install dartsclone
require 'dartsclone'
da = DartsClone::DoubleArray.new
# Construct a dictionary.
keys = ['abc', 'abcd', 'abcde', 'bcd', 'cde']
da.build(keys)
# Search for keys which match the prefix of given string.
p da.common_prefix_search('abcde')
# => [["abc", "abcd", "abcde"], [0, 1, 2]]
# Search a key which matches a given string.
p da.exact_match_search('abcd')
# => 1
# Dump the dictionary.
da.save('foo.dat')
# Load the dictionary.
da.open('foo.dat')
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/darts-clone.rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the BSD 2-clause License. Moreover, the gem includes the source code of Darts-clone. The License of Darts-clone can be found in COPYING.md.