docs / stdlib / search / ngram
Stdlib index
- Captured-borrow migration worklist (3.3.3)
- Owned-bind migration worklist (8.2.7)
- Return-side title audit — the ride-through enumeration
- stdlib ownership audit
- stdlib ownership dispositions (plan 1.3.1 / 4.3.1)
aot
codec
codec / csv
codec / json
collection
- ArrayList
- BPlusTree
- Cache
- Collectors
- HashMap
- HashSet
- Heap
- ImmutableList
- ImmutableMap
- ImmutableSet
- LinkedList
- RedBlackTree
- Sort
collection / ltm
concurrent
error
- Exception
- NoOptionalValueException
- NotProvidedException
- RecoverableException
- ScopedBuildFailedException
- ScopeNotActiveException
- Throwable
- UnrecoverableException
gfx
hash
ifx
io
io / file
io / net
io / net / dns
io / net / uri
lang
lang / stream
math
math / fft
math / linalg
math / npio
math / poly
math / random
math / stats
nucleo
- Columns — the Arrow-laid-out substrate
- Fused tensor expressions — Fuse
- Table — the lazy, typed dataframe
- Tape — define-by-run autograd
- Transform intrinsics — Grad, Vmap, Jit
process
reflect
search / distance
search / fuzzy
search / ngram
session
time
- Clock
- DateTimeFormatter
- Duration
- Instant
- LocalDate
- LocalDateTime
- LocalTime
- Period
- ZonedDateTime
- ZoneId
- ZoneOffset
wire
xpu
xpu / mesh
Index<T>
cajeta.search.ngram.Index — an n-gram inverted index for fuzzy candidate
generation. Maps key strings to stored values of type T and answers
candidates(query): every value whose key shares at least one n-gram with the
query, deduplicated. This is a recall-oriented prefilter — a superset the
caller (or fuzzy.Matcher) then scores with an edit
distance. Gram extraction is lowercased for recall; a key shorter than n is
indexed under itself as a single gram. add is O(len(key)); candidates
visits only the postings of the query’s grams (sub-linear in the key count).
Index<int32> idx = heap Index<int32>(); // trigrams (n = 3)
idx.add("apple", 1);
idx.add("zebra", 2);
ArrayList<int32> hits #= idx.candidates("aple"); // [1] — shares "ple"
Methods
| Signature | |
|---|---|
Index() ⚑ | Construct a trigram index (n = 3) |
Index(int32 gramSize) ⚑ | Construct an index with the given gram size |
void add(String key, T value) | Index value under every n-gram of key |
#ArrayList<T> candidates(String query) | Every value whose key shares at least one n-gram with query, deduplicated; empty when nothing shares a gram |
⚑ = @EntryPoint
See also
- Matcher — combines this prefilter with edit-distance scoring
- Distance — the scoring half
- Source:
runtime/src/cajeta/search/ngram/Index.cajeta