/** Characters of surrounding input carried on either side of a quote. */ export declare const SOURCE_ANCHOR_CONTEXT_CHARS = 32; /** * A verified reference from an ingested entity back into the text the * pipeline was given. * * `quote` is authoritative: it is the input's own text for the range, * so a consumer that stores a differently-normalized copy of the * document can re-locate it there rather than trusting these offsets. * `prefix` / `suffix` disambiguate a quote that occurs more than once. * * Offsets are **JS string indices (UTF-16 code units)** into the * pipeline input, which is why they say so in their names — a consumer * counting code points must convert. */ export type TIngestionSourceAnchor = { quote: string; startUtf16: number; endUtf16: number; prefix: string; suffix: string; }; /** * The occurrence of `needle` at or after `fromUtf16` whose start sits * nearest `hintUtf16`, or `undefined` when there is none. * * The same rule the anchor locator applies, exposed because the offsets * the model reports for segments and mentions need it too: take the * verifiable positions as the candidates and let the model's number pick * between them, never the reverse. */ export declare function nearestOccurrence(haystack: string, needle: string, hintUtf16: number, fromUtf16?: number): number | undefined; /** * A located anchor together with how many candidates it was chosen from. * * `occurrences > 1` means the quote is not unique in the input and the * hint broke the tie. Callers surface that as a note rather than * swallowing it: a silent tie-break is indistinguishable from a certain * match, and the two deserve different trust. */ export type TSourceAnchorMatch = { anchor: TIngestionSourceAnchor; occurrences: number; /** * Set when the quote was not in the input as written and the anchor is * the nearest passage instead — see `approximateRange` for each rule. * The anchor is still the input's own text for its range. */ approximate?: TApproximateAnchorRule; }; /** * How an approximate anchor was found: `normalized` — equal once quote * marks, dashes, ellipses, case and edge punctuation are folded; * `reworded` — a few words differ; `joined` — the quote splices passages, * and the anchor is its longest word-for-word run. */ export type TApproximateAnchorRule = "normalized" | "reworded" | "joined"; /** * Why a quote got no approximate anchor although more than one passage came * close: `ambiguousPassages` places in the input matched it equally well. */ type TAmbiguousApproximation = { ambiguousPassages: number; }; /** * Locate `quote` in `input`: a verified match, `ambiguousPassages` when the * quote is not in the input as written and several passages resemble it * equally, or `undefined` when nothing resembles it. * * `locateSourceAnchor` is this without the distinction between the two * misses, which only the finalize notes need. */ export declare function resolveSourceAnchor(input: string, quote: string, hintUtf16: number): TSourceAnchorMatch | TAmbiguousApproximation | undefined; /** * Locate `quote` in `input`, returning a verified match or `undefined`. * * `hintUtf16` selects among repeated occurrences — the occurrence whose * start sits nearest the hint wins. It never affects *whether* a quote * matches, so a wrong hint degrades to "picked another occurrence of the * same text", never to a wrong span. * * The ladder is exact match, then whitespace-insensitive match, then * both again with the quote's first character re-cased, and last an * approximate match (`approximateRange`), which the result marks. A quote * that matches none of them yields `undefined`. */ export declare function locateSourceAnchor(input: string, quote: string, hintUtf16: number): TSourceAnchorMatch | undefined; export {}; //# sourceMappingURL=source-anchors.d.ts.map