fuzzy_bolt 1.1.2
fuzzy_bolt: ^1.1.2 copied to clipboard
A high-performance fuzzy search algorithm in Dart, designed for intelligent auto-suggestions, typo tolerance, and fast string matching.
FuzzyBolt π₯ #
A powerful and optimized fuzzy search algorithm with typo tolerance and ranking.
Features #
β
Blazing Fast Performance π
β
Advanced String Matching with Jaro-Winkler & Levenshtein Distance
β
Ideal for Autocomplete, Search Bars, and Query Refinement
β
Asynchronous & Optimized for Large Datasets
π¦ Installation #
Add FuzzyBolt to your pubspec.yaml
:
dependencies:
fuzzy_bolt: <latest_version>
Then, run:
dart pub get
πNormal Search Usage #
import 'package:fuzzy_bolt/fuzzy_bolt.dart';
void main() async {
final results = await fuzzyBolt.search(
dataset: ["encyclopedia", "phenomenon", "philosophy", "psychology"],
query: "phsychology", // Typo: "phsychology" instead of "psychology"
strictThreshold: 0.8,
typoThreshold: 0.7,
);
}
π Output Example: #
psychology (Score: 0.92) β
(Fixes minor spelling mistake)
philosophy (Score: 0.75) β (Less relevant but somewhat similar)
β‘ API Reference #
Future<List<Map<String, dynamic>>> search({
required List<String> dataset,
required String query,
required double strictThreshold,
required double typoThreshold,
})
π Stream Based Search #
import 'package:fuzzy_bolt/fuzzy_bolt.dart';
void main() async {
final queryController = StreamController<String>();
final searchStream = fuzzyBolt.streamSearch(
dataset: ["apple", "banana", "berry", "grape", "pineapple"],
query: queryController.stream,
);
searchStream.listen((results) {
print(results);
});
queryController.add("b");
queryController.add("be");
queryController.add("ber");
queryController.add("berr");
queryController.add("berry");
}
π Output Example: #
π Running Stream-Based Search...
β¨οΈ Typing: 'b'
π Stream Update:
πΉ banana (Score: 0.750)
πΉ blueberry (Score: 0.733)
πΉ blackberry (Score: 0.730)
β¨οΈ Typing: 'be'
π Stream Update:
πΉ blueberry (Score: 0.767)
β¨οΈ Typing: 'ber'
π Stream Update:
πΉ blueberry (Score: 0.667)
πΉ tangerine (Score: 0.630)
πΉ watermelon (Score: 0.622)
πΉ pomegranate (Score: 0.616)
β¨οΈ Typing: 'berr'
π Stream Update:
πΉ blueberry (Score: 0.725)
πΉ blackberry (Score: 0.610)
β¨οΈ Typing: 'berry'
π Stream Update:
πΉ blueberry (Score: 0.680)
πΉ raspberry (Score: 0.444)
π Stream-based search completed.
Parameter | Type | Description |
---|---|---|
dataset |
List<String> |
The list of items to search through. |
query |
String |
The search term entered by the user. |
strictThreshold |
double |
Minimum Jaro-Winkler similarity score required for a match. |
typoThreshold |
double |
Minimum Damerau-Levenshtein distance score required for a match. |
π Use Cases #
β
Search & Auto-Suggestions - Enhance search bars with intelligent suggestions.
β
Spell Checking - Detect and correct minor spelling errors.
β
Command Line Interfaces - Improve fuzzy matching in CLI applications.
β
Data Deduplication - Identify similar records in datasets.
π₯ Platform Support #
Platform | Supported |
---|---|
Android | β Yes |
iOS | β Yes |
macOS | β Yes |
Windows | β Yes |
Linux | β Yes |
Web | β No |
Why no Web support?
FuzzyBolt uses Dart isolates for parallel computation, which are not supported on Flutter Web. I'll eventually enhance a fallback mechanism which leverages Web Workers for web platform.
π¬ Running Tests #
To run tests, use:
dart test
test/fuzzy_bolt_test.dart
π License #
This package is licensed under the BSD-3-Clause License. See the LICENSE file for details.
β€οΈ Contributing #
We welcome contributions! If you'd like to improve FuzzyBolt:
- Open an issue on GitHub
- Submit a pull request
- Suggest new features or report bugs
π¬ Questions? #
If you have any questions, feel free to open a discussion on GitHub or raise an issue.
π Like this package? Star it on GitHub! β