@mailwoman/resolver-wof-sqlite 10.3.0 → 10.5.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 +14 -14
- package/lib/address/point/schema.ts +1 -1
- package/lib/address/point.ts +81 -3
- package/lib/candidate/ancestors/sidecar.ts +3 -3
- package/lib/candidate/importance.ts +2 -2
- package/lib/candidate/own-name.ts +1 -1
- package/lib/coincident-roles.ts +1 -1
- package/lib/currency-backfill.ts +2 -2
- package/lib/extracts.ts +1 -1
- package/lib/fst/autocomplete.ts +3 -3
- package/lib/fst/deserialize-web.ts +1 -1
- package/lib/fst/format.ts +1 -1
- package/lib/geonames/postal.ts +3 -3
- package/lib/interpolation.ts +2 -2
- package/lib/lookup.ts +1 -1
- package/lib/nsul/lookup.ts +33 -0
- package/lib/nsul/schema.ts +6 -0
- package/lib/paths.ts +1 -1
- package/lib/place-importance-schema.ts +1 -1
- package/lib/poi/lookup.ts +2 -2
- package/lib/polygon-schema.ts +1 -1
- package/lib/postal/city/alias/lookup.ts +1 -1
- package/lib/postal/city/alias/schema.ts +2 -2
- package/lib/proximity-rerank.ts +1 -1
- package/lib/search-fetch.ts +5 -5
- package/lib/street/centroid/schema.ts +1 -1
- package/lib/street/morphology/fst/builder.ts +34 -14
- package/lib/street/normalize.ts +1 -1
- package/lib/street/segment-schema.ts +1 -1
- package/lib/types.ts +2 -1
- package/lib/uprn/lookup.ts +1 -1
- package/lib/weights-overlay-linker.ts +41 -1
- package/out/address/point/schema.js +1 -1
- package/out/address/point/schema.js.map +1 -1
- package/out/address/point.d.ts +9 -0
- package/out/address/point.d.ts.map +1 -1
- package/out/address/point.js +60 -2
- package/out/address/point.js.map +1 -1
- package/out/candidate/ancestors/sidecar.js +3 -3
- package/out/candidate/ancestors/sidecar.js.map +1 -1
- package/out/candidate/importance.d.ts +2 -2
- package/out/candidate/importance.js +1 -1
- package/out/candidate/own-name.js +1 -1
- package/out/coincident-roles.d.ts +1 -1
- package/out/coincident-roles.js +1 -1
- package/out/currency-backfill.d.ts +2 -2
- package/out/extracts.d.ts +1 -1
- package/out/fst/autocomplete.js +3 -3
- package/out/fst/deserialize-web.js +1 -1
- package/out/fst/format.d.ts +1 -1
- package/out/fst/format.js +1 -1
- package/out/geonames/postal.d.ts +3 -3
- package/out/geonames/postal.js +2 -2
- package/out/interpolation.js +2 -2
- package/out/lookup.js +1 -1
- package/out/nsul/lookup.d.ts +18 -0
- package/out/nsul/lookup.d.ts.map +1 -1
- package/out/nsul/lookup.js +11 -0
- package/out/nsul/lookup.js.map +1 -1
- package/out/nsul/schema.d.ts +5 -0
- package/out/nsul/schema.d.ts.map +1 -1
- package/out/nsul/schema.js +1 -0
- package/out/nsul/schema.js.map +1 -1
- package/out/paths.d.ts +1 -1
- package/out/paths.js +1 -1
- package/out/place-importance-schema.d.ts +1 -1
- package/out/poi/lookup.d.ts +1 -1
- package/out/poi/lookup.js +1 -1
- package/out/polygon-schema.d.ts +1 -1
- package/out/postal/city/alias/lookup.d.ts +1 -1
- package/out/postal/city/alias/lookup.js +1 -1
- package/out/postal/city/alias/schema.d.ts +2 -2
- package/out/postal/city/alias/schema.js +1 -1
- package/out/proximity-rerank.js +1 -1
- package/out/proximity-rerank.js.map +1 -1
- package/out/search-fetch.js +5 -5
- package/out/search-fetch.js.map +1 -1
- package/out/street/centroid/schema.d.ts +1 -1
- package/out/street/morphology/fst/builder.d.ts +21 -9
- package/out/street/morphology/fst/builder.d.ts.map +1 -1
- package/out/street/morphology/fst/builder.js +14 -5
- package/out/street/morphology/fst/builder.js.map +1 -1
- package/out/street/normalize.js +1 -1
- package/out/street/normalize.js.map +1 -1
- package/out/street/segment-schema.d.ts +1 -1
- package/out/street/segment-schema.js +1 -1
- package/out/types.d.ts +2 -1
- package/out/types.d.ts.map +1 -1
- package/out/uprn/lookup.js +1 -1
- package/out/weights-overlay-linker.d.ts +11 -0
- package/out/weights-overlay-linker.d.ts.map +1 -1
- package/out/weights-overlay-linker.js +22 -1
- package/out/weights-overlay-linker.js.map +1 -1
- package/package.json +10 -10
|
@@ -31,7 +31,7 @@ export interface StreetCentroidTable {
|
|
|
31
31
|
/**
|
|
32
32
|
* The commune key with any arrondissement removed.
|
|
33
33
|
*
|
|
34
|
-
* BAN stores Paris, Lyon and Marseille per arrondissement, but a query
|
|
34
|
+
* BAN stores Paris, Lyon and Marseille per arrondissement, but a query can give only the base commune.
|
|
35
35
|
* The reader uses this column when the query has no postcode.
|
|
36
36
|
*/
|
|
37
37
|
locality_base: NameKey
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
* `fst-street-morphology.bin`.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
+
import { AU_STATE_ABBREVIATIONS } from "@mailwoman/codex/au/state"
|
|
28
|
+
import { CA_PROVINCES } from "@mailwoman/codex/ca/province"
|
|
29
|
+
import { US_STATE_ABBREVIATIONS } from "@mailwoman/codex/us/state"
|
|
27
30
|
import { readLocalTextFile } from "@mailwoman/core/fs/readers"
|
|
28
31
|
import { isDirectory, isFile } from "@mailwoman/core/fs/readers/stat"
|
|
29
32
|
import { PathBuilder, type PathBuilderLike } from "path-ts"
|
|
@@ -45,6 +48,17 @@ const STREET_AFFIX_WOFID_BASE = 1_900_000_000
|
|
|
45
48
|
|
|
46
49
|
const STREET_TYPES_FILENAME = "street_types.txt"
|
|
47
50
|
|
|
51
|
+
/**
|
|
52
|
+
* The region abbreviations the codex holds, in the lower-case joined form the trie keys use.
|
|
53
|
+
*
|
|
54
|
+
* A street-type variant that spells one of these is excluded from the trie by default.
|
|
55
|
+
*/
|
|
56
|
+
export const REGION_ABBREVIATION_VARIANTS: ReadonlySet<string> = new Set(
|
|
57
|
+
[...US_STATE_ABBREVIATIONS, ...Object.keys(AU_STATE_ABBREVIATIONS), ...Object.keys(CA_PROVINCES)].map((code) =>
|
|
58
|
+
code.toLowerCase()
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
|
|
48
62
|
export interface BuildStreetMorphologyFSTOpts {
|
|
49
63
|
/**
|
|
50
64
|
* Path to the `core/data/libpostal/dictionaries` directory containing per-locale subfolders.
|
|
@@ -59,19 +73,25 @@ export interface BuildStreetMorphologyFSTOpts {
|
|
|
59
73
|
/**
|
|
60
74
|
* Minimum length (in characters, post-normalization) of variant surface forms to insert into the trie.
|
|
61
75
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
76
|
+
* libpostal's street_types dictionaries hold one-character variants (`a`, `b`, `c`) that collide
|
|
77
|
+
* with unit designators and single letters at parse time, so the default admits two characters
|
|
78
|
+
* and more: `st`, `rd`, `av`, `dr`, `ln`, `pl` and `sq` beside `ave`, `blvd`, `rue` and `str`.
|
|
79
|
+
* The two-character variants that are a region abbreviation go through {@link excludedVariants}.
|
|
66
80
|
*
|
|
67
|
-
*
|
|
68
|
-
|
|
81
|
+
* @defaultValue `2`
|
|
82
|
+
*/
|
|
83
|
+
minVariantLength?: number
|
|
84
|
+
/**
|
|
85
|
+
* Variant surface forms, in joined post-normalization form, that the trie never holds.
|
|
69
86
|
*
|
|
70
|
-
* A
|
|
87
|
+
* A two-character street type that is also a region abbreviation, `ct` for court
|
|
88
|
+
* and Connecticut or `la` for lane and Louisiana, reads as the region at parse time.
|
|
89
|
+
* The artifact is locale-general, so the variant stays out for every locale.
|
|
71
90
|
*
|
|
72
|
-
* @defaultValue
|
|
91
|
+
* @defaultValue {@link REGION_ABBREVIATION_VARIANTS}, the codex's US state, Australian state and
|
|
92
|
+
* Canadian province abbreviations
|
|
73
93
|
*/
|
|
74
|
-
|
|
94
|
+
excludedVariants?: ReadonlySet<string>
|
|
75
95
|
/**
|
|
76
96
|
* Optional progress callback.
|
|
77
97
|
*/
|
|
@@ -111,7 +131,8 @@ export async function buildStreetMorphologyFST(
|
|
|
111
131
|
opts: BuildStreetMorphologyFSTOpts
|
|
112
132
|
): Promise<BuildStreetMorphologyFSTResult> {
|
|
113
133
|
const progress = opts.onProgress ?? (() => {})
|
|
114
|
-
const minVariantLength = opts.minVariantLength ??
|
|
134
|
+
const minVariantLength = opts.minVariantLength ?? 2
|
|
135
|
+
const excludedVariants = opts.excludedVariants ?? REGION_ABBREVIATION_VARIANTS
|
|
115
136
|
const dictionariesDir = PathBuilder.from(opts.dictionariesDir)
|
|
116
137
|
|
|
117
138
|
// Discover locales — either provided explicitly, or all directories containing street_types.txt.
|
|
@@ -223,7 +244,7 @@ export async function buildStreetMorphologyFST(
|
|
|
223
244
|
// Fixed referential score: street affixes are structurally unambiguous
|
|
224
245
|
// (Avenue is almost never anything but street-typing).
|
|
225
246
|
// The morphology prior caps bias separately.
|
|
226
|
-
// This value
|
|
247
|
+
// This value only feeds the cap formula `referential * cap`.
|
|
227
248
|
// No encyclopedic score — a street affix is not a place and has no article.
|
|
228
249
|
referential: 1,
|
|
229
250
|
encyclopedic: null,
|
|
@@ -236,11 +257,10 @@ export async function buildStreetMorphologyFST(
|
|
|
236
257
|
const tokens = normalizeTokens(variant)
|
|
237
258
|
|
|
238
259
|
if (!tokens.length) continue
|
|
239
|
-
//
|
|
240
|
-
// We measure against the joined token form (no spaces) since FST keys are token sequences.
|
|
260
|
+
// The length and the exclusions read the joined token form, since FST keys are token sequences.
|
|
241
261
|
const joined = tokens.join("")
|
|
242
262
|
|
|
243
|
-
if (joined.length < minVariantLength) continue
|
|
263
|
+
if (joined.length < minVariantLength || excludedVariants.has(joined)) continue
|
|
244
264
|
insertName(tokens, entry)
|
|
245
265
|
|
|
246
266
|
insertCount++
|
package/lib/street/normalize.ts
CHANGED
|
@@ -272,7 +272,7 @@ export function normalizeStreetForKeyLocale(street: string, locale: StreetLocale
|
|
|
272
272
|
break
|
|
273
273
|
case "es":
|
|
274
274
|
// Keep the leading type, as `it` does and more strongly, because `Calle Mayor`
|
|
275
|
-
// and `Plaza Mayor`
|
|
275
|
+
// and `Plaza Mayor` can share a municipio.
|
|
276
276
|
if (tokens.length > 1) {
|
|
277
277
|
tokens[0] = ES_STREET_TYPE_ABBREV.get(tokens[0]!) ?? tokens[0]!
|
|
278
278
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The builder reads geometry from shapefiles via DuckDB's spatial extension (raw `ST_Read`, see
|
|
13
13
|
* agents.md "Database / inline SQL") and writes here through `node:sqlite`. The hot positional
|
|
14
|
-
* insert (
|
|
14
|
+
* insert (every edge in a county) stays raw. Its column list derives from
|
|
15
15
|
* {@link STREET_SEGMENT_COLUMNS} so it cannot drift from the DDL.
|
|
16
16
|
*/
|
|
17
17
|
|
package/lib/types.ts
CHANGED
|
@@ -181,7 +181,8 @@ export interface FindPlaceQuery {
|
|
|
181
181
|
regionQualifier?: string
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
|
-
* A proximity hint that boosts
|
|
184
|
+
* A proximity hint that boosts candidates closer to the point and filters by
|
|
185
|
+
* radius only when `maxDistanceKm` is set.
|
|
185
186
|
*/
|
|
186
187
|
near?: LatLon & { maxDistanceKm?: number }
|
|
187
188
|
|
package/lib/uprn/lookup.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { PathBuilderLike } from "path-ts"
|
|
|
15
15
|
import type { UPRNDatabase } from "#uprn/schema"
|
|
16
16
|
import { uprnFullCell } from "#uprn/schema"
|
|
17
17
|
/**
|
|
18
|
-
* Conservative floor, in meters, on the center distance one unit of res-9 grid distance
|
|
18
|
+
* Conservative floor, in meters, on the center distance one unit of res-9 grid distance covers,
|
|
19
19
|
* so multiplying a grid distance under-states reach and can never end the ring walk early.
|
|
20
20
|
*/
|
|
21
21
|
const RES9_CENTER_SPACING_FLOOR_M = 150
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { md5File } from "@mailwoman/core/hash"
|
|
18
18
|
import { parseJSONStrict } from "@mailwoman/core/json"
|
|
19
19
|
import { repoRootPath, repoRootPathBuilder, workspacePathBuilder } from "@mailwoman/core/paths"
|
|
20
|
+
import { newestPostcodePrefixFiles, shippedPostcodePrefixName } from "@mailwoman/core/postcode-prefix-files"
|
|
20
21
|
import { spawnProcessSync } from "@mailwoman/core/process"
|
|
21
22
|
import { readReleaseConfig, repoCommittedSoftFeedSources } from "@mailwoman/core/release-config"
|
|
22
23
|
import type { PathBuilder, PathBuilderLike } from "path-ts"
|
|
@@ -327,6 +328,34 @@ export async function linkLocaleFST(destDir: PathBuilder, locale: string): Promi
|
|
|
327
328
|
}
|
|
328
329
|
}
|
|
329
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Symlinks the newest dated PFX1 postcode-prefix index of each scope into an overlay under
|
|
333
|
+
* the scope's shipped name, so the anchor-region prior reads the file the package would ship.
|
|
334
|
+
*/
|
|
335
|
+
export async function linkPostcodePrefixIndexes(destDir: PathBuilder, scopes: readonly string[]): Promise<void> {
|
|
336
|
+
const newest = await newestPostcodePrefixFiles()
|
|
337
|
+
|
|
338
|
+
for (const scope of scopes) {
|
|
339
|
+
const file = newest.get(scope)
|
|
340
|
+
const name = shippedPostcodePrefixName(scope)
|
|
341
|
+
|
|
342
|
+
if (!file) {
|
|
343
|
+
console.error(
|
|
344
|
+
`WARNING: no postcode-prefix index for scope "${scope}" under ${dataRootPath("postcode-prefix")} — ` +
|
|
345
|
+
`the anchor-region prior reads the data-root directory instead of ${name}.`
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
continue
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
await linkSoftFeedSibling(
|
|
352
|
+
file.path,
|
|
353
|
+
destDir(name),
|
|
354
|
+
"the anchor-region prior reads the data-root directory instead."
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
330
359
|
/**
|
|
331
360
|
* Symlinks the prebuilt street-morphology FST into an overlay so that the
|
|
332
361
|
* street-context check does not rebuild it from dictionaries.
|
|
@@ -594,6 +623,13 @@ export interface DevOverlayManifest {
|
|
|
594
623
|
*/
|
|
595
624
|
evidenceLexiconsFromCard?: boolean
|
|
596
625
|
|
|
626
|
+
/**
|
|
627
|
+
* The PFX1 postcode-prefix scopes to link as `postcode-prefix-<scope>.bin`, such as `["gb-esw"]`.
|
|
628
|
+
*
|
|
629
|
+
* Each links the newest dated index of its scope from the data root's `postcode-prefix` directory.
|
|
630
|
+
*/
|
|
631
|
+
postcodePrefixScopes?: readonly string[]
|
|
632
|
+
|
|
597
633
|
/**
|
|
598
634
|
* Builds `postcode-<country>.bin` from a WOF postcode extract with the compiled CLI.
|
|
599
635
|
* The step is skipped when the file already exists.
|
|
@@ -807,7 +843,7 @@ export async function materializeDevOverlay(manifest: DevOverlayManifest): Promi
|
|
|
807
843
|
|
|
808
844
|
await makeDirectories(destDir)
|
|
809
845
|
|
|
810
|
-
// A package that declares `mailwoman.baseWeights` inherits its graph whatever the manifest
|
|
846
|
+
// A package that declares `mailwoman.baseWeights` inherits its graph whatever the manifest lists,
|
|
811
847
|
// because `resolveWeights` takes the base's graph over a file in the overlay directory.
|
|
812
848
|
const inherits =
|
|
813
849
|
manifest.model?.kind === "inherit" || (!manifest.model && (await declaresBaseWeights(manifest.locale)))
|
|
@@ -859,5 +895,9 @@ export async function materializeDevOverlay(manifest: DevOverlayManifest): Promi
|
|
|
859
895
|
await linkStreetMorphologyFST(destDir)
|
|
860
896
|
}
|
|
861
897
|
|
|
898
|
+
if (manifest.postcodePrefixScopes?.length) {
|
|
899
|
+
await linkPostcodePrefixIndexes(destDir, manifest.postcodePrefixScopes)
|
|
900
|
+
}
|
|
901
|
+
|
|
862
902
|
return { destDir, cli, card }
|
|
863
903
|
}
|
|
@@ -57,7 +57,7 @@ export async function createAddressPointIndexes(db) {
|
|
|
57
57
|
.columns(["locality_norm", "street_norm", "number"])
|
|
58
58
|
.execute();
|
|
59
59
|
await db.schema.createIndex("idx_ap_streetkey").on("address_point").columns(["postcode", "street_key"]).execute();
|
|
60
|
-
// Street-first index for the bbox scope: OSM points
|
|
60
|
+
// Street-first index for the bbox scope: some OSM points have no postcode or locality,
|
|
61
61
|
// so the reader scopes a `(street_norm, number)` probe by the resolved locality's bbox.
|
|
62
62
|
await db.schema.createIndex("idx_ap_street").on("address_point").columns(["street_norm", "number"]).execute();
|
|
63
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../lib/address/point/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiEH;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,aAAa;IACb,YAAY;IACZ,QAAQ;IACR,MAAM;IACN,UAAU;IACV,eAAe;IACf,YAAY;IACZ,KAAK;IACL,KAAK;IACL,QAAQ;IACR,SAAS;IACT,YAAY;IACZ,WAAW;CACF,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,EAA4B;IACzE,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,eAAe,CAAC;SAC5B,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAEpD,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACnD,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/C,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;SACzB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;SAC7B,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC;SAClC,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACnD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC5C,SAAS,CAAC,KAAK,EAAE,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EAAE,SAAS,CAAC;SACjC,OAAO,EAAE,CAAA;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAA4B;IAC3E,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,iBAAiB,CAAC;SAC9B,EAAE,CAAC,eAAe,CAAC;SACnB,OAAO,CAAC,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;SAC9C,OAAO,EAAE,CAAA;IAEX,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,iBAAiB,CAAC;SAC9B,EAAE,CAAC,eAAe,CAAC;SACnB,OAAO,CAAC,CAAC,eAAe,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;SACnD,OAAO,EAAE,CAAA;IAEX,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;IACjH,uFAAuF;IACvF,wFAAwF;IACxF,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;AAC9G,CAAC"}
|
package/out/address/point.d.ts
CHANGED
|
@@ -31,12 +31,21 @@ export declare class AddressPointSqliteLookup<DB extends AddressPointDatabase =
|
|
|
31
31
|
* Some counties abbreviate them (`addi` for Addison).
|
|
32
32
|
* Other counties replace them with the parent town.
|
|
33
33
|
*
|
|
34
|
+
* @param opts.localityLevel The kind of place the extract stores in `locality_norm`.
|
|
35
|
+
* With `"place"`, `locality_norm` holds the place an address line gives, such as a BAN commune.
|
|
36
|
+
* With `"finest"`, `locality_norm` holds the finest place the source recorded.
|
|
37
|
+
* That place can be a part of the place the line gives.
|
|
38
|
+
* The OSM builder stores `addr:suburb` before `addr:city`, so
|
|
39
|
+
* `Teschener Weg 5, 14163 Berlin` is stored under `zehlendorf`.
|
|
40
|
+
*
|
|
34
41
|
* @defaultValue `"us"`
|
|
35
42
|
* @defaultValue `"abbreviated"` for `"us"` and `"full"` for every other locale.
|
|
43
|
+
* @defaultValue `"place"`
|
|
36
44
|
*/
|
|
37
45
|
constructor(dbPath: PathBuilderLike, opts?: {
|
|
38
46
|
streetLocale?: StreetLocale;
|
|
39
47
|
localityKeys?: "full" | "abbreviated";
|
|
48
|
+
localityLevel?: "place" | "finest";
|
|
40
49
|
});
|
|
41
50
|
find(query: {
|
|
42
51
|
street: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../lib/address/point.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,oBAAoB,EAAqB,MAAM,uBAAuB,CAAA;AAEpF,OAAO,EASN,KAAK,YAAY,EACjB,MAAM,mBAAmB,CAAA;AAc1B;;;;;;;;;;GAUG;AACH,qBAAa,wBAAwB,CAAC,EAAE,SAAS,oBAAoB,GAAG,oBAAoB,CAC3F,YAAW,kBAAkB,EAAE,UAAU;;
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../lib/address/point.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,oBAAoB,EAAqB,MAAM,uBAAuB,CAAA;AAEpF,OAAO,EASN,KAAK,YAAY,EACjB,MAAM,mBAAmB,CAAA;AAc1B;;;;;;;;;;GAUG;AACH,qBAAa,wBAAwB,CAAC,EAAE,SAAS,oBAAoB,GAAG,oBAAoB,CAC3F,YAAW,kBAAkB,EAAE,UAAU;;IAiCzC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YACC,MAAM,EAAE,eAAe,EACvB,IAAI,GAAE;QACL,YAAY,CAAC,EAAE,YAAY,CAAA;QAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,aAAa,CAAA;QACrC,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;KAC7B,EA6CN;IAED,IAAI,CAAC,KAAK,EAAE;QACX,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,IAAI,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAA;KAC/E,GAAG,eAAe,GAAG,IAAI,CAsCzB;IA4LD,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAEvB;CACD"}
|
package/out/address/point.js
CHANGED
|
@@ -27,8 +27,14 @@ export class AddressPointSqliteLookup {
|
|
|
27
27
|
#db;
|
|
28
28
|
#locale;
|
|
29
29
|
#localityKeys;
|
|
30
|
+
#localityLevel;
|
|
30
31
|
#byPostcode;
|
|
31
32
|
#byPostcodeLocality;
|
|
33
|
+
/**
|
|
34
|
+
* This query counts the distinct stored localities that hold one (postcode, street, number) key.
|
|
35
|
+
* Unit siblings share a locality, so they count once.
|
|
36
|
+
*/
|
|
37
|
+
#postcodeKeyPlaces;
|
|
32
38
|
#byLocality;
|
|
33
39
|
/**
|
|
34
40
|
* This query matches the locality key by its suffix, for a `zh` query that gives the 鄉鎮市區 without its 縣市.
|
|
@@ -47,19 +53,30 @@ export class AddressPointSqliteLookup {
|
|
|
47
53
|
* Some counties abbreviate them (`addi` for Addison).
|
|
48
54
|
* Other counties replace them with the parent town.
|
|
49
55
|
*
|
|
56
|
+
* @param opts.localityLevel The kind of place the extract stores in `locality_norm`.
|
|
57
|
+
* With `"place"`, `locality_norm` holds the place an address line gives, such as a BAN commune.
|
|
58
|
+
* With `"finest"`, `locality_norm` holds the finest place the source recorded.
|
|
59
|
+
* That place can be a part of the place the line gives.
|
|
60
|
+
* The OSM builder stores `addr:suburb` before `addr:city`, so
|
|
61
|
+
* `Teschener Weg 5, 14163 Berlin` is stored under `zehlendorf`.
|
|
62
|
+
*
|
|
50
63
|
* @defaultValue `"us"`
|
|
51
64
|
* @defaultValue `"abbreviated"` for `"us"` and `"full"` for every other locale.
|
|
65
|
+
* @defaultValue `"place"`
|
|
52
66
|
*/
|
|
53
67
|
constructor(dbPath, opts = {}) {
|
|
54
68
|
this.#db = new DatabaseClient(dbPath, { readOnly: true });
|
|
55
69
|
this.#locale = opts.streetLocale ?? "us";
|
|
56
70
|
this.#localityKeys = opts.localityKeys ?? (this.#locale === "us" ? "abbreviated" : "full");
|
|
71
|
+
this.#localityLevel = opts.localityLevel ?? "place";
|
|
57
72
|
// An extract without an `address_point` table, such as an interrupted build, makes every lookup miss.
|
|
58
73
|
if (hasTable(this.#db, "address_point")) {
|
|
59
74
|
this.#byPostcode = prepareGet(this.#db, `SELECT ${SELECT_COLS} FROM address_point
|
|
60
75
|
WHERE postcode = ? AND street_norm = ? AND number = ? LIMIT 1`);
|
|
61
76
|
this.#byPostcodeLocality = prepareGet(this.#db, `SELECT ${SELECT_COLS} FROM address_point
|
|
62
77
|
WHERE postcode = ? AND locality_norm = ? AND street_norm = ? AND number = ? LIMIT 1`);
|
|
78
|
+
this.#postcodeKeyPlaces = prepareGet(this.#db, `SELECT COUNT(DISTINCT locality_norm) AS places FROM address_point
|
|
79
|
+
WHERE postcode = ? AND street_norm = ? AND number = ?`);
|
|
63
80
|
this.#byLocality = prepareGet(this.#db, `SELECT ${SELECT_COLS} FROM address_point
|
|
64
81
|
WHERE locality_norm = ? AND street_norm = ? AND number = ? LIMIT 1`);
|
|
65
82
|
this.#byBbox = prepareGet(this.#db, `SELECT ${SELECT_COLS} FROM address_point
|
|
@@ -147,6 +164,8 @@ export class AddressPointSqliteLookup {
|
|
|
147
164
|
*/
|
|
148
165
|
#probe(streetNorm, number, query) {
|
|
149
166
|
let row = null;
|
|
167
|
+
// A postcode row stored under a different locality waits until the probe for the query's own locality misses.
|
|
168
|
+
let heldBack = null;
|
|
150
169
|
if (query.postcode) {
|
|
151
170
|
const postcode = query.postcode.trim();
|
|
152
171
|
const localityKey = query.locality ? this.#localityKey(query.locality) : null;
|
|
@@ -155,7 +174,12 @@ export class AddressPointSqliteLookup {
|
|
|
155
174
|
// The postcode-only row answers only if `#scopeContradicts` accepts it.
|
|
156
175
|
const agreeing = localityKey ? this.#byPostcodeLocality(postcode, localityKey, streetNorm, number) : null;
|
|
157
176
|
const candidate = agreeing ?? this.#byPostcode(postcode, streetNorm, number);
|
|
158
|
-
|
|
177
|
+
if (candidate && !this.#scopeContradicts(candidate, query)) {
|
|
178
|
+
row = candidate;
|
|
179
|
+
}
|
|
180
|
+
else if (candidate && this.#isSublocalityRow(candidate, postcode, streetNorm, number, query.bbox)) {
|
|
181
|
+
heldBack = candidate;
|
|
182
|
+
}
|
|
159
183
|
}
|
|
160
184
|
if (!row && query.locality) {
|
|
161
185
|
row = this.#byLocality(this.#localityKey(query.locality), streetNorm, number);
|
|
@@ -164,6 +188,9 @@ export class AddressPointSqliteLookup {
|
|
|
164
188
|
// A Han key contains no `%` or `_`, so the pattern matches a literal suffix.
|
|
165
189
|
row = this.#byLocalityTail(streetNorm, number, `%${query.localityTail}`);
|
|
166
190
|
}
|
|
191
|
+
if (!row && heldBack) {
|
|
192
|
+
row = heldBack;
|
|
193
|
+
}
|
|
167
194
|
// The bounding box serves extracts whose points have no postcode or locality, such as OSM.
|
|
168
195
|
if (!row && query.bbox) {
|
|
169
196
|
const b = query.bbox;
|
|
@@ -190,15 +217,46 @@ export class AddressPointSqliteLookup {
|
|
|
190
217
|
* A row field that is empty never contradicts.
|
|
191
218
|
* The locality is compared only when the extract's `localityKeys` is `"full"`,
|
|
192
219
|
* because abbreviated keys would reject correct rows.
|
|
220
|
+
*
|
|
221
|
+
* Two locality keys agree when they are equal or when one is the leading words of the other.
|
|
222
|
+
* A German disambiguated name such as `Lauta b Hoyerswerda` or `Freiberg Sachs` begins with the place
|
|
223
|
+
* name that OSM's `addr:city` records, and a word boundary keeps `lauta` apart from `lautabach`.
|
|
193
224
|
*/
|
|
194
225
|
#scopeContradicts(row, query) {
|
|
195
226
|
if (query.postcode && row.postcode && row.postcode.trim() !== query.postcode.trim())
|
|
196
227
|
return true;
|
|
197
228
|
if (this.#localityKeys === "full" && query.locality && row.locality_norm) {
|
|
198
|
-
|
|
229
|
+
const queryKey = this.#localityKey(query.locality);
|
|
230
|
+
const [shorter, longer] = row.locality_norm.length <= queryKey.length ? [row.locality_norm, queryKey] : [queryKey, row.locality_norm];
|
|
231
|
+
return shorter !== longer && !longer.startsWith(`${shorter} `);
|
|
199
232
|
}
|
|
200
233
|
return false;
|
|
201
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Returns whether a postcode row stored under a different locality lies in a part of the queried place.
|
|
237
|
+
*
|
|
238
|
+
* Only an extract whose `localityLevel` is `"finest"` can store a part of a place.
|
|
239
|
+
* In a `"place"` extract, a different stored locality is a different place.
|
|
240
|
+
*
|
|
241
|
+
* In a `"finest"` extract, the row is accepted as part of the queried place when two conditions hold.
|
|
242
|
+
*
|
|
243
|
+
* No other stored locality holds the same (postcode, street, number) key.
|
|
244
|
+
* When the caller supplies the box around the query's resolved locality, the row lies inside it.
|
|
245
|
+
*
|
|
246
|
+
* The caller probes the query's own locality before it uses this row.
|
|
247
|
+
* A postcode key that two places share therefore still answers the place the query gives.
|
|
248
|
+
*/
|
|
249
|
+
#isSublocalityRow(row, postcode, streetNorm, number, bbox) {
|
|
250
|
+
if (this.#localityLevel !== "finest")
|
|
251
|
+
return false;
|
|
252
|
+
if (row.postcode && row.postcode.trim() !== postcode)
|
|
253
|
+
return false;
|
|
254
|
+
if ((this.#postcodeKeyPlaces?.(postcode, streetNorm, number)?.places ?? 0) !== 1)
|
|
255
|
+
return false;
|
|
256
|
+
if (!bbox)
|
|
257
|
+
return true;
|
|
258
|
+
return row.lat >= bbox.minLat && row.lat <= bbox.maxLat && row.lon >= bbox.minLon && row.lon <= bbox.maxLon;
|
|
259
|
+
}
|
|
202
260
|
[Symbol.dispose]() {
|
|
203
261
|
this.#db[Symbol.dispose]();
|
|
204
262
|
}
|
package/out/address/point.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.js","sourceRoot":"","sources":["../../lib/address/point.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAIzD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAA;AACtE,OAAO,EACN,0BAA0B,EAC1B,uBAAuB,EACvB,6BAA6B,EAG7B,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,GAEnB,MAAM,mBAAmB,CAAA;AAQ1B;;;GAGG;AACH,MAAM,WAAW,GAAG,oDAAoD,CAAA;AAExE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,wBAAwB;IAG3B,GAAG,CAAoB;IACvB,OAAO,CAAc;IACrB,aAAa,CAAwB;IACrC,WAAW,CAAiG;IAC5G,mBAAmB,CAEhB;IACH,WAAW,CAAkG;IACtH;;;;OAIG;IACM,eAAe,CAEZ;IACH,OAAO,CAKJ;IAEZ
|
|
1
|
+
{"version":3,"file":"point.js","sourceRoot":"","sources":["../../lib/address/point.ts"],"names":[],"mappings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OAAO,CAAC,EAAE,CAAA;IAC3B,CAAC;CACD"}
|
|
@@ -84,11 +84,11 @@ export async function buildAncestorsSidecar(ctx) {
|
|
|
84
84
|
const preOf = new Map();
|
|
85
85
|
const postOf = new Map();
|
|
86
86
|
for (const kids of childrenOf.values()) {
|
|
87
|
-
// oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass
|
|
87
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass built
|
|
88
88
|
kids.sort((a, b) => a - b);
|
|
89
89
|
}
|
|
90
90
|
const roots = [...forest].filter((id) => !canonicalParentOf.has(id));
|
|
91
|
-
// oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass
|
|
91
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass built
|
|
92
92
|
roots.sort((a, b) => a - b);
|
|
93
93
|
let counter = 0;
|
|
94
94
|
for (const root of roots) {
|
|
@@ -117,7 +117,7 @@ export async function buildAncestorsSidecar(ctx) {
|
|
|
117
117
|
const cycleSkipped = forest.size - preOf.size;
|
|
118
118
|
const insInterval = out.prepare(`INSERT INTO ${CANDIDATE_INTERVAL_TABLE} VALUES (?, ?, ?)`);
|
|
119
119
|
const labeled = [...preOf.keys()];
|
|
120
|
-
// oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass
|
|
120
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- sorts an array this pass built
|
|
121
121
|
labeled.sort((a, b) => a - b);
|
|
122
122
|
out.exec("BEGIN");
|
|
123
123
|
for (const id of labeled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidecar.js","sourceRoot":"","sources":["../../../lib/candidate/ancestors/sidecar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EACN,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,4BAA4B,EAC5B,kBAAk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AAC,IAAI,CAAA;IAE7C,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,wBAAwB,mBAAmB,CAAC,CAAA;IAC3F,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;IAEjC,mFAAmF;IACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAE7B,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAEjB,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;QAC1B,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC,CAAA;IACrD,CAAC;IAED,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAElB,QAAQ,CACP,WAAW,EACX,GAAG,YAAY,CAAC,cAAc,EAAE,wBAAwB,cAAc,CAAC,cAAc,EAAE,WAAW;QACjG,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,kBAAkB;QAChD,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,cAAc,EAAE,gDAAgD,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5G,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,cAAc,EAAE,0CAA0C,CAAC,CAAC,CAAC,EAAE,CAAC,CACnG,CAAA;IAED,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,CAAC,IAAI,EAAE,CAAA;AACpE,CAAC"}
|
|
@@ -54,7 +54,7 @@ interface ScoredPlace {
|
|
|
54
54
|
/**
|
|
55
55
|
* What {@link loadImportanceIndex} measured while reading the source.
|
|
56
56
|
*
|
|
57
|
-
* Reported by the builder so a run reports how much of the gazetteer it
|
|
57
|
+
* Reported by the builder so a run reports how much of the gazetteer it scored,
|
|
58
58
|
* rather than leaving the caller to infer it from a column full of nulls.
|
|
59
59
|
*/
|
|
60
60
|
export interface ImportanceIndexStats {
|
|
@@ -88,7 +88,7 @@ export declare class ImportanceIndex {
|
|
|
88
88
|
* The key matched a scored group, but the nearest member was outside the radius,
|
|
89
89
|
* so it is a different place wearing the same name.
|
|
90
90
|
*
|
|
91
|
-
*
|
|
91
|
+
* Compare this number across rebuilds.
|
|
92
92
|
* A jump means the score source and the admin source have drifted apart
|
|
93
93
|
* and the join is being asked to guess.
|
|
94
94
|
* It does not mean the radius is too tight.
|
|
@@ -70,7 +70,7 @@ export class ImportanceIndex {
|
|
|
70
70
|
* The key matched a scored group, but the nearest member was outside the radius,
|
|
71
71
|
* so it is a different place wearing the same name.
|
|
72
72
|
*
|
|
73
|
-
*
|
|
73
|
+
* Compare this number across rebuilds.
|
|
74
74
|
* A jump means the score source and the admin source have drifted apart
|
|
75
75
|
* and the join is being asked to guess.
|
|
76
76
|
* It does not mean the radius is too tight.
|
|
@@ -28,7 +28,7 @@ export const VARIANT_SIMILARITY_MIN = 0.85;
|
|
|
28
28
|
* BGN/pcgn-flavored Cyrillic romanization, folded to the name-key alphabet.
|
|
29
29
|
*
|
|
30
30
|
* Digraph outputs (zh, kh, ts, ch, sh, shch, yu, ya) match the dominant transliteration
|
|
31
|
-
* conventions the gazetteer's Latin aliases
|
|
31
|
+
* conventions the gazetteer's Latin aliases use.
|
|
32
32
|
* The `w`/`v` and `kh`/`h` style variance between systems is what the edit-similarity threshold absorbs.
|
|
33
33
|
*/
|
|
34
34
|
const CYRILLIC_TO_LATIN = {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* `buildCoincidentRoles` derives the coincident-roles relation into the unified gazetteer.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Some places occupy multiple admin tiers under one name: German city-states (Berlin, Hamburg,
|
|
9
9
|
* Bremen), Italian provinces whose names match their capital (Milano, Varese), Spanish
|
|
10
10
|
* provinces-after-capitals, UK unitary authorities, JP prefectures, NL province-capitals (Utrecht,
|
|
11
11
|
* Groningen), and Shanghai. When an address surfaces only the admin role because the parser
|
package/out/coincident-roles.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* `buildCoincidentRoles` derives the coincident-roles relation into the unified gazetteer.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Some places occupy multiple admin tiers under one name: German city-states (Berlin, Hamburg,
|
|
9
9
|
* Bremen), Italian provinces whose names match their capital (Milano, Varese), Spanish
|
|
10
10
|
* provinces-after-capitals, UK unitary authorities, JP prefectures, NL province-capitals (Utrecht,
|
|
11
11
|
* Groningen), and Shanghai. When an address surfaces only the admin role because the parser
|
|
@@ -12,8 +12,8 @@ import type { PlaceAttrs, StageRow } from "#candidate/place-attrs";
|
|
|
12
12
|
import type { CandidateDatabase } from "#candidate/schema";
|
|
13
13
|
import type { WOFDatabase } from "#schema";
|
|
14
14
|
/**
|
|
15
|
-
* Restore a deprecated locality only when no
|
|
16
|
-
* attests the same folded name above {@link CURRENCY_BACKFILL_POP_FLOOR}.
|
|
15
|
+
* Restore a deprecated locality only when no live namesake exists within CURRENCY_BACKFILL_RADIUS_KM
|
|
16
|
+
* and GeoNames attests the same folded name above {@link CURRENCY_BACKFILL_POP_FLOOR}.
|
|
17
17
|
*/
|
|
18
18
|
export interface CurrencyBackfillResults {
|
|
19
19
|
judged: number;
|
package/out/extracts.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare function deriveSchemaName(path: PathBuilderLike): string;
|
|
|
39
39
|
/**
|
|
40
40
|
* Per-extract configuration.
|
|
41
41
|
*
|
|
42
|
-
* The simple form is
|
|
42
|
+
* The simple form is a path string.
|
|
43
43
|
* The schema name is derived from it.
|
|
44
44
|
*
|
|
45
45
|
* The object form lets callers override the derived schema name (useful when a filename
|
package/out/fst/autocomplete.js
CHANGED
|
@@ -50,9 +50,9 @@ class FSTReader {
|
|
|
50
50
|
* Parent chains of the entries this reader has served, id-keyed.
|
|
51
51
|
*
|
|
52
52
|
* A place's chain is identical across its surfaces (it is place-row data), so last-write-wins is safe.
|
|
53
|
-
* The algorithm asks {@link FSTReader.ancestorsOf} only for ids it
|
|
54
|
-
* from {@link FSTReader.entriesAt}, so serving from this memo answers
|
|
55
|
-
* real call without an artifact-wide id index.
|
|
53
|
+
* The algorithm asks {@link FSTReader.ancestorsOf} only for ids it received in the
|
|
54
|
+
* same call from {@link FSTReader.entriesAt}, so serving from this memo answers
|
|
55
|
+
* every real call without an artifact-wide id index.
|
|
56
56
|
*/
|
|
57
57
|
#chains = new Map();
|
|
58
58
|
constructor(fst) {
|
|
@@ -81,7 +81,7 @@ export function deserializeFSTWeb(input) {
|
|
|
81
81
|
}
|
|
82
82
|
// v1 stored a raw population u32 here. v2-v4 stored the conflated `importance`
|
|
83
83
|
// float. v5 stored the referential score.
|
|
84
|
-
// The Node deserializer explains why a v1 value is
|
|
84
|
+
// The Node deserializer explains why a v1 value is the referential score.
|
|
85
85
|
const referential = isV2
|
|
86
86
|
? view.getFloat32(pp + 12, true)
|
|
87
87
|
: Math.min(1, Math.log2(1 + view.getUint32(pp + 12, true) / 1000) / 14);
|
package/out/fst/format.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare const WIDE_STATE_ENTRY_SIZE = 16;
|
|
|
51
51
|
export declare const NARROW_STATE_ENTRY_SIZE = 12;
|
|
52
52
|
/**
|
|
53
53
|
* First format version carrying the trailing metadata block.
|
|
54
|
-
* Older files
|
|
54
|
+
* Older files have none.
|
|
55
55
|
*/
|
|
56
56
|
export declare const VERSION_WITH_METADATA = 3;
|
|
57
57
|
/**
|
package/out/fst/format.js
CHANGED
|
@@ -50,7 +50,7 @@ export const WIDE_STATE_ENTRY_SIZE = 16;
|
|
|
50
50
|
export const NARROW_STATE_ENTRY_SIZE = 12;
|
|
51
51
|
/**
|
|
52
52
|
* First format version carrying the trailing metadata block.
|
|
53
|
-
* Older files
|
|
53
|
+
* Older files have none.
|
|
54
54
|
*/
|
|
55
55
|
export const VERSION_WITH_METADATA = 3;
|
|
56
56
|
/**
|