• Stars
    star
    42
  • Rank 656,625 (Top 13 %)
  • Language
    Crystal
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Crystal port of awesome Fzy project, a fuzzy finder algorithm.

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 = Fzy::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

More Repositories

1

sidekiq.cr

Simple, efficient job processing for Crystal
Crystal
767
star
2

tijolo

Simple and fast keyboard focused IDE written in Crystal and GTK.
Crystal
132
star
3

gtk4.cr

GTK4 bindings for Crystal
Crystal
92
star
4

RubyCreator

Plugins to add Ruby language support to QtCreator IDE.
C++
44
star
5

gi-crystal

Tool to generate Crystal bindings for gobject-based libraries (i.e. GTK)
Crystal
41
star
6

queryit

A very basic setupless terminal based SQL query runner meant to be used as a developer tool to test queries against a project database.
Crystal
22
star
7

rtfm

Gnome dash docset documentation reader written in Crystal
Crystal
21
star
8

reviewit

A git oriented review board for small/medium teams.
Ruby
19
star
9

textui

A simple Crystal UI framework for terminal interfaces.
Crystal
12
star
10

Meique

Meique is a simple build system for C and C++ which uses Lua as scripting language.
C++
10
star
11

Iceberg

Fork of Icemon, an Icecc monitor.
C++
8
star
12

version_from_shard

A macro to declare the VERSION constant from the value found in shard.yml, so you don't need to write the same version number in multiple places.
Crystal
8
star
13

crystal-tree-sitter

Crystal bindings for tree-sitter library
Crystal
8
star
14

invoicegenerator

Stupid script to create pdf invoices.
Ruby
6
star
15

http-status-code-manpages

Manpages for HTTP status codes.
Ruby
6
star
16

MeiqueQtCreatorPlugin

Build system plugin for QtCreator
C++
3
star
17

pg_query.cr

Crystal bindings for libpg_query.
Crystal
2
star
18

harfbuzz.cr

Crystal "bindings" for HarfBuzz library
Crystal
2
star
19

vte.cr

Crystal bindings for VTE library
Crystal
1
star
20

pango.cr

Crystal bindings for Pango library
Crystal
1
star