import type { UnitSplitter } from "#adapters/street/unit"; import type { RegionNames } from "#build/region/names"; import type { CanonicalRow } from "#types"; /** * The rules a component value can fail, as the `:` tail of a `component-invalid` reason. */ export declare const ComponentRule: { /** * The postcode doesn't have the form the country's postcode syntax states. */ readonly PostcodeFormat: "postcode:format"; /** * The street ends in the row's own postcode. */ readonly StreetRepeatsPostcode: "street:repeats-postcode"; /** * The street ends in the row's own locality and region, and its postcode where the row has one. */ readonly StreetHoldsPlace: "street:holds-place"; /** * The locality holds the row's house number and street: the publisher filled * the city with the street line. */ readonly LocalityHoldsStreet: "locality:holds-street"; /** * The postcode is the row's own region (`1811 Hayes Avenue, Hull, IA IA`). */ readonly PostcodeRepeatsRegion: "postcode:repeats-region"; /** * The locality is the code the row's country writes for the row's own region * (`BELLVILLE, TX, TX 77418` read with `TX` as the city). */ readonly LocalityRepeatsRegion: "locality:repeats-region"; /** * The street still ends in a unit designator and identifier of the row's * country (`Avenue des Armieres Entree 13`). */ readonly StreetTrailingUnit: "street:trailing-unit"; /** * The region is no name or abbreviation of a region or macroregion of the row's country * in the WOF admin database, in a country where that database holds regions. */ readonly RegionUnknown: "region:unknown"; }; export type ComponentRule = (typeof ComponentRule)[keyof typeof ComponentRule]; /** * The rules a build quarantines a row for. * * `postcode:format` is reported but not enforced. * The v0.8.9 dry run (#2898) found 522,089 rows failing it, among them legitimate partial * postcodes (WOF's Dutch `3704`) and spaced written forms (`31 261` in Kraków), beside the defects * it is meant for (NAD's 425,667 short ZIP Codes and Overture Brazil's dropped leading zeros). * * `locality:repeats-region` is reported but not enforced, because a publisher's own `NY` for * New York City (`150 E 71 ST, NY, NY 10021`) fails it beside the rows whose city was lost. * * `street:trailing-unit` is reported but not enforced, because some streets end in a * word a country also writes as a unit (`Morning Side`, `Skijor Steppe Upper`). * * `region:unknown` is reported but not enforced, because neither source holds every * form addresses write: Swiss canton codes (`TG`), Latvia's post-2021 municipalities * (`Valmieras nov.`), Bangkok's short `กรุงเทพ`. */ export declare const ENFORCED_COMPONENT_RULES: ReadonlySet; /** * One rule a row fails, with the component values that fail it. */ export interface ComponentFinding { rule: ComponentRule; values: string[]; } /** * Rows failing each rule, per `source` then rule. */ export type ComponentFindingCounts = Map>; /** * {@linkcode ComponentFindingCounts} as a JSON object, in the order each source and rule was first counted. */ export declare function componentFindingsRecord(counts: ComponentFindingCounts): Record>; /** * The key under which a row's region value is counted: its country and the value as the row writes it. */ export declare function regionValueKey(country: string, region: string): string; /** * The `region:unknown` count of rows counted per {@linkcode regionValueKey}, under `regions`. * * It applies the rule's own test, so it equals the count an align under `regions` would write. */ export declare function countRegionUnknown(values: Iterable, regions: RegionNames): number; /** * What the rules read beyond the row. */ export interface ComponentCheckContext { /** * The unit vocabulary `street:trailing-unit` reads. * Without it the rule isn't checked. */ units?: UnitSplitter | null; /** * The WOF region names `region:unknown` reads. * Without them the rule isn't checked. */ regions?: RegionNames | null; /** * Answers already computed for a (country, value) pair, from {@linkcode createComponentCheckMemo}. * * A source repeats one postcode or region on every row of a place. * Each answer reads only the country and the value. */ memo?: ComponentCheckMemo | null; } /** * The postcode and region answers one aligner has computed, keyed by country and value. */ export interface ComponentCheckMemo { readonly postcodeRejected: Map; readonly regionUnknown: Map; } /** * An empty memo for one aligner. */ export declare function createComponentCheckMemo(): ComponentCheckMemo; /** * The rules `components` fails for a row of `country`, in rule order. */ export declare function componentFindings(components: CanonicalRow["components"], country: string, context?: ComponentCheckContext): ComponentFinding[]; //# sourceMappingURL=component-check.d.ts.map