@mailwoman/corpus 4.16.2 → 5.1.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/out/src/adapter.d.ts +23 -26
- package/out/src/adapter.d.ts.map +1 -1
- package/out/src/adapter.js +25 -28
- package/out/src/adapter.js.map +1 -1
- package/out/src/adapters/ban/adapter.d.ts.map +1 -1
- package/out/src/adapters/ban/adapter.js +10 -10
- package/out/src/adapters/ban/adapter.js.map +1 -1
- package/out/src/adapters/ban/street-decompose.d.ts +2 -2
- package/out/src/adapters/ban/street-decompose.d.ts.map +1 -1
- package/out/src/adapters/ban/street-decompose.js +2 -2
- package/out/src/adapters/ban/street-decompose.js.map +1 -1
- package/out/src/adapters/fcc-bdc/adapter.d.ts +2 -2
- package/out/src/adapters/fcc-bdc/adapter.d.ts.map +1 -1
- package/out/src/adapters/fcc-bdc/adapter.js +9 -9
- package/out/src/adapters/fcc-bdc/adapter.js.map +1 -1
- package/out/src/adapters/geonames/adapter.d.ts.map +1 -1
- package/out/src/adapters/geonames/adapter.js +5 -5
- package/out/src/adapters/geonames/adapter.js.map +1 -1
- package/out/src/adapters/geonames-postal/adapter.d.ts.map +1 -1
- package/out/src/adapters/geonames-postal/adapter.js +3 -3
- package/out/src/adapters/geonames-postal/adapter.js.map +1 -1
- package/out/src/adapters/gnaf/adapter.d.ts +3 -3
- package/out/src/adapters/gnaf/adapter.d.ts.map +1 -1
- package/out/src/adapters/gnaf/adapter.js +11 -10
- package/out/src/adapters/gnaf/adapter.js.map +1 -1
- package/out/src/adapters/gnaf/assemble.d.ts +4 -5
- package/out/src/adapters/gnaf/assemble.d.ts.map +1 -1
- package/out/src/adapters/gnaf/assemble.js +1 -1
- package/out/src/adapters/gnaf/assemble.js.map +1 -1
- package/out/src/adapters/index.d.ts +9 -10
- package/out/src/adapters/index.d.ts.map +1 -1
- package/out/src/adapters/index.js +13 -14
- package/out/src/adapters/index.js.map +1 -1
- package/out/src/adapters/openaddresses/adapter.d.ts +8 -10
- package/out/src/adapters/openaddresses/adapter.d.ts.map +1 -1
- package/out/src/adapters/openaddresses/adapter.js +8 -8
- package/out/src/adapters/openaddresses/adapter.js.map +1 -1
- package/out/src/adapters/overture/adapter.d.ts.map +1 -1
- package/out/src/adapters/overture/adapter.js +2 -2
- package/out/src/adapters/overture/adapter.js.map +1 -1
- package/out/src/adapters/state-hi-schools/adapter.d.ts +1 -1
- package/out/src/adapters/state-hi-schools/adapter.d.ts.map +1 -1
- package/out/src/adapters/state-hi-schools/adapter.js +6 -6
- package/out/src/adapters/state-hi-schools/adapter.js.map +1 -1
- package/out/src/adapters/state-ia-contractors/adapter.d.ts +1 -1
- package/out/src/adapters/state-ia-contractors/adapter.d.ts.map +1 -1
- package/out/src/adapters/state-ia-contractors/adapter.js +6 -6
- package/out/src/adapters/state-ia-contractors/adapter.js.map +1 -1
- package/out/src/adapters/state-ny-notaries/adapter.d.ts +1 -1
- package/out/src/adapters/state-ny-notaries/adapter.d.ts.map +1 -1
- package/out/src/adapters/state-ny-notaries/adapter.js +6 -6
- package/out/src/adapters/state-ny-notaries/adapter.js.map +1 -1
- package/out/src/adapters/state-tx-notaries/adapter.d.ts.map +1 -1
- package/out/src/adapters/state-tx-notaries/adapter.js +7 -7
- package/out/src/adapters/state-tx-notaries/adapter.js.map +1 -1
- package/out/src/adapters/synth-po-box/adapter.d.ts +9 -9
- package/out/src/adapters/synth-po-box/adapter.d.ts.map +1 -1
- package/out/src/adapters/synth-po-box/adapter.js +6 -6
- package/out/src/adapters/synth-po-box/adapter.js.map +1 -1
- package/out/src/adapters/tiger/adapter.d.ts.map +1 -1
- package/out/src/adapters/tiger/adapter.js +2 -2
- package/out/src/adapters/tiger/adapter.js.map +1 -1
- package/out/src/adapters/tiger/street-decompose.d.ts +2 -2
- package/out/src/adapters/tiger/street-decompose.d.ts.map +1 -1
- package/out/src/adapters/tiger/street-decompose.js +2 -2
- package/out/src/adapters/tiger/street-decompose.js.map +1 -1
- package/out/src/adapters/usgov-hrsa-fqhc/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-hrsa-fqhc/adapter.js +15 -17
- package/out/src/adapters/usgov-hrsa-fqhc/adapter.js.map +1 -1
- package/out/src/adapters/usgov-imls-pls/adapter.d.ts +1 -1
- package/out/src/adapters/usgov-imls-pls/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-imls-pls/adapter.js +6 -6
- package/out/src/adapters/usgov-imls-pls/adapter.js.map +1 -1
- package/out/src/adapters/usgov-irs-bmf/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-irs-bmf/adapter.js +5 -5
- package/out/src/adapters/usgov-irs-bmf/adapter.js.map +1 -1
- package/out/src/adapters/usgov-nad/adapter.d.ts +2 -2
- package/out/src/adapters/usgov-nad/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-nad/adapter.js +6 -6
- package/out/src/adapters/usgov-nad/adapter.js.map +1 -1
- package/out/src/adapters/usgov-nppes/adapter.d.ts +3 -3
- package/out/src/adapters/usgov-nppes/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-nppes/adapter.js +7 -7
- package/out/src/adapters/usgov-nppes/adapter.js.map +1 -1
- package/out/src/adapters/usgov-samhsa-treatment-locator/adapter.d.ts.map +1 -1
- package/out/src/adapters/usgov-samhsa-treatment-locator/adapter.js +12 -12
- package/out/src/adapters/usgov-samhsa-treatment-locator/adapter.js.map +1 -1
- package/out/src/adapters/wof-admin-jp/adapter.d.ts +3 -3
- package/out/src/adapters/wof-admin-jp/adapter.d.ts.map +1 -1
- package/out/src/adapters/wof-admin-jp/adapter.js +6 -6
- package/out/src/adapters/wof-admin-jp/adapter.js.map +1 -1
- package/out/src/adapters/wof-admin-json/adapter.d.ts +17 -19
- package/out/src/adapters/wof-admin-json/adapter.d.ts.map +1 -1
- package/out/src/adapters/wof-admin-json/adapter.js +25 -28
- package/out/src/adapters/wof-admin-json/adapter.js.map +1 -1
- package/out/src/adapters/wof-postalcode-json/adapter.d.ts +8 -8
- package/out/src/adapters/wof-postalcode-json/adapter.d.ts.map +1 -1
- package/out/src/adapters/wof-postalcode-json/adapter.js +11 -11
- package/out/src/adapters/wof-postalcode-json/adapter.js.map +1 -1
- package/out/src/align.d.ts +14 -16
- package/out/src/align.d.ts.map +1 -1
- package/out/src/align.js +15 -16
- package/out/src/align.js.map +1 -1
- package/out/src/build.d.ts +13 -15
- package/out/src/build.d.ts.map +1 -1
- package/out/src/build.js +6 -6
- package/out/src/build.js.map +1 -1
- package/out/src/codex/us-fips-state.d.ts +6 -8
- package/out/src/codex/us-fips-state.d.ts.map +1 -1
- package/out/src/codex/us-fips-state.js +6 -8
- package/out/src/codex/us-fips-state.js.map +1 -1
- package/out/src/golden.d.ts.map +1 -1
- package/out/src/golden.js +1 -1
- package/out/src/golden.js.map +1 -1
- package/out/src/index.d.ts +1 -0
- package/out/src/index.d.ts.map +1 -1
- package/out/src/index.js +1 -0
- package/out/src/index.js.map +1 -1
- package/out/src/license.d.ts +5 -6
- package/out/src/license.d.ts.map +1 -1
- package/out/src/license.js +5 -6
- package/out/src/license.js.map +1 -1
- package/out/src/parquet-wrapper/reader.d.ts.map +1 -1
- package/out/src/parquet-wrapper/reader.js.map +1 -1
- package/out/src/parquet-wrapper/writer.d.ts.map +1 -1
- package/out/src/parquet-wrapper/writer.js +2 -2
- package/out/src/parquet-wrapper/writer.js.map +1 -1
- package/out/src/parquet.d.ts +16 -18
- package/out/src/parquet.d.ts.map +1 -1
- package/out/src/parquet.js +22 -23
- package/out/src/parquet.js.map +1 -1
- package/out/src/runner.d.ts +10 -10
- package/out/src/runner.d.ts.map +1 -1
- package/out/src/runner.js +8 -8
- package/out/src/runner.js.map +1 -1
- package/out/src/shard-recipes/anchor-absorption.d.ts +16 -0
- package/out/src/shard-recipes/anchor-absorption.d.ts.map +1 -0
- package/out/src/shard-recipes/anchor-absorption.js +73 -0
- package/out/src/shard-recipes/anchor-absorption.js.map +1 -0
- package/out/src/shard-recipes/boundary-stress.d.ts +16 -0
- package/out/src/shard-recipes/boundary-stress.d.ts.map +1 -0
- package/out/src/shard-recipes/boundary-stress.js +77 -0
- package/out/src/shard-recipes/boundary-stress.js.map +1 -0
- package/out/src/shard-recipes/country-balanced.d.ts +28 -0
- package/out/src/shard-recipes/country-balanced.d.ts.map +1 -0
- package/out/src/shard-recipes/country-balanced.js +370 -0
- package/out/src/shard-recipes/country-balanced.js.map +1 -0
- package/out/src/shard-recipes/fr-admin-split.d.ts +34 -0
- package/out/src/shard-recipes/fr-admin-split.d.ts.map +1 -0
- package/out/src/shard-recipes/fr-admin-split.js +175 -0
- package/out/src/shard-recipes/fr-admin-split.js.map +1 -0
- package/out/src/shard-recipes/fr-bare-street.d.ts +24 -0
- package/out/src/shard-recipes/fr-bare-street.d.ts.map +1 -0
- package/out/src/shard-recipes/fr-bare-street.js +76 -0
- package/out/src/shard-recipes/fr-bare-street.js.map +1 -0
- package/out/src/shard-recipes/fr-order.d.ts +34 -0
- package/out/src/shard-recipes/fr-order.d.ts.map +1 -0
- package/out/src/shard-recipes/fr-order.js +238 -0
- package/out/src/shard-recipes/fr-order.js.map +1 -0
- package/out/src/shard-recipes/german.d.ts +19 -0
- package/out/src/shard-recipes/german.d.ts.map +1 -0
- package/out/src/shard-recipes/german.js +170 -0
- package/out/src/shard-recipes/german.js.map +1 -0
- package/out/src/shard-recipes/house-venue.d.ts +14 -0
- package/out/src/shard-recipes/house-venue.d.ts.map +1 -0
- package/out/src/shard-recipes/house-venue.js +66 -0
- package/out/src/shard-recipes/house-venue.js.map +1 -0
- package/out/src/shard-recipes/index.d.ts +18 -0
- package/out/src/shard-recipes/index.d.ts.map +1 -0
- package/out/src/shard-recipes/index.js +58 -0
- package/out/src/shard-recipes/index.js.map +1 -0
- package/out/src/shard-recipes/intersection.d.ts +38 -0
- package/out/src/shard-recipes/intersection.d.ts.map +1 -0
- package/out/src/shard-recipes/intersection.js +473 -0
- package/out/src/shard-recipes/intersection.js.map +1 -0
- package/out/src/shard-recipes/locale.d.ts +19 -0
- package/out/src/shard-recipes/locale.d.ts.map +1 -0
- package/out/src/shard-recipes/locale.js +257 -0
- package/out/src/shard-recipes/locale.js.map +1 -0
- package/out/src/shard-recipes/no-street.d.ts +14 -0
- package/out/src/shard-recipes/no-street.d.ts.map +1 -0
- package/out/src/shard-recipes/no-street.js +66 -0
- package/out/src/shard-recipes/no-street.js.map +1 -0
- package/out/src/shard-recipes/po-box-cedex.d.ts +34 -0
- package/out/src/shard-recipes/po-box-cedex.d.ts.map +1 -0
- package/out/src/shard-recipes/po-box-cedex.js +686 -0
- package/out/src/shard-recipes/po-box-cedex.js.map +1 -0
- package/out/src/shard-recipes/po-box.d.ts +13 -0
- package/out/src/shard-recipes/po-box.d.ts.map +1 -0
- package/out/src/shard-recipes/po-box.js +93 -0
- package/out/src/shard-recipes/po-box.js.map +1 -0
- package/out/src/shard-recipes/scaffold.d.ts +104 -0
- package/out/src/shard-recipes/scaffold.d.ts.map +1 -0
- package/out/src/shard-recipes/scaffold.js +76 -0
- package/out/src/shard-recipes/scaffold.js.map +1 -0
- package/out/src/shard-recipes/street-affix.d.ts +31 -0
- package/out/src/shard-recipes/street-affix.d.ts.map +1 -0
- package/out/src/shard-recipes/street-affix.js +408 -0
- package/out/src/shard-recipes/street-affix.js.map +1 -0
- package/out/src/shard-recipes/street-bare.d.ts +21 -0
- package/out/src/shard-recipes/street-bare.d.ts.map +1 -0
- package/out/src/shard-recipes/street-bare.js +82 -0
- package/out/src/shard-recipes/street-bare.js.map +1 -0
- package/out/src/shard-recipes/street.d.ts +11 -0
- package/out/src/shard-recipes/street.d.ts.map +1 -0
- package/out/src/shard-recipes/street.js +63 -0
- package/out/src/shard-recipes/street.js.map +1 -0
- package/out/src/shard-recipes/unit.d.ts +25 -0
- package/out/src/shard-recipes/unit.d.ts.map +1 -0
- package/out/src/shard-recipes/unit.js +255 -0
- package/out/src/shard-recipes/unit.js.map +1 -0
- package/out/src/split.d.ts +23 -29
- package/out/src/split.d.ts.map +1 -1
- package/out/src/split.js +22 -29
- package/out/src/split.js.map +1 -1
- package/out/src/synthesize-anchor-absorption.d.ts +2 -3
- package/out/src/synthesize-anchor-absorption.d.ts.map +1 -1
- package/out/src/synthesize-anchor-absorption.js +2 -2
- package/out/src/synthesize-anchor-absorption.js.map +1 -1
- package/out/src/synthesize-boundary-stress.d.ts +3 -4
- package/out/src/synthesize-boundary-stress.d.ts.map +1 -1
- package/out/src/synthesize-boundary-stress.js +3 -4
- package/out/src/synthesize-boundary-stress.js.map +1 -1
- package/out/src/synthesize-german.d.ts +15 -19
- package/out/src/synthesize-german.d.ts.map +1 -1
- package/out/src/synthesize-german.js +14 -17
- package/out/src/synthesize-german.js.map +1 -1
- package/out/src/synthesize-house-venue.d.ts +2 -3
- package/out/src/synthesize-house-venue.d.ts.map +1 -1
- package/out/src/synthesize-house-venue.js +2 -3
- package/out/src/synthesize-house-venue.js.map +1 -1
- package/out/src/synthesize-intersection.d.ts +2 -2
- package/out/src/synthesize-intersection.d.ts.map +1 -1
- package/out/src/synthesize-intersection.js +4 -4
- package/out/src/synthesize-intersection.js.map +1 -1
- package/out/src/synthesize-no-street.d.ts +5 -5
- package/out/src/synthesize-no-street.d.ts.map +1 -1
- package/out/src/synthesize-no-street.js +27 -23
- package/out/src/synthesize-no-street.js.map +1 -1
- package/out/src/synthesize-po-box.d.ts +15 -17
- package/out/src/synthesize-po-box.d.ts.map +1 -1
- package/out/src/synthesize-po-box.js +27 -27
- package/out/src/synthesize-po-box.js.map +1 -1
- package/out/src/synthesize-street.d.ts +8 -9
- package/out/src/synthesize-street.d.ts.map +1 -1
- package/out/src/synthesize-street.js +3 -3
- package/out/src/synthesize-street.js.map +1 -1
- package/out/src/synthesize.d.ts +57 -66
- package/out/src/synthesize.d.ts.map +1 -1
- package/out/src/synthesize.js +56 -65
- package/out/src/synthesize.js.map +1 -1
- package/out/src/tokenize.d.ts +5 -6
- package/out/src/tokenize.d.ts.map +1 -1
- package/out/src/tokenize.js +5 -6
- package/out/src/tokenize.js.map +1 -1
- package/out/src/types.d.ts +49 -51
- package/out/src/types.d.ts.map +1 -1
- package/out/src/wof-json.d.ts +32 -34
- package/out/src/wof-json.d.ts.map +1 -1
- package/out/src/wof-json.js +23 -25
- package/out/src/wof-json.js.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `boundary-stress` shard recipe (#375) — the boundary-instability augmentation. Self-generates
|
|
7
|
+
* `--count` rows from {@link synthesizeBoundaryStressRow}'s weighted template mix (the v1.7.0,
|
|
8
|
+
* DeepSeek-tuned 2026-06-18 composition), aligns each to BIO, and emits a labeled JSONL. The
|
|
9
|
+
* lever for the taxonomy's #1 parser family (the boundary-wobble class). Ported from
|
|
10
|
+
* scripts/build-boundary-stress-shard.mjs.
|
|
11
|
+
*
|
|
12
|
+
* `synthesizeBoundaryStressRow` is NOT re-exported from the corpus index — imported directly here.
|
|
13
|
+
*/
|
|
14
|
+
import { alignRow } from "../align.js";
|
|
15
|
+
import { synthesizeBoundaryStressRow } from "../synthesize-boundary-stress.js";
|
|
16
|
+
import { makeMulberry32, shardSourceID } from "./scaffold.js";
|
|
17
|
+
// Revised composition (v1.7.0, DeepSeek-tuned 2026-06-18): `bare-locality` ~11% (recover the 84% locality
|
|
18
|
+
// drop on bare "City, STATE" rows WITHOUT becoming a locality-first majority), and
|
|
19
|
+
// house-number-before:after = 7:3 (FR's dominant order is number-BEFORE; 30% after breaks the order-bias
|
|
20
|
+
// shortcut without risking FR hn-before accuracy). The three original non-number shapes keep the bulk.
|
|
21
|
+
// Weights sum to 1.0. Key order is load-bearing — it drives the cumulative thresholds below.
|
|
22
|
+
const WEIGHTS = {
|
|
23
|
+
"street-eats-affix": 0.22,
|
|
24
|
+
"comma-less-city-state": 0.22,
|
|
25
|
+
"fr-prefix": 0.18,
|
|
26
|
+
"bare-locality": 0.11,
|
|
27
|
+
"house-number-before-street": 0.189,
|
|
28
|
+
"house-number-after-street": 0.081,
|
|
29
|
+
};
|
|
30
|
+
const CUM = (() => {
|
|
31
|
+
let acc = 0;
|
|
32
|
+
return Object.entries(WEIGHTS).map(([t, w]) => [t, (acc += w)]);
|
|
33
|
+
})();
|
|
34
|
+
function pickTemplate(r) {
|
|
35
|
+
const x = r();
|
|
36
|
+
for (const [t, c] of CUM)
|
|
37
|
+
if (x <= c)
|
|
38
|
+
return t;
|
|
39
|
+
return CUM[CUM.length - 1][0];
|
|
40
|
+
}
|
|
41
|
+
export const boundaryStressRecipe = {
|
|
42
|
+
name: "boundary-stress",
|
|
43
|
+
description: "Boundary-instability rows (#375): weighted template mix → synthesizeBoundaryStressRow → aligned BIO",
|
|
44
|
+
mode: "generate",
|
|
45
|
+
async run(opts, write) {
|
|
46
|
+
// Emit PRNG: the legacy build-boundary-stress-shard.mjs seeded mulberry32(opts.seed).
|
|
47
|
+
const random = makeMulberry32(opts.seed);
|
|
48
|
+
const count = opts.count ?? 20000;
|
|
49
|
+
let emitted = 0;
|
|
50
|
+
let skipped = 0;
|
|
51
|
+
for (let i = 0; i < count; i++) {
|
|
52
|
+
const row = synthesizeBoundaryStressRow(undefined, { random, forceTemplate: pickTemplate(random) });
|
|
53
|
+
const country = row.locale.split("-")[1] ?? "US";
|
|
54
|
+
const source_id = shardSourceID("synth-boundary-stress", { ...row.components, v: String(i) });
|
|
55
|
+
const canonical = {
|
|
56
|
+
raw: row.raw,
|
|
57
|
+
components: row.components,
|
|
58
|
+
country,
|
|
59
|
+
locale: row.locale,
|
|
60
|
+
source: "synth-boundary-stress",
|
|
61
|
+
source_id,
|
|
62
|
+
corpus_version: "0.6.0",
|
|
63
|
+
license: "Synthetic — boundary-stress; derived from public-domain locality/region tuples",
|
|
64
|
+
};
|
|
65
|
+
const aligned = alignRow(canonical);
|
|
66
|
+
if (aligned.kind !== "labeled") {
|
|
67
|
+
skipped++;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
// Match the base corpus parquet schema: flat synth_method / synth_base_id, not a nested `synth`.
|
|
71
|
+
write(JSON.stringify({ ...aligned.row, synth_method: `boundary-stress:${row.template}`, synth_base_id: null }) + "\n");
|
|
72
|
+
emitted++;
|
|
73
|
+
}
|
|
74
|
+
return { emitted, skipped };
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=boundary-stress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundary-stress.js","sourceRoot":"","sources":["../../../src/shard-recipes/boundary-stress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAA+B,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AAC3G,OAAO,EAAE,cAAc,EAAoB,aAAa,EAAE,MAAM,eAAe,CAAA;AAE/E,0GAA0G;AAC1G,mFAAmF;AACnF,yGAAyG;AACzG,uGAAuG;AACvG,6FAA6F;AAC7F,MAAM,OAAO,GAA2C;IACvD,mBAAmB,EAAE,IAAI;IACzB,uBAAuB,EAAE,IAAI;IAC7B,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,IAAI;IACrB,4BAA4B,EAAE,KAAK;IACnC,2BAA2B,EAAE,KAAK;CAClC,CAAA;AACD,MAAM,GAAG,GAA4C,CAAC,GAAG,EAAE;IAC1D,IAAI,GAAG,GAAG,CAAC,CAAA;IAEX,OAAQ,MAAM,CAAC,OAAO,CAAC,OAAO,CAA6C,CAAC,GAAG,CAC9E,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAqC,CAC/D,CAAA;AACF,CAAC,CAAC,EAAE,CAAA;AACJ,SAAS,YAAY,CAAC,CAAe;IACpC,MAAM,C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AClB,MAAM,EAAE,uBAAuB;gBAC/B,SAAS;gBACT,cAAc,EAAE,OAAO;gBACvB,OAAO,EAAE,gFAAgF;aACzF,CAAA;YACD,MAAM,OAAO,GAAG,QAAQ,CAAC,SAA2C,CAAC,CAAA;YAErE,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAChC,OAAO,EAAE,CAAA;gBACT,SAAQ;YACT,CAAC;YACD,iGAAiG;YACjG,KAAK,CACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE,mBAAmB,GAAG,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAC/G,CAAA;YACD,OAAO,EAAE,CAAA;QACV,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IAC5B,CAAC;CACD,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `country-balanced` shard recipe — the BALANCED, MODEL-FIRST country-coverage shard (#464). The
|
|
7
|
+
* shipped model is STARVED on `country` (P=R=F1=0 on the homograph eval), so this fills the void
|
|
8
|
+
* the way the `unit` shard did, but built to AVOID over-firing "trailing token ⇒ country". Three
|
|
9
|
+
* ingredients, ported faithfully from scripts/build-country-shard-balanced.mjs:
|
|
10
|
+
*
|
|
11
|
+
* 1. Breadth/recall — real OA skeletons (US/DE/FR/IT/NL) with a country token in a varied surface form
|
|
12
|
+
* from `@mailwoman/codex/country` (canonical / endonym / ISO code), + ~30% country-ABSENT
|
|
13
|
+
* negatives (teach O-emission, the precision floor).
|
|
14
|
+
* 2. Homograph CONTRAST pairs — each true country-name homograph (Georgia, Jordan, Lebanon, Mexico,
|
|
15
|
+
* Peru, Turkey) rendered BOTH ways: as `country` (foreign-city context) AND as the US
|
|
16
|
+
* `region`/`locality` (US-ZIP context). Teaches that the label is CONTEXTUAL, not
|
|
17
|
+
* positional.
|
|
18
|
+
* 3. Code-as-region negatives — 2-letter codes that are both a US state abbrev and an ISO country code
|
|
19
|
+
* (CA/GA/IN/MA/PA/AL) in US-ZIP context → must read as `region`, never `country`.
|
|
20
|
+
*
|
|
21
|
+
* `--golden` emits a held-out synthetic val over the VT (US) + Berlin (DE) holdouts. This is a
|
|
22
|
+
* `generate`-mode recipe that still reads REAL tuples off disk — `--count` bounds the OUTPUT, not
|
|
23
|
+
* the input. The passed `random` (the framework LCG) is consumed in the exact call order the
|
|
24
|
+
* legacy script used.
|
|
25
|
+
*/
|
|
26
|
+
import { type ShardRecipe } from "./scaffold.js";
|
|
27
|
+
export declare const countryBalancedRecipe: ShardRecipe;
|
|
28
|
+
//# sourceMappingURL=country-balanced.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-balanced.d.ts","sourceRoot":"","sources":["../../../src/shard-recipes/country-balanced.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAUH,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AA+UhE,eAAO,MAAM,qBAAqB,EAAE,WAwFnC,CAAA"}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `country-balanced` shard recipe — the BALANCED, MODEL-FIRST country-coverage shard (#464). The
|
|
7
|
+
* shipped model is STARVED on `country` (P=R=F1=0 on the homograph eval), so this fills the void
|
|
8
|
+
* the way the `unit` shard did, but built to AVOID over-firing "trailing token ⇒ country". Three
|
|
9
|
+
* ingredients, ported faithfully from scripts/build-country-shard-balanced.mjs:
|
|
10
|
+
*
|
|
11
|
+
* 1. Breadth/recall — real OA skeletons (US/DE/FR/IT/NL) with a country token in a varied surface form
|
|
12
|
+
* from `@mailwoman/codex/country` (canonical / endonym / ISO code), + ~30% country-ABSENT
|
|
13
|
+
* negatives (teach O-emission, the precision floor).
|
|
14
|
+
* 2. Homograph CONTRAST pairs — each true country-name homograph (Georgia, Jordan, Lebanon, Mexico,
|
|
15
|
+
* Peru, Turkey) rendered BOTH ways: as `country` (foreign-city context) AND as the US
|
|
16
|
+
* `region`/`locality` (US-ZIP context). Teaches that the label is CONTEXTUAL, not
|
|
17
|
+
* positional.
|
|
18
|
+
* 3. Code-as-region negatives — 2-letter codes that are both a US state abbrev and an ISO country code
|
|
19
|
+
* (CA/GA/IN/MA/PA/AL) in US-ZIP context → must read as `region`, never `country`.
|
|
20
|
+
*
|
|
21
|
+
* `--golden` emits a held-out synthetic val over the VT (US) + Berlin (DE) holdouts. This is a
|
|
22
|
+
* `generate`-mode recipe that still reads REAL tuples off disk — `--count` bounds the OUTPUT, not
|
|
23
|
+
* the input. The passed `random` (the framework LCG) is consumed in the exact call order the
|
|
24
|
+
* legacy script used.
|
|
25
|
+
*/
|
|
26
|
+
import { spawnSync } from "node:child_process";
|
|
27
|
+
import { COUNTRY_SURFACE_FORMS, CountryNames } from "@mailwoman/codex/country";
|
|
28
|
+
import { stableSourceID } from "../adapter.js";
|
|
29
|
+
import { alignRow } from "../align.js";
|
|
30
|
+
import { makeMulberry32 } from "./scaffold.js";
|
|
31
|
+
// v2: the country TOKEN is decoupled from the skeleton's locale and drawn from a BROAD pool — every
|
|
32
|
+
// ISO canonical name + every curated surface form (endonyms/abbrevs). Surface forms are over-weighted
|
|
33
|
+
// so endonyms/abbrevs ("Deutschland","USA","NL") get strong signal.
|
|
34
|
+
const COUNTRY_FORM_POOL = (() => {
|
|
35
|
+
const surface = Object.values(COUNTRY_SURFACE_FORMS).flat(); // endonyms + abbrevs + canonical (curated)
|
|
36
|
+
const names = [...CountryNames];
|
|
37
|
+
// all ~249 ISO canonical English names (breadth)
|
|
38
|
+
return { surface, names };
|
|
39
|
+
})();
|
|
40
|
+
const COUNTRY_ABSENT_PROB = 0.3; // negatives: rows with NO country token → teach golden precision
|
|
41
|
+
// Multi-locale OA sources. region = implied admin where the extract is single-region (US states, DE
|
|
42
|
+
// Saxony); countrywide extracts (FR/IT/NL) read region from the CSV when present.
|
|
43
|
+
const SOURCES = [
|
|
44
|
+
{ zip: "/tmp/oa-cache/us__ia__statewide.zip", csv: "us/ia/statewide.csv", iso2: "US", region: "IA", order: "us" },
|
|
45
|
+
{ zip: "/tmp/oa-cache/us__il__cook.zip", csv: "us/il/cook.csv", iso2: "US", region: "IL", order: "us" },
|
|
46
|
+
{ zip: "/tmp/oa-cache/us__mt__statewide.zip", csv: "us/mt/statewide.csv", iso2: "US", region: "MT", order: "us" },
|
|
47
|
+
{ zip: "/tmp/oa-cache/us__sd__statewide.zip", csv: "us/sd/statewide.csv", iso2: "US", region: "SD", order: "us" },
|
|
48
|
+
{ zip: "/tmp/oa-cache/de__sn__statewide.zip", csv: "de/sn/statewide.csv", iso2: "DE", region: "", order: "eu" },
|
|
49
|
+
{ zip: "/tmp/oa-cache/fr__countrywide.zip", csv: "fr/countrywide.csv", iso2: "FR", region: "", order: "fr" },
|
|
50
|
+
// ES uses the Spanish IGN schema, not the OA standard columns — skipped here (codex still recognizes
|
|
51
|
+
// "España"/"Spain"). A dedicated IGN adapter is a follow-up.
|
|
52
|
+
{ zip: "/tmp/oa-cache/it__countrywide.zip", csv: "it/countrywide.csv", iso2: "IT", region: "", order: "eu" },
|
|
53
|
+
{ zip: "/tmp/oa-cache/nl__countrywide.zip", csv: "nl/countrywide.csv", iso2: "NL", region: "", order: "eu" },
|
|
54
|
+
];
|
|
55
|
+
// Held-out for --golden: Vermont (US holdout) + Berlin (DE holdout) — geographic split, never trained.
|
|
56
|
+
const EVAL_SOURCES = [
|
|
57
|
+
{ zip: "/tmp/oa-cache/us__vt__statewide.zip", csv: "us/vt/statewide.csv", iso2: "US", region: "VT", order: "us" },
|
|
58
|
+
{ zip: "/tmp/oa-cache/de__berlin.zip", csv: "de/berlin.csv", iso2: "DE", region: "", order: "eu" },
|
|
59
|
+
];
|
|
60
|
+
function splitCSV(line) {
|
|
61
|
+
const out = [];
|
|
62
|
+
let cur = "", inQ = false;
|
|
63
|
+
for (let i = 0; i < line.length; i++) {
|
|
64
|
+
const c = line[i];
|
|
65
|
+
if (inQ) {
|
|
66
|
+
if (c === '"') {
|
|
67
|
+
if (line[i + 1] === '"') {
|
|
68
|
+
cur += '"';
|
|
69
|
+
i++;
|
|
70
|
+
}
|
|
71
|
+
else
|
|
72
|
+
inQ = false;
|
|
73
|
+
}
|
|
74
|
+
else
|
|
75
|
+
cur += c;
|
|
76
|
+
}
|
|
77
|
+
else if (c === '"')
|
|
78
|
+
inQ = true;
|
|
79
|
+
else if (c === ",") {
|
|
80
|
+
out.push(cur);
|
|
81
|
+
cur = "";
|
|
82
|
+
}
|
|
83
|
+
else
|
|
84
|
+
cur += c;
|
|
85
|
+
}
|
|
86
|
+
out.push(cur);
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
function readTuples(source, limit) {
|
|
90
|
+
// countrywide extracts (FR/IT/NL) are GB-scale — cap the bytes with `head` (read ~8 lines per wanted
|
|
91
|
+
// tuple to survive dedup/skips) so the toString stays under V8's string limit.
|
|
92
|
+
const maxLines = Math.max(limit * 8, 20000) + 1;
|
|
93
|
+
const r = spawnSync("bash", ["-c", `unzip -p "${source.zip}" "${source.csv}" | head -n ${maxLines}`], {
|
|
94
|
+
maxBuffer: 1024 * 1024 * 1024,
|
|
95
|
+
encoding: "buffer",
|
|
96
|
+
});
|
|
97
|
+
if (r.status !== 0) {
|
|
98
|
+
console.error(` WARN: unzip failed for ${source.zip} (status ${r.status})`);
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
const lines = r.stdout.toString("utf8").split(/\r?\n/);
|
|
102
|
+
if (lines.length < 2)
|
|
103
|
+
return [];
|
|
104
|
+
const header = splitCSV(lines[0]).map((h) => h.trim().toLowerCase());
|
|
105
|
+
const idx = (n) => header.indexOf(n);
|
|
106
|
+
const iNum = idx("number"), iStreet = idx("street"), iCity = idx("city"), iRegion = idx("region"), iPost = idx("postcode");
|
|
107
|
+
const get = (cells, i) => (i >= 0 && i < cells.length ? (cells[i] ?? "").trim() : "");
|
|
108
|
+
const tuples = [];
|
|
109
|
+
const seen = new Set();
|
|
110
|
+
for (let li = 1; li < lines.length && tuples.length < limit; li++) {
|
|
111
|
+
if (!lines[li])
|
|
112
|
+
continue;
|
|
113
|
+
const cells = splitCSV(lines[li]);
|
|
114
|
+
const street = get(cells, iStreet), locality = get(cells, iCity), house_number = get(cells, iNum);
|
|
115
|
+
if (!street || !locality || !house_number)
|
|
116
|
+
continue;
|
|
117
|
+
const key = `${house_number}|${street}|${locality}`.toLowerCase();
|
|
118
|
+
if (seen.has(key))
|
|
119
|
+
continue;
|
|
120
|
+
seen.add(key);
|
|
121
|
+
tuples.push({
|
|
122
|
+
house_number,
|
|
123
|
+
street,
|
|
124
|
+
locality,
|
|
125
|
+
region: get(cells, iRegion) || source.region,
|
|
126
|
+
postcode: get(cells, iPost),
|
|
127
|
+
iso2: source.iso2,
|
|
128
|
+
order: source.order,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return tuples;
|
|
132
|
+
}
|
|
133
|
+
/** Pick a country token from the BROAD pool, or null (a country-absent negative). v2. */
|
|
134
|
+
function pickCountry(random) {
|
|
135
|
+
if (random() < COUNTRY_ABSENT_PROB)
|
|
136
|
+
return null; // negative — teaches "trailing token != always country"
|
|
137
|
+
// 60% curated surface forms (endonym/abbrev variety), 40% broad ISO canonical names (coverage).
|
|
138
|
+
const pool = random() < 0.6 ? COUNTRY_FORM_POOL.surface : COUNTRY_FORM_POOL.names;
|
|
139
|
+
return pool[Math.floor(random() * pool.length)];
|
|
140
|
+
}
|
|
141
|
+
/** Render the address body in native-ish order. `country` null → a country-ABSENT negative row. */
|
|
142
|
+
function renderCountry(random, t, country) {
|
|
143
|
+
const { house_number: hn, street, locality: loc, region: reg, postcode: pc, order } = t;
|
|
144
|
+
const components = { house_number: hn, street, locality: loc };
|
|
145
|
+
if (reg)
|
|
146
|
+
components.region = reg;
|
|
147
|
+
if (pc)
|
|
148
|
+
components.postcode = pc;
|
|
149
|
+
let body;
|
|
150
|
+
if (order === "us") {
|
|
151
|
+
const regPc = [reg, pc].filter(Boolean).join(" ");
|
|
152
|
+
body = `${hn} ${street}, ${loc}${regPc ? ", " + regPc : ""}`;
|
|
153
|
+
}
|
|
154
|
+
else if (order === "fr") {
|
|
155
|
+
// French is NUMBER-street, postcode-city: "84 Route de la Fontaine, 75008 Paris".
|
|
156
|
+
body = `${hn} ${street}, ${[pc, loc].filter(Boolean).join(" ")}`;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// DE/IT/NL: street-number, postcode-city: "Pariser Platz 1, 10117 Berlin".
|
|
160
|
+
const pcCity = [pc, loc].filter(Boolean).join(" ");
|
|
161
|
+
body = `${street} ${hn}, ${pcCity}`;
|
|
162
|
+
}
|
|
163
|
+
if (!country) {
|
|
164
|
+
// Negative: a normal address, NO country token/component. Teaches that a trailing region/city/
|
|
165
|
+
// postcode is NOT a country (counters the v1 golden over-firing).
|
|
166
|
+
return { fmt: "negative", raw: body, components };
|
|
167
|
+
}
|
|
168
|
+
const withC = { ...components, country };
|
|
169
|
+
const r = random();
|
|
170
|
+
if (r < 0.8)
|
|
171
|
+
return { fmt: "full", raw: `${body}, ${country}`, components: withC };
|
|
172
|
+
if (r < 0.92)
|
|
173
|
+
return { fmt: "full-nl", raw: `${body}\n${country}`, components: withC };
|
|
174
|
+
const bareBody = order === "us" || order === "fr" ? `${hn} ${street}, ${loc}` : `${street} ${hn}, ${loc}`;
|
|
175
|
+
return {
|
|
176
|
+
fmt: "bare",
|
|
177
|
+
raw: `${bareBody}, ${country}`,
|
|
178
|
+
components: { house_number: hn, street, locality: loc, country },
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const HOMOGRAPHS = [
|
|
182
|
+
{
|
|
183
|
+
surface: "Georgia",
|
|
184
|
+
iso2: "GE",
|
|
185
|
+
cities: ["Tbilisi", "Batumi", "Kutaisi", "Rustavi"],
|
|
186
|
+
us: { role: "region", locality: "Atlanta", region: "Georgia", postcodes: ["30309", "31401", "30601", "31201"] },
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
surface: "Jordan",
|
|
190
|
+
iso2: "JO",
|
|
191
|
+
cities: ["Amman", "Irbid", "Zarqa", "Aqaba"],
|
|
192
|
+
us: { role: "locality", locality: "Jordan", region: "MN", postcodes: ["55352"] },
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
surface: "Lebanon",
|
|
196
|
+
iso2: "LB",
|
|
197
|
+
cities: ["Beirut", "Tripoli", "Sidon", "Byblos"],
|
|
198
|
+
us: { role: "locality", locality: "Lebanon", region: "TN", postcodes: ["37087", "03766", "17042", "45036"] },
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
surface: "Mexico",
|
|
202
|
+
iso2: "MX",
|
|
203
|
+
cities: ["Guadalajara", "Monterrey", "Puebla", "Oaxaca"],
|
|
204
|
+
us: { role: "locality", locality: "Mexico", region: "MO", postcodes: ["65265"] },
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
surface: "Peru",
|
|
208
|
+
iso2: "PE",
|
|
209
|
+
cities: ["Cusco", "Arequipa", "Trujillo", "Iquitos"],
|
|
210
|
+
us: { role: "locality", locality: "Peru", region: "IL", postcodes: ["61354", "46970"] },
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
surface: "Turkey",
|
|
214
|
+
iso2: "TR",
|
|
215
|
+
cities: ["Ankara", "Izmir", "Bursa", "Antalya"],
|
|
216
|
+
us: { role: "locality", locality: "Turkey", region: "TX", postcodes: ["79261", "28393"] },
|
|
217
|
+
},
|
|
218
|
+
];
|
|
219
|
+
const ABBREV_REGIONS = [
|
|
220
|
+
{ code: "CA", localities: ["Los Angeles", "Sacramento", "San Diego"], postcodes: ["90012", "95814", "92101"] }, // California / Canada
|
|
221
|
+
{ code: "GA", localities: ["Atlanta", "Savannah", "Macon"], postcodes: ["30309", "31401", "31201"] }, // Georgia(US) / Georgia
|
|
222
|
+
{ code: "IN", localities: ["Indianapolis", "Fort Wayne"], postcodes: ["46204", "46802"] }, // Indiana / India
|
|
223
|
+
{ code: "MA", localities: ["Boston", "Worcester"], postcodes: ["02108", "01608"] }, // Massachusetts / Morocco
|
|
224
|
+
{ code: "PA", localities: ["Philadelphia", "Pittsburgh"], postcodes: ["19103", "15222"] }, // Pennsylvania / Panama
|
|
225
|
+
{ code: "AL", localities: ["Birmingham", "Montgomery"], postcodes: ["35203", "36104"] }, // Alabama / Albania
|
|
226
|
+
];
|
|
227
|
+
const STREET_POOL = [
|
|
228
|
+
"Main Street",
|
|
229
|
+
"Oak Avenue",
|
|
230
|
+
"Park Road",
|
|
231
|
+
"Elm Street",
|
|
232
|
+
"Hill Road",
|
|
233
|
+
"Market Street",
|
|
234
|
+
"Church Street",
|
|
235
|
+
"King Street",
|
|
236
|
+
"2nd Avenue",
|
|
237
|
+
"Maple Drive",
|
|
238
|
+
];
|
|
239
|
+
const pick = (random, arr) => arr[Math.floor(random() * arr.length)];
|
|
240
|
+
const houseNo = (random) => String(1 + Math.floor(random() * 998));
|
|
241
|
+
/**
|
|
242
|
+
* A homograph CONTRAST row: ~half render the surface as `country` (foreign city), half as the US `region`/`locality`
|
|
243
|
+
* (US ZIP, NO country). Returns iso2 for provenance.
|
|
244
|
+
*/
|
|
245
|
+
function renderHomograph(random) {
|
|
246
|
+
const h = pick(random, HOMOGRAPHS);
|
|
247
|
+
const hn = houseNo(random), street = pick(random, STREET_POOL);
|
|
248
|
+
if (random() < 0.5) {
|
|
249
|
+
const city = pick(random, h.cities);
|
|
250
|
+
const withStreet = random() < 0.6;
|
|
251
|
+
const raw = withStreet ? `${hn} ${street}, ${city}, ${h.surface}` : `${city}, ${h.surface}`;
|
|
252
|
+
const components = withStreet
|
|
253
|
+
? { house_number: hn, street, locality: city, country: h.surface }
|
|
254
|
+
: { locality: city, country: h.surface };
|
|
255
|
+
return { fmt: "homograph-country", raw, components, iso2: h.iso2 };
|
|
256
|
+
}
|
|
257
|
+
const pc = pick(random, h.us.postcodes);
|
|
258
|
+
if (h.us.role === "region") {
|
|
259
|
+
// surface is the US STATE: "123 Oak Ave, Atlanta, Georgia 30309" → region, no country
|
|
260
|
+
return {
|
|
261
|
+
fmt: "homograph-us-region",
|
|
262
|
+
raw: `${hn} ${street}, ${h.us.locality}, ${h.surface} ${pc}`,
|
|
263
|
+
components: { house_number: hn, street, locality: h.us.locality, region: h.surface, postcode: pc },
|
|
264
|
+
iso2: "US",
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
// surface is the US CITY: "123 Oak Ave, Lebanon, TN 37087" → locality, no country
|
|
268
|
+
return {
|
|
269
|
+
fmt: "homograph-us-locality",
|
|
270
|
+
raw: `${hn} ${street}, ${h.surface}, ${h.us.region} ${pc}`,
|
|
271
|
+
components: { house_number: hn, street, locality: h.surface, region: h.us.region, postcode: pc },
|
|
272
|
+
iso2: "US",
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/** An abbrev-as-region negative: "123 Main St, Los Angeles, CA 90012" → region CA, NO country. */
|
|
276
|
+
function renderAbbrevRegion(random) {
|
|
277
|
+
const a = pick(random, ABBREV_REGIONS);
|
|
278
|
+
const hn = houseNo(random), street = pick(random, STREET_POOL), locality = pick(random, a.localities), postcode = pick(random, a.postcodes);
|
|
279
|
+
return {
|
|
280
|
+
fmt: "abbrev-region",
|
|
281
|
+
raw: `${hn} ${street}, ${locality}, ${a.code} ${postcode}`,
|
|
282
|
+
components: { house_number: hn, street, locality, region: a.code, postcode },
|
|
283
|
+
iso2: "US",
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
const HOMOGRAPH_FRAC = 0.22; // share of rows that are homograph contrast pairs
|
|
287
|
+
const ABBREV_FRAC = 0.08; // share that are code-as-region negatives (cumulative with HOMOGRAPH_FRAC)
|
|
288
|
+
export const countryBalancedRecipe = {
|
|
289
|
+
name: "country-balanced",
|
|
290
|
+
description: "Balanced model-first country rows (#464): OA skeletons + ISO surface forms + homograph contrast pairs",
|
|
291
|
+
mode: "generate",
|
|
292
|
+
options: [{ flag: "--golden", description: "Emit the held-out VT+Berlin eval slice" }],
|
|
293
|
+
async run(opts, write) {
|
|
294
|
+
if (opts.count == null)
|
|
295
|
+
throw new Error("country-balanced recipe requires --count <N>");
|
|
296
|
+
const count = opts.count;
|
|
297
|
+
// Legacy build-country-shard-balanced.mjs seeded mulberry32 with the raw seed: `const random = mulberry32(opts.seed)`.
|
|
298
|
+
const random = makeMulberry32(opts.seed);
|
|
299
|
+
const source = opts.sourceName ?? "synth-country";
|
|
300
|
+
const sources = opts.golden ? EVAL_SOURCES : SOURCES;
|
|
301
|
+
const perSource = Math.ceil((count * 3) / sources.length); // over-read; balance locales
|
|
302
|
+
const pool = [];
|
|
303
|
+
for (const s of sources) {
|
|
304
|
+
const t = readTuples(s, perSource);
|
|
305
|
+
console.error(` ${s.csv} (${s.iso2}): ${t.length} tuples`);
|
|
306
|
+
for (const x of t)
|
|
307
|
+
pool.push(x);
|
|
308
|
+
}
|
|
309
|
+
if (pool.length === 0) {
|
|
310
|
+
throw new Error("No tuples — are the cached OA zips present in /tmp/oa-cache?");
|
|
311
|
+
}
|
|
312
|
+
let emitted = 0;
|
|
313
|
+
let skipped = 0;
|
|
314
|
+
let guard = 0;
|
|
315
|
+
const N = pool.length;
|
|
316
|
+
while (emitted < count && guard++ < count * 8) {
|
|
317
|
+
// Mix three row types: homograph contrast (the distinction), code-as-region negatives, and the
|
|
318
|
+
// breadth/recall main path (random ISO form on an OA skeleton, ~30% country-absent).
|
|
319
|
+
const roll = random();
|
|
320
|
+
let rendered;
|
|
321
|
+
let rowISO2;
|
|
322
|
+
if (roll < HOMOGRAPH_FRAC) {
|
|
323
|
+
const h = renderHomograph(random);
|
|
324
|
+
rendered = h;
|
|
325
|
+
rowISO2 = h.iso2;
|
|
326
|
+
}
|
|
327
|
+
else if (roll < HOMOGRAPH_FRAC + ABBREV_FRAC) {
|
|
328
|
+
const a = renderAbbrevRegion(random);
|
|
329
|
+
rendered = a;
|
|
330
|
+
rowISO2 = a.iso2;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
const t = pool[Math.floor(random() * N)];
|
|
334
|
+
const country = pickCountry(random); // may be null → a country-absent negative row
|
|
335
|
+
rendered = renderCountry(random, t, country);
|
|
336
|
+
rowISO2 = t.iso2;
|
|
337
|
+
if (country && !rendered.raw.includes(country)) {
|
|
338
|
+
skipped++;
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const { raw, components } = rendered;
|
|
343
|
+
const localeTag = rowISO2 === "US" ? "en-US" : `${rowISO2.toLowerCase()}-${rowISO2}`;
|
|
344
|
+
if (opts.golden) {
|
|
345
|
+
write(JSON.stringify({ raw, components, country: rowISO2 }) + "\n");
|
|
346
|
+
emitted++;
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
const canonical = {
|
|
350
|
+
raw,
|
|
351
|
+
components,
|
|
352
|
+
country: rowISO2,
|
|
353
|
+
locale: localeTag,
|
|
354
|
+
source,
|
|
355
|
+
source_id: stableSourceID(source, components),
|
|
356
|
+
corpus_version: "0.4.0",
|
|
357
|
+
license: "OpenAddresses multi-locale skeletons + injected ISO-3166 country surface forms (codex)",
|
|
358
|
+
};
|
|
359
|
+
const aligned = alignRow(canonical);
|
|
360
|
+
if (aligned.kind !== "labeled" || !aligned.row) {
|
|
361
|
+
skipped++;
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
write(JSON.stringify({ ...aligned.row, synth_method: "country", synth_base_id: null }) + "\n");
|
|
365
|
+
emitted++;
|
|
366
|
+
}
|
|
367
|
+
return { emitted, skipped };
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
//# sourceMappingURL=country-balanced.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-balanced.js","sourceRoot":"","sources":["../../../src/shard-recipes/country-balanced.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAG9E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,cAAc,EAAoB,MAAM,eAAe,CAAA;AAEhE,oGAAoG;AACpG,sGAAsG;AACtG,oEAAoE;AACpE,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE;IAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,IAAI,EAAE,CAAA,CAAC,2CAA2C;IACvG,MAAM,KAAK,GAAG,CAAC,GAAG,YAAY,CAAC,CAAA;IAE/B,iDAAiD;IACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAC1B,CAAC,CAAC,EAAE,CAAA;AACJ,MAAM,mBAAmB,GAAG,GAAG,CAAA,CAAC,iEAAiE;AAWjG,oGAAoG;AACpG,kFAAkF;AAClF,MAAM,OAAO,GAA6B;IACzC,EAAE,GAAG,EAAE,qCAAqC,EAAE,GAAG,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;IACjH,EAAE,GAAG,EAAE,gCAAgC,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;IACvG,EAAE,GAAG,EAA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AAM,SAAS,GAAiB;gBAC/B,GAAG;gBACH,UAAU;gBACV,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE,SAAS;gBACjB,MAAM;gBACN,SAAS,EAAE,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC;gBAC7C,cAAc,EAAE,OAAO;gBACvB,OAAO,EAAE,wFAAwF;aACjG,CAAA;YACD,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAA;YAEnC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;gBAChD,OAAO,EAAE,CAAA;gBACT,SAAQ;YACT,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;YAC9F,OAAO,EAAE,CAAA;QACV,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IAC5B,CAAC;CACD,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `fr-admin-split` shard recipe — the FR admin-split coverage shard (night 2026-06-19,
|
|
7
|
+
* surpass-v1.5.0). Teaches the model to SPLIT the département out of the locality on
|
|
8
|
+
* bare/space/comma-delimited French place rows — the admin-deciding failure class the pre-GPU
|
|
9
|
+
* self-validation proved moves the resolved coordinate (collision communes −61%; see
|
|
10
|
+
* docs/articles/evals/2026-06-19-fr-admin-split-prevalidation.md). Ported from
|
|
11
|
+
* scripts/build-fr-admin-split-shard.mjs.
|
|
12
|
+
*
|
|
13
|
+
* Failure shapes (the model currently mis-handles all of these):
|
|
14
|
+
*
|
|
15
|
+
* - `Thauron, Creuse` → région dropped to null (the comma+full-name miss)
|
|
16
|
+
* - `Montredon, Lozère` → région = "ère" (the diacritic subword split, #727)
|
|
17
|
+
* - (AU analog) `CANBERRA ACT` → the space-delimited admin fuse
|
|
18
|
+
*
|
|
19
|
+
* The département is the essential admin unit for FR postal geography and maps to the `region`
|
|
20
|
+
* component tag in our schema. We derive it DETERMINISTICALLY from the real postcode via codex
|
|
21
|
+
* `departementForCodePostal` (first two digits = département) — salvage-first, no re-derived
|
|
22
|
+
* table.
|
|
23
|
+
*
|
|
24
|
+
* Data (`--communes`, opts.communes): REAL BAN (Base Adresse Nationale) commune+postcode+coord
|
|
25
|
+
* tuples, one per line, TAB-separated `commune <TAB> postcode <TAB> lon <TAB> lat`. Build the
|
|
26
|
+
* input TSV once from the BAN staging CSV (see the legacy script header). Anchor-ON by
|
|
27
|
+
* construction: rows carry a REAL postcode token in `raw` + a `postcode` component, so the
|
|
28
|
+
* training loader paints the anchor feature onto that span automatically. The trailing-postcode
|
|
29
|
+
* anchor REINFORCES the FR split (FR postcode is trailing, unlike German PLZ-leading — the v0.9.2
|
|
30
|
+
* scar is positional, not universal).
|
|
31
|
+
*/
|
|
32
|
+
import { type ShardRecipe } from "./scaffold.js";
|
|
33
|
+
export declare const frAdminSplitRecipe: ShardRecipe;
|
|
34
|
+
//# sourceMappingURL=fr-admin-split.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fr-admin-split.d.ts","sourceRoot":"","sources":["../../../src/shard-recipes/fr-admin-split.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAWH,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AA0FhE,eAAO,MAAM,kBAAkB,EAAE,WAgFhC,CAAA"}
|