import type { PathBuilderLike } from "path-ts"; import { type SubVenuePromotion } from "#subvenue/promotions"; import type { SubVenueLexiconTable } from "#subvenue/table"; import type { LocaleBaseTuple } from "#surfaces/locale"; /** * Resolves the path of the packaged sub-venue lexicon. */ export declare function defaultLexiconPath(): string; /** * Reads the sub-venue lexicon and throws on invalid JSON. */ export declare function readSubVenueLexicon(path?: string): Promise; /** * Reports whether a name has usable length and contains a letter. * It also rejects route punctuation. * * The check also rejects a single lowercase token because it represents a code in this source. */ export declare function isCleanName(name: string): boolean; /** * Reports whether a clean name can fill the venue slot. * * The check rejects names that start with a street or stop word or end with a street type. */ export declare function isVenueSlotName(name: string): boolean; /** * A designator phrase that may produce positives in one locale, with its shape constraints. */ export interface PromotedSurface { designatorID: string; phrase: string; /** * The title-cased form used when rendering the designator. */ surface: string; identifierRequired: boolean; modifierEligible: boolean; } /** * Reports whether a lowercased name contains the phrase at word boundaries. * * The boundary check keeps `gate` from matching inside `Briggate`. */ export declare function containsPhrase(lowerName: string, phrase: string): boolean; /** * Reports whether a value is a short sign identifier, such as `12`, `B` or `A3`, * or a range of two identifiers joined by `-` or `/`. * * Shape classification by itself accepts some values that this check rejects, so callers apply both. */ export declare function isSignIdentifier(value: string): boolean; /** * Reports whether a lowercased name uses a promoted phrase as ` `, * or as an English ` ` when the designator allows it. * * A bare mention of the phrase returns `false` because it doesn't show that the name is a sub-venue. */ export declare function hasPromotedShape(lowerName: string, promoted: PromotedSurface, modifiers?: readonly string[], english?: boolean): boolean; /** * Applies {@link hasPromotedShape} to names of at most four tokens. */ export declare function matchesPromotedShape(lowerName: string, promoted: PromotedSurface, modifiers?: readonly string[], english?: boolean): boolean; /** * Returns the designator surfaces that may produce `unit` positives in a locale. * * English locales get every shipped designator. * Every locale gets its promoted phrases. * * The function removes any pair that the ledger rejects for the locale. */ export declare function promotedSurfacesFor(locale: string, lexicon: SubVenueLexiconTable, promotions?: readonly SubVenuePromotion[]): PromotedSurface[]; /** * Returns the phrases that the promotion ledger rejects for a locale. */ export declare function rejectedPhrasesFor(locale: string, promotions?: readonly SubVenuePromotion[]): string[]; interface ShapeBucket { shape: string; observations: number; examples: string[]; } /** * One region's identifier shape distributions, per designator and pooled. */ export interface IdentifierModel { byDesignator: Map; pooled: ShapeBucket[]; } /** * Builds a region's identifier model from the lexicon's `identifierShapes`. * * The pooled fallback combines the airport gate, terminal and campus distributions. */ export declare function buildIdentifierModel(lexicon: SubVenueLexiconTable, region: string): IdentifierModel; /** * Samples an identifier for a designator, weighting shapes by observation count. * * A designator with fewer than 20 observations of its own uses the pooled distribution. */ export declare function sampleIdentifier(model: IdentifierModel, designatorID: string, random: () => number): string | null; /** * The publication a pooled name was read from. * * Each row records the sources of its names. * The two publications are licensed differently: OpenStreetMap under ODbL 1.0, * Overture Places under CDLA-Permissive-2.0. */ export declare const NameSource: { readonly OpenStreetMap: "openstreetmap"; readonly OverturePlaces: "overture-places"; }; export type NameSource = (typeof NameSource)[keyof typeof NameSource]; /** * A pooled name with the publication it was read from. * * A name both sources hold appears once per source, so its draw still records the pool it came from. */ export interface SourcedName { name: string; source: NameSource; } /** * The name pools that one source contributes to a recipe leg. * * Only OSM extracts fill `attested` and `unpromotedShapes`, because POI data has no tier or localized names. */ export interface NamePools { /** * Real venue-tier names that fit the venue slot, such as stations, airports, campuses and hospitals. */ venues: string[]; /** * Extract names of at most four tokens that use a promoted phrase in its required shape. */ attested: string[]; /** * Venue names that contain a phrase rejected for the locale. */ rejectedVenues: string[]; /** * Names that contain a designator inside a longer proper name, so the whole string is a `venue`. */ longerNames: string[]; /** * Venue names that contain a promoted phrase without its required shape. */ unpromotedShapes: string[]; } /** * The address context and name pools for one recipe leg. * * `attested` and `unpromotedShapes` hold OpenStreetMap names only, as {@linkcode NamePools} states. * The other three pools merge both sources and keep each name's source. */ export interface LegPools { context: LocaleBaseTuple[]; venues: SourcedName[]; attested: string[]; rejectedVenues: SourcedName[]; longerNames: SourcedName[]; unpromotedShapes: string[]; } /** * Empty name pools for a source that a leg lacks. */ export declare const EMPTY_NAME_POOLS: NamePools; /** * The locale-specific filters that the pool readers apply. */ export interface PoolQuery { promoted: readonly PromotedSurface[]; rejectedPhrases: readonly string[]; designatorPhrases: readonly string[]; modifiers: readonly string[]; english: boolean; } /** * Reads an OSM sub-venue extract and sorts its names into name pools. */ export declare function readExtractPools(path: string, query: PoolQuery): Promise; /** * Reads the venue and confound name pools for one country from the Overture place-names file. * * That file holds `name`, `category` and `country` for every country the release covers. * * The venue categories fill the `venues` pool. * Every row of a venue or confound category is tested against the rejected phrases * and the designator phrases, as the OSM extracts are. */ export declare function readOvertureNamePools(venueNames: PathBuilderLike, country: string, query: PoolQuery): Promise; /** * Concatenates an OpenStreetMap extract's pools and the Overture Places pools, * OpenStreetMap first, and tags each merged name with its source. * * The order and length of every pool match a plain concatenation, so a seeded run * draws the same names as one that recorded no source. */ export declare function mergeNamePools(osm: NamePools, overture: NamePools): Omit; export {}; //# sourceMappingURL=sources.d.ts.map