FLUTTER ECOSYSTEM

IvoriApp/woozy-search

一個基於編輯距離的超簡單且輕量級的客戶端模糊搜尋庫。

woozy-search 專案封面
Stars
10
Forks
3
最近推送(UTC)
2021年4月14日
專案狀態
未封存
IvoriApp GitHub avatar
GITHUB Organization

IvoriApp ↗

語言Dart

技術主題

此儲存庫發佈的套件

使用的依賴

依賴清單 4 項
  • collection>=1.15.0 <2.0.0
  • uuid開發依賴^3.0.3
  • pedantic開發依賴^1.11.0
  • test開發依賴^1.16.8

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 README

Woozy Search

A super simple and lightweight client-side fuzzy-search library based on Levenshtein distance.

Usage

dependencies:
  woozy_search: '>=2.0.2 <3.0.0'

Basic Usage

import 'package:woozy_search/woozy_search.dart';

main() {
  final woozy = Woozy();
  woozy.addEntries(['basketball', 'badminton', 'skating']);
  final output = woozy.search('badmi');
  output.forEach((element) => print(' - ${element}'));
}

Output:

 - text: badminton, score: 0.56
 - text: basketball, score: 0.20
 - text: skating, score: 0.14

With Associate Values

Associate value can be anything, integers, UUIDs, text, etc. As an example, we use a name and their phone number here.

import 'package:woozy_search/woozy_search.dart';

main() {
  final woozy = new Woozy();
  woozy.addEntry('John Doe', value: "+1 210-269-0117");
  woozy.addEntry('Nate Humphrey', value: "+1 (416) 527-4927");
  woozy.addEntry('Serena Waldorf', value: "+ 1 914-514-7901");
  final output = woozy.search('humphray');
  output.forEach((element) => print(' - ${element}'));
}

Output:

 - text: Nate Humphrey, score: 0.88, value: +1 (416) 527-4927
 - text: Serena Waldorf, score: 0.13, value: + 1 914-514-7901
 - text: John Doe, score: 0.13, value: +1 210-269-0117

With Search Output Limit

Limit the number of search result to return. It is defaulted to 10, but can be overwritten.

import 'package:woozy_search/woozy_search.dart';
  
main() {
  final woozy = Woozy(limit: 2);
  woozy.setEntries(List.filled(100, 'foo'));
  final output = woozy.search('f');
  output.forEach((element) => print(' - ${element}'));
}

Output:

 - text: foo, score: 0.33
 - text: foo, score: 0.33

With Case Sensitive

main() {
  final woozy = Woozy(caseSensitive: true);
  woozy.setEntries(['FOO', 'boo']);
  final output = woozy.search('foo');
  output.forEach((element) => print(' - ${element}'));
}

Output:

 - text: boo, score: 0.67
 - text: FOO, score: 0.00

Features and bugs

Please file feature requests and bugs at the issue tracker.