/** * Stage 5: matching blocks against messages that already existed. * * This is the strongest evidence the pipeline can have. Every other signal is an inference from * markup or wording: an attribution line suggests a quote follows, a blockquote suggests its * contents are old. A match against the actual parent message is not an inference. The text * demonstrably existed before this message was written, so it cannot be something the sender just * wrote. * * In the working corpus 90.9 percent of replies resolve their In-Reply-To to a message that is also * present, which makes this unusually available here. It remains strictly optional: extraction * works with no history at all, and history only ever adds evidence. * * The matcher is deliberately conservative in one direction. A match can promote a block to * REPLY_HISTORY, which hides it, so short blocks are never matched, and a high containment * threshold is required. A non match never demotes anything. */ import { type Block } from '../segment/types'; import { type ShingleIndex } from './shingle'; export interface HistoryDocument { /** Identifier for diagnostics, typically a path or Message-ID. */ id: string; /** Normalised text of the whole message, all representations concatenated. */ normalised: string; index: ShingleIndex; /** True when this is the direct parent rather than an older ancestor. */ isParent: boolean; } export interface BlockMatch { blockIndex: number; documentId: string; isParent: boolean; containment: number; /** True when the normalised text appeared verbatim. */ exact: boolean; } /** * Build a searchable document from a raw earlier message. * * Both representations are folded into one text projection. Which representation the earlier * message used has nothing to do with which one the reply quoted from, and clients routinely quote * the HTML of a message into the plain text of a reply. */ export declare function buildHistoryDocument(raw: Buffer | string, id: string, isParent: boolean): Promise; /** * Build a searchable document from already parsed content. * * The counterpart to buildHistoryDocument for callers that never had a raw message. Both * representations are folded together for the same reason: which one the earlier message used has * nothing to do with which one the reply quoted from. */ export declare function buildHistoryDocumentFromContent(text: string, html: string, id: string, isParent: boolean): HistoryDocument; /** * Match blocks against known history. * * Returns one match per block at most, preferring the direct parent over older ancestors, and * higher containment over lower. */ export declare function matchBlocks(blocks: readonly Block[], history: readonly HistoryDocument[]): BlockMatch[]; /** Convenience view for the classifier, which only needs to know which indices matched. */ export declare function matchedIndices(matches: readonly BlockMatch[]): Set; /** * Containment at or above which a match needs no corroboration from markup. * * The ordinary threshold admits a paraphrase or a heavily edited quote, which is right when markup * already says the region is history and the match only confirms it. Identifying history that * carries no markup at all is a stronger claim and takes a stronger match. Measured across the * reference set the ratio of correct to incorrect reclassification is best here, at almost twelve * to one. */ export declare const STRONG_CONTAINMENT = 0.95; /** Matches strong enough to identify history that carries no markup of its own. */ export declare function strongMatchedIndices(matches: readonly BlockMatch[]): Set; //# sourceMappingURL=history.d.ts.map