AutoTrie는 최적화된 Trie 데이터 구조를 기반으로 한 Dart 및 Flutter 애플리케이션용 고성능 자동 완성 엔진입니다. 빠른 접두사 기반 검색을 효율적으로 지원하여 텍스트 입력 상자, 검색 바, 코드 에디터에서 실시간 제안에 이상적입니다. 낮은 메모리 사용량과 빠른 검색을 위해 설계되어 대규모 데이터셋에서도 원활한 사용자 경험을 보장합니다. AutoTrie는 플랫폼 독립적이며 Android, iOS, macOS, Windows, Linux를 모두 지원합니다. 가벼운 특성과 간단한 API로 기존 프로젝트에 쉽게 통합할 수 있습니다.
사용 사례
실시간 검색 제안
코드 완성 기능
자동 완성 텍스트 필드
동적 드롭다운
입력 예측
주요 기능
최적화된 트라이 구현
빠른 접두사 매칭
낮은 메모리 사용량
크로스 플랫폼 지원
간단한 API 통합
적합한 대상
자동 완성 UI를 구축하는 개발자
빠른 텍스트 필터링이 필요한 앱
검색 중심 애플리케이션
교육 또는 코딩 도구
고성능 입력 컴포넌트
고려 사항
정적 또는 자주 업데이트되지 않는 데이터 세트에 가장 적합
동적 데이터에 대한 사전 처리가 필요할 수 있습니다
전문 검색에 적합하지 않습니다
접두사 기반 매칭에 제한됨
메모리 사용량은 데이터 세트 크기에 따라 증가합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
AutoTrie
A versatile library which solves autocompletion in Dart/Flutter. It is based around
a space-efficient implementation of Trie which uses variable-length lists. With this, serving
auto-suggestions is both fast and no-hassle. Suggestions are also sorted by how often
they've been entered and subsorted by recency of entry, for search-engine-like results.
It takes time, effort, and mental power to keep this package updated, useful, and
improving. If you used or are using the package, I'd appreciate it if you could spare a few
dollars to help me continue development.
Usage
A usage example is provided below. Check the API Reference for detailed docs:
import'package:autotrie/autotrie.dart';
voidmain() {
// You are allowed to initialize with a starting databank by passing a `bank` parameter.var engine = AutoComplete(engine: SortEngine.configMulti(Duration(seconds: 1), 15, 0.5, 0.5));
engine.enter('more'); // Enter more thrice.
engine.enter('more');
engine.enter('more');
engine.enter('moody'); // Enter moody twice.
engine.enter('moody');
engine.enter('morose'); // Enter scattered words (with mo).
engine.enter('morty');
engine.enter('moment');
engine.enter('momentum');
engine.enter('sorose'); // Enter scattered words (without mo).
engine.enter('sorty');
engine.delete('morose'); // Delete morose.// Check if morose is deleted.print('Morose deletion check: ${!engine.contains('morose')}');
// Check if engine is empty.print('Engine emptiness check: ${engine.isEmpty}');
// They've been ranked by frequency and recency. Since they're all so similar// in recency, frequency takes priority.print("'mo' suggestions: ${engine.suggest('mo')}");
// Result: [more, moody, momentum, moment, morty]// Get all entries.// They've *not* been sorted.// Use `engine.suggest('')` to get all entries sorted` print('All entries: ${engine.allEntries}');
// Result: [more, moody, sorty, sorose, momentum, moment, morty]
}
Sorting
The AutoComplete constructor takes a SortEngine, which it uses to sort the result of the autocompletion operation.
There are a few different modes it can operate in:
SortEngine.entriesOnly() -> AutoComplete results are only sorted by number of entries in the engine (High to Low)
SortEngine.msOnly() -> AutoComplete results are only sorted by how much time has passed since their last entry (Low to High)
SortEngine.simpleMulti() ->
Sorted using two logistic curves, one for ms and one for entries
The ms curve is set to use 3 years (a LOT) as the upper end of how far back entries could have been entered
The entries curve is set to use 30 entries as the max amount of entries
These values are highly arbitrary and not likely to fit your project; this mode is not recommended unless
you are just playing around.
Takes two weights (one for recency and one for entries) which can be used to balance how heavily each factor
should affect the final sorting.
SortEngine.configMulti() ->
Sorted using two logistic curves, one for ms and one for entries
The ms curve is balanced using a parameter (a Duration) for the max time since entry in this engine.
The entries curve is balanced using a parameter (an int) for the max amount of entries in this engine.
If you know approximately how old and how big this AutoComplete engine is, it is highly recommended that
you use this mode.
Takes two weights (one for recency and one for entries) which can be used to balance how heavily each factor
should affect the final sorting.
Basic File Persistence
AutoComplete is natively capable of writing itself to and reading itself from a file. To do this, persist to a file
using the persist method (it takes a File object):
await engine.persist(myFile);
Then you can rebuild using AutoComplete.fromFile (it takes a File along with the mandatory SortEngine):
var engine = AutoComplete.fromFile(file: myFile, engine: SortEngine.entriesOnly());
This persistence will preserve all the metadata (last insert, number of entries) in the table as well as the
core data (the Strings themselves).
Hive Integration
Hive is a speedy, local, and key-value database for Dart/Flutter. Go check it out if you haven't already!
Hive integration is now available with autotrie:
Our way of integration uses extension methods.
Import Hive and AutoTrie, and create a normal Hive box using Hive.openBox('nameHere').
You can then call searchKeys(String prefix) and searchValues(String prefix) on that box to get auto-suggestions.
There is no sorting options: only entry-level sorting is available.
Features and bugs
Please file feature requests and bugs at the issue tracker.
This library and its contents are subject to the terms of the Mozilla Public License, v. 2.0.