fuzzy_bolt 1.1.5 copy "fuzzy_bolt: ^1.1.5" to clipboard
fuzzy_bolt: ^1.1.5 copied to clipboard

A high-performance fuzzy search algorithm in Dart, designed for intelligent auto-suggestions, typo tolerance, and fast string matching.

Fuzzy Bolt #

An advanced Fuzzy Search Algorithm with intelligent typo correction, adaptive ranking, and lightning-fast performance.

pub package License: BSD-3-Clause

Table of Contents #

Why Fuzzy Bolt ?? #

I've found many packages that just purely does the fuzzy search job but haven't encountered that deals with typo/error in query automatically.

  • Uses Jaro–Winkler Distance for ranking the results.
  • Uses Levenshtein Distance to handle the typo errors in the query if any.
  • Automatically switch to host's Isolate mechanism if the dataset becomes huge. (Right now capped at dataset length to 500)
  • Allow developers to set their threshold on results for better accuracy.

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,
  double? strictThreshold,
  double? typoThreshold,
})
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.

API Reference #

Stream<List<Map<String, dynamic>>> streamSearch({
    required List<String> dataset,
    required Stream<String> query,
    double? strictThreshold,
    double? typoThreshold,
  });

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
6
likes
0
points
404
downloads

Publisher

verified publishervishwakarthik.in

Weekly Downloads

A high-performance fuzzy search algorithm in Dart, designed for intelligent auto-suggestions, typo tolerance, and fast string matching.

Repository (GitHub)
View/report issues

Topics

#fuzzy-search #search-ranking #text-processing #auto-suggestions #ranking

License

unknown (license)

Dependencies

collection

More

Packages that depend on fuzzy_bolt