Fuzzy is a fast and accurate fuzzy matching library for file search. It combines multiple search algorithms with a smart frecency-based ranking system to provide relevant results quickly.
Important
Fuzzy focuses on accuracy and typo tolerance while maintaining high performance.
It is optimized for file path searching rather than just single strings.
This package is intended for local use or side projects.
- Typo tolerance: Handles common typing errors using Levenshtein distance
- Multi-algorithm: Uses bitset filtering and optimal alignment fuzzy matching
- Frecency ranking: Learns from user behavior to prioritize frequently and recently used files
- Parallel processing: Scalable performance for large datasets
- Thread-safe: Safe for concurrent use in multi-threaded applications
go get github.com/versenilvis/fuzzyRequirements: Go 1.21+
Basic Example
package main
import (
"fmt"
"github.com/versenilvis/fuzzy"
)
func main() {
// 1. Create Searcher
files := []string{
"/home/user/Documents/report.pdf",
"/home/user/Documents/contract.docx",
"/home/user/Music/song.mp3",
"/home/user/Code/main.go",
"/home/user/Code/utils.go",
}
searcher := fuzzy.NewSearcher(files)
// 2. Basic Search
fmt.Println("--- Searching 'report' ---")
results := searcher.Search("report")
for _, path := range results {
fmt.Println(" ->", path)
}
// 3. Typo Tolerance
fmt.Println("\n--- Searching 'maiin' (typo) ---")
results = searcher.Search("maiin")
for _, path := range results {
fmt.Println(" ->", path)
}
// 4. Learning from User behavior
searcher.RecordSelection("main", "/home/user/Code/main.go")
// Subsequent searches will prioritize this file
results = searcher.Search("mai")
}Creates a new searcher optimized for file paths.
Returns the top matching results for a query, automatically applying frecency boosts.
Records a selection to increase the priority (frecency) of a file for future searches.
This project is licensed under the 0BSD License. Meaning you can do whatever you want with it.