@mailwoman/resolver-wof-sqlite 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.
Files changed (297) hide show
  1. package/README.md +28 -9
  2. package/address-point-interpolation.ts +18 -8
  3. package/address-point-schema.ts +18 -6
  4. package/address-point.ts +111 -18
  5. package/ancestry.ts +9 -6
  6. package/build-candidate.ts +287 -157
  7. package/build-slim.ts +3 -3
  8. package/candidate/alias-bags.ts +54 -0
  9. package/candidate/ancestors-sidecar.ts +206 -0
  10. package/candidate/country-display-names.ts +79 -0
  11. package/candidate/name-roles.ts +237 -0
  12. package/candidate/own-name.ts +146 -0
  13. package/candidate/place-attrs.ts +44 -0
  14. package/candidate/shard-fold.ts +137 -0
  15. package/candidate-ancestors-schema.ts +195 -0
  16. package/candidate-fts.ts +4 -2
  17. package/candidate-importance.ts +228 -0
  18. package/candidate-lookup.ts +564 -174
  19. package/candidate-schema.ts +60 -3
  20. package/candidate-scoring.ts +268 -0
  21. package/capital-schema.ts +90 -0
  22. package/capitals.ts +148 -0
  23. package/coincident-roles.ts +69 -10
  24. package/convention-schema.ts +72 -0
  25. package/convention.ts +2 -2
  26. package/coverage-manifest-schema.ts +7 -7
  27. package/currency-backfill.ts +249 -0
  28. package/exact-match.ts +104 -0
  29. package/fst-autocomplete.ts +105 -122
  30. package/fst-builder.ts +39 -47
  31. package/fst-deserialize-web.ts +43 -7
  32. package/fst-freshness.ts +2 -2
  33. package/fst-serialize.ts +68 -12
  34. package/fst-types.ts +35 -1
  35. package/fts-query.ts +1 -1
  36. package/fts.ts +16 -4
  37. package/geonames-postal.ts +2 -2
  38. package/index.ts +26 -14
  39. package/interpolation.ts +113 -19
  40. package/lookup.ts +118 -560
  41. package/name-score.ts +6 -4
  42. package/out/address-point-interpolation.d.ts.map +1 -1
  43. package/out/address-point-interpolation.js +13 -7
  44. package/out/address-point-interpolation.js.map +1 -1
  45. package/out/address-point-schema.d.ts +16 -6
  46. package/out/address-point-schema.d.ts.map +1 -1
  47. package/out/address-point-schema.js.map +1 -1
  48. package/out/address-point.d.ts.map +1 -1
  49. package/out/address-point.js +70 -14
  50. package/out/address-point.js.map +1 -1
  51. package/out/ancestry.d.ts +2 -2
  52. package/out/ancestry.d.ts.map +1 -1
  53. package/out/ancestry.js +5 -6
  54. package/out/ancestry.js.map +1 -1
  55. package/out/build-candidate.d.ts +108 -0
  56. package/out/build-candidate.d.ts.map +1 -1
  57. package/out/build-candidate.js +151 -120
  58. package/out/build-candidate.js.map +1 -1
  59. package/out/build-slim.d.ts +1 -1
  60. package/out/build-slim.js +3 -3
  61. package/out/build-slim.js.map +1 -1
  62. package/out/candidate/alias-bags.d.ts +17 -0
  63. package/out/candidate/alias-bags.d.ts.map +1 -0
  64. package/out/candidate/alias-bags.js +39 -0
  65. package/out/candidate/alias-bags.js.map +1 -0
  66. package/out/candidate/ancestors-sidecar.d.ts +33 -0
  67. package/out/candidate/ancestors-sidecar.d.ts.map +1 -0
  68. package/out/candidate/ancestors-sidecar.js +140 -0
  69. package/out/candidate/ancestors-sidecar.js.map +1 -0
  70. package/out/candidate/country-display-names.d.ts +35 -0
  71. package/out/candidate/country-display-names.d.ts.map +1 -0
  72. package/out/candidate/country-display-names.js +59 -0
  73. package/out/candidate/country-display-names.js.map +1 -0
  74. package/out/candidate/name-roles.d.ts +55 -0
  75. package/out/candidate/name-roles.d.ts.map +1 -0
  76. package/out/candidate/name-roles.js +165 -0
  77. package/out/candidate/name-roles.js.map +1 -0
  78. package/out/candidate/own-name.d.ts +50 -0
  79. package/out/candidate/own-name.d.ts.map +1 -0
  80. package/out/candidate/own-name.js +132 -0
  81. package/out/candidate/own-name.js.map +1 -0
  82. package/out/candidate/place-attrs.d.ts +43 -0
  83. package/out/candidate/place-attrs.d.ts.map +1 -0
  84. package/out/candidate/place-attrs.js +15 -0
  85. package/out/candidate/place-attrs.js.map +1 -0
  86. package/out/candidate/shard-fold.d.ts +31 -0
  87. package/out/candidate/shard-fold.d.ts.map +1 -0
  88. package/out/candidate/shard-fold.js +104 -0
  89. package/out/candidate/shard-fold.js.map +1 -0
  90. package/out/candidate-ancestors-schema.d.ts +150 -0
  91. package/out/candidate-ancestors-schema.d.ts.map +1 -0
  92. package/out/candidate-ancestors-schema.js +123 -0
  93. package/out/candidate-ancestors-schema.js.map +1 -0
  94. package/out/candidate-fts.d.ts +4 -2
  95. package/out/candidate-fts.d.ts.map +1 -1
  96. package/out/candidate-fts.js +4 -2
  97. package/out/candidate-fts.js.map +1 -1
  98. package/out/candidate-importance.d.ts +132 -0
  99. package/out/candidate-importance.d.ts.map +1 -0
  100. package/out/candidate-importance.js +174 -0
  101. package/out/candidate-importance.js.map +1 -0
  102. package/out/candidate-lookup.d.ts +22 -37
  103. package/out/candidate-lookup.d.ts.map +1 -1
  104. package/out/candidate-lookup.js +446 -132
  105. package/out/candidate-lookup.js.map +1 -1
  106. package/out/candidate-schema.d.ts +52 -4
  107. package/out/candidate-schema.d.ts.map +1 -1
  108. package/out/candidate-schema.js +8 -0
  109. package/out/candidate-schema.js.map +1 -1
  110. package/out/candidate-scoring.d.ts +34 -0
  111. package/out/candidate-scoring.d.ts.map +1 -0
  112. package/out/candidate-scoring.js +200 -0
  113. package/out/candidate-scoring.js.map +1 -0
  114. package/out/capital-schema.d.ts +51 -0
  115. package/out/capital-schema.d.ts.map +1 -0
  116. package/out/capital-schema.js +63 -0
  117. package/out/capital-schema.js.map +1 -0
  118. package/out/capitals.d.ts +69 -0
  119. package/out/capitals.d.ts.map +1 -0
  120. package/out/capitals.js +98 -0
  121. package/out/capitals.js.map +1 -0
  122. package/out/coincident-roles.d.ts +7 -0
  123. package/out/coincident-roles.d.ts.map +1 -1
  124. package/out/coincident-roles.js +42 -8
  125. package/out/coincident-roles.js.map +1 -1
  126. package/out/convention-schema.d.ts +51 -0
  127. package/out/convention-schema.d.ts.map +1 -0
  128. package/out/convention-schema.js +34 -0
  129. package/out/convention-schema.js.map +1 -0
  130. package/out/convention.d.ts +1 -1
  131. package/out/convention.js +2 -2
  132. package/out/coverage-manifest-schema.js +3 -7
  133. package/out/coverage-manifest-schema.js.map +1 -1
  134. package/out/currency-backfill.d.ts +46 -0
  135. package/out/currency-backfill.d.ts.map +1 -0
  136. package/out/currency-backfill.js +180 -0
  137. package/out/currency-backfill.js.map +1 -0
  138. package/out/exact-match.d.ts +25 -0
  139. package/out/exact-match.d.ts.map +1 -0
  140. package/out/exact-match.js +89 -0
  141. package/out/exact-match.js.map +1 -0
  142. package/out/fst-autocomplete.d.ts +24 -14
  143. package/out/fst-autocomplete.d.ts.map +1 -1
  144. package/out/fst-autocomplete.js +84 -100
  145. package/out/fst-autocomplete.js.map +1 -1
  146. package/out/fst-builder.d.ts.map +1 -1
  147. package/out/fst-builder.js +32 -40
  148. package/out/fst-builder.js.map +1 -1
  149. package/out/fst-deserialize-web.d.ts.map +1 -1
  150. package/out/fst-deserialize-web.js +36 -7
  151. package/out/fst-deserialize-web.js.map +1 -1
  152. package/out/fst-freshness.d.ts +2 -2
  153. package/out/fst-freshness.js +2 -2
  154. package/out/fst-serialize.d.ts +14 -4
  155. package/out/fst-serialize.d.ts.map +1 -1
  156. package/out/fst-serialize.js +60 -12
  157. package/out/fst-serialize.js.map +1 -1
  158. package/out/fst-types.d.ts +35 -1
  159. package/out/fst-types.d.ts.map +1 -1
  160. package/out/fts-query.js +1 -1
  161. package/out/fts-query.js.map +1 -1
  162. package/out/fts.d.ts +15 -4
  163. package/out/fts.d.ts.map +1 -1
  164. package/out/fts.js +15 -4
  165. package/out/fts.js.map +1 -1
  166. package/out/geonames-postal.d.ts +2 -2
  167. package/out/geonames-postal.js +2 -2
  168. package/out/index.d.ts +4 -2
  169. package/out/index.d.ts.map +1 -1
  170. package/out/index.js +3 -2
  171. package/out/index.js.map +1 -1
  172. package/out/interpolation.d.ts +8 -0
  173. package/out/interpolation.d.ts.map +1 -1
  174. package/out/interpolation.js +91 -19
  175. package/out/interpolation.js.map +1 -1
  176. package/out/lookup.d.ts +4 -5
  177. package/out/lookup.d.ts.map +1 -1
  178. package/out/lookup.js +102 -444
  179. package/out/lookup.js.map +1 -1
  180. package/out/name-score.d.ts +0 -10
  181. package/out/name-score.d.ts.map +1 -1
  182. package/out/name-score.js +6 -4
  183. package/out/name-score.js.map +1 -1
  184. package/out/place-importance-schema.d.ts +226 -0
  185. package/out/place-importance-schema.d.ts.map +1 -0
  186. package/out/place-importance-schema.js +288 -0
  187. package/out/place-importance-schema.js.map +1 -0
  188. package/out/poi-lookup.d.ts +1 -1
  189. package/out/poi-lookup.d.ts.map +1 -1
  190. package/out/poi-lookup.js +12 -13
  191. package/out/poi-lookup.js.map +1 -1
  192. package/out/poi-schema.d.ts +7 -3
  193. package/out/poi-schema.d.ts.map +1 -1
  194. package/out/poi-schema.js.map +1 -1
  195. package/out/polygon-schema.d.ts +37 -0
  196. package/out/polygon-schema.d.ts.map +1 -0
  197. package/out/polygon-schema.js +23 -0
  198. package/out/polygon-schema.js.map +1 -0
  199. package/out/postal-city-alias-lookup.d.ts +1 -1
  200. package/out/postal-city-alias-lookup.js +1 -1
  201. package/out/postal-city-candidate-schema.d.ts +2 -1
  202. package/out/postal-city-candidate-schema.d.ts.map +1 -1
  203. package/out/postal-city-candidate-schema.js.map +1 -1
  204. package/out/postcode-point-lookup.d.ts +1 -1
  205. package/out/postcode-point-lookup.js +1 -1
  206. package/out/primary-preference.d.ts +125 -0
  207. package/out/primary-preference.d.ts.map +1 -0
  208. package/out/primary-preference.js +138 -0
  209. package/out/primary-preference.js.map +1 -0
  210. package/out/proximity-rerank.d.ts +77 -0
  211. package/out/proximity-rerank.d.ts.map +1 -0
  212. package/out/proximity-rerank.js +86 -0
  213. package/out/proximity-rerank.js.map +1 -0
  214. package/out/region-keys.d.ts +47 -0
  215. package/out/region-keys.d.ts.map +1 -0
  216. package/out/region-keys.js +121 -0
  217. package/out/region-keys.js.map +1 -0
  218. package/out/reverse.d.ts.map +1 -1
  219. package/out/reverse.js +6 -9
  220. package/out/reverse.js.map +1 -1
  221. package/out/schema.d.ts +1 -1
  222. package/out/search-fetch.d.ts +57 -0
  223. package/out/search-fetch.d.ts.map +1 -0
  224. package/out/search-fetch.js +183 -0
  225. package/out/search-fetch.js.map +1 -0
  226. package/out/sharding.d.ts +3 -3
  227. package/out/sharding.js +1 -1
  228. package/out/sqlite-convention-source.d.ts +1 -1
  229. package/out/sqlite-convention-source.js +1 -1
  230. package/out/sqlite-utils.d.ts +31 -1
  231. package/out/sqlite-utils.d.ts.map +1 -1
  232. package/out/sqlite-utils.js +38 -0
  233. package/out/sqlite-utils.js.map +1 -1
  234. package/out/street-centroid-schema.d.ts +7 -2
  235. package/out/street-centroid-schema.d.ts.map +1 -1
  236. package/out/street-centroid-schema.js.map +1 -1
  237. package/out/street-centroid.d.ts.map +1 -1
  238. package/out/street-centroid.js +7 -7
  239. package/out/street-centroid.js.map +1 -1
  240. package/out/street-morphology-fst-builder.d.ts.map +1 -1
  241. package/out/street-morphology-fst-builder.js +5 -4
  242. package/out/street-morphology-fst-builder.js.map +1 -1
  243. package/out/street-normalize.d.ts +83 -9
  244. package/out/street-normalize.d.ts.map +1 -1
  245. package/out/street-normalize.js +177 -10
  246. package/out/street-normalize.js.map +1 -1
  247. package/out/street-segment-schema.d.ts +6 -2
  248. package/out/street-segment-schema.d.ts.map +1 -1
  249. package/out/street-segment-schema.js.map +1 -1
  250. package/out/types.d.ts +74 -1
  251. package/out/types.d.ts.map +1 -1
  252. package/out/unified-schema.d.ts +1 -1
  253. package/out/unified-schema.js +1 -1
  254. package/out/uprn-lookup.d.ts +85 -0
  255. package/out/uprn-lookup.d.ts.map +1 -0
  256. package/out/uprn-lookup.js +152 -0
  257. package/out/uprn-lookup.js.map +1 -0
  258. package/out/uprn-schema.d.ts +93 -0
  259. package/out/uprn-schema.d.ts.map +1 -0
  260. package/out/uprn-schema.js +78 -0
  261. package/out/uprn-schema.js.map +1 -0
  262. package/out/weights-overlay-linker.d.ts +141 -0
  263. package/out/weights-overlay-linker.d.ts.map +1 -0
  264. package/out/weights-overlay-linker.js +259 -0
  265. package/out/weights-overlay-linker.js.map +1 -0
  266. package/package.json +296 -16
  267. package/place-importance-schema.ts +402 -0
  268. package/poi-lookup.ts +12 -13
  269. package/poi-schema.ts +8 -3
  270. package/polygon-schema.ts +47 -0
  271. package/postal-city-alias-lookup.ts +1 -1
  272. package/postal-city-candidate-schema.ts +3 -1
  273. package/postcode-point-lookup.ts +1 -1
  274. package/primary-preference.ts +207 -0
  275. package/proximity-rerank.ts +120 -0
  276. package/region-keys.ts +144 -0
  277. package/reverse.ts +17 -16
  278. package/schema.ts +1 -1
  279. package/search-fetch.ts +256 -0
  280. package/sharding.ts +3 -3
  281. package/sqlite-convention-source.ts +1 -1
  282. package/sqlite-utils.ts +63 -1
  283. package/street-centroid-schema.ts +8 -2
  284. package/street-centroid.ts +13 -8
  285. package/street-morphology-fst-builder.ts +5 -4
  286. package/street-normalize.ts +254 -24
  287. package/street-segment-schema.ts +7 -2
  288. package/types.ts +74 -1
  289. package/unified-schema.ts +1 -1
  290. package/uprn-lookup.ts +210 -0
  291. package/uprn-schema.ts +124 -0
  292. package/weights-overlay-linker.ts +377 -0
  293. package/geo.ts +0 -121
  294. package/out/geo.d.ts +0 -74
  295. package/out/geo.d.ts.map +0 -1
  296. package/out/geo.js +0 -71
  297. package/out/geo.js.map +0 -1
@@ -0,0 +1,140 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Pass 3b of the candidate build — the containment sidecar (closure rows + interval labels).
6
+ */
7
+ import { placetypeDepth } from "../ancestry.js";
8
+ import { CANDIDATE_ANCESTOR_COLUMNS, CANDIDATE_ANCESTOR_TABLE, CANDIDATE_INTERVAL_TABLE, createCandidateAncestorTable, createCandidateIntervalTable, MAX_ANCESTOR_DEPTH, } from "../candidate-ancestors-schema.js";
9
+ /**
10
+ * Pass 3b — the ancestors sidecar: closure rows + interval labels (candidate-ancestors-schema.ts owns the encoding
11
+ * decision and the DAG/absence semantics). Reads the same source `ancestors` table the region stamp reads,
12
+ * denormalizing each edge with the parent's name/key from `attrs`, streamed `ORDER BY id` so the clustered `(spr_id,
13
+ * depth)` insert is sorted — the contiguous-leaves discipline of the candidate table itself.
14
+ *
15
+ * Excluded by policy: self rows, and placetypes outside the containment ladder (continent, empire, …: `placetypeDepth`
16
+ * 0) — they discriminate nothing a consumer of this sidecar checks. An edge to a parent with no current `spr` row has
17
+ * no name to denormalize; it is dropped and counted rather than stored blind.
18
+ */
19
+ export async function buildAncestorsSidecar(ctx) {
20
+ const { src, out, attrs, ptID, progress } = ctx;
21
+ progress("ancestors", "building containment sidecar (closure rows + interval labels)");
22
+ await createCandidateAncestorTable(ctx.kdb);
23
+ await createCandidateIntervalTable(ctx.kdb);
24
+ const insAncestor = out.prepare(`INSERT INTO ${CANDIDATE_ANCESTOR_TABLE} VALUES (${CANDIDATE_ANCESTOR_COLUMNS.map(() => "?").join(", ")})`);
25
+ // The canonical-parent forest the interval labels are computed over. One parent per place — the
26
+ // depth-1 edge (finest containment tier, lowest ancestor id; the `regionOf` MIN-stability
27
+ // convention). ALL parents stay in the closure rows; only the interval tree canonicalizes.
28
+ const canonicalParentOf = new Map();
29
+ const childrenOf = new Map();
30
+ const forest = new Set();
31
+ let ancestorRows = 0;
32
+ let ancestorPlaces = 0;
33
+ let droppedParents = 0;
34
+ // Per-child edge buffer; the stream below is grouped by child id, so each flush owns one place.
35
+ let childID = -1;
36
+ let edges = [];
37
+ const flush = () => {
38
+ if (childID < 0 || !edges.length)
39
+ return;
40
+ // Deterministic nearest-first: containment depth descending, then ancestor id ascending —
41
+ // the FTS backend's `ancestorLineage` ordering, made stable across rebuilds.
42
+ edges.sort((a, b) => placetypeDepth(b.apt) - placetypeDepth(a.apt) || a.aid - b.aid);
43
+ if (edges.length > MAX_ANCESTOR_DEPTH) {
44
+ edges = edges.slice(0, MAX_ANCESTOR_DEPTH);
45
+ }
46
+ ancestorPlaces++;
47
+ for (const [i, edge] of edges.entries()) {
48
+ const parent = attrs.get(edge.aid);
49
+ insAncestor.run(childID, i + 1, edge.aid, ptID(edge.apt), parent.name, parent.pkey);
50
+ ancestorRows++;
51
+ }
52
+ const canonical = edges[0].aid;
53
+ canonicalParentOf.set(childID, canonical);
54
+ const siblings = childrenOf.get(canonical);
55
+ if (siblings) {
56
+ siblings.push(childID);
57
+ }
58
+ else {
59
+ childrenOf.set(canonical, [childID]);
60
+ }
61
+ forest.add(childID);
62
+ forest.add(canonical);
63
+ };
64
+ out.exec("BEGIN");
65
+ for (const r of src
66
+ .prepare("SELECT id, ancestor_id, ancestor_placetype FROM ancestors WHERE ancestor_id != id ORDER BY id")
67
+ .iterate()) {
68
+ const id = Number(r.id);
69
+ if (id !== childID) {
70
+ flush();
71
+ childID = id;
72
+ edges = [];
73
+ }
74
+ if (!attrs.has(id))
75
+ continue;
76
+ const apt = String(r.ancestor_placetype ?? "");
77
+ if (placetypeDepth(apt) === 0)
78
+ continue;
79
+ const aid = Number(r.ancestor_id);
80
+ if (!attrs.has(aid)) {
81
+ droppedParents++;
82
+ continue;
83
+ }
84
+ edges.push({ aid, apt });
85
+ }
86
+ flush();
87
+ out.exec("COMMIT");
88
+ // Interval labels: pre/post-order DFS over the canonical-parent forest. Root order and child
89
+ // order are id-ascending so the labels are stable across rebuilds of the same source.
90
+ const preOf = new Map();
91
+ const postOf = new Map();
92
+ for (const kids of childrenOf.values()) {
93
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass just built
94
+ kids.sort((a, b) => a - b);
95
+ }
96
+ const roots = [...forest].filter((id) => !canonicalParentOf.has(id));
97
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass just built
98
+ roots.sort((a, b) => a - b);
99
+ let counter = 0;
100
+ for (const root of roots) {
101
+ preOf.set(root, counter++);
102
+ const stack = [{ id: root, next: 0 }];
103
+ while (stack.length) {
104
+ const top = stack.at(-1);
105
+ const kids = childrenOf.get(top.id);
106
+ if (kids && top.next < kids.length) {
107
+ const kid = kids[top.next++];
108
+ // Each child holds exactly one canonical parent, so a labeled node here means the
109
+ // grouping upstream broke — skip rather than corrupt the numbering.
110
+ if (preOf.has(kid))
111
+ continue;
112
+ preOf.set(kid, counter++);
113
+ stack.push({ id: kid, next: 0 });
114
+ }
115
+ else {
116
+ postOf.set(top.id, counter++);
117
+ stack.pop();
118
+ }
119
+ }
120
+ }
121
+ // A canonical-parent CYCLE (corrupt source ancestry) leaves its members unreachable from any
122
+ // root: they simply receive no label, and containment against them reads unverifiable — the
123
+ // absence semantics the schema module states. Counted so a jump is visible across rebuilds.
124
+ const cycleSkipped = forest.size - preOf.size;
125
+ const insInterval = out.prepare(`INSERT INTO ${CANDIDATE_INTERVAL_TABLE} VALUES (?, ?, ?)`);
126
+ const labeled = [...preOf.keys()];
127
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass just built
128
+ labeled.sort((a, b) => a - b);
129
+ out.exec("BEGIN");
130
+ for (const id of labeled) {
131
+ insInterval.run(id, preOf.get(id), postOf.get(id));
132
+ }
133
+ out.exec("COMMIT");
134
+ progress("ancestors", `${ancestorRows.toLocaleString()} closure rows across ${ancestorPlaces.toLocaleString()} places; ` +
135
+ `${preOf.size.toLocaleString()} interval labels` +
136
+ (droppedParents ? `; ${droppedParents.toLocaleString()} edges dropped (parent has no current spr row)` : "") +
137
+ (cycleSkipped ? `; ${cycleSkipped.toLocaleString()} places skipped (canonical-parent cycle)` : ""));
138
+ return { ancestorRows, ancestorPlaces, intervalPlaces: preOf.size };
139
+ }
140
+ //# sourceMappingURL=ancestors-sidecar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ancestors-sidecar.js","sourceRoot":"","sources":["../../candidate/ancestors-sidecar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EACN,0BAA0B,EAC1B,wBAAw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3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Pass 1b of the candidate build — fold ICU's country display names onto the country rows.
6
+ */
7
+ import type { PlaceAttrs, StageRow } from "./place-attrs.ts";
8
+ /**
9
+ * Fold every country surface ICU knows onto that country's candidate row (#1678 thread 1).
10
+ *
11
+ * A bare `格鲁吉亚` (Georgia the country) resolved to NOTHING while `佐治亚州` (Georgia the US state) resolved correctly, and
12
+ * the model gave both the same wrong `locality` tag — so the tag was never the variable. Measured 2026-08-15: 140 of
13
+ * 237 country rows are synthetic and carry a canonical English name and nothing else; WOF holds no Chinese country
14
+ * names at all; and the GeoNames alias fold filters through a Latin-script regex, so neither existing source could ever
15
+ * supply them.
16
+ *
17
+ * `Intl.DisplayNames` already knows every one — ~280 regions, ~5,244 surfaces, from the same ICU the runtime uses for
18
+ * every other locale-sensitive operation. No download, no vendored corpus, no snapshot to drift.
19
+ *
20
+ * `is_primary = 0`: these are NAMES THE WORLD USES, not the country's canonical name. The display `name` stays whatever
21
+ * the gazetteer already had, so resolving `格鲁吉亚` answers with the Georgia country row rather than renaming it.
22
+ *
23
+ * Returns the row count so the caller can report it — a zero means ICU supplied nothing, which is a different fact from
24
+ * the pass not having run.
25
+ */
26
+ export declare function stageCountryDisplayNames(ctx: {
27
+ attrs: Map<number, PlaceAttrs>;
28
+ iso2ByID: Map<number, string>;
29
+ countryPtID: number;
30
+ stageRow: StageRow;
31
+ tx: {
32
+ exec(sql: string): void;
33
+ };
34
+ }): number;
35
+ //# sourceMappingURL=country-display-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country-display-names.d.ts","sourceRoot":"","sources":["../../candidate/country-display-names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE;IAC7C,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,QAAQ,CAAA;IAClB,EAAE,EAAE;QAAE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAC/B,GAAG,MAAM,CA0CT"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Pass 1b of the candidate build — fold ICU's country display names onto the country rows.
6
+ */
7
+ import { enumerateCountryDisplayNames } from "@mailwoman/codex/country";
8
+ import { normalizeLocalityForKey } from "../street-normalize.js";
9
+ /**
10
+ * Fold every country surface ICU knows onto that country's candidate row (#1678 thread 1).
11
+ *
12
+ * A bare `格鲁吉亚` (Georgia the country) resolved to NOTHING while `佐治亚州` (Georgia the US state) resolved correctly, and
13
+ * the model gave both the same wrong `locality` tag — so the tag was never the variable. Measured 2026-08-15: 140 of
14
+ * 237 country rows are synthetic and carry a canonical English name and nothing else; WOF holds no Chinese country
15
+ * names at all; and the GeoNames alias fold filters through a Latin-script regex, so neither existing source could ever
16
+ * supply them.
17
+ *
18
+ * `Intl.DisplayNames` already knows every one — ~280 regions, ~5,244 surfaces, from the same ICU the runtime uses for
19
+ * every other locale-sensitive operation. No download, no vendored corpus, no snapshot to drift.
20
+ *
21
+ * `is_primary = 0`: these are NAMES THE WORLD USES, not the country's canonical name. The display `name` stays whatever
22
+ * the gazetteer already had, so resolving `格鲁吉亚` answers with the Georgia country row rather than renaming it.
23
+ *
24
+ * Returns the row count so the caller can report it — a zero means ICU supplied nothing, which is a different fact from
25
+ * the pass not having run.
26
+ */
27
+ export function stageCountryDisplayNames(ctx) {
28
+ // One country row per ISO2. Where a code has several (historic rows surviving the is_current filter), the most
29
+ // populous wins — the same tiebreak the ranking uses everywhere else.
30
+ const countryByISO2 = new Map();
31
+ for (const [sid, a] of ctx.attrs) {
32
+ if (a.ptid !== ctx.countryPtID)
33
+ continue;
34
+ const iso2 = ctx.iso2ByID.get(a.cid);
35
+ if (!iso2 || iso2 === "??")
36
+ continue;
37
+ const held = countryByISO2.get(iso2);
38
+ if (!held || a.pop > held.a.pop) {
39
+ countryByISO2.set(iso2, { sid, a });
40
+ }
41
+ }
42
+ let staged = 0;
43
+ ctx.tx.exec("BEGIN");
44
+ for (const { iso2, name } of enumerateCountryDisplayNames()) {
45
+ const target = countryByISO2.get(iso2);
46
+ if (!target)
47
+ continue;
48
+ const k = normalizeLocalityForKey(name);
49
+ // The country's own key is already staged as its primary; INSERT OR IGNORE at materialization dedupes the
50
+ // rest, so this only skips the obvious self-alias.
51
+ if (!k || k === target.a.pkey)
52
+ continue;
53
+ ctx.stageRow(k, target.a, target.sid, 0);
54
+ staged++;
55
+ }
56
+ ctx.tx.exec("COMMIT");
57
+ return staged;
58
+ }
59
+ //# sourceMappingURL=country-display-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country-display-names.js","sourceRoot":"","sources":["../../candidate/country-display-names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA;AAEvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAGhE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAMxC;IACA,+GAA+G;IAC/G,sEAAsE;IACtE,MAAM,aAAa,GAAG,IAAI,GAAG,EAA0C,CAAA;IAEvE,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QAClC,IAAI,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,WAAW;YAAE,SAAQ;QAExC,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QAEpC,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI;YAAE,SAAQ;QAEpC,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEpC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;YACjC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;QACpC,CAAC;IACF,CAAC;IAED,IAAI,MAAM,GAAG,CAAC,CAAA;IAEd,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAEpB,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,4BAA4B,EAAE,EAAE,CAAC;QAC7D,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEtC,IAAI,CAAC,MAAM;YAAE,SAAQ;QAErB,MAAM,CAAC,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAA;QAEvC,0GAA0G;QAC1G,mDAAmD;QACnD,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI;YAAE,SAAQ;QAEvC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAExC,MAAM,EAAE,CAAA;IACT,CAAC;IAED,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAErB,OAAO,MAAM,CAAA;AACd,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Pass 3c of the candidate build — the `name_role` detectors and the cuts they are judged by.
6
+ */
7
+ import type { DatabaseSync } from "node:sqlite";
8
+ import type { PlaceAttrs } from "./place-attrs.ts";
9
+ /**
10
+ * Key-count cut for the gloss anomaly detector (#1730) — the sweep's own boundary: 4,000 places carried >= 50 keys, and
11
+ * a legitimate famous place at that count (New York, 176 keys) is separated by the PROMINENCE gate, never by this
12
+ * number alone.
13
+ */
14
+ export declare const GLOSS_KEY_THRESHOLD = 50;
15
+ /**
16
+ * Placetypes the gloss detector never flags. A country or region legitimately carries a name in every language — that
17
+ * is what an exonym set IS — so key volume discriminates nothing there. The detector's population is the non-admin
18
+ * tail, where a place named by a common noun ("Poisson", "Sunday") accumulating 200+ translations is a
19
+ * machine-translated gloss set, not fame.
20
+ */
21
+ export declare const GLOSS_EXCLUDED_PLACETYPES: ReadonlySet<string>;
22
+ /**
23
+ * Pass 3c — the #1730 name-role prototype: two independent detectors over the staged rows, WRITE-ONLY in this
24
+ * generation (no ranking consumer; the rank penalty is its own D-rule-gated step with the `gloss_key` board as
25
+ * tripwire). Both stamp `is_primary = 0` rows only — a place's canonical name and the `place_abbr` region abbreviations
26
+ * are never a gloss or a variant.
27
+ *
28
+ * - `gloss` is ANOMALY-based, and stamps only the certain core: key volume at/over the threshold + a non-admin placetype
29
+ *
30
+ * - NO measured prominence (population absent AND importance unmeasured). Provenance cannot separate a gloss from an
31
+ * exonym — WOF imported both as `x_preferred` — and prominence is what rescues New York/Paris.
32
+ * - `abbr` is PROVENANCE-based — the #936 signal: a WOF `variant` name in one of the country's official languages (or
33
+ * English), measured there at a 13× key-collision rate. A source without a `names` table (fixture-scale admin DBs)
34
+ * skips this detector loudly.
35
+ *
36
+ * Returns the stamp counts plus the census the prototype exists to report: how much of the ≥-threshold key tail carries
37
+ * any role.
38
+ */
39
+ export declare function stampNameRoles(ctx: {
40
+ src: DatabaseSync;
41
+ out: DatabaseSync;
42
+ attrs: Map<number, PlaceAttrs>;
43
+ keyCounts: Map<number, number>;
44
+ glossThreshold: number;
45
+ ptcodes: Map<string, number>;
46
+ ccodes: Map<string, number>;
47
+ progress: (phase: string, message: string) => void;
48
+ }): {
49
+ roleGloss: number;
50
+ roleAbbr: number;
51
+ roleVariant: number;
52
+ keyTailPlaces: number;
53
+ keyTailWithRole: number;
54
+ };
55
+ //# sourceMappingURL=name-roles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-roles.d.ts","sourceRoot":"","sources":["../../candidate/name-roles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,MAAM,CASxD,CAAA;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE;IACnC,GAAG,EAAE,YAAY,CAAA;IACjB,GAAG,EAAE,YAAY,CAAA;IACjB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAClD,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CA2K/G"}
@@ -0,0 +1,165 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Pass 3c of the candidate build — the `name_role` detectors and the cuts they are judged by.
6
+ */
7
+ import { isOfficialLanguage } from "@mailwoman/codex/country";
8
+ import { normalizeLocalityForKey } from "../street-normalize.js";
9
+ import { isOwnNameVariant } from "./own-name.js";
10
+ /**
11
+ * Key-count cut for the gloss anomaly detector (#1730) — the sweep's own boundary: 4,000 places carried >= 50 keys, and
12
+ * a legitimate famous place at that count (New York, 176 keys) is separated by the PROMINENCE gate, never by this
13
+ * number alone.
14
+ */
15
+ export const GLOSS_KEY_THRESHOLD = 50;
16
+ /**
17
+ * Placetypes the gloss detector never flags. A country or region legitimately carries a name in every language — that
18
+ * is what an exonym set IS — so key volume discriminates nothing there. The detector's population is the non-admin
19
+ * tail, where a place named by a common noun ("Poisson", "Sunday") accumulating 200+ translations is a
20
+ * machine-translated gloss set, not fame.
21
+ */
22
+ export const GLOSS_EXCLUDED_PLACETYPES = new Set([
23
+ "country",
24
+ "dependency",
25
+ "disputed",
26
+ "empire",
27
+ "macroregion",
28
+ "region",
29
+ "macrocounty",
30
+ "county",
31
+ ]);
32
+ /**
33
+ * Pass 3c — the #1730 name-role prototype: two independent detectors over the staged rows, WRITE-ONLY in this
34
+ * generation (no ranking consumer; the rank penalty is its own D-rule-gated step with the `gloss_key` board as
35
+ * tripwire). Both stamp `is_primary = 0` rows only — a place's canonical name and the `place_abbr` region abbreviations
36
+ * are never a gloss or a variant.
37
+ *
38
+ * - `gloss` is ANOMALY-based, and stamps only the certain core: key volume at/over the threshold + a non-admin placetype
39
+ *
40
+ * - NO measured prominence (population absent AND importance unmeasured). Provenance cannot separate a gloss from an
41
+ * exonym — WOF imported both as `x_preferred` — and prominence is what rescues New York/Paris.
42
+ * - `abbr` is PROVENANCE-based — the #936 signal: a WOF `variant` name in one of the country's official languages (or
43
+ * English), measured there at a 13× key-collision rate. A source without a `names` table (fixture-scale admin DBs)
44
+ * skips this detector loudly.
45
+ *
46
+ * Returns the stamp counts plus the census the prototype exists to report: how much of the ≥-threshold key tail carries
47
+ * any role.
48
+ */
49
+ export function stampNameRoles(ctx) {
50
+ const { src, out, attrs, keyCounts, glossThreshold, progress } = ctx;
51
+ progress("roles", "stamping name roles (gloss anomaly + abbr provenance)");
52
+ const ptNameByID = new Map([...ctx.ptcodes].map(([placetype, id]) => [id, placetype]));
53
+ const iso2ByCID = new Map([...ctx.ccodes].map(([code, id]) => [id, code]));
54
+ let keyTailPlaces = 0;
55
+ const glossSids = [];
56
+ for (const [sid, count] of keyCounts) {
57
+ if (count < glossThreshold)
58
+ continue;
59
+ keyTailPlaces++;
60
+ const a = attrs.get(sid);
61
+ if (!a)
62
+ continue;
63
+ if (GLOSS_EXCLUDED_PLACETYPES.has(ptNameByID.get(a.ptid) ?? ""))
64
+ continue;
65
+ if (a.pop > 0 || a.imp != null)
66
+ continue;
67
+ glossSids.push(sid);
68
+ }
69
+ out.exec("CREATE TEMP TABLE role_key (spr_id INTEGER NOT NULL, name_key TEXT NOT NULL, PRIMARY KEY (spr_id, name_key)) WITHOUT ROWID");
70
+ const insRoleKey = out.prepare("INSERT OR IGNORE INTO role_key VALUES (?, ?)");
71
+ // Zero abbr stamps from a skipped detector is a different fact from zero variants found.
72
+ const hasSourceNames = src.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='names'").get() !== undefined;
73
+ if (hasSourceNames) {
74
+ out.exec("BEGIN");
75
+ // Two provenance routes into the same stamp: WOF's abbreviation/short name KINDS arrive in the
76
+ // LANGUAGE column ('abbr'/'short' — 280 rows, measured 2026-08-18, Toledo's 'TO' among them) and
77
+ // qualify by kind alone; everything else qualifies as a variant in an official language.
78
+ for (const r of src
79
+ .prepare("SELECT id, name, language FROM names WHERE privateuse = 'variant' OR language IN ('abbr', 'short')")
80
+ .iterate()) {
81
+ const a = attrs.get(Number(r.id));
82
+ if (!a)
83
+ continue;
84
+ const language = String(r.language ?? "");
85
+ if (language !== "abbr" && language !== "short") {
86
+ const iso2 = iso2ByCID.get(a.cid) ?? "??";
87
+ if (language !== "eng" && !isOfficialLanguage(iso2, language))
88
+ continue;
89
+ }
90
+ const k = normalizeLocalityForKey(String(r.name ?? ""));
91
+ if (!k || k === a.pkey)
92
+ continue;
93
+ insRoleKey.run(Number(r.id), k);
94
+ }
95
+ out.exec("COMMIT");
96
+ }
97
+ else {
98
+ progress("roles", "source carries no `names` table — abbr detector skipped (gloss still runs)");
99
+ }
100
+ // Stamp order is precedence: the provenance-based abbr first, then the own-name variant verdict,
101
+ // then gloss fills what neither claimed.
102
+ const roleAbbr = Number(out
103
+ .prepare(`UPDATE cand_stage SET name_role = 'abbr'
104
+ WHERE is_primary = 0 AND EXISTS (
105
+ SELECT 1 FROM role_key rk WHERE rk.spr_id = cand_stage.spr_id AND rk.name_key = cand_stage.name_key)`)
106
+ .run().changes);
107
+ // --- variant detector (#1882): the alias surface is the holder's OWN primary name in another
108
+ // orthography — romanization, spacing/diacritic variant, or abbreviation expansion. The verdict
109
+ // is per (alias key, primary key) pair, so it runs in JS over the still-unstamped alias rows;
110
+ // an uncovered script answers no-verdict and stamps nothing (own-name.ts owns the predicate and
111
+ // its measured threshold). Runs BEFORE gloss on purpose: a surface that IS the place's own name
112
+ // is not a translation, whatever the key volume says.
113
+ out.exec("CREATE TEMP TABLE variant_key (spr_id INTEGER NOT NULL, name_key TEXT NOT NULL, PRIMARY KEY (spr_id, name_key)) WITHOUT ROWID");
114
+ const insVariantKey = out.prepare("INSERT OR IGNORE INTO variant_key VALUES (?, ?)");
115
+ let variantScanned = 0;
116
+ out.exec("BEGIN");
117
+ for (const r of out
118
+ .prepare("SELECT DISTINCT spr_id, name_key FROM cand_stage WHERE is_primary = 0 AND name_role IS NULL")
119
+ .iterate()) {
120
+ variantScanned++;
121
+ const a = attrs.get(Number(r.spr_id));
122
+ if (!a?.pkey)
123
+ continue;
124
+ if (isOwnNameVariant(String(a.pkey), String(r.name_key))) {
125
+ insVariantKey.run(Number(r.spr_id), String(r.name_key));
126
+ }
127
+ }
128
+ out.exec("COMMIT");
129
+ const roleVariant = Number(out
130
+ .prepare(`UPDATE cand_stage SET name_role = 'variant'
131
+ WHERE is_primary = 0 AND name_role IS NULL AND EXISTS (
132
+ SELECT 1 FROM variant_key vk WHERE vk.spr_id = cand_stage.spr_id AND vk.name_key = cand_stage.name_key)`)
133
+ .run().changes);
134
+ out.exec("DROP TABLE variant_key");
135
+ progress("roles", `variant: ${roleVariant.toLocaleString()} of ${variantScanned.toLocaleString()} unstamped alias keys are own-name variants`);
136
+ out.exec("CREATE TEMP TABLE role_place (spr_id INTEGER PRIMARY KEY) WITHOUT ROWID");
137
+ out.exec("CREATE TEMP TABLE key_tail (spr_id INTEGER PRIMARY KEY) WITHOUT ROWID");
138
+ const insRolePlace = out.prepare("INSERT OR IGNORE INTO role_place VALUES (?)");
139
+ const insKeyTail = out.prepare("INSERT OR IGNORE INTO key_tail VALUES (?)");
140
+ out.exec("BEGIN");
141
+ for (const sid of glossSids) {
142
+ insRolePlace.run(sid);
143
+ }
144
+ for (const [sid, count] of keyCounts) {
145
+ if (count >= glossThreshold) {
146
+ insKeyTail.run(sid);
147
+ }
148
+ }
149
+ out.exec("COMMIT");
150
+ const roleGloss = Number(out
151
+ .prepare(`UPDATE cand_stage SET name_role = 'gloss'
152
+ WHERE is_primary = 0 AND name_role IS NULL AND spr_id IN (SELECT spr_id FROM role_place)`)
153
+ .run().changes);
154
+ const keyTailWithRole = Number(out
155
+ .prepare(`SELECT count(DISTINCT spr_id) AS n FROM cand_stage
156
+ WHERE name_role IS NOT NULL AND spr_id IN (SELECT spr_id FROM key_tail)`)
157
+ .get()["n"]);
158
+ out.exec("DROP TABLE role_key");
159
+ out.exec("DROP TABLE role_place");
160
+ out.exec("DROP TABLE key_tail");
161
+ progress("roles", `${roleAbbr.toLocaleString()} abbr + ${roleGloss.toLocaleString()} gloss rows stamped; ` +
162
+ `key tail (>= ${glossThreshold} keys): ${keyTailWithRole.toLocaleString()} of ${keyTailPlaces.toLocaleString()} places carry a role`);
163
+ return { roleGloss, roleAbbr, roleVariant, keyTailPlaces, keyTailWithRole };
164
+ }
165
+ //# sourceMappingURL=name-roles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-roles.js","sourceRoot":"","sources":["../../candidate/name-roles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAGhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC;IACrE,SAAS;IACT,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,aAAa;IACb,QAAQ;IACR,aAAa;IACb,QAAQ;CACR,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,GAS9B;IACA,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;IACpE,QAAQ,CAAC,OAAO,EAAE,uDAAuD,CAAC,CAAA;IAE1E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;IACtF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,C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AS,EAAE,CAAC;QACtC,IAAI,KAAK,IAAI,cAAc,EAAE,CAAC;YAC7B,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACpB,CAAC;IACF,CAAC;IAED,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAElB,MAAM,SAAS,GAAG,MAAM,CACvB,GAAG;SACD,OAAO,CACP;8FAC0F,CAC1F;SACA,GAAG,EAAE,CAAC,OAAO,CACf,CAAA;IAED,MAAM,eAAe,GAAG,MAAM,CAC7B,GAAG;SACD,OAAO,CACP;6EACyE,CACzE;SACA,GAAG,EAAG,CAAC,GAAG,CAAC,CACb,CAAA;IAED,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;IAC/B,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;IACjC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;IAE/B,QAAQ,CACP,OAAO,EACP,GAAG,QAAQ,CAAC,cAAc,EAAE,WAAW,SAAS,CAAC,cAAc,EAAE,uBAAuB;QACvF,gBAAgB,cAAc,WAAW,eAAe,CAAC,cAAc,EAAE,OAAO,aAAa,CAAC,cAAc,EAAE,sBAAsB,CACrI,CAAA;IAED,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,CAAA;AAC5E,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The OWN-NAME VARIANT predicate (#1882): is an alias surface the holder's own primary name in
7
+ * another orthography — a romanization (`Брэст` → `brest`), a spacing/diacritic variant
8
+ * (`George Town` → `georgetown`), an abbreviation expansion (`St. George's` → `Saint George's`)
9
+ * — rather than a different name that merely shares the folded key?
10
+ *
11
+ * The comparator is `levenshteinSimilarity`, NOT Jaro-Winkler: JW's common-prefix bonus scores
12
+ * the load-bearing NEGATIVE case (`chanchun` vs `cancun`, 0.925) above real positives
13
+ * (`saint george s` vs `st georges` expanded, 0.914), so no JW threshold separates them.
14
+ * Measured on the #1882 census contests, edit similarity separates every case with margin:
15
+ *
16
+ * - IN: `brest`/`brest` 1.0 · `george town`/`georgetown` 0.909 · `saint george s`/`saint georges`
17
+ * 0.929 · `adamovka`/`adamowka` 0.875
18
+ * - OUT: `lievin`/`levin` 0.833 (Liévin FR vs Levin NZ — different places with near-identical
19
+ * names; the panel's `41 Weraroa Road, Levin` row needs this side) · `chanchun`/`cancun` 0.75 ·
20
+ * `augsburg`/`augusta` 0.375 · `west bay`/`west end` 0.625 · `derry`/`londonderry` 0.455
21
+ * (Derry/Londonderry is a DUAL NAME, not a variant — its own follow-up on #1882)
22
+ *
23
+ * An unhandled script (Arabic, Hebrew, CJK — the romanizer covers Cyrillic only) answers NULL,
24
+ * never "different name": absence of a verdict must not stamp anything (the meaning-of-zero rule).
25
+ * The #1882 census counted 396 demoted Arabic/Hebrew-primary aliases left unclassified by this.
26
+ */
27
+ /**
28
+ * Edit-similarity floor for the variant verdict. The measured band: nearest admitted pair 0.875
29
+ * (`adamovka`/`adamowka`), nearest refused pair 0.833 (`lievin`/`levin`).
30
+ */
31
+ export declare const VARIANT_SIMILARITY_MIN = 0.85;
32
+ /**
33
+ * Expand the whole-word abbreviations above.
34
+ */
35
+ export declare function expandNameAbbreviations(key: string): string;
36
+ /**
37
+ * Romanize a folded name key to the a–z0–9/space alphabet. `null` when characters outside the covered scripts remain —
38
+ * an unhandled script is NO VERDICT, not a mismatch.
39
+ */
40
+ export declare function romanizeNameKey(key: string): string | null;
41
+ /**
42
+ * Edit similarity between a holder's primary name key and one of its alias keys, both romanized and
43
+ * abbreviation-expanded. `null` when either side's script is uncovered.
44
+ */
45
+ export declare function ownNameSimilarity(primaryKey: string, aliasKey: string): number | null;
46
+ /**
47
+ * The stamp predicate: the alias surface is the holder's own name in another orthography.
48
+ */
49
+ export declare function isOwnNameVariant(primaryKey: string, aliasKey: string): boolean;
50
+ //# sourceMappingURL=own-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"own-name.d.ts","sourceRoot":"","sources":["../../candidate/own-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;;GAGG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAA;AA2D1C;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ3D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAc1D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOrF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI9E"}