/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * Pre-compute corpus-wide token + bigram label distributions for the corpus linter. * * Reads one or more Parquet shards, builds per-(token, label) and per-(bigram, label-bigram) * histograms, and serializes them as JSON. The output file is consumed by `lint-corpus-shard.ts` * as the baseline against which a new shard is compared. * * Stats are cheap to compute (~5–30s per 100K rows) but expensive enough that we cache them between * linter invocations. Re-run this script whenever the corpus changes substantially (a new * mainline shard added, a source-pool re-weighted, etc.). * * Output schema: * * ```ts * interface CorpusStats { * row_count: number * shard_paths: string[] * tokens: { [token: string]: { [label: string]: number } } * bigrams: { [token_bigram: string]: { [label_bigram: string]: number } } * // token_bigram = "tok1tok2" (US sep), label_bigram = "lab1lab2" * // For memory: only keep bigrams with count >= MIN_BIGRAM_COUNT (2). * } * ``` * * Usage: node scripts/build-corpus-stats.ts\ * --shards \ * --output * * For a quick local-corpus baseline (limited but useful for linter testing): node * scripts/build-corpus-stats.ts\ * --shards $MAILWOMAN_DATA_ROOT/corpus/versioned/v0.4.0/corpus-v0.4.0/train/\ * --output /tmp/corpus-stats-local.json */ export interface CorpusStatsOptions { shardsArg: string; outputPath: string; limitPerShard?: number; } export declare function buildCorpusStats(args: CorpusStatsOptions): Promise; //# sourceMappingURL=corpus-stats.d.ts.map