@mailwoman/neural-weights-it-it 8.6.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 +10 -0
- package/model-card.json +25 -0
- package/package.json +27 -0
- package/pair-index-it.bin +0 -0
- package/scripts/link-dev-weights.ts +117 -0
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @mailwoman/neural-weights-it-it
|
|
2
|
+
|
|
3
|
+
it-IT weights overlay for [mailwoman](https://mailwoman.sister.software).
|
|
4
|
+
|
|
5
|
+
**Data-only.** Declares `mailwoman.baseWeights` and shares the base model and tokenizer with
|
|
6
|
+
`@mailwoman/neural-weights-en-us`; what it adds is `pair-index-it.bin`.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @mailwoman/neural-weights-it-it
|
|
10
|
+
```
|
package/model-card.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mailwoman/neural-weights-it-it",
|
|
3
|
+
"version": "7.0.0",
|
|
4
|
+
"locale": "it-IT",
|
|
5
|
+
"license": "AGPL-3.0",
|
|
6
|
+
"$comment": "Data-only overlay. Shares model.onnx + tokenizer.model with en-us via mailwoman.baseWeights.",
|
|
7
|
+
"files": {
|
|
8
|
+
"model_card": "model-card.json",
|
|
9
|
+
"pair_index": "pair-index-it.bin"
|
|
10
|
+
},
|
|
11
|
+
"it_artifacts": {
|
|
12
|
+
"$comment": "Hierarchy campaign R11 (2026-08-02). The Italian instance of the dependent-locality prior.",
|
|
13
|
+
"pair_index_it_bin": {
|
|
14
|
+
"format": "PIX1 placetype-pair index \u2014 a retrieval-augmented (quartiere, comune) dependent_locality prior, e.g. (\"Trastevere\", \"Roma\")",
|
|
15
|
+
"source": "Who's On First admin hierarchy. No postal register carries the sub-city line for this country, so WOF is the source \u2014 the same call the US, DE and IN instances made.",
|
|
16
|
+
"pairs": 4026,
|
|
17
|
+
"bytes": 103515,
|
|
18
|
+
"delta_calibration": "\u03b4=10, transitionBeta=5 \u2014 inherited from GB per R5's uniform-deficit finding.",
|
|
19
|
+
"country_gate": "hard-gated on the header's country (it).",
|
|
20
|
+
"requires_leading_postcode_strip": "INERT without the `it` entries in SEGMENT_PARENT_POSTCODE_SHAPES and LEADING_POSTCODE_COUNTRIES (neural/placetype-pair-prior.ts) \u2014 Italian addresses write the postcode first.",
|
|
21
|
+
"parent_alias_expansion": "ENABLED. WOF stores `Rome` (its English preferred name) for a city Italians write `Roma`, carried as the `ita` preferred name. Aliases are drawn from names whose language is OFFICIAL for the country (codex isOfficialLanguage) plus English, and must be LATIN-SCRIPT \u2014 the model never sees other scripts.",
|
|
22
|
+
"not_committed": "derived artifact, .gitignore'd \u2014 rebuilt via `mailwoman gazetteer pair-index --out neural-weights-it-it --country it --delta 10 --transition-beta 5 --borough-db <wof/admin-global-priority.db>`"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mailwoman/neural-weights-it-it",
|
|
3
|
+
"version": "8.6.0",
|
|
4
|
+
"description": "it-IT weights overlay for mailwoman — data-only; shares the base model with @mailwoman/neural-weights-en-us.",
|
|
5
|
+
"license": "AGPL-3.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/sister-software/mailwoman.git",
|
|
9
|
+
"directory": "neural-weights-it-it"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"model-card.json",
|
|
13
|
+
"pair-index-it.bin",
|
|
14
|
+
"README.md",
|
|
15
|
+
"*.ts",
|
|
16
|
+
"**/*.ts",
|
|
17
|
+
"!*.test.ts",
|
|
18
|
+
"!**/*.test.ts"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@mailwoman/neural-weights-en-us": "8.6.0"
|
|
23
|
+
},
|
|
24
|
+
"mailwoman": {
|
|
25
|
+
"baseWeights": "@mailwoman/neural-weights-en-us"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Dev-weights linker for `@mailwoman/neural-weights-it-it` (hierarchy campaign R11).
|
|
7
|
+
*
|
|
8
|
+
* This overlay ships exactly ONE artifact — `pair-index-it.bin` — because it declares
|
|
9
|
+
* `mailwoman.baseWeights` and shares the base model/tokenizer with the en-us package. There is
|
|
10
|
+
* nothing to symlink; the only job is building the index so `resolveWeights({locale: "de-de"})`
|
|
11
|
+
* surfaces `pairIndexPath` in local dev.
|
|
12
|
+
*
|
|
13
|
+
* The index is INERT without the `de` entries in `SEGMENT_PARENT_POSTCODE_SHAPES` and
|
|
14
|
+
* `LEADING_POSTCODE_COUNTRIES` (`neural/placetype-pair-prior.ts`): German addresses write
|
|
15
|
+
* "50733 Köln", so a parent segment folds to a key no bare-Gemeinde entry matches. Measured
|
|
16
|
+
* during R9 — the artifact alone changed nothing until both landed.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { spawnSync } from "node:child_process"
|
|
20
|
+
import { existsSync, readFileSync } from "node:fs"
|
|
21
|
+
import { resolve } from "node:path"
|
|
22
|
+
|
|
23
|
+
import { dataRootPath, repoRootPath } from "@mailwoman/core/utils"
|
|
24
|
+
|
|
25
|
+
const PKG_DIR = String(repoRootPath("neural-weights-it-it"))
|
|
26
|
+
const CLI = String(repoRootPath("mailwoman", "out", "cli.js"))
|
|
27
|
+
const PAIR_INDEX_BIN_DEST = resolve(PKG_DIR, "pair-index-it.bin")
|
|
28
|
+
/**
|
|
29
|
+
* Checked-in WOF-derived (Ortsteil, Gemeinde) pairs — the same posture as the GB secondary sources.
|
|
30
|
+
*/
|
|
31
|
+
const WOF_ADMIN_DB = String(dataRootPath("wof", "admin-global-priority.db"))
|
|
32
|
+
/**
|
|
33
|
+
* Calibrated magnitudes — the pair the R11 bars were measured at (0/60 confound FPs).
|
|
34
|
+
*/
|
|
35
|
+
const PAIR_INDEX_DELTA = 10
|
|
36
|
+
const PAIR_INDEX_TRANSITION_BETA = 5
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Minimal PIX1 header reader — magic + header only, reimplemented so this data-only package gains no dependency on
|
|
40
|
+
* `@mailwoman/neural` (which pulls onnxruntime-node) to read two fields.
|
|
41
|
+
*/
|
|
42
|
+
function peekPairIndexHeaderFields(path: string): { delta: number; transitionBeta: number | undefined } {
|
|
43
|
+
const bytes = readFileSync(path)
|
|
44
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
45
|
+
// "PIX1" little-endian.
|
|
46
|
+
const MAGIC = 0x31_58_49_50
|
|
47
|
+
|
|
48
|
+
if (view.getUint32(0, true) !== MAGIC) {
|
|
49
|
+
throw new Error(`pair index: bad magic reading ${path}`)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const headerLen = view.getUint32(4, true)
|
|
53
|
+
const header = JSON.parse(Buffer.from(bytes.subarray(8, 8 + headerLen)).toString("utf8")) as {
|
|
54
|
+
delta: number
|
|
55
|
+
transitionBeta?: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return { delta: header.delta, transitionBeta: header.transitionBeta }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!existsSync(CLI)) {
|
|
62
|
+
console.error(`WARNING: ${CLI} not built — run \`yarn compile\` first, then re-run for pair-index-it.bin.`)
|
|
63
|
+
} else if (!existsSync(WOF_ADMIN_DB)) {
|
|
64
|
+
console.error(`WARNING: missing ${WOF_ADMIN_DB} — pair-index-it.bin not built.`)
|
|
65
|
+
} else {
|
|
66
|
+
let needsRebuild = true
|
|
67
|
+
|
|
68
|
+
if (existsSync(PAIR_INDEX_BIN_DEST)) {
|
|
69
|
+
try {
|
|
70
|
+
const header = peekPairIndexHeaderFields(PAIR_INDEX_BIN_DEST)
|
|
71
|
+
|
|
72
|
+
if (header.delta !== PAIR_INDEX_DELTA) {
|
|
73
|
+
console.log(`rebuilding pair-index-it.bin — delta ${header.delta} → ${PAIR_INDEX_DELTA}`)
|
|
74
|
+
} else if (header.transitionBeta !== PAIR_INDEX_TRANSITION_BETA) {
|
|
75
|
+
console.log(
|
|
76
|
+
`rebuilding pair-index-it.bin — transitionBeta ${header.transitionBeta} → ${PAIR_INDEX_TRANSITION_BETA}`
|
|
77
|
+
)
|
|
78
|
+
} else {
|
|
79
|
+
needsRebuild = false
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.log(`rebuilding pair-index-it.bin — header unreadable (${(error as Error).message})`)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!needsRebuild) {
|
|
87
|
+
console.log(`skipped pair-index-it.bin build — ${PAIR_INDEX_BIN_DEST} is current`)
|
|
88
|
+
} else {
|
|
89
|
+
const result = spawnSync(
|
|
90
|
+
process.execPath,
|
|
91
|
+
[
|
|
92
|
+
CLI,
|
|
93
|
+
"gazetteer",
|
|
94
|
+
"pair-index",
|
|
95
|
+
"--out",
|
|
96
|
+
PKG_DIR,
|
|
97
|
+
"--country",
|
|
98
|
+
"it",
|
|
99
|
+
"--delta",
|
|
100
|
+
String(PAIR_INDEX_DELTA),
|
|
101
|
+
"--transition-beta",
|
|
102
|
+
String(PAIR_INDEX_TRANSITION_BETA),
|
|
103
|
+
"--borough-db",
|
|
104
|
+
WOF_ADMIN_DB,
|
|
105
|
+
],
|
|
106
|
+
{ stdio: "inherit" }
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
if (result.status !== 0 || !existsSync(PAIR_INDEX_BIN_DEST)) {
|
|
110
|
+
console.error(`FAILED: gazetteer pair-index --country it (exit ${result.status})`)
|
|
111
|
+
|
|
112
|
+
process.exit(1)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
console.log(`built pair-index-it.bin ← ${WOF_ADMIN_DB}`)
|
|
116
|
+
}
|
|
117
|
+
}
|