import type { SearchIndex } from '../search-index.js'; /** * The loose pass's membership, read off the published dictionary. * * This answers the set MiniSearch answered when the pass built an index per * question: every held name tokenized with MiniSearch's default tokenizer, each * token kept whole and split into the words it is written in, terms shorter * than two dropped and the rest lowercased; the query tokenized without the * split; then `combineWith: 'AND'`, * `prefix: true`, `fuzzy: 0.2` and `maxFuzzy: 1`. Each query term is satisfied * by any dictionary term equal to it, starting with it, or one edit from it * when the term is three characters or longer; a name is in the answer when * every query term is satisfied by its name or by the doc of a published or * exported row the area admits. * * One edit, because the caller is an agent. An agent copies a name; it does * not mistype one. What it gets wrong is a letter of a name it recalled from * elsewhere: a plural, a case, one character. A wider budget answers a * human's slip and costs every agent a longer list of names it did not mean, * and a typo in the code is fixed in the code, not searched around. * * Only membership was ever read from MiniSearch — the tool orders what it * returns by its own rules — so scores are not reproduced. `loose.test.ts` * holds the two to the same sets. */ /** Sorted terms, by their UTF-8 bytes: the search file's dictionary, or any other kept by the same rule. */ export type Dictionary = Pick; /** How far a term may be from what was typed, as MiniSearch computes it. */ export declare function editsAllowed(term: string, fuzzy: number): number; /** * Names reached loosely, as name ids. * * `already` names are never reached: the substring answered them. `within`, * file ids when given, admits a name and a doc only through a row * {@link rowWithin} the area. * * `through`, when given, receives the exported rows whose doc reached a name its * own words never did: the rows to show it through. */ export declare function looseNames(index: SearchIndex, query: string, fuzzy: number, within: ReadonlySet | undefined, already: ReadonlySet, through?: Map>): ReadonlySet; /** * Whether one row is the area's, `within` file ids: a published row when a file * of the area imports it, an exported row when the file exporting it is in the * area. A published name with no import site in an area is a name the area does * not use, however well it matches the question, and an exported row has no * import site to count. Every section asks this one question, so a name is * admitted, weighed and shown through the same rows. */ export declare function rowWithin(index: SearchIndex, kind: 'published' | 'exported', row: number, within: ReadonlySet): boolean; /** * Whether a name may be reached through its own words: never when `already` * holds it, and inside `within` only through a row {@link rowWithin} it. * Remembered per name, because every matching term asks again. */ export declare function admittedBy(index: SearchIndex, within: ReadonlySet | undefined, already: ReadonlySet): (name: number) => boolean; /** Dictionary terms equal to `term`, starting with it, or within `edits` of it. */ export declare function matchingTerms(index: Dictionary, term: string, edits: number): ReadonlySet; /** * Per stem, the dictionary terms that reduce to it, by the dependency * lexicon's stemmer: the terms under the stem are read once and kept only * where they reduce to it, so `modul` admits `module` and not `modular`. */ export declare function termsOfStems(index: Dictionary, stems: readonly string[]): readonly (readonly number[])[]; //# sourceMappingURL=loose.d.ts.map