fzy.cr
A Crystal port of awesome Fzy fuzzy finder algorithm.
Installation
-
Add the dependency to your
shard.yml
:dependencies: fzy: github: hugopl/fzy
-
Run
shards install
Usage
require "fzy"
results = Fzy.search("hey", %w(Hey Halley Whatever))
results.each do |result|
puts "value: #{result.value}"
puts " pos: #{result.positions.inspect}"
end
Should print
value: Hey
pos: [0, 1, 2]
value: Halley
pos: [0, 4, 5]
TODO
Current version works and it's pretty fast, but common use case for fyz is to have the same haystack and find for different needles, so it's on my plans to improve the API a bit to avoid some double computation and save some allocations.
Options like "do not compute positions" should also appear in next versions.
Write some API documentation!
Contributing
- Fork it (https://github.com/hugopl/fzy/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
Contributors
- Hugo Parente Lima - creator and maintainer