/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * `wof-admin`: Who's On First admin GeoJSON-bundle adapter. * * **Phase 1.5.1 pivot.** The original Phase 1.5 SQLite adapter (formerly at * `packages/corpus/src/adapters/wof-admin/`, removed in this same change) was replaced by this * one because the SQLite distribution path was unworkable for the real corpus build: * * 1. `dist.whosonfirst.org/sqlite/` is dead (NXDOMAIN); the Geocode-Earth mirror is the only one. * 2. The Geocode-Earth-hosted postalcode DB tags every row `mz:is_current = -1` ("unknown but treated * as active"); the SQLite adapter's `is_current = 1` predicate emitted zero rows. * 3. The `names` table in the SQLite distribution is empty — localized `name:*` variants live in a * separate distribution. The St. Petersburg / Mt. Vernon / Ft. Lauderdale alternation cases * (the original Phase 1.5.1 motivator) cannot be solved on the SQLite path even with a * patched `is_current` predicate. * * Input: a directory containing one or more cloned `whosonfirst-data-admin-` GitHub repos. Each * repo has `data/XXX/YYY/ZZZ/.geojson` files; `**\/*.geojson` walks the tree recursively. * Alternate-geometry siblings (`-alt-*`) are skipped — they're separate exports of the same * record, not new records. * * Per record, the adapter emits one row per `(name-variant, hierarchy-variant)` pair: * * - **Name variants**: the canonical `wof:name` (slot key `default`) plus every `name:*` localized * variant present on the feature (`name:eng_x_preferred`, `name:eng_x_colloquial`, * `name:rus_x_preferred`, ...). This is the Phase 1.5.1 fix for the St. Petersburg case: * `"Saint Petersburg"` (canonical) and `"St. Petersburg"` (eng_x_colloquial) both become * training rows for the same WOF id. * - **Hierarchy variants** (unchanged from the SQLite adapter): locality → 3 variants, region → 2, * country → 1, county → 1. * * `source_id` is `wof-admin---`. The previous SQLite adapter * used `wof-admin--` (no name slot); the new format adds a name-slot * segment so the colloquial / preferred / per-locale variants survive dedup independently. * * License: CC0. The adapter stamps every row with `CC0-1.0`. */ import type { ComponentTag } from "@mailwoman/core/types"; import type { CorpusAdapter } from "@mailwoman/corpus/types"; import { type WOFRecord } from "@mailwoman/corpus/utils"; interface VariantSpec { /** * Hierarchy-variant id appended to `source_id`. */ suffix: string; /** * Component tag → display string the adapter will hand to the runner. */ components: Partial>; } /** * Compute the hierarchy variants for a record given its ancestry chain and the chosen `selfName`. * * `selfName` is the surface form to use for the record's own component (locality / region / country / subregion). * Callers pass the canonical `wof:name` for the `"default"` slot and a `name:*` localized value for variant slots; * ancestor names always come from the ancestor's canonical `wof:name`. * * Country variants substitute `COUNTRY_DISPLAY_NAME` for the default slot so the OpenCage template produces the * canonicalized form (`"United States of America"`), matching the legacy SQLite adapter's behavior. */ export declare function variantsFor(row: WOFRecord, ancestry: WOFRecord[], selfName: string): VariantSpec[]; /** * Build the per-record name-slot list. The canonical `"default"` slot uses the OpenCage-canonical country form when the * record is itself a country (matches SQLite-adapter behavior); every other placetype's default slot uses `wof:name` * verbatim. * * Subsequent slots come from `name:*` variants, deduplicated against the default name so we don't emit a redundant * `"default"`-equivalent row under a localized key. */ export declare function nameSlotsFor(rec: WOFRecord): Array<{ key: string; value: string; }>; /** * Registry id for this adapter. Stamped into every row it emits, so a corpus record can be traced back to the dataset * it came from. */ export declare const WOF_ADMIN_ADAPTER_ID = "wof-admin"; /** * Construct the wof-admin JSON-bundle adapter. The adapter is stateless across runs; calling this twice with the same * input directory produces byte-identical `canonical.jsonl` (records are emitted in sorted `wof:id` order to be * insensitive to filesystem walk ordering). */ export declare function createWOFAdminAdapter(): CorpusAdapter; /** * Single shared instance, suitable for `defaultAdapterRegistry`. */ export declare const wofAdminAdapter: CorpusAdapter; export {}; //# sourceMappingURL=adapter.d.ts.map