/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * @file Builds the sub-venue designator lexicon from Wikidata, OSM and Overture fetch outputs. */ import { type PathBuilderLike } from "path-ts"; import { type SubVenueHarvestRow } from "#subvenue/harvest"; import { type SubVenuePromotion } from "#subvenue/promotions"; import { type SubVenueLexiconSource, type SubVenueLexiconTable, type SubVenueSurface } from "#subvenue/table"; export * from "#subvenue/harvest"; export * from "#tools/sub/venue/head-nouns"; export * from "#subvenue/surfaces"; export * from "#subvenue/table"; export * from "#tools/sub/venue/wikidata"; /** * Returns a copy of the surfaces with `curated: true` set on each surface that a promotion matches. * * A promotion matches a surface with the same record id and phrase whose language * is the promotion's language or `und`. * An extract surface must also come from the promotion's region. * * A surface without a region, such as a Wikidata label, matches only when no rejection * exists for the same designator, phrase and language in any region. * For example, `pier` is promoted for en-GB and rejected for en-US, * so the region-free English `pier` stays uncurated. * * Rejections never mark a surface. * They stay in the table as a record of the decision. */ export declare function applyPromotions(surfaces: readonly SubVenueSurface[], promotions: readonly SubVenuePromotion[]): SubVenueSurface[]; /** * One harvest input with the source and region stamped on its surfaces. */ export interface SubVenueHarvest { rows: readonly SubVenueHarvestRow[]; source?: string; region?: string; } /** * The parsed inputs of {@link buildSubVenueLexicon}, which never reads the filesystem. */ export interface BuildSubVenueLexiconInput { /** * The raw `designator-labels.json` SPARQL response, or `null` to build the seed-only table. */ wikidata: unknown | null; /** * The harvest inputs in contribution order. * * Each harvest can match only phrases that exist before it runs, including those from earlier harvests. */ harvests: readonly SubVenueHarvest[]; /** * Provenance rows that the caller copies from the fetch manifests. */ sources: readonly SubVenueLexiconSource[]; /** * Defaults to {@link SUBVENUE_PROMOTIONS}. * * An empty array builds the uncurated table. */ promotions?: readonly SubVenuePromotion[]; } /** * Builds the lexicon table deterministically, so identical inputs produce identical output. * * Three ordering rules apply: * * 1. Seed surfaces come first, so `terminal` indexes to the `terminal` designator * instead of a Wikidata alias. * 2. Head nouns are derived after Wikidata and before the harvests, because a harvest * can find only phrases such as `ターミナル` that already exist as surfaces. * 3. Promotions apply last, so they can curate a surface from any source. */ export declare function buildSubVenueLexicon(input: BuildSubVenueLexiconInput): SubVenueLexiconTable; /** * Serializes the table as pretty-printed JSON. * * Run `oxfmt` over the written file before committing, because committed JSON must match oxfmt's output. */ export declare function serializeSubVenueLexicon(table: SubVenueLexiconTable): string; /** * One OSM extract to harvest, with the ISO country code of its rows. */ export interface SubVenueExtractInput { path: string; region: string; } /** * Options for {@link generateSubVenueLexicon}. */ export interface GenerateSubVenueLexiconOptions { /** * The output directory of `mailwoman corpus fetch wikidata-subvenue`. * * Without it, the function builds the seed-only table. */ wikidataDir?: PathBuilderLike; /** * OSM extract JSONL files, one per region. */ extracts?: readonly SubVenueExtractInput[]; /** * Overture rows that the caller already read with `readOvertureSubVenues`. * * The caller opens `poi.db`, so this function does not depend on the database. */ overtureRows?: readonly (SubVenueHarvestRow & { country: string; })[]; /** * The `poi.db` layer vintage. * The builder uses it only when `overtureRows` is non-empty. */ overtureVintage?: string; /** * The path of the written table. */ outPath: string; } /** * Reads the fetch outputs, builds the table with {@link buildSubVenueLexicon}, and writes it. * * Run `oxfmt` over `outPath` afterwards, because committed JSON must match oxfmt's output. */ export declare function generateSubVenueLexicon(options: GenerateSubVenueLexiconOptions): Promise; //# sourceMappingURL=lexicon.d.ts.map