@mailwoman/corpus 11.3.0 → 11.4.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/data/PROVENANCE.md +3 -4
- package/data/address-source-register.json +4 -4
- package/data/builds/v0.8.23-overlay/OVERLAY_PLAN.json +3656 -0
- package/data/builds/v0.8.23-prominent-overlay/OVERLAY_PLAN.json +42 -0
- package/data/builds/v0.8.23-rebuild/inputs.json +141 -0
- package/data/builds/v0.8.24-rebuild/inputs.json +111 -0
- package/data/corpus-source-inputs.json +95 -1
- package/data/holdout/evaluation-groups.v0.8.24.json +222158 -0
- package/data/license-decisions.json +5 -0
- package/data/region-slot-second-level.json +1 -1
- package/data/training-configs/v8.11.0-base-c6-90k-v0823-s42.yaml +920 -0
- package/data/training-configs/v8.12.0-base-c6-wofreps-v0823-s42.yaml +944 -0
- package/data/training-configs/v8.13.0-base-c6-wofreps-v0822-s42.yaml +918 -0
- package/lib/adapters/cordis/adapter.ts +3 -2
- package/lib/adapters/gleif/adapter.ts +123 -20
- package/lib/adapters/openaddresses/adapter.ts +2 -2
- package/lib/adapters/osm/adapter.ts +62 -4
- package/lib/adapters/overture/adapter.ts +97 -15
- package/lib/adapters/overture/address-key.ts +89 -0
- package/lib/adapters/overture/places-in/adapter.ts +258 -0
- package/lib/adapters/street/convention.ts +49 -0
- package/lib/adapters/street/country-line.ts +65 -0
- package/lib/adapters/wof/admin/json/adapter.ts +4 -4
- package/lib/adapters/wof/admin/json/region-codes.ts +98 -0
- package/lib/adapters/wof/json-rows.ts +2 -2
- package/lib/adapters.ts +2 -0
- package/lib/build/align/range.ts +21 -11
- package/lib/build/align/totals.ts +20 -0
- package/lib/build/align.ts +218 -20
- package/lib/build/budget.ts +55 -20
- package/lib/build/checkpoint.ts +9 -0
- package/lib/build/component-check.ts +97 -3
- package/lib/build/inputs.ts +122 -31
- package/lib/build/manifest.ts +1 -0
- package/lib/build/parallel.ts +140 -23
- package/lib/build/{region-names.ts → region/names.ts} +16 -4
- package/lib/build/region/recount.ts +153 -0
- package/lib/build/reuse.ts +112 -0
- package/lib/build/settings.ts +84 -3
- package/lib/build/source-record.ts +45 -8
- package/lib/build/types.ts +26 -0
- package/lib/build/worker.ts +75 -10
- package/lib/build.ts +2 -1
- package/lib/de/recipes/locale.ts +9 -3
- package/lib/evaluation/corpus-adapter.ts +2 -2
- package/lib/fi/adapters/ryhti/adapter.ts +2 -2
- package/lib/fo/adapters/adressur/adapter.ts +2 -2
- package/lib/fr/recipes/lieudit.ts +3 -4
- package/lib/in/street-line/segment.ts +370 -0
- package/lib/international/recipes/locale.ts +6 -3
- package/lib/li/adapters/llv/adapter.ts +2 -2
- package/lib/lu/adapters/bd-adresses/adapter.ts +2 -2
- package/lib/no/adapters/matrikkelen/adapter.ts +2 -2
- package/lib/parquet/streams.ts +18 -3
- package/lib/parquet/writers.ts +161 -29
- package/lib/recipes/country-balanced.ts +32 -18
- package/lib/recipes/fragment-assay/build.ts +8 -5
- package/lib/recipes/fragment-assay/rows.ts +4 -4
- package/lib/recipes/house/venue.ts +2 -1
- package/lib/recipes/postal/guideline/leg.ts +3 -2
- package/lib/recipes/prominent/places.ts +4 -4
- package/lib/runner.ts +139 -20
- package/lib/sg/recipes/register.ts +6 -1
- package/lib/source-register/row-license.ts +12 -2
- package/lib/surfaces/corpus-row.ts +84 -0
- package/lib/surfaces/locale.ts +20 -24
- package/lib/synthesizers/house-venue.ts +33 -40
- package/lib/synthesizers/no-street.ts +2 -2
- package/lib/synthesizers/po-box.ts +3 -3
- package/lib/synthesizers/tail.ts +3 -2
- package/lib/synthesizers/utils.ts +95 -56
- package/lib/test-kit.ts +50 -1
- package/lib/tools/fetch/overture-places-in.ts +118 -0
- package/lib/tools/fetch/storage.ts +3 -0
- package/lib/tools/fetch.ts +2 -0
- package/lib/tools/region-slot-census.run.ts +2 -2
- package/lib/types.ts +39 -0
- package/lib/us/adapters/state/tx-notaries/adapter.ts +2 -1
- package/lib/us/adapters/usgov/imls-pls/adapter.ts +2 -1
- package/lib/us/adapters/usgov/nad/adapter.ts +32 -4
- package/lib/us/adapters/usgov/nad/address-key.ts +8 -47
- package/lib/us/adapters/usgov/nppes/adapter.ts +2 -1
- package/lib/utils/address-key.ts +57 -0
- package/lib/utils/align.ts +22 -10
- package/lib/utils/evaluation-groups.ts +13 -6
- package/lib/utils/split.ts +24 -3
- package/out/adapters/cordis/adapter.d.ts.map +1 -1
- package/out/adapters/cordis/adapter.js +3 -2
- package/out/adapters/cordis/adapter.js.map +1 -1
- package/out/adapters/gleif/adapter.d.ts +4 -0
- package/out/adapters/gleif/adapter.d.ts.map +1 -1
- package/out/adapters/gleif/adapter.js +100 -20
- package/out/adapters/gleif/adapter.js.map +1 -1
- package/out/adapters/openaddresses/adapter.js +2 -2
- package/out/adapters/openaddresses/adapter.js.map +1 -1
- package/out/adapters/osm/adapter.d.ts +9 -0
- package/out/adapters/osm/adapter.d.ts.map +1 -1
- package/out/adapters/osm/adapter.js +55 -13
- package/out/adapters/osm/adapter.js.map +1 -1
- package/out/adapters/overture/adapter.d.ts +6 -0
- package/out/adapters/overture/adapter.d.ts.map +1 -1
- package/out/adapters/overture/adapter.js +72 -9
- package/out/adapters/overture/adapter.js.map +1 -1
- package/out/adapters/overture/address-key.d.ts +39 -0
- package/out/adapters/overture/address-key.d.ts.map +1 -0
- package/out/adapters/overture/address-key.js +75 -0
- package/out/adapters/overture/address-key.js.map +1 -0
- package/out/adapters/overture/places-in/adapter.d.ts +20 -0
- package/out/adapters/overture/places-in/adapter.d.ts.map +1 -0
- package/out/adapters/overture/places-in/adapter.js +191 -0
- package/out/adapters/overture/places-in/adapter.js.map +1 -0
- package/out/adapters/street/convention.d.ts +11 -0
- package/out/adapters/street/convention.d.ts.map +1 -0
- package/out/adapters/street/convention.js +40 -0
- package/out/adapters/street/convention.js.map +1 -0
- package/out/adapters/street/country-line.d.ts +31 -0
- package/out/adapters/street/country-line.d.ts.map +1 -0
- package/out/adapters/street/country-line.js +31 -0
- package/out/adapters/street/country-line.js.map +1 -0
- package/out/adapters/wof/admin/json/adapter.js +4 -4
- package/out/adapters/wof/admin/json/adapter.js.map +1 -1
- package/out/adapters/wof/admin/json/region-codes.d.ts +5 -0
- package/out/adapters/wof/admin/json/region-codes.d.ts.map +1 -1
- package/out/adapters/wof/admin/json/region-codes.js +83 -0
- package/out/adapters/wof/admin/json/region-codes.js.map +1 -1
- package/out/adapters/wof/json-rows.d.ts.map +1 -1
- package/out/adapters/wof/json-rows.js +2 -2
- package/out/adapters/wof/json-rows.js.map +1 -1
- package/out/adapters.d.ts.map +1 -1
- package/out/adapters.js +2 -0
- package/out/adapters.js.map +1 -1
- package/out/build/align/range.d.ts +7 -3
- package/out/build/align/range.d.ts.map +1 -1
- package/out/build/align/range.js +17 -9
- package/out/build/align/range.js.map +1 -1
- package/out/build/align/totals.d.ts +12 -0
- package/out/build/align/totals.d.ts.map +1 -1
- package/out/build/align/totals.js +8 -0
- package/out/build/align/totals.js.map +1 -1
- package/out/build/align.d.ts +60 -5
- package/out/build/align.d.ts.map +1 -1
- package/out/build/align.js +136 -12
- package/out/build/align.js.map +1 -1
- package/out/build/budget.d.ts +35 -11
- package/out/build/budget.d.ts.map +1 -1
- package/out/build/budget.js +52 -20
- package/out/build/budget.js.map +1 -1
- package/out/build/checkpoint.d.ts +9 -0
- package/out/build/checkpoint.d.ts.map +1 -1
- package/out/build/checkpoint.js.map +1 -1
- package/out/build/component-check.d.ts +29 -1
- package/out/build/component-check.d.ts.map +1 -1
- package/out/build/component-check.js +57 -2
- package/out/build/component-check.js.map +1 -1
- package/out/build/inputs.d.ts +58 -0
- package/out/build/inputs.d.ts.map +1 -1
- package/out/build/inputs.js +57 -20
- package/out/build/inputs.js.map +1 -1
- package/out/build/manifest.d.ts.map +1 -1
- package/out/build/manifest.js +1 -0
- package/out/build/manifest.js.map +1 -1
- package/out/build/parallel.d.ts +19 -1
- package/out/build/parallel.d.ts.map +1 -1
- package/out/build/parallel.js +92 -11
- package/out/build/parallel.js.map +1 -1
- package/out/build/{region-names.d.ts → region/names.d.ts} +10 -1
- package/out/build/region/names.d.ts.map +1 -0
- package/out/build/{region-names.js → region/names.js} +16 -5
- package/out/build/region/names.js.map +1 -0
- package/out/build/region/recount.d.ts +47 -0
- package/out/build/region/recount.d.ts.map +1 -0
- package/out/build/region/recount.js +105 -0
- package/out/build/region/recount.js.map +1 -0
- package/out/build/reuse.d.ts +31 -0
- package/out/build/reuse.d.ts.map +1 -0
- package/out/build/reuse.js +50 -0
- package/out/build/reuse.js.map +1 -0
- package/out/build/settings.d.ts +38 -0
- package/out/build/settings.d.ts.map +1 -1
- package/out/build/settings.js +67 -3
- package/out/build/settings.js.map +1 -1
- package/out/build/source-record.d.ts +32 -7
- package/out/build/source-record.d.ts.map +1 -1
- package/out/build/source-record.js +17 -4
- package/out/build/source-record.js.map +1 -1
- package/out/build/types.d.ts +24 -0
- package/out/build/types.d.ts.map +1 -1
- package/out/build/worker.d.ts +17 -0
- package/out/build/worker.d.ts.map +1 -1
- package/out/build/worker.js +44 -9
- package/out/build/worker.js.map +1 -1
- package/out/build.d.ts.map +1 -1
- package/out/build.js +2 -1
- package/out/build.js.map +1 -1
- package/out/de/recipes/locale.d.ts.map +1 -1
- package/out/de/recipes/locale.js +9 -3
- package/out/de/recipes/locale.js.map +1 -1
- package/out/evaluation/corpus-adapter.d.ts +14 -0
- package/out/evaluation/corpus-adapter.d.ts.map +1 -1
- package/out/evaluation/corpus-adapter.js +2 -16
- package/out/evaluation/corpus-adapter.js.map +1 -1
- package/out/fi/adapters/ryhti/adapter.js +2 -2
- package/out/fi/adapters/ryhti/adapter.js.map +1 -1
- package/out/fo/adapters/adressur/adapter.js +2 -2
- package/out/fo/adapters/adressur/adapter.js.map +1 -1
- package/out/fr/recipes/lieudit.d.ts.map +1 -1
- package/out/fr/recipes/lieudit.js +3 -3
- package/out/fr/recipes/lieudit.js.map +1 -1
- package/out/in/street-line/segment.d.ts +75 -0
- package/out/in/street-line/segment.d.ts.map +1 -0
- package/out/in/street-line/segment.js +298 -0
- package/out/in/street-line/segment.js.map +1 -0
- package/out/international/recipes/locale.d.ts.map +1 -1
- package/out/international/recipes/locale.js +6 -3
- package/out/international/recipes/locale.js.map +1 -1
- package/out/li/adapters/llv/adapter.js +2 -2
- package/out/li/adapters/llv/adapter.js.map +1 -1
- package/out/lu/adapters/bd-adresses/adapter.js +2 -2
- package/out/lu/adapters/bd-adresses/adapter.js.map +1 -1
- package/out/no/adapters/matrikkelen/adapter.js +2 -2
- package/out/no/adapters/matrikkelen/adapter.js.map +1 -1
- package/out/parquet/streams.d.ts +9 -0
- package/out/parquet/streams.d.ts.map +1 -1
- package/out/parquet/streams.js +7 -3
- package/out/parquet/streams.js.map +1 -1
- package/out/parquet/writers.d.ts +55 -2
- package/out/parquet/writers.d.ts.map +1 -1
- package/out/parquet/writers.js +109 -27
- package/out/parquet/writers.js.map +1 -1
- package/out/recipes/country-balanced.d.ts.map +1 -1
- package/out/recipes/country-balanced.js +32 -15
- package/out/recipes/country-balanced.js.map +1 -1
- package/out/recipes/fragment-assay/build.d.ts +5 -2
- package/out/recipes/fragment-assay/build.d.ts.map +1 -1
- package/out/recipes/fragment-assay/build.js +8 -5
- package/out/recipes/fragment-assay/build.js.map +1 -1
- package/out/recipes/fragment-assay/rows.d.ts +2 -2
- package/out/recipes/fragment-assay/rows.js +4 -4
- package/out/recipes/fragment-assay/rows.js.map +1 -1
- package/out/recipes/house/venue.d.ts.map +1 -1
- package/out/recipes/house/venue.js +2 -1
- package/out/recipes/house/venue.js.map +1 -1
- package/out/recipes/postal/guideline/leg.d.ts.map +1 -1
- package/out/recipes/postal/guideline/leg.js +2 -7
- package/out/recipes/postal/guideline/leg.js.map +1 -1
- package/out/recipes/prominent/places.js +4 -4
- package/out/recipes/prominent/places.js.map +1 -1
- package/out/runner.d.ts +28 -0
- package/out/runner.d.ts.map +1 -1
- package/out/runner.js +85 -18
- package/out/runner.js.map +1 -1
- package/out/sg/recipes/register.d.ts.map +1 -1
- package/out/sg/recipes/register.js +6 -1
- package/out/sg/recipes/register.js.map +1 -1
- package/out/source-register/row-license.d.ts +8 -0
- package/out/source-register/row-license.d.ts.map +1 -1
- package/out/source-register/row-license.js +10 -2
- package/out/source-register/row-license.js.map +1 -1
- package/out/surfaces/corpus-row.d.ts +32 -0
- package/out/surfaces/corpus-row.d.ts.map +1 -0
- package/out/surfaces/corpus-row.js +70 -0
- package/out/surfaces/corpus-row.js.map +1 -0
- package/out/surfaces/locale.d.ts.map +1 -1
- package/out/surfaces/locale.js +16 -22
- package/out/surfaces/locale.js.map +1 -1
- package/out/synthesizers/house-venue.d.ts +9 -4
- package/out/synthesizers/house-venue.d.ts.map +1 -1
- package/out/synthesizers/house-venue.js +25 -35
- package/out/synthesizers/house-venue.js.map +1 -1
- package/out/synthesizers/no-street.js +2 -9
- package/out/synthesizers/no-street.js.map +1 -1
- package/out/synthesizers/po-box.js +3 -7
- package/out/synthesizers/po-box.js.map +1 -1
- package/out/synthesizers/tail.d.ts.map +1 -1
- package/out/synthesizers/tail.js +2 -2
- package/out/synthesizers/tail.js.map +1 -1
- package/out/synthesizers/utils.d.ts +20 -3
- package/out/synthesizers/utils.d.ts.map +1 -1
- package/out/synthesizers/utils.js +74 -57
- package/out/synthesizers/utils.js.map +1 -1
- package/out/test-kit.d.ts +11 -0
- package/out/test-kit.d.ts.map +1 -1
- package/out/test-kit.js +30 -1
- package/out/test-kit.js.map +1 -1
- package/out/tools/fetch/overture-places-in.d.ts +14 -0
- package/out/tools/fetch/overture-places-in.d.ts.map +1 -0
- package/out/tools/fetch/overture-places-in.js +82 -0
- package/out/tools/fetch/overture-places-in.js.map +1 -0
- package/out/tools/fetch/storage.d.ts +2 -0
- package/out/tools/fetch/storage.d.ts.map +1 -1
- package/out/tools/fetch/storage.js +3 -0
- package/out/tools/fetch/storage.js.map +1 -1
- package/out/tools/fetch.d.ts +2 -0
- package/out/tools/fetch.d.ts.map +1 -1
- package/out/tools/fetch.js +2 -0
- package/out/tools/fetch.js.map +1 -1
- package/out/tools/region-slot-census.run.js +2 -2
- package/out/types.d.ts +41 -0
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/out/us/adapters/state/tx-notaries/adapter.d.ts.map +1 -1
- package/out/us/adapters/state/tx-notaries/adapter.js +2 -1
- package/out/us/adapters/state/tx-notaries/adapter.js.map +1 -1
- package/out/us/adapters/usgov/imls-pls/adapter.d.ts.map +1 -1
- package/out/us/adapters/usgov/imls-pls/adapter.js +2 -1
- package/out/us/adapters/usgov/imls-pls/adapter.js.map +1 -1
- package/out/us/adapters/usgov/nad/adapter.d.ts +15 -0
- package/out/us/adapters/usgov/nad/adapter.d.ts.map +1 -1
- package/out/us/adapters/usgov/nad/adapter.js +21 -3
- package/out/us/adapters/usgov/nad/adapter.js.map +1 -1
- package/out/us/adapters/usgov/nad/address-key.d.ts +1 -5
- package/out/us/adapters/usgov/nad/address-key.d.ts.map +1 -1
- package/out/us/adapters/usgov/nad/address-key.js +8 -33
- package/out/us/adapters/usgov/nad/address-key.js.map +1 -1
- package/out/us/adapters/usgov/nppes/adapter.d.ts.map +1 -1
- package/out/us/adapters/usgov/nppes/adapter.js +2 -1
- package/out/us/adapters/usgov/nppes/adapter.js.map +1 -1
- package/out/utils/address-key.d.ts +23 -0
- package/out/utils/address-key.d.ts.map +1 -0
- package/out/utils/address-key.js +43 -0
- package/out/utils/address-key.js.map +1 -0
- package/out/utils/align.d.ts +7 -0
- package/out/utils/align.d.ts.map +1 -1
- package/out/utils/align.js +18 -8
- package/out/utils/align.js.map +1 -1
- package/out/utils/evaluation-groups.d.ts +5 -1
- package/out/utils/evaluation-groups.d.ts.map +1 -1
- package/out/utils/evaluation-groups.js +12 -1
- package/out/utils/evaluation-groups.js.map +1 -1
- package/out/utils/split.d.ts +11 -0
- package/out/utils/split.d.ts.map +1 -1
- package/out/utils/split.js +18 -3
- package/out/utils/split.js.map +1 -1
- package/package.json +19 -19
- package/out/build/region-names.d.ts.map +0 -1
- package/out/build/region-names.js.map +0 -1
package/lib/build/checkpoint.ts
CHANGED
|
@@ -42,6 +42,10 @@ export interface AlignSettings {
|
|
|
42
42
|
exclude_licenses: readonly string[]
|
|
43
43
|
profile: string
|
|
44
44
|
holdout_digest: string
|
|
45
|
+
/**
|
|
46
|
+
* Each capped source's `trainShare`, present only when one is capped.
|
|
47
|
+
*/
|
|
48
|
+
train_shares?: Record<string, number>
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
/**
|
|
@@ -87,6 +91,11 @@ export interface AlignCheckpoint {
|
|
|
87
91
|
* rather than restarting it at zero and understating the refusal in its manifest.
|
|
88
92
|
*/
|
|
89
93
|
refused_by_source: Record<string, number>
|
|
94
|
+
/**
|
|
95
|
+
* Training rows each source's `trainShare` left out.
|
|
96
|
+
* A checkpoint written before the share existed has none.
|
|
97
|
+
*/
|
|
98
|
+
train_rows_left_out_by_source?: Record<string, number>
|
|
90
99
|
excluded_by_license: number
|
|
91
100
|
admitted_unresolved_license_rows: number
|
|
92
101
|
excluded_by_eligibility: number
|
|
@@ -14,7 +14,7 @@ import { acceptPostcode, statesPostcodeSyntax } from "@mailwoman/postcode/countr
|
|
|
14
14
|
|
|
15
15
|
import type { UnitSplitter } from "#adapters/street/unit"
|
|
16
16
|
import { writtenSubdivisionCode } from "#adapters/wof/admin/json/region-codes"
|
|
17
|
-
import type { RegionNames } from "#build/region
|
|
17
|
+
import type { RegionNames } from "#build/region/names"
|
|
18
18
|
import type { CanonicalRow } from "#types"
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -106,6 +106,35 @@ export function componentFindingsRecord(counts: ComponentFindingCounts): Record<
|
|
|
106
106
|
return Object.fromEntries([...counts].map(([source, rules]) => [source, Object.fromEntries(rules)]))
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* The key under which a row's region value is counted: its country and the value as the row writes it.
|
|
111
|
+
*/
|
|
112
|
+
export function regionValueKey(country: string, region: string): string {
|
|
113
|
+
return `${country}\u001E${region}`
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The `region:unknown` count of rows counted per {@linkcode regionValueKey}, under `regions`.
|
|
118
|
+
*
|
|
119
|
+
* It applies the rule's own test, so it equals the count an align under `regions` would write.
|
|
120
|
+
*/
|
|
121
|
+
export function countRegionUnknown(
|
|
122
|
+
values: Iterable<readonly [key: string, rows: number]>,
|
|
123
|
+
regions: RegionNames
|
|
124
|
+
): number {
|
|
125
|
+
let unknown = 0
|
|
126
|
+
|
|
127
|
+
for (const [key, rows] of values) {
|
|
128
|
+
const separator = key.indexOf("\u001E")
|
|
129
|
+
|
|
130
|
+
if (regions.holds(key.slice(0, separator), key.slice(separator + 1)) === false) {
|
|
131
|
+
unknown += rows
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return unknown
|
|
136
|
+
}
|
|
137
|
+
|
|
109
138
|
/**
|
|
110
139
|
* The fewest digits a street's ending needs before it is compared with the row's postcode.
|
|
111
140
|
*/
|
|
@@ -132,6 +161,57 @@ export interface ComponentCheckContext {
|
|
|
132
161
|
* Without them the rule isn't checked.
|
|
133
162
|
*/
|
|
134
163
|
regions?: RegionNames | null
|
|
164
|
+
/**
|
|
165
|
+
* Answers already computed for a (country, value) pair, from {@linkcode createComponentCheckMemo}.
|
|
166
|
+
*
|
|
167
|
+
* A source repeats one postcode or region on every row of a place.
|
|
168
|
+
* Each answer reads only the country and the value.
|
|
169
|
+
*/
|
|
170
|
+
memo?: ComponentCheckMemo | null
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The postcode and region answers one aligner has computed, keyed by country and value.
|
|
175
|
+
*/
|
|
176
|
+
export interface ComponentCheckMemo {
|
|
177
|
+
readonly postcodeRejected: Map<string, boolean>
|
|
178
|
+
readonly regionUnknown: Map<string, boolean>
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Entries the postcode table holds before it starts again empty.
|
|
183
|
+
*
|
|
184
|
+
* NAD writes ZIP+4 forms, millions of distinct values, and an align worker's heap is 1.5 GiB.
|
|
185
|
+
* Regions take a few thousand values per country, so their table needs no bound.
|
|
186
|
+
*/
|
|
187
|
+
const POSTCODE_MEMO_ENTRIES = 200_000
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* An empty memo for one aligner.
|
|
191
|
+
*/
|
|
192
|
+
export function createComponentCheckMemo(): ComponentCheckMemo {
|
|
193
|
+
return { postcodeRejected: new Map(), regionUnknown: new Map() }
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function memoized(
|
|
197
|
+
table: Map<string, boolean>,
|
|
198
|
+
key: string,
|
|
199
|
+
compute: () => boolean,
|
|
200
|
+
bound = Number.POSITIVE_INFINITY
|
|
201
|
+
): boolean {
|
|
202
|
+
const known = table.get(key)
|
|
203
|
+
|
|
204
|
+
if (known !== undefined) return known
|
|
205
|
+
|
|
206
|
+
if (table.size >= bound) {
|
|
207
|
+
table.clear()
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const answer = compute()
|
|
211
|
+
|
|
212
|
+
table.set(key, answer)
|
|
213
|
+
|
|
214
|
+
return answer
|
|
135
215
|
}
|
|
136
216
|
|
|
137
217
|
/**
|
|
@@ -145,7 +225,21 @@ export function componentFindings(
|
|
|
145
225
|
const findings: ComponentFinding[] = []
|
|
146
226
|
const { postcode, street, locality, region } = components
|
|
147
227
|
|
|
148
|
-
|
|
228
|
+
const postcodeRejected = (value: string): boolean => {
|
|
229
|
+
const compute = () => statesPostcodeSyntax(country) && acceptPostcode(value, country) == null
|
|
230
|
+
|
|
231
|
+
return context.memo
|
|
232
|
+
? memoized(context.memo.postcodeRejected, `${country}\u001E${value}`, compute, POSTCODE_MEMO_ENTRIES)
|
|
233
|
+
: compute()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const regionUnknown = (value: string): boolean => {
|
|
237
|
+
const compute = () => context.regions?.holds(country, value) === false
|
|
238
|
+
|
|
239
|
+
return context.memo ? memoized(context.memo.regionUnknown, `${country}\u001E${value}`, compute) : compute()
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (postcode && postcodeRejected(postcode)) {
|
|
149
243
|
findings.push({ rule: ComponentRule.PostcodeFormat, values: [postcode] })
|
|
150
244
|
}
|
|
151
245
|
|
|
@@ -213,7 +307,7 @@ export function componentFindings(
|
|
|
213
307
|
}
|
|
214
308
|
}
|
|
215
309
|
|
|
216
|
-
if (region &&
|
|
310
|
+
if (region && regionUnknown(region)) {
|
|
217
311
|
findings.push({ rule: ComponentRule.RegionUnknown, values: [region] })
|
|
218
312
|
}
|
|
219
313
|
|
package/lib/build/inputs.ts
CHANGED
|
@@ -59,6 +59,37 @@ export interface BuildInputRecord {
|
|
|
59
59
|
* A build reads the index built from the previous corpus version.
|
|
60
60
|
*/
|
|
61
61
|
streetIndex?: string
|
|
62
|
+
/**
|
|
63
|
+
* The fraction of rows rendered with a country surface, for a country-implicit source.
|
|
64
|
+
*/
|
|
65
|
+
countryFraction?: number
|
|
66
|
+
/**
|
|
67
|
+
* The seed of the {@linkcode BuildInputRecord.countryFraction} draw.
|
|
68
|
+
*/
|
|
69
|
+
seed?: number
|
|
70
|
+
/**
|
|
71
|
+
* The share of the source's training rows the build keeps (`AdapterOptions.trainShare`).
|
|
72
|
+
*/
|
|
73
|
+
trainShare?: number
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* One `corpus run` of an adapter under a source name of its own.
|
|
78
|
+
*
|
|
79
|
+
* A build's `adapters` map holds one entry per adapter id and can't state several runs of one adapter.
|
|
80
|
+
* The `overture` runs for BR, MX and CA stamped `overture-latam` are each a run here.
|
|
81
|
+
*
|
|
82
|
+
* Their rows join a corpus as an overlay (`corpus overlay-manifest --replace-source`).
|
|
83
|
+
*/
|
|
84
|
+
export interface SourceRunRecord extends BuildInputRecord {
|
|
85
|
+
/**
|
|
86
|
+
* The adapter id `corpus run` resolves.
|
|
87
|
+
*/
|
|
88
|
+
adapter: string
|
|
89
|
+
/**
|
|
90
|
+
* The `source` the run stamps on every row (`corpus run --source-name`).
|
|
91
|
+
*/
|
|
92
|
+
sourceName: string
|
|
62
93
|
}
|
|
63
94
|
|
|
64
95
|
/**
|
|
@@ -68,6 +99,20 @@ export interface BuildInputsRecord {
|
|
|
68
99
|
corpusVersion: string
|
|
69
100
|
builtAt?: string
|
|
70
101
|
adapters: Record<string, BuildInputRecord>
|
|
102
|
+
/**
|
|
103
|
+
* The runs whose rows join the corpus as an overlay, run by `corpus recorded-runs`.
|
|
104
|
+
* `corpus build` reads `adapters` only.
|
|
105
|
+
*/
|
|
106
|
+
sourceRuns?: SourceRunRecord[]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* One recorded source run with its input resolved, as `corpus recorded-runs` runs it.
|
|
111
|
+
*/
|
|
112
|
+
export interface SourceRun {
|
|
113
|
+
adapter: string
|
|
114
|
+
sourceName: string
|
|
115
|
+
options: AdapterOptions
|
|
71
116
|
}
|
|
72
117
|
|
|
73
118
|
/**
|
|
@@ -93,35 +138,81 @@ export async function readBuildInputs(path: PathBuilderLike): Promise<Record<str
|
|
|
93
138
|
throw new Error(`${path.toString()} names no adapter under \`adapters\`, so the build would read nothing.`)
|
|
94
139
|
}
|
|
95
140
|
|
|
96
|
-
return Object.fromEntries(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
141
|
+
return Object.fromEntries(entries.map(([id, input]) => [id, resolveBuildInput(path, `adapter ${id}`, input)]))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* One recorded input as {@linkcode AdapterOptions}, its paths resolved against their roots.
|
|
146
|
+
*
|
|
147
|
+
* @throws When the input has no `inputPath`, or its root is neither `cache` nor `data`.
|
|
148
|
+
*/
|
|
149
|
+
function resolveBuildInput(path: PathBuilderLike, label: string, input: BuildInputRecord): AdapterOptions {
|
|
150
|
+
if (typeof input?.inputPath !== "string" || !input.inputPath) {
|
|
151
|
+
throw new Error(`${path.toString()}: ${label} has no \`inputPath\`.`)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const { inputPath, streetIndex, root = BuildInputRoot.data, ...options } = input
|
|
155
|
+
|
|
156
|
+
if (root !== BuildInputRoot.cache && root !== BuildInputRoot.data) {
|
|
157
|
+
throw new Error(`${path.toString()}: ${label} names root "${String(root)}", not "cache" or "data".`)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const under = (base: (relative: string) => PathBuilderLike, relative: string) =>
|
|
161
|
+
isAbsolute(relative) ? relative : base(relative).toString()
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
...options,
|
|
165
|
+
inputPath: under(
|
|
166
|
+
root === BuildInputRoot.cache
|
|
167
|
+
? (relative) => cacheRootPathBuilder(relative)
|
|
168
|
+
: (relative) => dataRootPath(relative),
|
|
169
|
+
inputPath
|
|
170
|
+
),
|
|
171
|
+
// The street index is built from the previous corpus, a built artifact under the data root.
|
|
172
|
+
...(streetIndex ? { streetIndex: under((relative) => dataRootPath(relative), streetIndex) } : {}),
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Read a committed record's `sourceRuns`, each input resolved as {@linkcode readBuildInputs} resolves one.
|
|
178
|
+
*
|
|
179
|
+
* @throws When the record lists no source run, a run lacks its adapter or source name,
|
|
180
|
+
* or two runs would write one source and country.
|
|
181
|
+
*/
|
|
182
|
+
export async function readSourceRuns(path: PathBuilderLike): Promise<SourceRun[]> {
|
|
183
|
+
const record = await readLocalJSONFile<BuildInputsRecord>(path)
|
|
184
|
+
const runs = record.sourceRuns ?? []
|
|
185
|
+
|
|
186
|
+
if (!runs.length) throw new Error(`${path.toString()} lists no run under \`sourceRuns\`.`)
|
|
187
|
+
|
|
188
|
+
const seen = new Set<string>()
|
|
189
|
+
|
|
190
|
+
return runs.map((run, index) => {
|
|
191
|
+
const label = `source run ${index}`
|
|
192
|
+
|
|
193
|
+
if (typeof run?.adapter !== "string" || !run.adapter)
|
|
194
|
+
throw new Error(`${path.toString()}: ${label} names no adapter.`)
|
|
195
|
+
|
|
196
|
+
if (typeof run.sourceName !== "string" || !run.sourceName) {
|
|
197
|
+
throw new Error(`${path.toString()}: ${label} names no \`sourceName\`.`)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const slot = sourceRunDirectoryName(run)
|
|
201
|
+
|
|
202
|
+
if (seen.has(slot)) throw new Error(`${path.toString()}: ${label} repeats ${slot}.`)
|
|
203
|
+
|
|
204
|
+
seen.add(slot)
|
|
205
|
+
|
|
206
|
+
const { adapter, sourceName, ...input } = run
|
|
207
|
+
|
|
208
|
+
return { adapter, sourceName, options: resolveBuildInput(path, label, input) }
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The directory a source run writes under the output root: its source name,
|
|
214
|
+
* and its country when it has one.
|
|
215
|
+
*/
|
|
216
|
+
export function sourceRunDirectoryName(run: { sourceName: string; country?: string }): string {
|
|
217
|
+
return run.country ? `${run.sourceName}-${run.country.toLowerCase()}` : run.sourceName
|
|
127
218
|
}
|
package/lib/build/manifest.ts
CHANGED
|
@@ -116,6 +116,7 @@ export async function writeBuildManifests(inputs: BuildManifestInputs): Promise<
|
|
|
116
116
|
refused_by_license_kind: Object.fromEntries(totals.refusedByKind),
|
|
117
117
|
refused_license_values: Object.fromEntries(refusedValues),
|
|
118
118
|
refused_rows_by_source: Object.fromEntries(totals.refusedBySource),
|
|
119
|
+
train_rows_left_out_by_source: Object.fromEntries(totals.trainRowsLeftOutBySource),
|
|
119
120
|
admitted_unresolved_license_rows: totals.admittedUnresolved,
|
|
120
121
|
profile: inputs.profile,
|
|
121
122
|
excluded_by_eligibility: totals.excludedByEligibility,
|
package/lib/build/parallel.ts
CHANGED
|
@@ -36,14 +36,21 @@ import type { PathBuilder, PathBuilderLike } from "path-ts"
|
|
|
36
36
|
import { TextSpliterator } from "spliterator"
|
|
37
37
|
|
|
38
38
|
import { adapterRunInputs, reusableRun } from "#build/adapters"
|
|
39
|
-
import { alignSettings } from "#build/align"
|
|
39
|
+
import { alignSettings, trainSharesOf } from "#build/align"
|
|
40
40
|
import { planAlignRanges, reusableAlignRange, type AlignRangePlan } from "#build/align/range"
|
|
41
41
|
import { mergeAlignTotals } from "#build/align/totals"
|
|
42
42
|
import { WORKER_CLASSES, workerReservationBytes, type WorkerBudget, type WorkerClass } from "#build/budget"
|
|
43
43
|
import { readSourceDecisionTable } from "#build/eligibility"
|
|
44
44
|
import { admitParquetManifest, UNCHECKED_PARQUET_MANIFEST_FILE } from "#build/holdout-check"
|
|
45
45
|
import { writeBuildManifests } from "#build/manifest"
|
|
46
|
-
import {
|
|
46
|
+
import { tryReadDefaultRegionNames, type RegionNames } from "#build/region/names"
|
|
47
|
+
import { importPriorSource } from "#build/reuse"
|
|
48
|
+
import {
|
|
49
|
+
adapterDerivations,
|
|
50
|
+
derivationConfig,
|
|
51
|
+
regionCheckFingerprints,
|
|
52
|
+
type ResolvedBuildSettings,
|
|
53
|
+
} from "#build/settings"
|
|
47
54
|
import {
|
|
48
55
|
readReusableSource,
|
|
49
56
|
sourceStateDirectory,
|
|
@@ -57,7 +64,7 @@ import { corpusDirectoryName } from "#directory"
|
|
|
57
64
|
import { resolveDerivation } from "#parquet/record"
|
|
58
65
|
import { parquetManifestOf } from "#parquet/writers"
|
|
59
66
|
import type { SourceRightsAdmission } from "#source-register/corpus-inputs"
|
|
60
|
-
import type { CorpusAdapter } from "#types"
|
|
67
|
+
import type { AdapterOptions, CorpusAdapter } from "#types"
|
|
61
68
|
import { defaultHoldouts, SPLIT_NAMES, writeSplitManifestsFromLabeledFiles, type SplitName } from "#utils/split"
|
|
62
69
|
|
|
63
70
|
/**
|
|
@@ -331,6 +338,38 @@ export function alignRangeCount(bytes: number, rangeBytes: number, jobs: number)
|
|
|
331
338
|
return Math.min(2 * jobs, Math.max(1, Math.ceil(bytes / rangeBytes)))
|
|
332
339
|
}
|
|
333
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Input rows per adapter partition.
|
|
343
|
+
*
|
|
344
|
+
* NAD's adapter reads about 14,700 rows a second on one core, so a partition
|
|
345
|
+
* of this size runs in about 11 minutes.
|
|
346
|
+
*/
|
|
347
|
+
export const PARTITION_ROWS = 10_000_000
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* The row ranges a source's adapter run is split into, or `null` to run it in one worker.
|
|
351
|
+
*
|
|
352
|
+
* A source splits when its adapter declares `inputRowCount`, no `limit` caps the run,
|
|
353
|
+
* and its input holds more than one partition's rows.
|
|
354
|
+
* A capped run stops at a count of the rows before it, and a partition can't know that count.
|
|
355
|
+
*/
|
|
356
|
+
export async function partitionRanges(
|
|
357
|
+
adapter: CorpusAdapter,
|
|
358
|
+
options: AdapterOptions,
|
|
359
|
+
partitionRows: number
|
|
360
|
+
): Promise<{ start: number; end: number }[] | null> {
|
|
361
|
+
if (!adapter.inputRowCount || typeof options.limit === "number") return null
|
|
362
|
+
|
|
363
|
+
const rows = await adapter.inputRowCount(options)
|
|
364
|
+
|
|
365
|
+
if (rows <= partitionRows) return null
|
|
366
|
+
|
|
367
|
+
return Array.from({ length: Math.ceil(rows / partitionRows) }, (_, index) => ({
|
|
368
|
+
start: index * partitionRows,
|
|
369
|
+
end: Math.min(rows, (index + 1) * partitionRows),
|
|
370
|
+
}))
|
|
371
|
+
}
|
|
372
|
+
|
|
334
373
|
/**
|
|
335
374
|
* Concatenate files in order into `destination`.
|
|
336
375
|
*
|
|
@@ -378,6 +417,7 @@ export async function runParallelBuild(ctx: ParallelBuildContext): Promise<Build
|
|
|
378
417
|
licensePolicy: settings.licensePolicy,
|
|
379
418
|
excludeLicenses: settings.excludeLicenses.map((pattern) => ({ source: pattern.source, flags: pattern.flags })),
|
|
380
419
|
holdouts,
|
|
420
|
+
trainShares: trainSharesOf(opts.adapterInputs),
|
|
381
421
|
}
|
|
382
422
|
|
|
383
423
|
const buildSettings: SourceBuildSettings = {
|
|
@@ -420,6 +460,11 @@ export async function runParallelBuild(ctx: ParallelBuildContext): Promise<Build
|
|
|
420
460
|
`${ctx.adapters.length} sources`
|
|
421
461
|
)
|
|
422
462
|
|
|
463
|
+
// A reused source made under other region data recounts `region:unknown` under these.
|
|
464
|
+
const regionCheck = await regionCheckFingerprints()
|
|
465
|
+
let regionNames: Promise<RegionNames | null> | null = null
|
|
466
|
+
const readRegions = (): Promise<RegionNames | null> => (regionNames ??= tryReadDefaultRegionNames())
|
|
467
|
+
|
|
423
468
|
const buildSource = async (adapter: CorpusAdapter): Promise<SourceCompletionRecord> => {
|
|
424
469
|
const source = adapter.id
|
|
425
470
|
const sourceDir = sourceStateDirectory(intermediateDir, source)
|
|
@@ -434,6 +479,8 @@ export async function runParallelBuild(ctx: ParallelBuildContext): Promise<Build
|
|
|
434
479
|
const reusable = await readReusableSource(sourceDir, {
|
|
435
480
|
settings: buildSettings,
|
|
436
481
|
derivation: await resolveDerivation(await sourceDerivation()),
|
|
482
|
+
regionCheck,
|
|
483
|
+
readRegions,
|
|
437
484
|
})
|
|
438
485
|
|
|
439
486
|
if (reusable.record) {
|
|
@@ -445,6 +492,31 @@ export async function runParallelBuild(ctx: ParallelBuildContext): Promise<Build
|
|
|
445
492
|
onProgress("adapter-run", `[${source}] not complete: ${reusable.problem}`)
|
|
446
493
|
}
|
|
447
494
|
|
|
495
|
+
for (const priorOutputDir of opts.reuseFrom ?? []) {
|
|
496
|
+
const imported = await importPriorSource({
|
|
497
|
+
source,
|
|
498
|
+
priorOutputDir,
|
|
499
|
+
outputDir,
|
|
500
|
+
expected: {
|
|
501
|
+
settings: buildSettings,
|
|
502
|
+
derivation: await resolveDerivation(await sourceDerivation()),
|
|
503
|
+
regionCheck,
|
|
504
|
+
readRegions,
|
|
505
|
+
},
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
if (imported.record) {
|
|
509
|
+
onProgress(
|
|
510
|
+
"adapter-run",
|
|
511
|
+
`[${source}] cloned the complete source from ${priorOutputDir.toString()} (${imported.record.parts.length} parts)`
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
return imported.record
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
onProgress("adapter-run", `[${source}] not reusable from ${priorOutputDir.toString()}: ${imported.problem}`)
|
|
518
|
+
}
|
|
519
|
+
|
|
448
520
|
const inputStat = await tryStat(options.inputPath)
|
|
449
521
|
// A directory input's size doesn't predict its rows, so it is ranked first and starts early.
|
|
450
522
|
const inputWeight = inputStat?.isFile() ? inputStat.size : Number.MAX_SAFE_INTEGER
|
|
@@ -460,22 +532,67 @@ export async function runParallelBuild(ctx: ParallelBuildContext): Promise<Build
|
|
|
460
532
|
} else {
|
|
461
533
|
const { signal: _signal, dropped: _dropped, ...serializable } = options
|
|
462
534
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
"
|
|
477
|
-
|
|
478
|
-
|
|
535
|
+
const adapterTask = {
|
|
536
|
+
kind: "adapter" as const,
|
|
537
|
+
source,
|
|
538
|
+
adapterModule: derivationFor.modules.get(source)!,
|
|
539
|
+
adapterOptions: { ...serializable, inputPath: options.inputPath.toString() },
|
|
540
|
+
corpusVersion: opts.corpusVersion,
|
|
541
|
+
inputs,
|
|
542
|
+
intermediateDir: intermediateDir.toString(),
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
const ranges = await partitionRanges(adapter, options, opts.partitionRows ?? PARTITION_ROWS)
|
|
546
|
+
|
|
547
|
+
if (ranges) {
|
|
548
|
+
const partitionDir = adapterDir("partitions")
|
|
549
|
+
|
|
550
|
+
await removePathIfPresent(partitionDir)
|
|
551
|
+
await makeDirectories(partitionDir)
|
|
552
|
+
|
|
553
|
+
const records = await Promise.all(
|
|
554
|
+
ranges.map(async (rowRange, index) => {
|
|
555
|
+
const recordPath = partitionDir(`part-${index}.json`).toString()
|
|
556
|
+
|
|
557
|
+
await pool.run(
|
|
558
|
+
{
|
|
559
|
+
...adapterTask,
|
|
560
|
+
id: `${source}/adapter-${index + 1}-of-${ranges.length}`,
|
|
561
|
+
resources: WORKER_CLASSES.partition,
|
|
562
|
+
temporaryRoot: temporaryRoot(`adapter-${index}`),
|
|
563
|
+
partition: { rowRange, outputPath: partitionDir(`part-${index}.tsv`).toString(), recordPath },
|
|
564
|
+
},
|
|
565
|
+
"partition",
|
|
566
|
+
inputWeight
|
|
567
|
+
)
|
|
568
|
+
|
|
569
|
+
return recordPath
|
|
570
|
+
})
|
|
571
|
+
)
|
|
572
|
+
|
|
573
|
+
await pool.run(
|
|
574
|
+
{
|
|
575
|
+
...adapterTask,
|
|
576
|
+
id: `${source}/adapter-merge`,
|
|
577
|
+
resources: WORKER_CLASSES.adapter,
|
|
578
|
+
temporaryRoot: temporaryRoot("adapter"),
|
|
579
|
+
mergeRecords: records,
|
|
580
|
+
},
|
|
581
|
+
"adapter",
|
|
582
|
+
inputWeight
|
|
583
|
+
)
|
|
584
|
+
} else {
|
|
585
|
+
await pool.run(
|
|
586
|
+
{
|
|
587
|
+
...adapterTask,
|
|
588
|
+
id: `${source}/adapter`,
|
|
589
|
+
resources: WORKER_CLASSES.adapter,
|
|
590
|
+
temporaryRoot: temporaryRoot("adapter"),
|
|
591
|
+
},
|
|
592
|
+
"adapter",
|
|
593
|
+
inputWeight
|
|
594
|
+
)
|
|
595
|
+
}
|
|
479
596
|
|
|
480
597
|
run = await readLocalJSONFile(adapterDir("MANIFEST.json"))
|
|
481
598
|
}
|
|
@@ -497,14 +614,14 @@ export async function runParallelBuild(ctx: ParallelBuildContext): Promise<Build
|
|
|
497
614
|
kind: "align",
|
|
498
615
|
id: `${source}/align-${plan.index + 1}-of-${plan.count}`,
|
|
499
616
|
source,
|
|
500
|
-
resources: WORKER_CLASSES.
|
|
617
|
+
resources: WORKER_CLASSES.align,
|
|
501
618
|
temporaryRoot: temporaryRoot(`align-${plan.index}`),
|
|
502
619
|
canonicalPath,
|
|
503
620
|
plan,
|
|
504
621
|
sourceDir: sourceDir.toString(),
|
|
505
622
|
settings: taskSettings,
|
|
506
623
|
},
|
|
507
|
-
"
|
|
624
|
+
"align",
|
|
508
625
|
weight
|
|
509
626
|
)
|
|
510
627
|
})
|
|
@@ -515,7 +632,7 @@ export async function runParallelBuild(ctx: ParallelBuildContext): Promise<Build
|
|
|
515
632
|
kind: "finish",
|
|
516
633
|
id: `${source}/finish`,
|
|
517
634
|
source,
|
|
518
|
-
resources: WORKER_CLASSES.
|
|
635
|
+
resources: WORKER_CLASSES.finish,
|
|
519
636
|
temporaryRoot: temporaryRoot("finish"),
|
|
520
637
|
sourceDir: sourceDir.toString(),
|
|
521
638
|
outputDir: outputDir.toString(),
|
|
@@ -526,7 +643,7 @@ export async function runParallelBuild(ctx: ParallelBuildContext): Promise<Build
|
|
|
526
643
|
derivation: await sourceDerivation(),
|
|
527
644
|
resume: settings.resume,
|
|
528
645
|
},
|
|
529
|
-
"
|
|
646
|
+
"finish",
|
|
530
647
|
weight
|
|
531
648
|
)
|
|
532
649
|
|
|
@@ -598,12 +598,24 @@ async function readSecondLevelRegionCountries(): Promise<string[]> {
|
|
|
598
598
|
* @throws When the database is on this host and the GeoNames first-level file isn't.
|
|
599
599
|
*/
|
|
600
600
|
export async function tryReadDefaultRegionNames(): Promise<RegionNames | null> {
|
|
601
|
-
const
|
|
601
|
+
const inputs = defaultRegionNameInputs()
|
|
602
602
|
|
|
603
|
-
if (!(await pathExists(
|
|
603
|
+
if (!(await pathExists(inputs.database))) return null
|
|
604
604
|
|
|
605
|
-
return readRegionNames(
|
|
605
|
+
return readRegionNames(inputs.database, {
|
|
606
606
|
secondLevelCountries: await readSecondLevelRegionCountries(),
|
|
607
|
-
geonamesDirectory:
|
|
607
|
+
geonamesDirectory: inputs.geonamesDirectory,
|
|
608
608
|
})
|
|
609
609
|
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* The files {@linkcode tryReadDefaultRegionNames} reads, so a build can
|
|
613
|
+
* fingerprint what its align phase read.
|
|
614
|
+
*/
|
|
615
|
+
export function defaultRegionNameInputs(): { database: string; geonamesDirectory: string; secondLevelTable: string } {
|
|
616
|
+
return {
|
|
617
|
+
database: wofDatabasePath("admin-global-priority.db").toString(),
|
|
618
|
+
geonamesDirectory: dataRootPath("geonames").toString(),
|
|
619
|
+
secondLevelTable: SECOND_LEVEL_REGION_TABLE_PATH.toString(),
|
|
620
|
+
}
|
|
621
|
+
}
|