https://github.com/doums/ruzy
a Lua library for fuzzy search
https://github.com/doums/ruzy
fuzzy fuzzy-library fuzzy-match fuzzy-search lua lua-library match
Last synced: about 2 months ago
JSON representation
a Lua library for fuzzy search
- Host: GitHub
- URL: https://github.com/doums/ruzy
- Owner: doums
- Created: 2023-02-17T21:09:28.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-19T10:59:03.000Z (almost 3 years ago)
- Last Synced: 2025-01-15T18:30:47.389Z (about 1 year ago)
- Topics: fuzzy, fuzzy-library, fuzzy-match, fuzzy-search, lua, lua-library, match
- Language: Rust
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## ruzy
⚡ A Lua library for fuzzy search
### API
The library exposes a Lua module with one function:
#### fuzzy (input: `string`, items: `list`)
`fuzzy` function takes 2 arguments. The first is the search
input, the second is the list of string to fuzzy match.
returns a list of the matching items sorted by score. Each
item includes:
- item: `string`
- score: `number`, fuzzy score
- indexes: `list`, the matching indexes
### Usage
Move the `libruzy.so` shared library (latest [release](https://github.com/doums/ruzy/releases/latest))
in your project and import it from Lua code.
```lua
local fuzzy = require('libruzy').fuzzy
local res = fuzzy('lou', { 'pierre', 'et', 'le', 'loup' })
-- res:
-- { {
-- item = "loup",
-- score = 71,
-- indexes = { 0, 1, 2 }
-- } }
```
### Algorithm
Skim V2
### Build
#### prerequisites:
- [rust](https://www.rust-lang.org/tools/install)
To build for production run
```
cargo build --release
```
### Credits
- https://crates.io/crates/fuzzy-matcher
- https://github.com/khvzak/mlua
### License
Mozilla Public License 2.0