import { type PathBuilderLike } from "path-ts"; import type { CanonicalRow } from "#types"; /** * The script most of `text`'s letters are written in, or `Other` when none * of {@link SCRIPTS} holds a letter. */ export declare function dominantScript(text: string): string; /** * The street-type forms a country's addresses use, each mapped to its canonical * spelling, and which lexicon supplied them. */ export interface StreetTypeLexicon { readonly forms: ReadonlyMap; /** * The libpostal languages read: the country's official languages that have a `street_types.txt`, * or `all` when none does and every language's list was read instead. */ readonly languages: readonly string[] | "all"; } /** * The libpostal street-type lexicon for `country`'s official languages. * * A country whose official languages have no libpostal list (Armenian, Uzbek, Kyrgyz) reads * every language's list, so a street written in a neighbor's language still counts its type. */ export declare function loadStreetTypeLexicon(country: string): Promise; /** * Returns the canonical street type encoded in the first or last one * or two words of a street name, or `null`. */ export declare function streetTypeOf(street: string, lexicon: StreetTypeLexicon): string | null; /** * What one row contributes to a variety census. */ export interface RowVariety { readonly locality: string; readonly dependentLocality: string | null; /** * The locality and the dependent locality together: the settlement a row is stratified by. */ readonly place: string; readonly postcode: string | null; readonly street: string | null; readonly streetType: string | null; readonly hasUnit: boolean; readonly hasDependentLocality: boolean; readonly hasVenue: boolean; readonly streetless: boolean; readonly script: string; /** * The components present, the street type and the script, joined: the row's form. */ readonly form: string; } /** * Reads one canonical row's variety keys. * * The locality is the row's `locality`, else its `dependent_locality`, else its `region`. * A streetless premise in a place with a name is stratified by that place. * * The place a row is stratified by joins the dependent locality to it, so an Estonian village is * its own place rather than one of its municipality's, and a city's districts are each their own. */ export declare function rowVariety(row: Pick, lexicon: StreetTypeLexicon): RowVariety; /** * The variety measures of a set of rows. */ export interface VarietyMeasures { rows: number; localities: number; dependentLocalities: number; /** * Distinct locality and dependent-locality pairs. */ places: number; postcodes: number; streets: number; streetTypes: number; forms: number; unitShare: number; dependentLocalityShare: number; venueShare: number; streetlessShare: number; postcodeShare: number; scripts: Record; /** * The share of rows in the largest locality, a measure of how concentrated the rows are. */ largestLocalityShare: number; } /** * Accumulates {@link VarietyMeasures} one row at a time. */ export declare class VarietyCensus { #private; add(variety: RowVariety): void; measures(): VarietyMeasures; } /** * The limits a variety sample is drawn under. */ export interface VarietySampleLimits { /** * The most rows kept from one street in one locality. */ perStreet: number; /** * The most rows kept from one place, a locality and dependent-locality pair. */ perPlace: number; /** * The most rows kept for the country. */ ceiling: number; seed: number; } /** * The selection key of one row: interned ids, so a country's rows fit in memory as integers. */ export interface SelectionKey { readonly place: number; readonly street: number; readonly form: number; readonly postcode: number; } /** * Chooses the row indices of a variety sample. * * Rows are visited in a seeded random order. * A street keeps its first {@link VarietySampleLimits.perStreet} rows. * * Within a place the kept rows are interleaved across forms, and within a form across postcodes, * and the first {@link VarietySampleLimits.perPlace} are the place's candidates. * Candidates are then taken by their rank within their place, lowest first, so every place supplies * its first row before any supplies its second, until {@link VarietySampleLimits.ceiling}. * The returned indices are ascending. */ export declare function selectVarietySample(keys: readonly SelectionKey[], limits: VarietySampleLimits): number[]; /** * What a variety-sample run read, wrote and measured. */ export interface VarietySampleReport { input: string; inputSHA256: string; output: string; outputSHA256: string; country: string; limits: VarietySampleLimits; streetTypeLanguages: readonly string[] | "all"; /** * Lines that didn't parse as a canonical row of the requested country. */ skipped: Record; full: VarietyMeasures; sample: VarietyMeasures; /** * The share of the full output's distinct values the sample keeps. */ coverage: { localities: number; places: number; postcodes: number; streetTypes: number; forms: number; }; } /** * Reads a complete adapter output, writes its variety sample to `output` and the * report beside it as `.variety.json`, and returns the report. * * The input is read twice, once to key every row and once to copy the chosen lines, * so memory holds integers per row rather than the rows themselves. */ export declare function writeVarietySample(options: { input: PathBuilderLike; output: PathBuilderLike; country: string; limits: VarietySampleLimits; }): Promise; //# sourceMappingURL=variety-sample.d.ts.map