Fuzzies
Fuzzies is a memory-mapped FST spellchecker and fuzzy dictionary built on fst and levenshtein-automata.
More information about this crate can be found in the crate documentation.
Installation
See the Node.js README for Node-specific APIs and its usage details.
Example
use ;
If you don't want to manage external .fst files on disk, you can construct a Dictionary directly:
// From an embedded FST binary slice:
static DICT_DATA: & = include_bytes!;
let dict = from_embedded?;
// From an iterator of strings (automatically sorted and deduplicated):
let words = vec!;
let dict = from_iterator?;
See examples for more.
🎈 Performance
- Instant Exact Matches: Finding a word takes about
130ns. If a word isn't in the dictionary, it figures that out and rejects it in under10ns. - Fast Typo Correction: Searching for a word with a 1-character typo through 50,000 words takes about
75µs. - Multithreading: Throwing 1,000 fuzzy searches at it in parallel (via Rayon) finishes in just
~5ms. - Zero Loading Screen: Opening a saved dictionary is instant, no matter how huge the file is, because it just maps the file directly to memory.
Want the hard numbers? Check out the Benchmarks.
Safety
This crate uses unsafe in a single location:
- Memory-Mapped I/O (
Dictionary::open): Callsmemmap2::Mmap::map(&file)to map FST data directly from disk into memory.
License
This project is licensed under the MIT license.