@mailwoman/mtf 10.7.0 → 11.0.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 +37 -7
- package/crates/mtf-channels/tests/fixtures/README.md +13 -0
- package/crates/mtf-sampler/tests/fixtures/README.md +120 -0
- package/lib/code-units.ts +45 -0
- package/lib/index.ts +6 -2
- package/out/code-units.d.ts +24 -0
- package/out/code-units.d.ts.map +1 -0
- package/out/code-units.js +36 -0
- package/out/code-units.js.map +1 -0
- package/out/index.d.ts +4 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +6 -2
- package/out/index.js.map +1 -1
- package/out/tools/build-wasm.run.js +2 -2
- package/out/tools/build-wasm.run.js.map +1 -1
- package/out/tools/sampler/native.d.ts +314 -0
- package/out/tools/sampler/native.d.ts.map +1 -0
- package/out/tools/sampler/native.js +114 -0
- package/out/tools/sampler/native.js.map +1 -0
- package/out/tools/tokenizer/binary.d.ts +38 -0
- package/out/tools/tokenizer/binary.d.ts.map +1 -0
- package/out/tools/tokenizer/binary.js +94 -0
- package/out/tools/tokenizer/binary.js.map +1 -0
- package/out/tools/tokenizer/byte-fallback.d.ts +39 -0
- package/out/tools/tokenizer/byte-fallback.d.ts.map +1 -0
- package/out/tools/tokenizer/byte-fallback.js +49 -0
- package/out/tools/tokenizer/byte-fallback.js.map +1 -0
- package/out/tools/tokenizer/model.d.ts +70 -0
- package/out/tools/tokenizer/model.d.ts.map +1 -0
- package/out/tools/tokenizer/model.js +56 -0
- package/out/tools/tokenizer/model.js.map +1 -0
- package/out/tools/tokenizer/prune.d.ts +69 -0
- package/out/tools/tokenizer/prune.d.ts.map +1 -0
- package/out/tools/tokenizer/prune.js +126 -0
- package/out/tools/tokenizer/prune.js.map +1 -0
- package/out/tools/tokenizer/prune.run.d.ts +16 -0
- package/out/tools/tokenizer/prune.run.d.ts.map +1 -0
- package/out/tools/tokenizer/prune.run.js +34 -0
- package/out/tools/tokenizer/prune.run.js.map +1 -0
- package/out/tools/tokenizer/sentencepiece.d.ts +63 -0
- package/out/tools/tokenizer/sentencepiece.d.ts.map +1 -0
- package/out/tools/tokenizer/sentencepiece.js +90 -0
- package/out/tools/tokenizer/sentencepiece.js.map +1 -0
- package/out/tools/tokenizer/splice.d.ts +117 -0
- package/out/tools/tokenizer/splice.d.ts.map +1 -0
- package/out/tools/tokenizer/splice.js +398 -0
- package/out/tools/tokenizer/splice.js.map +1 -0
- package/out/tools/tokenizer/splice.run.d.ts +29 -0
- package/out/tools/tokenizer/splice.run.d.ts.map +1 -0
- package/out/tools/tokenizer/splice.run.js +114 -0
- package/out/tools/tokenizer/splice.run.js.map +1 -0
- package/out/tools/tokenizer/symbols.d.ts +42 -0
- package/out/tools/tokenizer/symbols.d.ts.map +1 -0
- package/out/tools/tokenizer/symbols.js +113 -0
- package/out/tools/tokenizer/symbols.js.map +1 -0
- package/out/tools/tokenizer/train/text.run.d.ts +16 -0
- package/out/tools/tokenizer/train/text.run.d.ts.map +1 -0
- package/out/tools/tokenizer/train/text.run.js +67 -0
- package/out/tools/tokenizer/train/text.run.js.map +1 -0
- package/out/tools/tokenizer/train.d.ts +113 -0
- package/out/tools/tokenizer/train.d.ts.map +1 -0
- package/out/tools/tokenizer/train.js +162 -0
- package/out/tools/tokenizer/train.js.map +1 -0
- package/out/tools/tokenizer/train.run.d.ts +24 -0
- package/out/tools/tokenizer/train.run.d.ts.map +1 -0
- package/out/tools/tokenizer/train.run.js +131 -0
- package/out/tools/tokenizer/train.run.js.map +1 -0
- package/out/tools/tokenizer/utilization.run.d.ts +17 -0
- package/out/tools/tokenizer/utilization.run.d.ts.map +1 -0
- package/out/tools/tokenizer/utilization.run.js +80 -0
- package/out/tools/tokenizer/utilization.run.js.map +1 -0
- package/out/tools/tokenizer/verify.d.ts +94 -0
- package/out/tools/tokenizer/verify.d.ts.map +1 -0
- package/out/tools/tokenizer/verify.js +193 -0
- package/out/tools/tokenizer/verify.js.map +1 -0
- package/out/tools/tokenizer/verify.run.d.ts +22 -0
- package/out/tools/tokenizer/verify.run.d.ts.map +1 -0
- package/out/tools/tokenizer/verify.run.js +71 -0
- package/out/tools/tokenizer/verify.run.js.map +1 -0
- package/package.json +15 -3
- package/tools/build-wasm.run.ts +2 -2
- package/tools/sampler/native.ts +433 -0
- package/tools/tokenizer/binary.ts +118 -0
- package/tools/tokenizer/byte-fallback.ts +80 -0
- package/tools/tokenizer/model.ts +110 -0
- package/tools/tokenizer/prune.run.ts +37 -0
- package/tools/tokenizer/prune.ts +195 -0
- package/tools/tokenizer/sentencepiece.ts +142 -0
- package/tools/tokenizer/splice.run.ts +141 -0
- package/tools/tokenizer/splice.ts +592 -0
- package/tools/tokenizer/symbols.ts +119 -0
- package/tools/tokenizer/train/text.run.ts +80 -0
- package/tools/tokenizer/train.run.ts +151 -0
- package/tools/tokenizer/train.ts +266 -0
- package/tools/tokenizer/utilization.run.ts +96 -0
- package/tools/tokenizer/verify.run.ts +77 -0
- package/tools/tokenizer/verify.ts +313 -0
package/README.md
CHANGED
|
@@ -11,10 +11,10 @@ rollback runtime.
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import {
|
|
14
|
+
import { MTFRuntime, mtfWASMURL } from "@mailwoman/mtf"
|
|
15
15
|
|
|
16
16
|
// Node reads the committed binary from disk. A browser fetches the URL its bundler resolved.
|
|
17
|
-
const runtime = await MTFRuntime.instantiate(new Uint8Array(await readFile(
|
|
17
|
+
const runtime = await MTFRuntime.instantiate(new Uint8Array(await readFile(mtfWASMURL())))
|
|
18
18
|
using model = runtime.loadModel(tokenizerModelBytes)
|
|
19
19
|
|
|
20
20
|
const { ids, pieces, begins, ends } = model.encode("10 Downing Street, London SW1A 2AA")
|
|
@@ -52,12 +52,16 @@ The work proceeds in two phases.
|
|
|
52
52
|
### Layout
|
|
53
53
|
|
|
54
54
|
```text
|
|
55
|
-
packages/mtf/
|
|
56
|
-
Cargo.toml Cargo workspace for the crates below
|
|
55
|
+
packages/mtf/ (the crates are members of the repository root's cargo workspace)
|
|
57
56
|
crates/mtf-core/ Model representation, normalization, unigram encode, decode, errors
|
|
58
57
|
crates/mtf-wasm/ Thin wasm-bindgen adapter around mtf-core
|
|
59
|
-
crates/mtf-
|
|
58
|
+
crates/mtf-channels/ The training-row encoder: label projection, channel painters, packing
|
|
59
|
+
crates/mtf-sampler/ The training-row sampler: corpus listing, source mixture, augmentation, relabel, char path
|
|
60
|
+
crates/mtf-node/ The Node addon over mtf-sampler and mtf-channels, for the TypeScript audits and tools
|
|
61
|
+
crates/mtf-tools/ The `mtf-tokenizer` binary behind tools/tokenizer: model edits, corpus sampling, ONNX surgery
|
|
60
62
|
lib/ TypeScript loader and result conversion
|
|
63
|
+
tools/tokenizer/ Tokenizer training, splicing, pruning and checks
|
|
64
|
+
tools/sampler/ The loader for the mtf-node addon, built from source on first use
|
|
61
65
|
wasm/ Committed WASM binary and its build metadata
|
|
62
66
|
test/fixtures/ Reference outputs from the deployed runtime
|
|
63
67
|
```
|
|
@@ -87,7 +91,7 @@ toolchain. A repository check will rebuild it and compare hashes.
|
|
|
87
91
|
- **Model loading.** The loader validates lengths, counts and versions before allocating, and bounds input
|
|
88
92
|
length and token count.
|
|
89
93
|
- **Downstream consumers.** `packages/neural/lib/tokenizer.ts` converts byte offsets to UTF-16 ranges and
|
|
90
|
-
trims leading whitespace.
|
|
94
|
+
trims leading whitespace. The deleted Python tokenizer converted them to Python
|
|
91
95
|
character positions for label projection. A change to `▁` or to word boundaries changes both.
|
|
92
96
|
|
|
93
97
|
## Stage 1 baseline
|
|
@@ -178,6 +182,32 @@ Run the parity test from this directory with
|
|
|
178
182
|
`MTF_REFERENCE_MODEL=<path to the shipped tokenizer.model> cargo test --release`. Without the variable it
|
|
179
183
|
reads `../neural-weights-en-us/tokenizer.model` and fails if that file is absent.
|
|
180
184
|
|
|
185
|
+
## Tokenizer tools
|
|
186
|
+
|
|
187
|
+
`tools/tokenizer/` trains, splices, prunes and checks tokenizers. Each entry point is a `.run.ts` file, run from the
|
|
188
|
+
repository root with `node`:
|
|
189
|
+
|
|
190
|
+
| Tool | What it does |
|
|
191
|
+
| ------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
192
|
+
| `train.run.ts` | Samples a corpus's train split per country, trains with `spm_train`, writes the model card |
|
|
193
|
+
| `train-text.run.ts` | Trains the 16,000-piece first-generation recipe on a text file |
|
|
194
|
+
| `splice.run.ts build-tokenizer` | Appends a locale model's diacritic pieces to a frozen tokenizer and checks code point overlap |
|
|
195
|
+
| `splice.run.ts onnx-mean-init` | Grows an exported model's embedding table, and its int8 twin's, onto a spliced tokenizer |
|
|
196
|
+
| `utilization.run.ts` | Counts each piece's use over a corpus's train split |
|
|
197
|
+
| `prune.run.ts` | Drops unused pieces from a tokenizer and the matching rows from the int8 model |
|
|
198
|
+
| `verify.run.ts prune` | Checks a pruned tokenizer and model for segmentation identity and bit-equal logits |
|
|
199
|
+
| `verify.run.ts byte-fallback` | Reports a tokenizer's byte-fallback rate on a fixture, overall and per script |
|
|
200
|
+
|
|
201
|
+
Training runs native `spm_train`, built from google/sentencepiece `v0.2.2` under the cache root on first use. It
|
|
202
|
+
reproduces the Python wheel's model byte for byte: the CLI records every trainer default it set, and the tool drops
|
|
203
|
+
the spec fields the training call did not name. That is the form the wheel writes. `tools/tokenizer/sentencepiece.integration.test.ts`
|
|
204
|
+
checks five recorded wheel trainings against `test/fixtures/spm-recipes/`.
|
|
205
|
+
|
|
206
|
+
The proto edits, parquet reads, CPython-compatible sampling, the byte-fallback count and the ONNX initializer
|
|
207
|
+
rewrite run in `mtf-tokenizer`, which Cargo builds under the `tools` profile on first use. It is a binary rather
|
|
208
|
+
than a Node addon: each tool calls it a few times over files, and a binary needs no addon toolchain or
|
|
209
|
+
per-platform artifact.
|
|
210
|
+
|
|
181
211
|
## License
|
|
182
212
|
|
|
183
213
|
`@mailwoman/mtf` is licensed AGPL-3.0-only, with a commercial license available, like the rest of
|
|
@@ -189,4 +219,4 @@ copyright notice in its header and states how it was modified. `third-party/` ho
|
|
|
189
219
|
unchanged, and `THIRD_PARTY_NOTICES.md` maps each ported file to its upstream source. A later port from
|
|
190
220
|
either project follows the same three steps: keep the upstream notice in the file header, state the
|
|
191
221
|
modification, and add the file to `THIRD_PARTY_NOTICES.md`. Code written here without an upstream
|
|
192
|
-
source
|
|
222
|
+
source has only the AGPL header.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# mtf-channels test fixtures
|
|
2
|
+
|
|
3
|
+
Both files are records of the training encoder this crate replaced (#2870). They were written from
|
|
4
|
+
that implementation before its deletion, so they are not regenerated. Each file states the source revision
|
|
5
|
+
it was recorded at.
|
|
6
|
+
|
|
7
|
+
- `encode-row-reference.json` holds one row encoded by the Python `encode_row` with every soft-feed
|
|
8
|
+
channel on, under both label sources, with the shaped anchor and with no channels. It also holds every
|
|
9
|
+
input the encoder read: pieces, lexicons, the anchor table and the label table.
|
|
10
|
+
- `text-reference.json` holds the postcode-shape matches, code units with acceptance counts, and
|
|
11
|
+
`str.lower`, `str.upper` and `str.strip` results for a list of adversarial texts. For each of 17
|
|
12
|
+
templates, it groups every Unicode scalar value by the answer that value gives when placed in the
|
|
13
|
+
template.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# mtf-sampler fixtures
|
|
2
|
+
|
|
3
|
+
`cpython-random.json` records CPython 3.12.3's `random.Random` outputs for the methods the training sampler and the
|
|
4
|
+
corpus builders call. `tests/pyrandom_cpython.rs` replays every case through `PyRandom` and requires equal values.
|
|
5
|
+
|
|
6
|
+
The file covers eight seeds: the integers `0`, `42`, `2**31 - 1`, `2**40 + 7` and `-5`, and the strings
|
|
7
|
+
`"20260601:corpus"`, `"42-postcode"` and `""`. For each seed, it records 50 consecutive calls of `random`,
|
|
8
|
+
`getrandbits` at 1, 32 and 33 bits, `randrange(7)`, `randrange(10, 2**33)`, `randint(1, 6)` and `choice` over 1,000
|
|
9
|
+
items, and 40 calls of `getrandbits(100)`. It also records `choices` uniform, with `weights` and with `cum_weights`,
|
|
10
|
+
`sample` on both of CPython's paths (a pool for a small population, a selected set for a large one), ten shuffles of
|
|
11
|
+
50 items, and a 140-step sequence that interleaves seven methods on one generator.
|
|
12
|
+
|
|
13
|
+
A population argument is stored as its size `n`, and its items are `list(range(n))`. An integer of 2**63 or more is
|
|
14
|
+
stored as a decimal string.
|
|
15
|
+
|
|
16
|
+
## Regeneration
|
|
17
|
+
|
|
18
|
+
The file was written on 2026-10-29 by a generator run under CPython 3.12.3. The generator is archived in this README
|
|
19
|
+
as text, so the repository tracks no Python file for it. To regenerate, save the block below as `cpython_random_fixture.py` outside the
|
|
20
|
+
repository and run `python3.12 -I cpython_random_fixture.py packages/mtf/crates/mtf-sampler/tests/fixtures/cpython-random.json`.
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import json, platform, random, sys
|
|
24
|
+
|
|
25
|
+
SEEDS = [0, 42, 2**31 - 1, 2**40 + 7, -5, "20260601:corpus", "42-postcode", ""]
|
|
26
|
+
N = 50
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def case(seed, method, args, calls):
|
|
30
|
+
rng = random.Random(seed)
|
|
31
|
+
out = []
|
|
32
|
+
for _ in range(calls):
|
|
33
|
+
if method == "choices":
|
|
34
|
+
n, weights, cum_weights, k = args
|
|
35
|
+
out.append(rng.choices(list(range(n)), weights=weights, cum_weights=cum_weights, k=k))
|
|
36
|
+
elif method in ("choice", "sample"):
|
|
37
|
+
out.append(getattr(rng, method)(list(range(args[0])), *args[1:]))
|
|
38
|
+
else:
|
|
39
|
+
value = getattr(rng, method)(*args)
|
|
40
|
+
out.append(str(value) if isinstance(value, int) and value >= 2**63 else value)
|
|
41
|
+
return {"seed": seed, "method": method, "args": args, "outputs": out}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def shuffled(seed, n, rounds):
|
|
45
|
+
rng = random.Random(seed)
|
|
46
|
+
out = []
|
|
47
|
+
for _ in range(rounds):
|
|
48
|
+
items = list(range(n))
|
|
49
|
+
rng.shuffle(items)
|
|
50
|
+
out.append(items)
|
|
51
|
+
return {"seed": seed, "method": "shuffle", "args": [n], "outputs": out}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def mixed(seed):
|
|
55
|
+
rng = random.Random(seed)
|
|
56
|
+
weights = [0.5, 1, 2, 0, 3.25, 1, 1, 0.1, 7]
|
|
57
|
+
trace = []
|
|
58
|
+
for i in range(140):
|
|
59
|
+
kind = i % 7
|
|
60
|
+
if kind == 0:
|
|
61
|
+
trace.append(["random", [], rng.random()])
|
|
62
|
+
elif kind == 1:
|
|
63
|
+
trace.append(["randrange", [3, 1000], rng.randrange(3, 1000)])
|
|
64
|
+
elif kind == 2:
|
|
65
|
+
trace.append(["choices", [list(range(9)), weights, 4], rng.choices(list(range(9)), weights=weights, k=4)])
|
|
66
|
+
elif kind == 3:
|
|
67
|
+
items = list(range(17))
|
|
68
|
+
rng.shuffle(items)
|
|
69
|
+
trace.append(["shuffle", [17], items])
|
|
70
|
+
elif kind == 4:
|
|
71
|
+
trace.append(["sample", [40, 6], rng.sample(range(40), 6)])
|
|
72
|
+
elif kind == 5:
|
|
73
|
+
trace.append(["randint", [-3, 3], rng.randint(-3, 3)])
|
|
74
|
+
else:
|
|
75
|
+
trace.append(["choice", [11], rng.choice(range(11))])
|
|
76
|
+
return {"seed": seed, "method": "mixed", "args": [], "outputs": trace}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
cases = []
|
|
80
|
+
for seed in SEEDS:
|
|
81
|
+
cases.append(case(seed, "random", [], N))
|
|
82
|
+
cases.append(case(seed, "getrandbits", [1], N))
|
|
83
|
+
cases.append(case(seed, "getrandbits", [32], N))
|
|
84
|
+
cases.append(case(seed, "getrandbits", [33], N))
|
|
85
|
+
cases.append(case(seed, "getrandbits", [100], 40))
|
|
86
|
+
cases.append(case(seed, "randrange", [7], N))
|
|
87
|
+
cases.append(case(seed, "randrange", [10, 2**33], N))
|
|
88
|
+
cases.append(case(seed, "randint", [1, 6], N))
|
|
89
|
+
cases.append(case(seed, "choice", [1000], N))
|
|
90
|
+
cases.append(case(seed, "choices", [50, None, None, 25], 8))
|
|
91
|
+
cases.append(case(seed, "choices", [5, [1, 0, 2.5, 0.001, 9], None, 25], 8))
|
|
92
|
+
cases.append(case(seed, "choices", [4, None, [1, 3, 3, 10], 25], 8))
|
|
93
|
+
cases.append(case(seed, "sample", [30, 10], 20))
|
|
94
|
+
cases.append(case(seed, "sample", [10000, 50], 10))
|
|
95
|
+
cases.append(case(seed, "sample", [500, 5], 20))
|
|
96
|
+
cases.append(shuffled(seed, 50, 10))
|
|
97
|
+
cases.append(mixed(seed))
|
|
98
|
+
|
|
99
|
+
doc = {
|
|
100
|
+
"generator": "cpython_random_fixture.py (archived in the fixture README)",
|
|
101
|
+
"python": sys.version.split()[0],
|
|
102
|
+
"implementation": platform.python_implementation(),
|
|
103
|
+
"cases": cases,
|
|
104
|
+
}
|
|
105
|
+
with open(sys.argv[1], "w", encoding="utf-8") as out:
|
|
106
|
+
json.dump(doc, out, separators=(",", ":"))
|
|
107
|
+
out.write("\n")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## The loader-split reference
|
|
111
|
+
|
|
112
|
+
`loader-split-reference.json` records what the Python loader drew from the corpus `build_reference_corpus` in
|
|
113
|
+
`tests/common/mod.rs` writes: two sources, three countries with unequal country and source weights, several row groups
|
|
114
|
+
per file, a mixed-source validation file, and every augmentation before the postcode move on. `rows` is one pass of
|
|
115
|
+
the train stream with seed 11 and a shuffle buffer of 6, as `source|country|raw`; `val_rows` is the same over the
|
|
116
|
+
validation split; `encoded` is one pass of the char path in word mode with the default shuffle buffer, as each row's
|
|
117
|
+
labels, attention and first three units of char ids; `source_row_counts` is the rows per source. The Python loader
|
|
118
|
+
wrote it before the Rust sampler replaced it, and `tests/loader_split_reference.rs` requires the Rust sampler to
|
|
119
|
+
reproduce every value in order. It is a record of the Python sampler's output and is not regenerated from the Rust
|
|
120
|
+
sampler.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file Code units: each digit run or alphanumeric code in an address, segmented as one unit (#2845).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { TextSpan } from "@mailwoman/query-shape/types"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* One code unit and its half-open UTF-16 offsets into the text.
|
|
12
|
+
*/
|
|
13
|
+
export type CodeUnit = TextSpan
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A run of ASCII letters and digits holding at least one digit, with a hyphen
|
|
17
|
+
* allowed between two digits (`12345-6789`, `100-0005`).
|
|
18
|
+
*
|
|
19
|
+
* The run must not touch another ASCII letter or digit on either side, so `B2B` and `SW1A` are whole units.
|
|
20
|
+
* A Han or Kana character next to a run is a boundary, because Japanese and Chinese
|
|
21
|
+
* addresses write a block number straight after its place name (`丸の内1-9-1`).
|
|
22
|
+
*/
|
|
23
|
+
const CODE_UNIT = /(?<![A-Za-z0-9])(?=[A-Za-z0-9-]*\d)[A-Za-z0-9]+(?:-(?=\d)[A-Za-z0-9]+)*(?![A-Za-z0-9])/gu
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Every code unit in `text`, left to right.
|
|
27
|
+
*
|
|
28
|
+
* A word-piece vocabulary makes a postcode one piece only by memorizing that code.
|
|
29
|
+
* A code unit keeps the whole code together and describes it by its shape instead.
|
|
30
|
+
*/
|
|
31
|
+
export function segmentCodeUnits(text: string): CodeUnit[] {
|
|
32
|
+
return [...text.matchAll(CODE_UNIT)].map((match) => ({
|
|
33
|
+
text: match[0],
|
|
34
|
+
start: match.index,
|
|
35
|
+
end: match.index + match[0].length,
|
|
36
|
+
}))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The unit's character pattern: `9` per digit, `A` per letter, other characters
|
|
41
|
+
* kept (`SW1A` → `AA9A`, `12345-6789` → `99999-9999`).
|
|
42
|
+
*/
|
|
43
|
+
export function codeUnitPattern(unit: string): string {
|
|
44
|
+
return unit.replaceAll(/\d/g, "9").replaceAll(/[A-Za-z]/g, "A")
|
|
45
|
+
}
|
package/lib/index.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* The module's import has no side effects: the WASM fetch and instantiation happen in the caller.
|
|
9
9
|
* The caller obtains the WASM bytes or a compiled `WebAssembly.Module` (Workers supply the latter)
|
|
10
10
|
* and passes it to {@linkcode MTFRuntime.instantiate}.
|
|
11
|
-
*
|
|
11
|
+
* {@linkcode mtfWASMURL} locates the committed binary beside this package.
|
|
12
12
|
* A loaded model's encode and decode methods are synchronous.
|
|
13
13
|
*/
|
|
14
14
|
|
|
@@ -16,8 +16,12 @@
|
|
|
16
16
|
* The location of the committed `wasm/mtf.wasm`, resolved from this module.
|
|
17
17
|
*
|
|
18
18
|
* The same relative path holds from `lib/` in the repository and from `out/` in a tarball.
|
|
19
|
+
* It is computed on call rather than at import, because a Cloudflare Worker bundle has no
|
|
20
|
+
* `import.meta.url` to resolve against, and a Worker supplies the compiled module instead.
|
|
19
21
|
*/
|
|
20
|
-
export
|
|
22
|
+
export function mtfWASMURL(): URL {
|
|
23
|
+
return new URL("../wasm/mtf.wasm", import.meta.url)
|
|
24
|
+
}
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
27
|
* A compiled `WebAssembly.Module`, as a Worker runtime supplies it.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file Code units: each digit run or alphanumeric code in an address, segmented as one unit (#2845).
|
|
6
|
+
*/
|
|
7
|
+
import type { TextSpan } from "@mailwoman/query-shape/types";
|
|
8
|
+
/**
|
|
9
|
+
* One code unit and its half-open UTF-16 offsets into the text.
|
|
10
|
+
*/
|
|
11
|
+
export type CodeUnit = TextSpan;
|
|
12
|
+
/**
|
|
13
|
+
* Every code unit in `text`, left to right.
|
|
14
|
+
*
|
|
15
|
+
* A word-piece vocabulary makes a postcode one piece only by memorizing that code.
|
|
16
|
+
* A code unit keeps the whole code together and describes it by its shape instead.
|
|
17
|
+
*/
|
|
18
|
+
export declare function segmentCodeUnits(text: string): CodeUnit[];
|
|
19
|
+
/**
|
|
20
|
+
* The unit's character pattern: `9` per digit, `A` per letter, other characters
|
|
21
|
+
* kept (`SW1A` → `AA9A`, `12345-6789` → `99999-9999`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function codeUnitPattern(unit: string): string;
|
|
24
|
+
//# sourceMappingURL=code-units.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-units.d.ts","sourceRoot":"","sources":["../lib/code-units.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAE5D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAA;AAY/B;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAMzD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file Code units: each digit run or alphanumeric code in an address, segmented as one unit (#2845).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A run of ASCII letters and digits holding at least one digit, with a hyphen
|
|
9
|
+
* allowed between two digits (`12345-6789`, `100-0005`).
|
|
10
|
+
*
|
|
11
|
+
* The run must not touch another ASCII letter or digit on either side, so `B2B` and `SW1A` are whole units.
|
|
12
|
+
* A Han or Kana character next to a run is a boundary, because Japanese and Chinese
|
|
13
|
+
* addresses write a block number straight after its place name (`丸の内1-9-1`).
|
|
14
|
+
*/
|
|
15
|
+
const CODE_UNIT = /(?<![A-Za-z0-9])(?=[A-Za-z0-9-]*\d)[A-Za-z0-9]+(?:-(?=\d)[A-Za-z0-9]+)*(?![A-Za-z0-9])/gu;
|
|
16
|
+
/**
|
|
17
|
+
* Every code unit in `text`, left to right.
|
|
18
|
+
*
|
|
19
|
+
* A word-piece vocabulary makes a postcode one piece only by memorizing that code.
|
|
20
|
+
* A code unit keeps the whole code together and describes it by its shape instead.
|
|
21
|
+
*/
|
|
22
|
+
export function segmentCodeUnits(text) {
|
|
23
|
+
return [...text.matchAll(CODE_UNIT)].map((match) => ({
|
|
24
|
+
text: match[0],
|
|
25
|
+
start: match.index,
|
|
26
|
+
end: match.index + match[0].length,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The unit's character pattern: `9` per digit, `A` per letter, other characters
|
|
31
|
+
* kept (`SW1A` → `AA9A`, `12345-6789` → `99999-9999`).
|
|
32
|
+
*/
|
|
33
|
+
export function codeUnitPattern(unit) {
|
|
34
|
+
return unit.replaceAll(/\d/g, "9").replaceAll(/[A-Za-z]/g, "A");
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=code-units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-units.js","sourceRoot":"","sources":["../lib/code-units.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;;;;;;GAOG;AACH,MAAM,SAAS,GAAG,0FAA0F,CAAA;AAE5G;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QACd,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;KAClC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;AAChE,CAAC"}
|
package/out/index.d.ts
CHANGED
|
@@ -8,15 +8,17 @@
|
|
|
8
8
|
* The module's import has no side effects: the WASM fetch and instantiation happen in the caller.
|
|
9
9
|
* The caller obtains the WASM bytes or a compiled `WebAssembly.Module` (Workers supply the latter)
|
|
10
10
|
* and passes it to {@linkcode MTFRuntime.instantiate}.
|
|
11
|
-
*
|
|
11
|
+
* {@linkcode mtfWASMURL} locates the committed binary beside this package.
|
|
12
12
|
* A loaded model's encode and decode methods are synchronous.
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
15
|
* The location of the committed `wasm/mtf.wasm`, resolved from this module.
|
|
16
16
|
*
|
|
17
17
|
* The same relative path holds from `lib/` in the repository and from `out/` in a tarball.
|
|
18
|
+
* It is computed on call rather than at import, because a Cloudflare Worker bundle has no
|
|
19
|
+
* `import.meta.url` to resolve against, and a Worker supplies the compiled module instead.
|
|
18
20
|
*/
|
|
19
|
-
export declare
|
|
21
|
+
export declare function mtfWASMURL(): URL;
|
|
20
22
|
/**
|
|
21
23
|
* A compiled `WebAssembly.Module`, as a Worker runtime supplies it.
|
|
22
24
|
*
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"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AAE,MAAM,GAAG,MAAM,CAAA;IACrC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;CACrC;AAUD;;;;GAIG;AACH,qBAAa,UAAU;;IAGtB,OAAO,eAEN;IAED;;OAEG;IACH,OAAa,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAOnE;IAED;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAMrC;IAED;;;;OAIG;IACH,SAAS,IAAI,MAAM,CAIlB;IAED;;;;OAIG;IACH,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAExE;CAgBD;AAED;;;;GAIG;AACH,qBAAa,QAAS,YAAW,UAAU;;IAK1C;;OAEG;IACH,YAAY,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAInE;IAQD;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAqBpC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAmBrC;IAED;;;OAGG;IACH,OAAO,IAAI,IAAI,CAKd;IAED,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAEvB;CACD"}
|
package/out/index.js
CHANGED
|
@@ -8,15 +8,19 @@
|
|
|
8
8
|
* The module's import has no side effects: the WASM fetch and instantiation happen in the caller.
|
|
9
9
|
* The caller obtains the WASM bytes or a compiled `WebAssembly.Module` (Workers supply the latter)
|
|
10
10
|
* and passes it to {@linkcode MTFRuntime.instantiate}.
|
|
11
|
-
*
|
|
11
|
+
* {@linkcode mtfWASMURL} locates the committed binary beside this package.
|
|
12
12
|
* A loaded model's encode and decode methods are synchronous.
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
15
|
* The location of the committed `wasm/mtf.wasm`, resolved from this module.
|
|
16
16
|
*
|
|
17
17
|
* The same relative path holds from `lib/` in the repository and from `out/` in a tarball.
|
|
18
|
+
* It is computed on call rather than at import, because a Cloudflare Worker bundle has no
|
|
19
|
+
* `import.meta.url` to resolve against, and a Worker supplies the compiled module instead.
|
|
18
20
|
*/
|
|
19
|
-
export
|
|
21
|
+
export function mtfWASMURL() {
|
|
22
|
+
return new URL("../wasm/mtf.wasm", import.meta.url);
|
|
23
|
+
}
|
|
20
24
|
/**
|
|
21
25
|
* Words per piece in the encode output buffer: id, begin, end, piece offset, piece length.
|
|
22
26
|
*/
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU;IACzB,OAAO,IAAI,GAAG,CAAC,kBAAkB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AACpD,CAAC;AAmED;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,CAAA;AAErB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AACjC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AAEzD;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACb,QAAQ,CAAY;IAE7B,YAAoB,OAAmB;QACtC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;IACxB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAqB;QAC7C,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AAM,CAAC,CAAC,CAAA;IACpF,CAAC;IAED;;;OAGG;IACH,OAAO;QACN,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC;YAAE,OAAM;QAE9B,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC1C,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;IACjB,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAA;IACf,CAAC;CACD"}
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
import { statPath } from "@mailwoman/core/fs/readers/stat";
|
|
14
14
|
import { replaceFileAtomically } from "@mailwoman/core/fs/writers";
|
|
15
15
|
import { sha256File } from "@mailwoman/core/hash";
|
|
16
|
-
import { workspacePath } from "@mailwoman/core/paths";
|
|
16
|
+
import { repoRootPath, workspacePath } from "@mailwoman/core/paths";
|
|
17
17
|
import { runFile } from "@mailwoman/core/process";
|
|
18
18
|
import { parseArguments } from "@mailwoman/core/scripting/arguments";
|
|
19
19
|
const { values } = parseArguments({ options: { check: { type: "boolean", default: false } } });
|
|
20
20
|
const workspace = workspacePath("mtf");
|
|
21
|
-
const built =
|
|
21
|
+
const built = repoRootPath("target", "wasm32-unknown-unknown", "release", "mtf_wasm.wasm");
|
|
22
22
|
const committed = workspacePath("mtf", "wasm", "mtf.wasm");
|
|
23
23
|
await runFile("cargo", ["build", "--release", "--locked", "--target", "wasm32-unknown-unknown", "-p", "mtf-wasm"], {
|
|
24
24
|
cwd: workspace,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-wasm.run.js","sourceRoot":"","sources":["../../tools/build-wasm.run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,UAAU,EA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