/** * Stratified sampling over the corpus. * * Uniform random sampling of this corpus would produce a set that is almost entirely Gmail top * posts in English, because that is what the corpus mostly is. The structures that actually break * an extractor, interleaved replies, Outlook's unmarked history, malformed HTML, plain text only * mail, are each a percent or two, and a random sample of a few hundred messages would contain a * handful of each at best. * * So strata are defined by the structural properties that change how extraction behaves, each gets * a quota, and a random control slice is included alongside so that unbiased numbers remain * available. Selection within a stratum is deterministic: the same seed always picks the same * messages, regardless of database order. */ import { type CorpusStore } from './store'; export interface Stratum { id: string; /** SQL predicate over the messages table, aliased m, joined to files as f. */ predicate: string; /** Share of the total sample to allocate. Normalised across strata. */ weight: number; description: string; } /** * The strata that matter, with the reason each one exists. * * Weights are not proportional to prevalence. They are proportional to how much is learned per * message, which for a rare structure is a great deal more. */ export declare const DEFAULT_STRATA: readonly Stratum[]; export interface SampleOptions { /** Total messages wanted. */ count: number; seed: string; /** Restrict to a traffic class, or 'all'. */ traffic?: string; /** Only messages that look like replies. */ repliesOnly?: boolean; /** Exclude these paths, for example ones already annotated. */ exclude?: ReadonlySet; strata?: readonly Stratum[]; } export interface SampleRow { path: string; stratum: string; } export interface SampleResult { rows: SampleRow[]; /** How many were taken from each stratum, and how many were available. */ coverage: { id: string; requested: number; taken: number; available: number; description: string; }[]; } /** * Draw a stratified sample. * * Strata overlap by design: a message can be an Outlook interleaved reply in Estonian. It is * assigned to the first stratum that claims it, so the rarer strata listed earlier fill first, and * no message appears twice. */ export declare function stratifiedSample(store: CorpusStore, options: SampleOptions): SampleResult; //# sourceMappingURL=sample.d.ts.map