/** * Token shingle matching with rolling hashes. * * Stage 5's middle tier. Exact normalised comparison catches text that was quoted verbatim; * shingles catch text that was quoted with an edit, a truncation, or an interleaved insertion, * which clients and people both do. * * A shingle is a window of consecutive tokens. Two texts sharing most of their shingles share most * of their content regardless of where it moved to. The hash is rolling, so building the index for * a parent message costs one pass over its tokens. */ /** Tokens per shingle. Long enough to be specific, short enough to survive small edits. */ export declare const SHINGLE_SIZE = 5; export interface ShingleIndex { hashes: Set; tokenCount: number; } /** * Build a shingle index over normalised text. * * The rolling hash is a simple polynomial over per token 32 bit hashes. Collisions are possible and * harmless at this scale: a collision inflates a similarity score slightly, and the containment * threshold plus the corroboration rules downstream absorb that. */ export declare function buildShingleIndex(normalised: string): ShingleIndex; export interface ContainmentResult { /** Share of the block's shingles that also appear in the reference. */ containment: number; /** Shingles compared. Zero means the block was too short to judge. */ shingles: number; } /** * How much of `block` is contained in `reference`. * * Containment rather than Jaccard similarity, deliberately: a quoted paragraph is a small part of a * large parent message, so symmetric similarity would be near zero for a perfect quote. What * matters is whether everything in this block already existed. */ export declare function containment(block: ShingleIndex, reference: ShingleIndex): ContainmentResult; /** Containment at or above this counts as a match, once the block is long enough to judge. */ export declare const CONTAINMENT_THRESHOLD = 0.8; /** True when a block is long enough for a containment score to mean anything. */ export declare function isMatchable(index: ShingleIndex): boolean; //# sourceMappingURL=shingle.d.ts.map