import type { PathBuilderLike } from "path-ts"; import { type NADRecord } from "#us/adapters/usgov/nad/adapter"; import { type NADZipCityCounty } from "#us/recipes/skeleton-sources"; /** * The OpenAddresses columns a skeleton CSV contains, in OpenAddresses' order. */ export declare const NAD_SKELETON_COLUMNS: readonly ["NUMBER", "STREET", "UNIT", "CITY", "DISTRICT", "REGION", "POSTCODE", "ID"]; /** * One NAD row projected onto {@link NAD_SKELETON_COLUMNS}. */ export type NADSkeletonRow = Record<(typeof NAD_SKELETON_COLUMNS)[number], string>; /** * The unit identifier of a NAD row without its designator, as OpenAddresses' `UNIT` column mostly states it. * * NAD writes `APT 6`, `UNIT D` or a bare `200`; the recipes add their own designator in * front of the identifier, so the designator NAD wrote is dropped rather than doubled. */ export declare function nadUnitIdentifier(record: NADRecord): string; /** * Projects one NAD record onto the OpenAddresses columns, or returns null * when it lacks a house number, street, locality, state or five-digit ZIP. * * A street whose name NAD publishes in capitals is written wholly in capitals, * because NAD spells its structured types in title case (`East MAIN Street`) * and a recipe would otherwise teach that mixed case. */ export declare function nadSkeletonRow(record: NADRecord): NADSkeletonRow | null; /** * The address-shape measures for one state's usable NAD rows. */ export interface NADStateShape { region: string; /** * Rows with a house number, street, locality and five-digit ZIP. */ usable: number; unitShare: number; /** * Distinct `St_PosTyp` and `St_PreTyp` values. */ streetTypes: number; zips: number; /** * Share of rows whose street opens with a type, such as `County Road 12` or `Farm to Market 1960`. */ prefixTypeShare: number; numericNameShare: number; postDirectionalShare: number; ruralRouteShare: number; hyphenatedNumberShare: number; /** * Share of house numbers that open with a direction letter, as Wisconsin's `E2755` does. */ gridNumberShare: number; } export interface BuildNADSkeletonsOptions { /** * The release Parquet file `mailwoman corpus fetch nad` writes. */ parquetPath: PathBuilderLike; /** * The states to sample, as USPS abbreviations. */ states: readonly string[]; /** * The most rows any one state's sample keeps. */ cap: number; seed: number; zipCityCounties: readonly NADZipCityCounty[]; /** * Called after every millionth record with the count read so far. */ onProgress?: (recordsRead: number) => void; } export interface NADSkeletonSummary { /** * The records read from the release, usable or not. */ records: number; cap: number; seed: number; shapes: NADStateShape[]; samples: Array<{ region: string; rows: number; zip: string; csv: string; csvSHA256: string; }>; zipCity: Array<{ region: string; county: string; zips: number; path: string; sha256: string; }>; } /** * Reads every NAD record once, measures every state's address shapes, * keeps a uniform reservoir sample of at most `cap` rows for each requested state, * and tallies the majority city of each ZIP in each requested county. * * The sample is written in reservoir order rather than file order, so a reader that * takes the first N rows still draws across the whole state. * It refuses to replace a file that already exists. */ export declare function buildNADSkeletons(options: BuildNADSkeletonsOptions): Promise; /** * Writes the summary beside the skeletons it describes. */ export declare function writeNADSkeletonSummary(summary: NADSkeletonSummary, path: PathBuilderLike): Promise; //# sourceMappingURL=nad-skeletons.d.ts.map