@mailwoman/resolver 9.0.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -0
- package/admin-coherence-passes.ts +435 -0
- package/admin-containment.ts +101 -0
- package/admin-winner.ts +178 -0
- package/backend-capabilities.ts +88 -0
- package/bare-toponym-race.ts +129 -0
- package/decorate-node.ts +127 -0
- package/fold-name.ts +19 -3
- package/index.ts +14 -0
- package/out/admin-coherence-passes.d.ts +70 -0
- package/out/admin-coherence-passes.d.ts.map +1 -0
- package/out/admin-coherence-passes.js +327 -0
- package/out/admin-coherence-passes.js.map +1 -0
- package/out/admin-containment.d.ts +48 -0
- package/out/admin-containment.d.ts.map +1 -0
- package/out/admin-containment.js +82 -0
- package/out/admin-containment.js.map +1 -0
- package/out/admin-winner.d.ts +109 -0
- package/out/admin-winner.d.ts.map +1 -0
- package/out/admin-winner.js +119 -0
- package/out/admin-winner.js.map +1 -0
- package/out/backend-capabilities.d.ts +37 -0
- package/out/backend-capabilities.d.ts.map +1 -0
- package/out/backend-capabilities.js +75 -0
- package/out/backend-capabilities.js.map +1 -0
- package/out/bare-toponym-race.d.ts +55 -0
- package/out/bare-toponym-race.d.ts.map +1 -0
- package/out/bare-toponym-race.js +110 -0
- package/out/bare-toponym-race.js.map +1 -0
- package/out/decorate-node.d.ts +24 -0
- package/out/decorate-node.d.ts.map +1 -0
- package/out/decorate-node.js +103 -0
- package/out/decorate-node.js.map +1 -0
- package/out/fold-name.d.ts +18 -3
- package/out/fold-name.d.ts.map +1 -1
- package/out/fold-name.js +19 -3
- package/out/fold-name.js.map +1 -1
- package/out/index.d.ts +4 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/postcode-country-coherence.d.ts +91 -14
- package/out/postcode-country-coherence.d.ts.map +1 -1
- package/out/postcode-country-coherence.js +279 -42
- package/out/postcode-country-coherence.js.map +1 -1
- package/out/postcode-prefix.d.ts +101 -0
- package/out/postcode-prefix.d.ts.map +1 -0
- package/out/postcode-prefix.js +125 -0
- package/out/postcode-prefix.js.map +1 -0
- package/out/postcode-shape-coherence.d.ts +113 -0
- package/out/postcode-shape-coherence.d.ts.map +1 -0
- package/out/postcode-shape-coherence.js +193 -0
- package/out/postcode-shape-coherence.js.map +1 -0
- package/out/resolve.d.ts +1 -1
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +592 -410
- package/out/resolve.js.map +1 -1
- package/out/span-rescore.d.ts +28 -0
- package/out/span-rescore.d.ts.map +1 -1
- package/out/span-rescore.js +151 -17
- package/out/span-rescore.js.map +1 -1
- package/out/street-evidence.js +1 -1
- package/out/street-evidence.js.map +1 -1
- package/out/street-tier.d.ts.map +1 -1
- package/out/street-tier.js +28 -5
- package/out/street-tier.js.map +1 -1
- package/out/toponym-prior.d.ts +139 -0
- package/out/toponym-prior.d.ts.map +1 -0
- package/out/toponym-prior.js +308 -0
- package/out/toponym-prior.js.map +1 -0
- package/package.json +98 -7
- package/postcode-country-coherence.ts +355 -50
- package/postcode-prefix.ts +166 -0
- package/postcode-shape-coherence.ts +248 -0
- package/resolve.ts +809 -527
- package/span-rescore.ts +206 -19
- package/street-evidence.ts +1 -1
- package/street-tier.ts +31 -5
- package/toponym-prior.ts +367 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The three post-walk admin coherence passes (#263 / #822 / the region-country pass) — split from
|
|
7
|
+
* `resolve.ts` on the `bare-toponym-race.ts` precedent: the walk file holds the walk, this one
|
|
8
|
+
* holds the joint-consistency re-picks that run after it. Each pass's contract, triggers, and
|
|
9
|
+
* byte-stability guarantees are documented on the pass itself; `resolveTree` sequences them.
|
|
10
|
+
*/
|
|
11
|
+
import { matchCountry, matchSubdivision } from "@mailwoman/codex/country";
|
|
12
|
+
import { decorateNode, isResolvedWithCoord } from "./decorate-node.js";
|
|
13
|
+
/**
|
|
14
|
+
* Admin descendant-consistency (#263) — the joint-consistency resolve, scoped to the admin assignment. The greedy walk
|
|
15
|
+
* resolves a region on its own (name + population), so "ME" picks Messina (IT) over Maine, then scopes "Portland" to
|
|
16
|
+
* Messina's descendants, finds nothing, and the result falls back to the region centroid (Sicily). The region's
|
|
17
|
+
* same-named runner-ups (Maine, Missouri, …) were already captured as `alternatives`; this pass asks the question the
|
|
18
|
+
* greedy order skipped — _which "ME" has a "Portland" under it?_ — and re-picks the (region, locality) pair where a
|
|
19
|
+
* same-named locality descends from a same-named region candidate. Geography decides; no country prior, no list.
|
|
20
|
+
*
|
|
21
|
+
* Fires ONLY for a resolved region whose child locality fell through (the unresolved-locality signal), so a
|
|
22
|
+
* well-resolved tree ("Springfield, IL" → Illinois, Springfield) is byte-identical. Costs one unscoped locality lookup
|
|
23
|
+
* per triggering pair. Needs {@link ResolverBackend.ancestors}; no-op without it. See `ResolveOpts.adminCoherence`.
|
|
24
|
+
*/
|
|
25
|
+
export async function applyAdminCoherence(roots, backend) {
|
|
26
|
+
const visit = async (node, regionAncestor) => {
|
|
27
|
+
const regionHere = node.tag === "region" && isResolvedWithCoord(node) ? node : regionAncestor;
|
|
28
|
+
if (regionHere &&
|
|
29
|
+
(node.tag === "locality" || node.tag === "dependent_locality") &&
|
|
30
|
+
!isResolvedWithCoord(node) &&
|
|
31
|
+
node.value.trim().length) {
|
|
32
|
+
await reconcileAdminPair(regionHere, node, backend);
|
|
33
|
+
}
|
|
34
|
+
for (const child of node.children) {
|
|
35
|
+
await visit(child, regionHere);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
for (const root of roots) {
|
|
39
|
+
await visit(root, null);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Re-pick a (region, locality) pair so the locality descends from the region. `alternatives` on the node are the
|
|
44
|
+
* `ResolvedPlace` runner-ups `decorateNode` attached (typed `unknown[]` in the decoder, which can't import resolver
|
|
45
|
+
* types — the cast is sound). Picks the FIRST same-named locality (already score-ordered) that descends from a
|
|
46
|
+
* same-named region candidate, then swaps both nodes. Leaves both untouched when no consistent pair exists (a genuinely
|
|
47
|
+
* un-gazetteered locality — "Portland, VT" with no Portland in Vermont — stays as the region centroid, not a foreign
|
|
48
|
+
* namesake).
|
|
49
|
+
*/
|
|
50
|
+
async function reconcileAdminPair(regionNode, localityNode, backend) {
|
|
51
|
+
// EXACT region matches only: the alternatives for a 2-letter token are loose ("ME" also surfaces
|
|
52
|
+
// Missouri/Michigan/Mississippi as fuzzy M-state runner-ups). Restricting to exact name/alias matches
|
|
53
|
+
// (Maine/Messina/Medway for "ME") keeps the join honest. `exactMatch` is stamped by exactMatchTiering.
|
|
54
|
+
const regionCands = (regionNode.alternatives ?? []).filter((r) => r.exactMatch);
|
|
55
|
+
// For each exact region candidate, ask the gazetteer directly: is there a same-named locality UNDER it?
|
|
56
|
+
// The `parentID` scope is the descendant test (over the #832-repaired ancestors table), and it finds the
|
|
57
|
+
// instance regardless of its global population rank — "Springfield, ME" reaches the small Springfield in
|
|
58
|
+
// Maine that an unscoped top-N window would drop. First region with an exact-named descendant wins; the
|
|
59
|
+
// region candidates are score-ordered, so a tie breaks toward the more prominent place.
|
|
60
|
+
for (const region of regionCands) {
|
|
61
|
+
const scoped = await backend.findPlace({
|
|
62
|
+
text: localityNode.value,
|
|
63
|
+
placetype: "locality",
|
|
64
|
+
parentID: region.id,
|
|
65
|
+
limit: 3,
|
|
66
|
+
});
|
|
67
|
+
const lc = scoped.find((l) => l.exactMatch && !(l.lat === 0 && l.lon === 0));
|
|
68
|
+
if (lc) {
|
|
69
|
+
decorateNode(regionNode, region, regionCands.filter((r) => r !== region));
|
|
70
|
+
regionNode.metadata = { ...regionNode.metadata, admin_coherence_repicked: true };
|
|
71
|
+
decorateNode(localityNode, lc, scoped.filter((l) => l !== lc));
|
|
72
|
+
localityNode.metadata = { ...localityNode.metadata, admin_coherence_repicked: true };
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// #267 follow-up: the token may name a COUNTRY whose namesake is a more-populous foreign region — "Tbilisi,
|
|
77
|
+
// Georgia" parses region("Georgia") → the US state, but Tbilisi descends from Georgia the COUNTRY. When no
|
|
78
|
+
// region candidate holds the locality, try same-named country candidates: a foreign capital under its
|
|
79
|
+
// country out-votes the state namesake. Needs the country + the locality's ancestry in the gazetteer (the
|
|
80
|
+
// #267 admin fold). The re-picked region node then carries the country place; the locality coordinate wins.
|
|
81
|
+
const countryCands = (await backend.findPlace({ text: regionNode.value, placetype: "country", limit: 3 })).filter((c) => c.exactMatch);
|
|
82
|
+
for (const country of countryCands) {
|
|
83
|
+
const scoped = await backend.findPlace({
|
|
84
|
+
text: localityNode.value,
|
|
85
|
+
placetype: "locality",
|
|
86
|
+
parentID: country.id,
|
|
87
|
+
limit: 3,
|
|
88
|
+
});
|
|
89
|
+
const lc = scoped.find((l) => l.exactMatch && !(l.lat === 0 && l.lon === 0));
|
|
90
|
+
if (lc) {
|
|
91
|
+
decorateNode(regionNode, country, regionCands);
|
|
92
|
+
regionNode.metadata = { ...regionNode.metadata, admin_coherence_repicked: true };
|
|
93
|
+
decorateNode(localityNode, lc, scoped.filter((l) => l !== lc));
|
|
94
|
+
localityNode.metadata = { ...localityNode.metadata, admin_coherence_repicked: true };
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// #1023: the admin gazetteer may carry NO `country`-placetype node for the token AND the same-named
|
|
99
|
+
// foreign locality may be ORPHANED (parent_id = -1) — the 2026-07-07 rebuild flattened Georgia's admin
|
|
100
|
+
// hierarchy to localities-only, so the country-node lookup above finds nothing and the `parentID`
|
|
101
|
+
// descendant test can never reach Tbilisi. Fall back to matchCountry: normalize the token to an
|
|
102
|
+
// ISO-3166 alpha-2 and scope the locality by the gazetteer's `country` COLUMN (set even on an orphaned
|
|
103
|
+
// row). Same primitive reconcileExplicitCountry (#822) uses, so the region-parsed namesake path
|
|
104
|
+
// ("Tbilisi, Georgia") converges with the country-parsed one ("Vienna, Austria"). matchCountry returns
|
|
105
|
+
// null for a US state name/abbrev ("Illinois" / "ME" / "IL"), so a real US (region, locality) pair
|
|
106
|
+
// never reaches here — this stays inert on the domestic path.
|
|
107
|
+
const mc = matchCountry(regionNode.value);
|
|
108
|
+
if (mc) {
|
|
109
|
+
const scoped = await backend.findPlace({
|
|
110
|
+
text: localityNode.value,
|
|
111
|
+
placetype: "locality",
|
|
112
|
+
country: mc.iso2,
|
|
113
|
+
limit: 3,
|
|
114
|
+
});
|
|
115
|
+
const lc = scoped.find((l) => l.exactMatch && !(l.lat === 0 && l.lon === 0));
|
|
116
|
+
if (lc) {
|
|
117
|
+
decorateNode(localityNode, lc, scoped.filter((l) => l !== lc));
|
|
118
|
+
localityNode.metadata = { ...localityNode.metadata, admin_coherence_repicked: true };
|
|
119
|
+
// The token named a foreign country the admin gazetteer has no node for, but the greedy walk had
|
|
120
|
+
// already decorated the region node with the US-state namesake. Revert that stale decoration so the
|
|
121
|
+
// node stops asserting the wrong-country coordinate + `resolver_country` (which would otherwise leak
|
|
122
|
+
// into the result's `countryCode`); the re-picked locality carries the winning coordinate, and the
|
|
123
|
+
// region node falls back to the parsed "Georgia" token, unresolved (the admin DB has nothing truer).
|
|
124
|
+
revertResolverDecoration(regionNode);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Undo a resolver decoration on a node: restore the classifier attribution {@link decorateNode} displaced into
|
|
130
|
+
* `metadata.classifier_source(_id)` and drop the resolver-supplied coordinate/identity/alternatives. Used by the #1023
|
|
131
|
+
* country fall-through when the region token turns out to name a foreign country the admin gazetteer holds no node for
|
|
132
|
+
* — the greedy walk had bound it to the US-state namesake, and that stale claim must not survive the locality re-pick.
|
|
133
|
+
*/
|
|
134
|
+
function revertResolverDecoration(node) {
|
|
135
|
+
const meta = { ...node.metadata };
|
|
136
|
+
const priorSource = meta["classifier_source"];
|
|
137
|
+
const priorSourceID = meta["classifier_source_id"];
|
|
138
|
+
node.source = typeof priorSource === "string" ? priorSource : undefined;
|
|
139
|
+
node.sourceID = typeof priorSourceID === "string" ? priorSourceID : undefined;
|
|
140
|
+
for (const key of [
|
|
141
|
+
"classifier_source",
|
|
142
|
+
"classifier_source_id",
|
|
143
|
+
"resolver_score",
|
|
144
|
+
"resolver_prominence",
|
|
145
|
+
"resolver_name",
|
|
146
|
+
"resolver_country",
|
|
147
|
+
"resolution_quality",
|
|
148
|
+
"postcode_city_mismatch",
|
|
149
|
+
]) {
|
|
150
|
+
// oxlint-disable-next-line typescript/no-dynamic-delete -- removing one key from a plain record; the object is not on a hot path
|
|
151
|
+
delete meta[key];
|
|
152
|
+
}
|
|
153
|
+
node.metadata = meta;
|
|
154
|
+
node.lat = undefined;
|
|
155
|
+
node.lon = undefined;
|
|
156
|
+
node.placeID = undefined;
|
|
157
|
+
node.alternatives = undefined;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Explicit-country coherence (#822) — the joint-consistency resolve keyed on the query's own EXPLICIT country token.
|
|
161
|
+
* The greedy walk resolves a locality on name + population alone, so "Vienna, Austria" picks the populous US namesake
|
|
162
|
+
* (Vienna WV) and IGNORES the "Austria" the address named. This pass asks the question the greedy order skipped —
|
|
163
|
+
* _which "Vienna" is in the country the address names?_ — and re-picks the locality to the same-named place under that
|
|
164
|
+
* country. The country code comes from the parser's OWN `country` emission via codex's ISO-3166 table (a name→code
|
|
165
|
+
* normalization of a token the model already classified, NOT a routing prior or safelist); the gazetteer's `country`
|
|
166
|
+
* column does the geographic confirmation. No pin, no list; generalizes to every country.
|
|
167
|
+
*
|
|
168
|
+
* Disjoint from {@link applyAdminCoherence} by the region guard: that pass owns the case where a REGION scopes the
|
|
169
|
+
* locality; this one fires only when the explicit country is the locality's nearest admin context (no region between),
|
|
170
|
+
* and then regardless of the locality's resolution state — so it covers both the resolved-but-foreign locality (Sydney
|
|
171
|
+
* → the greedy AU pick was wrong) and the unresolved locality the span-rescore tier would otherwise back-fill with the
|
|
172
|
+
* US namesake (Vienna → Vienna WV). Byte-stable when the locality already resolved in-country (the id guard) or the
|
|
173
|
+
* named country holds no same-named locality (the fail-safe — what also protects "Turkey, TX": no country token ⇒ no
|
|
174
|
+
* trigger; and an in-country lookup that finds nothing keeps the greedy result). Costs one country-scoped locality
|
|
175
|
+
* lookup per triggering pair. See `ResolveOpts.adminCoherence`.
|
|
176
|
+
*/
|
|
177
|
+
export async function applyExplicitCountryCoherence(roots, backend) {
|
|
178
|
+
const visit = async (node, countryToken, regionAbove) => {
|
|
179
|
+
const countryHere = node.tag === "country" && node.value.trim().length ? node : countryToken;
|
|
180
|
+
// A region suppresses the country re-pick only when it RESOLVED: the suppression's rationale is
|
|
181
|
+
// that applyAdminCoherence + the region's `parentID` scope already disambiguate the locality
|
|
182
|
+
// ("Springfield, IL" must not re-pick to the most populous US Springfield), and an UNRESOLVED
|
|
183
|
+
// region disambiguates nothing — 'NIC-38' (an ISO-3166-2 code the gazetteer holds no node for)
|
|
184
|
+
// silently swallowed the explicit 'Nicaragua', and El Sauce resolved a US namesake. This pass
|
|
185
|
+
// runs post-walk, so resolution state is known.
|
|
186
|
+
const regionHere = regionAbove || ((node.tag === "region" || node.tag === "subregion") && isResolvedWithCoord(node));
|
|
187
|
+
// Fire only when the explicit country is the locality's NEAREST RESOLVED admin context.
|
|
188
|
+
// Fires regardless of the locality's resolution state, so it PRE-EMPTS the span-rescore tier
|
|
189
|
+
// (which would otherwise back-fill the unresolved locality with the US namesake).
|
|
190
|
+
if (countryHere && !regionHere && (node.tag === "locality" || node.tag === "dependent_locality")) {
|
|
191
|
+
await reconcileExplicitCountry(countryHere, node, backend);
|
|
192
|
+
}
|
|
193
|
+
for (const child of node.children) {
|
|
194
|
+
await visit(child, countryHere, regionHere);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
for (const root of roots) {
|
|
198
|
+
await visit(root, null, false);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Re-pick a resolved locality to its same-named place UNDER the explicitly-named country. `matchCountry` turns the
|
|
203
|
+
* country token into an ISO-3166 alpha-2 (returns null for an unrecognized token → no-op); the backend then surfaces
|
|
204
|
+
* the in-country namesake the population-first unscoped window buried. Leaves the node untouched when the country is
|
|
205
|
+
* unrecognized, the named country has no exact same-named locality (the fail-safe), or the locality already resolved to
|
|
206
|
+
* that place (the id guard → byte-stable). The country node itself stays as the parser emitted it — the named
|
|
207
|
+
* well-covered countries carry no `country`-placetype row in the admin gazetteer, so there is nothing to decorate it
|
|
208
|
+
* with; the locality coordinate is what the re-pick fixes.
|
|
209
|
+
*/
|
|
210
|
+
async function reconcileExplicitCountry(countryNode, localityNode, backend) {
|
|
211
|
+
const mc = matchCountry(countryNode.value);
|
|
212
|
+
if (!mc)
|
|
213
|
+
return;
|
|
214
|
+
const scoped = await backend.findPlace({
|
|
215
|
+
text: localityNode.value,
|
|
216
|
+
placetype: "locality",
|
|
217
|
+
country: mc.iso2,
|
|
218
|
+
limit: 3,
|
|
219
|
+
});
|
|
220
|
+
const lc = scoped.find((l) => l.exactMatch && !(l.lat === 0 && l.lon === 0));
|
|
221
|
+
if (!lc)
|
|
222
|
+
return;
|
|
223
|
+
// Already the in-country place? (placeID encodes the WOF id.) Then the greedy walk was right — byte-stable.
|
|
224
|
+
if (localityNode.placeID === `wof:${lc.id}`)
|
|
225
|
+
return;
|
|
226
|
+
decorateNode(localityNode, lc, scoped.filter((l) => l !== lc));
|
|
227
|
+
localityNode.metadata = { ...localityNode.metadata, explicit_country_repicked: true };
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Region-country coherence — the joint-consistency resolve keyed on a REGION token the locale-inferred default-country
|
|
231
|
+
* filter could not resolve. Companion to {@link applyExplicitCountryCoherence} (which keys on an explicit COUNTRY token)
|
|
232
|
+
* and disjoint from {@link applyAdminCoherence} (which needs a region that DID resolve): this pass owns the mirror case,
|
|
233
|
+
* where the region qualifier is a foreign subdivision the default-country hard filter (`spr.country = ?`) discarded.
|
|
234
|
+
*
|
|
235
|
+
* "Montreal QC" under a US locale: the walk applies `defaultCountry="US"` as a hard candidate filter to every admin
|
|
236
|
+
* lookup, so the region "QC" (a Canadian subdivision) resolves to nothing and is dropped — the one signal that would
|
|
237
|
+
* redirect the country to CA — and the locality "Montreal" is force-matched to the populous US namesake (Montreal, WI).
|
|
238
|
+
* The greedy order threw away the evidence that could correct it.
|
|
239
|
+
*
|
|
240
|
+
* The fix expands the region token to its country via codex's ISO-3166-2 subdivision table (`matchSubdivision`: "QC" →
|
|
241
|
+
* `{ name: "Quebec", country: "CA" }`, handling the FTS index's missing "QC" alt-name code-side), then asks the two
|
|
242
|
+
* questions the greedy walk skipped: does that subdivision genuinely resolve UNDER its own country, and is there a
|
|
243
|
+
* same-named locality under it? Only when BOTH hold does it swap the region and locality to the in-country pair.
|
|
244
|
+
* Geography confirms; the subdivision table is a soft name→country prior, not a routing decision.
|
|
245
|
+
*
|
|
246
|
+
* Evidence-gated to stay byte-stable on the domestic path. It fires ONLY when (a) a default country is in force, (b)
|
|
247
|
+
* the region node is UNRESOLVED (the default-country filter came up empty — a US region resolves fine under `US`, so a
|
|
248
|
+
* well-formed US query never trips this), (c) the token is a subdivision of a DIFFERENT country than the default, and
|
|
249
|
+
* (d) both the foreign region and a same-named foreign locality resolve. "Springfield, IL" / "Portland, ME": the region
|
|
250
|
+
* resolves under `US`, so gate (b) fails and the tree is untouched. Costs one region + one locality lookup per
|
|
251
|
+
* triggering pair. See `ResolveOpts.adminCoherence`.
|
|
252
|
+
*/
|
|
253
|
+
export async function applyRegionCountryCoherence(roots, backend, defaultCountry) {
|
|
254
|
+
// No default country → no hard country filter was applied, so no region qualifier was discarded by one. The bug
|
|
255
|
+
// this pass corrects is specific to the locale-inferred default country; without it, there is nothing to rescue.
|
|
256
|
+
if (!defaultCountry)
|
|
257
|
+
return;
|
|
258
|
+
const visit = async (node, regionAncestor) => {
|
|
259
|
+
// Track the nearest region ancestor regardless of its resolution state (the trigger is an UNRESOLVED region).
|
|
260
|
+
const regionHere = node.tag === "region" || node.tag === "subregion" ? node : regionAncestor;
|
|
261
|
+
// Fire for an UNRESOLVED region (the default-country filter came up empty) whose companion locality node
|
|
262
|
+
// exists — regardless of the locality's resolution state, so it covers both the resolved-but-foreign namesake
|
|
263
|
+
// (Montreal → the greedy US pick, Montreal WI) and the unresolved locality the span-rescore tier would
|
|
264
|
+
// otherwise back-fill with a US namesake. The in-country lookups below are the evidence gate.
|
|
265
|
+
if (regionHere &&
|
|
266
|
+
!isResolvedWithCoord(regionHere) &&
|
|
267
|
+
(node.tag === "locality" || node.tag === "dependent_locality") &&
|
|
268
|
+
node.value.trim().length) {
|
|
269
|
+
await reconcileRegionCountry(regionHere, node, backend, defaultCountry);
|
|
270
|
+
}
|
|
271
|
+
for (const child of node.children) {
|
|
272
|
+
await visit(child, regionHere);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
for (const root of roots) {
|
|
276
|
+
await visit(root, null);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Re-pick an (unresolved region, resolved-but-foreign-namesake locality) pair to the in-country instance the
|
|
281
|
+
* default-country filter hid. `matchSubdivision` turns the region token into `{ name, country }` (null for anything
|
|
282
|
+
* that isn't a US state or CA province → no-op); the region's full name then resolves it under that country (expanding
|
|
283
|
+
* the abbreviation the gazetteer FTS index lacks), and the locality is re-scoped to the same country. Leaves both nodes
|
|
284
|
+
* untouched unless every gate holds — the subdivision names a different country than the default, the region resolves
|
|
285
|
+
* under it, and a same-named locality exists there — so the domestic path stays byte-identical.
|
|
286
|
+
*/
|
|
287
|
+
async function reconcileRegionCountry(regionNode, localityNode, backend, defaultCountry) {
|
|
288
|
+
const sub = matchSubdivision(regionNode.value);
|
|
289
|
+
if (!sub)
|
|
290
|
+
return;
|
|
291
|
+
// The subdivision must belong to a DIFFERENT country than the locale default. A US-state token under a US default
|
|
292
|
+
// (sub.country === defaultCountry) never reaches the swap — the pass is inert on the domestic path.
|
|
293
|
+
if (sub.country.toUpperCase() === defaultCountry.toUpperCase())
|
|
294
|
+
return;
|
|
295
|
+
// The locality already resolved in the subdivision's country? Then the greedy walk was already right — byte-stable.
|
|
296
|
+
const localityCountry = localityNode.metadata?.["resolver_country"]?.toUpperCase();
|
|
297
|
+
if (localityCountry === sub.country.toUpperCase())
|
|
298
|
+
return;
|
|
299
|
+
// Confirm the subdivision genuinely resolves under its own country, by its full name (expands "QC" → "Quebec", the
|
|
300
|
+
// form the FTS index carries). No resolvable region → no evidence the token is a real foreign subdivision; abstain.
|
|
301
|
+
const regionScoped = await backend.findPlace({
|
|
302
|
+
text: sub.name,
|
|
303
|
+
placetype: "region",
|
|
304
|
+
country: sub.country,
|
|
305
|
+
limit: 3,
|
|
306
|
+
});
|
|
307
|
+
const rc = regionScoped.find((r) => r.exactMatch && !(r.lat === 0 && r.lon === 0));
|
|
308
|
+
if (!rc)
|
|
309
|
+
return;
|
|
310
|
+
// Is there a same-named locality under that country? (the descendant test, by country column — the same primitive
|
|
311
|
+
// reconcileExplicitCountry uses.) No in-country namesake → keep the greedy result (fail-safe).
|
|
312
|
+
const scoped = await backend.findPlace({
|
|
313
|
+
text: localityNode.value,
|
|
314
|
+
placetype: "locality",
|
|
315
|
+
country: sub.country,
|
|
316
|
+
limit: 3,
|
|
317
|
+
});
|
|
318
|
+
const lc = scoped.find((l) => l.exactMatch && !(l.lat === 0 && l.lon === 0));
|
|
319
|
+
if (!lc)
|
|
320
|
+
return;
|
|
321
|
+
// Adopt the in-country pair: the region gets the foreign subdivision, the locality its same-named foreign instance.
|
|
322
|
+
decorateNode(regionNode, rc, regionScoped.filter((r) => r !== rc));
|
|
323
|
+
regionNode.metadata = { ...regionNode.metadata, region_country_repicked: true };
|
|
324
|
+
decorateNode(localityNode, lc, scoped.filter((l) => l !== lc));
|
|
325
|
+
localityNode.metadata = { ...localityNode.metadata, region_country_repicked: true };
|
|
326
|
+
}
|
|
327
|
+
//# sourceMappingURL=admin-coherence-passes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-coherence-passes.js","sourceRoot":"","sources":["../admin-coherence-passes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAIzE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAEtE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAA6B,EAAE,OAAwB;IAChG,MAAM,KAAK,GAAG,KAAK,EAAE,IAAiB,EAAE,cAAkC,EAAiB,EAAE;QAC5F,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAA;QAE7F,IACC,UAAU;YACV,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,IAAI,IAAI,CAAC,GAAG,KAAK,oBAAoB,CAAC;YAC9D,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,EACvB,CAAC;YACF,MAAM,kBAAkB,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnC,MAAM,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;QAC/B,CAAC;IACF,CAAC,CAAA;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACx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MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC;QACtC,IAAI,EAAE,YAAY,CAAC,KAAK;QACxB,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,KAAK,EAAE,CAAC;KACR,CAAC,CAAA;IAEF,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IAE5E,IAAI,CAAC,EAAE;QAAE,OAAM;IAEf,oHAAoH;IACpH,YAAY,CACX,UAAU,EACV,EAAE,EACF,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CACpC,CAAA;IAED,UAAU,CAAC,QAAQ,GAAG,EAAE,GAAG,UAAU,CAAC,QAAQ,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAA;IAE/E,YAAY,CACX,YAAY,EACZ,EAAE,EACF,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAC9B,CAAA;IAED,YAAY,CAAC,QAAQ,GAAG,EAAE,GAAG,YAAY,CAAC,QAAQ,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAA;AACpF,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The admin-containment partition (#1717 stage 2) — the ONE ordering function both deciding sites
|
|
7
|
+
* call, per the #861 rule (shared constants prove nothing; the #861 parity contract diverged at
|
|
8
|
+
* exactly the points a constant cannot express). The candidate backend partitions its row set
|
|
9
|
+
* before the limit window (so a contained candidate can reach the walk at all), and the resolver
|
|
10
|
+
* walk partitions AGAIN after its fame/anchor re-ranks (so `rankByImportance` cannot hand the top
|
|
11
|
+
* slot back to a more-famous uncontained namesake — Richmond VA outscores Richmond, North
|
|
12
|
+
* Yorkshire on importance, and without the second partition the lever loses exactly where fame
|
|
13
|
+
* disagrees with the qualifier). Two call sites, one function, one ordering.
|
|
14
|
+
*/
|
|
15
|
+
import type { AddressNode } from "@mailwoman/core/decoder";
|
|
16
|
+
/**
|
|
17
|
+
* Find the first non-empty region-tagged span anywhere in a tree — the qualifier the walk threads onto locality
|
|
18
|
+
* lookups. Deliberately the same node the admin-coherence VERDICTS read (the first `region` node), so the lever's
|
|
19
|
+
* firing population and the flag's `contradicted` population are the same rows. A `region` slot can hold a country name
|
|
20
|
+
* the parser mislabeled ("Moscow, Russia" parses region="Russia") — the backend's qualifier probe answers that too,
|
|
21
|
+
* because containment is containment whatever tier the container sits at.
|
|
22
|
+
*/
|
|
23
|
+
export declare function firstRegionQualifier(roots: readonly AddressNode[]): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Stable, TIER-SAFE partition: within each match tier, candidates the containment source vouched for (`isContained`)
|
|
26
|
+
* move ahead of the rest, and BOTH groups keep their incoming relative order — the same house rules every soft ranking
|
|
27
|
+
* key here obeys (`toponym-prior.ts`): tier-safe (a contained partial match never outranks an exact one — `isExact`
|
|
28
|
+
* splits the population exactly as `rankWithinTier`'s tri-state rule does, only a stated exact tier earns the front),
|
|
29
|
+
* positive-evidence-only (only a stated `true` moves a row; `false` and "never evaluated" both hold their incoming
|
|
30
|
+
* rank, so an incapable backend is a no-op by construction), and stable (the backend's own ordering survives within
|
|
31
|
+
* each (tier, containment) cell).
|
|
32
|
+
*
|
|
33
|
+
* Implemented with the slot idiom (`reorderMeasured`'s mechanics): each tier's members permute only among the positions
|
|
34
|
+
* that tier already occupies, so a tier-interleaved list — the walk's no-importance path never regrouped tiers — cannot
|
|
35
|
+
* have a rest-tier row promoted across an exact-tier boundary by this partition.
|
|
36
|
+
*/
|
|
37
|
+
export declare function partitionByContainment<T>(rows: readonly T[], isContained: (row: T) => boolean, isExact: (row: T) => boolean): T[];
|
|
38
|
+
/**
|
|
39
|
+
* The trace verdict for one locality pick under the lever — stamped as `metadata.admin_containment` so an inert
|
|
40
|
+
* mechanism is visible in the result rather than silently dead (#1719's rule). Derived from the candidates'
|
|
41
|
+
* `containedByQualifier` stamps: any `true` → `"contained"`; stamps present but none true → `"no_contained_candidate"`;
|
|
42
|
+
* no stamps at all → `"unavailable"` (the backend or artifact cannot answer — a pre-sidecar candidate.db, the FTS or
|
|
43
|
+
* browser backend, or a qualifier the probe never ran for).
|
|
44
|
+
*/
|
|
45
|
+
export declare function adminContainmentVerdict(candidates: ReadonlyArray<{
|
|
46
|
+
containedByQualifier?: boolean | undefined;
|
|
47
|
+
}>): "contained" | "no_contained_candidate" | "unavailable";
|
|
48
|
+
//# sourceMappingURL=admin-containment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-containment.d.ts","sourceRoot":"","sources":["../admin-containment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,GAAG,SAAS,CAWtF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,EAChC,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,GAC1B,CAAC,EAAE,CAuBL;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,aAAa,CAAC;IAAE,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,CAAC,GACvE,WAAW,GAAG,wBAAwB,GAAG,aAAa,CAYxD"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The admin-containment partition (#1717 stage 2) — the ONE ordering function both deciding sites
|
|
7
|
+
* call, per the #861 rule (shared constants prove nothing; the #861 parity contract diverged at
|
|
8
|
+
* exactly the points a constant cannot express). The candidate backend partitions its row set
|
|
9
|
+
* before the limit window (so a contained candidate can reach the walk at all), and the resolver
|
|
10
|
+
* walk partitions AGAIN after its fame/anchor re-ranks (so `rankByImportance` cannot hand the top
|
|
11
|
+
* slot back to a more-famous uncontained namesake — Richmond VA outscores Richmond, North
|
|
12
|
+
* Yorkshire on importance, and without the second partition the lever loses exactly where fame
|
|
13
|
+
* disagrees with the qualifier). Two call sites, one function, one ordering.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Find the first non-empty region-tagged span anywhere in a tree — the qualifier the walk threads onto locality
|
|
17
|
+
* lookups. Deliberately the same node the admin-coherence VERDICTS read (the first `region` node), so the lever's
|
|
18
|
+
* firing population and the flag's `contradicted` population are the same rows. A `region` slot can hold a country name
|
|
19
|
+
* the parser mislabeled ("Moscow, Russia" parses region="Russia") — the backend's qualifier probe answers that too,
|
|
20
|
+
* because containment is containment whatever tier the container sits at.
|
|
21
|
+
*/
|
|
22
|
+
export function firstRegionQualifier(roots) {
|
|
23
|
+
const stack = [...roots];
|
|
24
|
+
while (stack.length) {
|
|
25
|
+
const n = stack.pop();
|
|
26
|
+
if (n.tag === "region" && n.value.trim().length)
|
|
27
|
+
return n.value.trim();
|
|
28
|
+
stack.push(...n.children);
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Stable, TIER-SAFE partition: within each match tier, candidates the containment source vouched for (`isContained`)
|
|
34
|
+
* move ahead of the rest, and BOTH groups keep their incoming relative order — the same house rules every soft ranking
|
|
35
|
+
* key here obeys (`toponym-prior.ts`): tier-safe (a contained partial match never outranks an exact one — `isExact`
|
|
36
|
+
* splits the population exactly as `rankWithinTier`'s tri-state rule does, only a stated exact tier earns the front),
|
|
37
|
+
* positive-evidence-only (only a stated `true` moves a row; `false` and "never evaluated" both hold their incoming
|
|
38
|
+
* rank, so an incapable backend is a no-op by construction), and stable (the backend's own ordering survives within
|
|
39
|
+
* each (tier, containment) cell).
|
|
40
|
+
*
|
|
41
|
+
* Implemented with the slot idiom (`reorderMeasured`'s mechanics): each tier's members permute only among the positions
|
|
42
|
+
* that tier already occupies, so a tier-interleaved list — the walk's no-importance path never regrouped tiers — cannot
|
|
43
|
+
* have a rest-tier row promoted across an exact-tier boundary by this partition.
|
|
44
|
+
*/
|
|
45
|
+
export function partitionByContainment(rows, isContained, isExact) {
|
|
46
|
+
const out = [...rows];
|
|
47
|
+
for (const wantExact of [true, false]) {
|
|
48
|
+
const slots = [];
|
|
49
|
+
for (const [index, row] of out.entries()) {
|
|
50
|
+
if (isExact(row) === wantExact) {
|
|
51
|
+
slots.push(index);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (slots.length < 2)
|
|
55
|
+
continue;
|
|
56
|
+
const members = slots.map((slot) => out[slot]);
|
|
57
|
+
const reordered = [...members.filter((row) => isContained(row)), ...members.filter((row) => !isContained(row))];
|
|
58
|
+
for (const [k, slot] of slots.entries()) {
|
|
59
|
+
out[slot] = reordered[k];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The trace verdict for one locality pick under the lever — stamped as `metadata.admin_containment` so an inert
|
|
66
|
+
* mechanism is visible in the result rather than silently dead (#1719's rule). Derived from the candidates'
|
|
67
|
+
* `containedByQualifier` stamps: any `true` → `"contained"`; stamps present but none true → `"no_contained_candidate"`;
|
|
68
|
+
* no stamps at all → `"unavailable"` (the backend or artifact cannot answer — a pre-sidecar candidate.db, the FTS or
|
|
69
|
+
* browser backend, or a qualifier the probe never ran for).
|
|
70
|
+
*/
|
|
71
|
+
export function adminContainmentVerdict(candidates) {
|
|
72
|
+
let evaluated = false;
|
|
73
|
+
for (const candidate of candidates) {
|
|
74
|
+
if (candidate.containedByQualifier === true)
|
|
75
|
+
return "contained";
|
|
76
|
+
if (candidate.containedByQualifier !== undefined) {
|
|
77
|
+
evaluated = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return evaluated ? "no_contained_candidate" : "unavailable";
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=admin-containment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-containment.js","sourceRoot":"","sources":["../admin-containment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAA6B;IACjE,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;IAExB,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAG,CAAA;QAEtB,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM;YAAE,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;QACtE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC1B,CAAC;IAED,OAAO,SAAS,CAAA;AACjB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,sBAAsB,CACrC,IAAkB,EAClB,WAAgC,EAChC,OAA4B;IAE5B,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IAErB,KAAK,MAAM,SAAS,IAAI,CAAC,IAAI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;IAED,OAAO,SAAS,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,aAAa,CAAA;AAC5D,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file Which resolved admin place answers the query — the one ordering whose postcode rung is not a constant.
|
|
6
|
+
*
|
|
7
|
+
* `postalcode` is the only placetype whose specificity depends on the hit rather than the name. An NL PC6 or a GB unit
|
|
8
|
+
* postcode covers ~8 and ~15 addresses, categorically tighter than any locality centroid; a US ZIP, a French code
|
|
9
|
+
* postal or a German PLZ covers a delivery AREA. `PLACETYPE_SPECIFICITY` answers "which placetype covers less ground"
|
|
10
|
+
* and cannot express that split, so a consumer that sorts by it alone promotes every postcode.
|
|
11
|
+
*
|
|
12
|
+
* Two consumers need the split in two shapes, and both live here so a divergence is a test failure rather than a
|
|
13
|
+
* silent disagreement: result assembly walks a TAG ladder, and the eval harnesses sort resolved nodes by placetype.
|
|
14
|
+
*/
|
|
15
|
+
import type { AddressNode } from "@mailwoman/core/decoder";
|
|
16
|
+
/**
|
|
17
|
+
* The admin fallback order when the postcode leads — a unit-grade exact hit, or an address system whose area-grade code
|
|
18
|
+
* is still finer than its locality ({@link areaPostcodeLeadsLocality}).
|
|
19
|
+
*/
|
|
20
|
+
export declare const ADMIN_LADDER_POSTCODE_FIRST: ReadonlyArray<string>;
|
|
21
|
+
/**
|
|
22
|
+
* The admin fallback order everywhere else: the locality tiers lead and the postcode sits between them and `region`.
|
|
23
|
+
*
|
|
24
|
+
* This is the #945 epoch convention, and it is the DEFAULT rather than the universal answer — which address systems
|
|
25
|
+
* leave it is `AREA_POSTCODE_FINER_THAN_LOCALITY`'s question, and that table carries the per-country measurement.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ADMIN_LADDER_LOCALITY_FIRST: ReadonlyArray<string>;
|
|
28
|
+
/**
|
|
29
|
+
* The resolved postcode a ladder decision reads: the PARSED span, the resolver's own hit, and the country the resolver
|
|
30
|
+
* placed it in.
|
|
31
|
+
*
|
|
32
|
+
* The first two are needed together because a full unit shape the resolver answered with a coarser stem is area-grade,
|
|
33
|
+
* whatever the user typed. `country` is separate evidence and answers a different question — not how tight this code
|
|
34
|
+
* is, but whether this address system's codes are tighter than its localities at all.
|
|
35
|
+
*/
|
|
36
|
+
export interface ResolvedPostcodeHit {
|
|
37
|
+
value: string;
|
|
38
|
+
resolverName: string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* ISO-3166 alpha-2 the RESOLVER placed the postcode in, not a caller's requested scope. Absent when the postcode did
|
|
41
|
+
* not resolve to a country, which reads as the locality-first default.
|
|
42
|
+
*/
|
|
43
|
+
country?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Pick the admin fallback order for one resolved tree.
|
|
47
|
+
*
|
|
48
|
+
* Two independent routes to postcode-first: the code itself is unit-grade, or the address system's area-grade codes are
|
|
49
|
+
* finer than its localities. Either one is sufficient and the second is what makes this per-country rather than
|
|
50
|
+
* global.
|
|
51
|
+
*/
|
|
52
|
+
export declare function adminLadderFor(postcode: ResolvedPostcodeHit | undefined): ReadonlyArray<string>;
|
|
53
|
+
/**
|
|
54
|
+
* The ladder for a flat list of resolved nodes — the shape result assembly holds.
|
|
55
|
+
*
|
|
56
|
+
* Which node counts, and which of its fields the decision reads, is part of the ordering rather than the caller's
|
|
57
|
+
* business: `country` is the one the RESOLVER placed the code in, never a caller's requested scope, because the ladder
|
|
58
|
+
* is asking which address system this code belongs to and a scope is a filter on the answer rather than evidence about
|
|
59
|
+
* it. Getting that wrong at a call site would be invisible.
|
|
60
|
+
*/
|
|
61
|
+
export declare function adminLadderForNodes(nodes: readonly AddressNode[]): ReadonlyArray<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Where an AREA-grade postal code sits on `PLACETYPE_SPECIFICITY`: below the whole locality tier, above `county` (2).
|
|
64
|
+
*
|
|
65
|
+
* The tier is `PLACETYPE_FILTER_GROUPS.locality` — `locality` (4), `borough` (5) and `localadmin` (3) — not the
|
|
66
|
+
* `locality` placetype alone, because that is what the resolver's own `locality` tag expands to. New England civil
|
|
67
|
+
* towns are `localadmin` in WOF, so a value between `locality` and `localadmin` would rank a US ZIP above the town it
|
|
68
|
+
* sits in and reproduce the defect on exactly the rows that motivated the group.
|
|
69
|
+
*
|
|
70
|
+
* Deliberately not an integer. The scale's rungs are placetypes and this is not one — it is the position
|
|
71
|
+
* {@link ADMIN_LADDER_LOCALITY_FIRST} puts a postcode in, expressed on the scale the sorting consumers already use.
|
|
72
|
+
*/
|
|
73
|
+
export declare const AREA_GRADE_POSTALCODE_SPECIFICITY = 2.5;
|
|
74
|
+
/**
|
|
75
|
+
* A resolved place, as much of it as an ordering decision reads.
|
|
76
|
+
*/
|
|
77
|
+
export interface ResolvedSpecificityInput {
|
|
78
|
+
placetype: string;
|
|
79
|
+
/**
|
|
80
|
+
* ISO-3166 alpha-2 the resolver placed this candidate in. Read only for a `postalcode`, where it decides whether the
|
|
81
|
+
* address system's area-grade codes outrank its localities.
|
|
82
|
+
*/
|
|
83
|
+
country?: string;
|
|
84
|
+
/**
|
|
85
|
+
* The parsed span. Absent for a non-postcode candidate, where nothing conditional applies.
|
|
86
|
+
*/
|
|
87
|
+
value?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The resolver's own hit name, as `resolver_name` metadata carries it.
|
|
90
|
+
*/
|
|
91
|
+
resolverName?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Rank a resolved place for "whose coordinate answers the query" — `PLACETYPE_SPECIFICITY`, except that a `postalcode`
|
|
95
|
+
* is ranked by its hit.
|
|
96
|
+
*
|
|
97
|
+
* An unranked placetype returns `-Infinity` so it wins only when nothing else resolved.
|
|
98
|
+
*/
|
|
99
|
+
export declare function resolvedSpecificity(candidate: ResolvedSpecificityInput): number;
|
|
100
|
+
/**
|
|
101
|
+
* The best of a resolved set under {@link resolvedSpecificity}, or `null` when the set is empty. Ties keep the first,
|
|
102
|
+
* which is document order.
|
|
103
|
+
*
|
|
104
|
+
* `toInput` is explicit rather than structural because each consumer spells the resolver's hit differently — the eval
|
|
105
|
+
* harnesses carry it as `name`, result assembly reads it off `resolver_name` metadata — and a projection at the call
|
|
106
|
+
* site is where that mapping is visible.
|
|
107
|
+
*/
|
|
108
|
+
export declare function mostSpecificResolved<T>(candidates: readonly T[], toInput: (candidate: T) => ResolvedSpecificityInput): T | null;
|
|
109
|
+
//# sourceMappingURL=admin-winner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-winner.d.ts","sourceRoot":"","sources":["../admin-winner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAG1D;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAE,aAAa,CAAC,MAAM,CAM7D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,aAAa,CAAC,MAAM,CAM7D,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAO/F;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,CAYxF;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iCAAiC,MAAM,CAAA;AAEpD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,SAAS,EAAE,MAAM,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