Popularity
5.4
Growing
Activity
2.1
-
24
2
1

Programming language: Crystal
License: MIT License
Tags: Algorithms And Data Structures    
Latest version: v0.5.0

fzy alternatives and similar shards

Based on the "Algorithms and Data structures" category.
Alternatively, view fzy alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of fzy or a related project?

Add another 'Algorithms and Data structures' Shard

README

fzy.cr

Build Status

A Crystal port of awesome Fzy fuzzy finder algorithm.

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  fzy:
    github: hugopl/fzy
  1. Run shards install

Usage

require "fzy"

matches = Fzy.search("hey", %w(Hey Whatever Halley))
matches.each do |match|
  puts "value: #{match.value}"
  puts "score: #{match.score}"
  puts "  pos: #{match.positions.inspect}"
  puts "index: #{match.index}"
end

Should print

value: Hey
score: Infinity
  pos: [0, 1, 2]
index: 0
value: Halley
score: 1.87
  pos: [0, 4, 5]
index: 2

If you need to do many searches on the same set of data you can speed up things by using a prepared haystack.

require "fzy"

haystack = %w(Hey Halley Whatever)
prepared_haystack = PreparedHaystack.new(haystack)
matches = Fzy.search("hey", prepared_haystack)
matches.each do |match|
  puts "value: #{match.value}"
  puts "score: #{match.score}"
  puts "  pos: #{match.positions.inspect}"
end

# Reusing the prepared haystack makes the search faster.
matches = Fzy.search("ho let's go!", prepared_haystack)

Contributing

  1. Fork it (https://github.com/hugopl/fzy/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors