import type { StreetLocalityEvidence } from "@mailwoman/resolver"; /** * The words a country writes a unit with, and the street-type words that end its streets. */ export interface UnitVocabulary { country: string; /** * Designators written before their identifier (`Bat B`, `STE 302`, `# 190`), * folded by `foldDesignatorSpelling`. */ prefix: ReadonlySet; /** * The prefix designators the country lets stand with no identifier (`OFFICE`, `LOWER`, `REAR`), * from its designator table's `identifierOptional` rows. */ bare?: ReadonlySet; /** * Designators written after their identifier with no space (`2楼`, `305号室`). */ suffix: ReadonlySet; /** * Street-type words in the country's official and regional languages, * lower-cased (`street`, `rd`, `avenida`, `路`). */ streetTypes: ReadonlySet; /** * Function words in the country's official and regional languages, lower-cased (`de`, `la`, `of`). * * A street name ends in none of them, so `Chemin de la` reads as an incomplete street name. */ stopwords?: ReadonlySet; /** * One-word directionals in the country's official languages, lower-cased (`n`, `sw`, `west`), * which can follow a street's type word or number (`HIGHWAY 6 N`, `CROWN RD SW`). */ directionals: ReadonlySet; /** * Where the vocabulary came from: the country's codex designator table, * or libpostal's dictionaries for its official languages. */ origin: "codex" | "libpostal" | "none"; } /** * A unit split off a street. */ export interface TrailingUnitSplit { street: string; unit: string; /** * Which test confirmed that the remainder is still a street: it ends in a street-type word, * it ends in a number, or the street index holds it. */ admittedBy: "street-word" | "number" | "attested"; } /** * The context one split reads. */ export interface TrailingUnitContext { vocabulary: UnitVocabulary; /** * The street index of the country's premise registers. * * Without it, a remainder is confirmed only by a street-type word or a number. */ evidence?: StreetLocalityEvidence | null; locality?: string; postcode?: string; } /** * The unit vocabulary for `country`, read once per process. * * The country's codex designator table supplies it where one exists. * Every other country reads libpostal's unit, floor, entrance, staircase * and building words for its official languages (`OFFICIAL_LANGUAGES`), * so every country gets the same treatment from the same rule. * * A designator row marked `partOfStreetLine` is left out, so the splitter keeps it in the street. */ export declare function unitVocabularyFor(country: string): Promise; /** * The place a street line belongs to. * * Its locality and postcode scope a street-index probe. */ export interface StreetPlace { country: string; locality?: string; postcode?: string; } /** * Splits units off street lines for every country, synchronously, after * {@linkcode createUnitSplitter} has read each country's vocabulary. */ export interface UnitSplitter { split(street: string, place: StreetPlace): TrailingUnitSplit | null; /** * The unit designator and identifier `street` ends in, in the words of the place's country, * whether or not the remainder passes the street test {@linkcode UnitSplitter.split} applies. * * @returns `null` when the street ends in no unit the country's vocabulary writes. */ trailingUnit(street: string, place: StreetPlace): { street: string; unit: string; } | null; /** * The loaded street-type, directional, and unit vocabulary for `country`, or `null` when none was loaded. */ vocabulary(country: string): UnitVocabulary | null; } export interface CreateUnitSplitterOptions { /** * The street index for the premise registers, built by `#tools/street-index/build`. * * Without it, a remainder is confirmed only by a street-type word or a number. */ streetIndex?: StreetIndexOpener | null; } /** * Opens the street index for one country, or returns `null` where it holds none. */ export type StreetIndexOpener = (country: string) => StreetLocalityEvidence | null; /** * A splitter over every country codex or `OFFICIAL_LANGUAGES` lists. */ export declare function createUnitSplitter(options?: CreateUnitSplitterOptions): Promise; /** * Splits a unit off the end of `street` when two tests hold. * * The street's last words are a unit designator from the row's country's vocabulary and an identifier * (`du General Charles de Gaulle Bat B`, `LAWRENCE EXPY # 190`, `MAIN ST. RM203`, `武定路1101弄2楼`). * What remains still reads as a street: it ends in a street-type word or a number, * or the street index of the country's premise registers holds it. * * `Chemin de la Tour D` therefore keeps its `Tour D`: `Chemin de la` ends in neither, * and no register publishes it. * * A designator that opens the street (`PIER 39`, `Tour Eiffel`) keeps it. * A line ending in two units (`ROSS AVE. BLDG2 SUITE207B`) yields both as one unit, in the order written. * * @returns `null` when the street ends in no unit the tests confirm. */ export declare function splitTrailingUnit(street: string, context: TrailingUnitContext): TrailingUnitSplit | null; //# sourceMappingURL=unit.d.ts.map