@mailwoman/core 8.1.0 → 8.3.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/api/APIClient.ts +3 -4
- package/api/responses.ts +6 -3
- package/coarse-placer/coarse-placer.ts +26 -11
- package/coarse-placer/featurize.ts +25 -16
- package/coarse-placer/tools/build-dataset.ts +42 -18
- package/coarse-placer/tools/build-outlier-exposure.ts +51 -18
- package/coarse-placer/tools/build-outlier-latin.ts +48 -22
- package/coarse-placer/tools/build-outlier-oa.ts +52 -20
- package/coarse-placer/tools/eval-latin-offmap.ts +37 -12
- package/coarse-placer/tools/eval-openset.ts +104 -37
- package/coarse-placer/tools/eval-quant-compare.ts +41 -11
- package/coarse-placer/tools/eval.ts +51 -13
- package/coarse-placer/tools/fnv-hash.ts +5 -3
- package/coarse-placer/tools/probe-frontier.ts +63 -32
- package/coarse-placer/tools/quantize.ts +30 -8
- package/coarse-placer/tools/train.ts +63 -17
- package/collections.ts +2 -2
- package/decoder/build-tree.ts +16 -3
- package/decoder/calibration.ts +23 -7
- package/decoder/containment.ts +3 -1
- package/decoder/proposals-to-tree.ts +2 -0
- package/decoder/resolve-proposal-overlaps.ts +5 -1
- package/decoder/serialize-json.ts +8 -2
- package/decoder/serialize-tuples.ts +7 -2
- package/decoder/serialize-xml.ts +29 -11
- package/decoder/types.ts +34 -12
- package/decoder/unknown-spans.ts +14 -5
- package/decoder/validate-tree.ts +6 -1
- package/env/index.ts +1 -1
- package/env/load.ts +1 -1
- package/env/paths.ts +1 -1
- package/env/schema.ts +12 -4
- package/errors/schema.ts +1 -1
- package/fs/node.ts +9 -10
- package/identifiers.ts +3 -3
- package/kysley/adapter.ts +1 -1
- package/layers/manifest.ts +22 -8
- package/layers/schema.ts +59 -19
- package/locale/locale.ts +6 -2
- package/locale/profiles/en-us.ts +3 -0
- package/locale/profiles/fr-fr.ts +3 -0
- package/locale/profiles/ja-jp.ts +6 -0
- package/locale/registry.ts +3 -1
- package/logging/shared.ts +1 -0
- package/logging/utils.ts +1 -1
- package/objects.ts +7 -2
- package/out/api/APIClient.d.ts +1 -1
- package/out/api/APIClient.d.ts.map +1 -1
- package/out/api/APIClient.js +3 -2
- package/out/api/APIClient.js.map +1 -1
- package/out/api/responses.d.ts.map +1 -1
- package/out/api/responses.js +3 -3
- package/out/api/responses.js.map +1 -1
- package/out/coarse-placer/coarse-placer.d.ts +19 -9
- package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
- package/out/coarse-placer/coarse-placer.js +6 -4
- package/out/coarse-placer/coarse-placer.js.map +1 -1
- package/out/coarse-placer/featurize.d.ts.map +1 -1
- package/out/coarse-placer/featurize.js +20 -16
- package/out/coarse-placer/featurize.js.map +1 -1
- package/out/coarse-placer/tools/build-dataset.d.ts +15 -5
- package/out/coarse-placer/tools/build-dataset.d.ts.map +1 -1
- package/out/coarse-placer/tools/build-dataset.js +19 -14
- package/out/coarse-placer/tools/build-dataset.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-exposure.d.ts +21 -7
- package/out/coarse-placer/tools/build-outlier-exposure.d.ts.map +1 -1
- package/out/coarse-placer/tools/build-outlier-exposure.js +24 -12
- package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-latin.d.ts +18 -6
- package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
- package/out/coarse-placer/tools/build-outlier-latin.js +27 -17
- package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-oa.d.ts +18 -6
- package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
- package/out/coarse-placer/tools/build-outlier-oa.js +29 -15
- package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
- package/out/coarse-placer/tools/eval-latin-offmap.d.ts +18 -6
- package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval-latin-offmap.js +13 -7
- package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
- package/out/coarse-placer/tools/eval-openset.d.ts +24 -8
- package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval-openset.js +52 -31
- package/out/coarse-placer/tools/eval-openset.js.map +1 -1
- package/out/coarse-placer/tools/eval-quant-compare.d.ts +30 -10
- package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval-quant-compare.js +4 -2
- package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
- package/out/coarse-placer/tools/eval.d.ts +24 -8
- package/out/coarse-placer/tools/eval.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval.js +16 -6
- package/out/coarse-placer/tools/eval.js.map +1 -1
- package/out/coarse-placer/tools/fnv-hash.d.ts +3 -1
- package/out/coarse-placer/tools/fnv-hash.d.ts.map +1 -1
- package/out/coarse-placer/tools/fnv-hash.js +5 -3
- package/out/coarse-placer/tools/fnv-hash.js.map +1 -1
- package/out/coarse-placer/tools/probe-frontier.d.ts +18 -6
- package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
- package/out/coarse-placer/tools/probe-frontier.js +39 -23
- package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
- package/out/coarse-placer/tools/quantize.d.ts +15 -5
- package/out/coarse-placer/tools/quantize.d.ts.map +1 -1
- package/out/coarse-placer/tools/quantize.js +11 -4
- package/out/coarse-placer/tools/quantize.js.map +1 -1
- package/out/coarse-placer/tools/train.d.ts +24 -8
- package/out/coarse-placer/tools/train.d.ts.map +1 -1
- package/out/coarse-placer/tools/train.js +24 -10
- package/out/coarse-placer/tools/train.js.map +1 -1
- package/out/collections.js +2 -2
- package/out/collections.js.map +1 -1
- package/out/decoder/build-tree.d.ts.map +1 -1
- package/out/decoder/build-tree.js +9 -3
- package/out/decoder/build-tree.js.map +1 -1
- package/out/decoder/calibration.d.ts +17 -3
- package/out/decoder/calibration.d.ts.map +1 -1
- package/out/decoder/calibration.js +12 -4
- package/out/decoder/calibration.js.map +1 -1
- package/out/decoder/containment.d.ts +3 -1
- package/out/decoder/containment.d.ts.map +1 -1
- package/out/decoder/containment.js +3 -1
- package/out/decoder/containment.js.map +1 -1
- package/out/decoder/proposals-to-tree.d.ts.map +1 -1
- package/out/decoder/proposals-to-tree.js.map +1 -1
- package/out/decoder/resolve-proposal-overlaps.d.ts.map +1 -1
- package/out/decoder/resolve-proposal-overlaps.js +5 -1
- package/out/decoder/resolve-proposal-overlaps.js.map +1 -1
- package/out/decoder/serialize-json.d.ts +6 -2
- package/out/decoder/serialize-json.d.ts.map +1 -1
- package/out/decoder/serialize-json.js.map +1 -1
- package/out/decoder/serialize-tuples.d.ts +6 -2
- package/out/decoder/serialize-tuples.d.ts.map +1 -1
- package/out/decoder/serialize-tuples.js.map +1 -1
- package/out/decoder/serialize-xml.d.ts +21 -7
- package/out/decoder/serialize-xml.d.ts.map +1 -1
- package/out/decoder/serialize-xml.js +7 -5
- package/out/decoder/serialize-xml.js.map +1 -1
- package/out/decoder/types.d.ts +34 -12
- package/out/decoder/types.d.ts.map +1 -1
- package/out/decoder/types.js +1 -1
- package/out/decoder/types.js.map +1 -1
- package/out/decoder/unknown-spans.d.ts +9 -3
- package/out/decoder/unknown-spans.d.ts.map +1 -1
- package/out/decoder/unknown-spans.js +4 -2
- package/out/decoder/unknown-spans.js.map +1 -1
- package/out/decoder/validate-tree.d.ts +3 -1
- package/out/decoder/validate-tree.d.ts.map +1 -1
- package/out/decoder/validate-tree.js +3 -1
- package/out/decoder/validate-tree.js.map +1 -1
- package/out/env/index.js +0 -1
- package/out/env/index.js.map +1 -1
- package/out/env/load.js +1 -1
- package/out/env/load.js.map +1 -1
- package/out/env/paths.js +1 -1
- package/out/env/paths.js.map +1 -1
- package/out/env/schema.d.ts.map +1 -1
- package/out/env/schema.js +12 -4
- package/out/env/schema.js.map +1 -1
- package/out/errors/schema.js +1 -1
- package/out/errors/schema.js.map +1 -1
- package/out/fs/node.d.ts +1 -2
- package/out/fs/node.d.ts.map +1 -1
- package/out/fs/node.js +7 -8
- package/out/fs/node.js.map +1 -1
- package/out/identifiers.js +3 -3
- package/out/identifiers.js.map +1 -1
- package/out/kysley/adapter.d.ts +1 -1
- package/out/kysley/adapter.d.ts.map +1 -1
- package/out/kysley/adapter.js +1 -1
- package/out/kysley/adapter.js.map +1 -1
- package/out/layers/manifest.d.ts +18 -6
- package/out/layers/manifest.d.ts.map +1 -1
- package/out/layers/manifest.js +8 -4
- package/out/layers/manifest.js.map +1 -1
- package/out/layers/schema.d.ts +57 -19
- package/out/layers/schema.d.ts.map +1 -1
- package/out/layers/schema.js +24 -8
- package/out/layers/schema.js.map +1 -1
- package/out/locale/locale.d.ts +6 -2
- package/out/locale/locale.d.ts.map +1 -1
- package/out/locale/profiles/en-us.d.ts +3 -0
- package/out/locale/profiles/en-us.d.ts.map +1 -1
- package/out/locale/profiles/en-us.js +3 -0
- package/out/locale/profiles/en-us.js.map +1 -1
- package/out/locale/profiles/fr-fr.d.ts +3 -0
- package/out/locale/profiles/fr-fr.d.ts.map +1 -1
- package/out/locale/profiles/fr-fr.js +3 -0
- package/out/locale/profiles/fr-fr.js.map +1 -1
- package/out/locale/profiles/ja-jp.d.ts +3 -0
- package/out/locale/profiles/ja-jp.d.ts.map +1 -1
- package/out/locale/profiles/ja-jp.js +6 -0
- package/out/locale/profiles/ja-jp.js.map +1 -1
- package/out/locale/registry.d.ts +3 -1
- package/out/locale/registry.d.ts.map +1 -1
- package/out/locale/registry.js +3 -1
- package/out/locale/registry.js.map +1 -1
- package/out/logging/shared.d.ts.map +1 -1
- package/out/logging/shared.js +1 -0
- package/out/logging/shared.js.map +1 -1
- package/out/logging/utils.js +1 -1
- package/out/logging/utils.js.map +1 -1
- package/out/objects.d.ts.map +1 -1
- package/out/objects.js +2 -2
- package/out/objects.js.map +1 -1
- package/out/pipeline/index.d.ts +2 -2
- package/out/pipeline/index.d.ts.map +1 -1
- package/out/pipeline/index.js +1 -1
- package/out/pipeline/index.js.map +1 -1
- package/out/pipeline/reconcile-lookups.d.ts.map +1 -1
- package/out/pipeline/reconcile-lookups.js.map +1 -1
- package/out/pipeline/reconcile.d.ts +30 -10
- package/out/pipeline/reconcile.d.ts.map +1 -1
- package/out/pipeline/reconcile.js +12 -9
- package/out/pipeline/reconcile.js.map +1 -1
- package/out/pipeline/runtime-pipeline.d.ts +18 -0
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.js +73 -46
- package/out/pipeline/runtime-pipeline.js.map +1 -1
- package/out/pipeline/span-logit-aggregation.d.ts.map +1 -1
- package/out/pipeline/span-logit-aggregation.js +5 -2
- package/out/pipeline/span-logit-aggregation.js.map +1 -1
- package/out/pipeline/span-proposer.d.ts +19 -9
- package/out/pipeline/span-proposer.d.ts.map +1 -1
- package/out/pipeline/span-proposer.js +42 -22
- package/out/pipeline/span-proposer.js.map +1 -1
- package/out/pipeline/types.d.ts +77 -19
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js +16 -0
- package/out/pipeline/types.js.map +1 -1
- package/out/policy/proposal-collection.d.ts +1 -1
- package/out/policy/proposal-collection.d.ts.map +1 -1
- package/out/policy/proposal-collection.js +2 -3
- package/out/policy/proposal-collection.js.map +1 -1
- package/out/policy/registry.d.ts +9 -3
- package/out/policy/registry.d.ts.map +1 -1
- package/out/policy/registry.js +9 -3
- package/out/policy/registry.js.map +1 -1
- package/out/resolver/index.d.ts.map +1 -1
- package/out/resolver/types.d.ts +94 -30
- package/out/resolver/types.d.ts.map +1 -1
- package/out/resolver/types.js +7 -1
- package/out/resolver/types.js.map +1 -1
- package/out/resources/LocaleIndex.d.ts +1 -1
- package/out/resources/LocaleIndex.d.ts.map +1 -1
- package/out/resources/LocaleIndex.js +1 -2
- package/out/resources/LocaleIndex.js.map +1 -1
- package/out/resources/ResourceMapCache.d.ts.map +1 -1
- package/out/resources/ResourceMapCache.js +1 -1
- package/out/resources/ResourceMapCache.js.map +1 -1
- package/out/resources/collections.d.ts.map +1 -1
- package/out/resources/collections.js +3 -1
- package/out/resources/collections.js.map +1 -1
- package/out/resources/languages/index.d.ts +1 -1
- package/out/resources/languages/index.d.ts.map +1 -1
- package/out/resources/languages/index.js +1 -1
- package/out/resources/languages/index.js.map +1 -1
- package/out/resources/libpostal.d.ts +1 -1
- package/out/resources/libpostal.d.ts.map +1 -1
- package/out/resources/libpostal.js +7 -5
- package/out/resources/libpostal.js.map +1 -1
- package/out/resources/set.js +6 -6
- package/out/resources/set.js.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.d.ts +1 -4
- package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.js +1 -20
- package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.js +2 -2
- package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
- package/out/resources/whosonfirst/backoff.d.ts +19 -0
- package/out/resources/whosonfirst/backoff.d.ts.map +1 -0
- package/out/resources/whosonfirst/backoff.js +35 -0
- package/out/resources/whosonfirst/backoff.js.map +1 -0
- package/out/resources/whosonfirst/loader.d.ts +1 -1
- package/out/resources/whosonfirst/loader.d.ts.map +1 -1
- package/out/resources/whosonfirst/loader.js +0 -1
- package/out/resources/whosonfirst/loader.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.d.ts +4 -1
- package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.js +8 -6
- package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.d.ts +6 -4
- package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.js +8 -4
- package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/definition.d.ts +5 -6
- package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/definition.js +3 -0
- package/out/resources/whosonfirst/placetypes/definition.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/graph.d.ts +4 -2
- package/out/resources/whosonfirst/placetypes/graph.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/graph.js +0 -0
- package/out/resources/whosonfirst/placetypes/graph.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/mermaid.d.ts +4 -2
- package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/mermaid.js +0 -1
- package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/tree.d.ts +1 -1
- package/out/resources/whosonfirst/placetypes/tree.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/tree.js +0 -1
- package/out/resources/whosonfirst/placetypes/tree.js.map +1 -1
- package/out/routing/index.d.ts.map +1 -1
- package/out/routing/index.js +1 -1
- package/out/routing/index.js.map +1 -1
- package/out/scripting/utils/index.d.ts +3 -1
- package/out/scripting/utils/index.d.ts.map +1 -1
- package/out/scripting/utils/index.js +3 -1
- package/out/scripting/utils/index.js.map +1 -1
- package/out/tokenization/Span.js.map +1 -1
- package/out/tokenization/normalizer.js +11 -11
- package/out/tokenization/normalizer.js.map +1 -1
- package/out/tools/download-libpostal-resources.d.ts.map +1 -1
- package/out/tools/download-libpostal-resources.js.map +1 -1
- package/out/tools/download-ssl-address.d.ts +9 -3
- package/out/tools/download-ssl-address.d.ts.map +1 -1
- package/out/tools/download-ssl-address.js +8 -4
- package/out/tools/download-ssl-address.js.map +1 -1
- package/out/tools/generate-language-types.d.ts +12 -4
- package/out/tools/generate-language-types.d.ts.map +1 -1
- package/out/tools/generate-language-types.js +3 -1
- package/out/tools/generate-language-types.js.map +1 -1
- package/out/types/Classification.d.ts.map +1 -1
- package/out/types/Classification.js.map +1 -1
- package/out/types/classifier.d.ts +27 -9
- package/out/types/classifier.d.ts.map +1 -1
- package/out/types/component.d.ts +8 -4
- package/out/types/component.d.ts.map +1 -1
- package/out/types/component.js +3 -3
- package/out/types/component.js.map +1 -1
- package/out/utils/data-root.d.ts +3 -1
- package/out/utils/data-root.d.ts.map +1 -1
- package/out/utils/data-root.js +3 -1
- package/out/utils/data-root.js.map +1 -1
- package/out/utils/hash.d.ts +6 -2
- package/out/utils/hash.d.ts.map +1 -1
- package/out/utils/hash.js +6 -2
- package/out/utils/hash.js.map +1 -1
- package/out/utils/jsonl.d.ts +9 -3
- package/out/utils/jsonl.d.ts.map +1 -1
- package/out/utils/jsonl.js +9 -3
- package/out/utils/jsonl.js.map +1 -1
- package/out/utils/python-json.d.ts +6 -2
- package/out/utils/python-json.d.ts.map +1 -1
- package/out/utils/python-json.js +9 -3
- package/out/utils/python-json.js.map +1 -1
- package/out/utils/python-random.d.ts +15 -5
- package/out/utils/python-random.d.ts.map +1 -1
- package/out/utils/python-random.js +17 -7
- package/out/utils/python-random.js.map +1 -1
- package/out/utils/repo.d.ts +4 -0
- package/out/utils/repo.d.ts.map +1 -1
- package/out/utils/repo.js +4 -0
- package/out/utils/repo.js.map +1 -1
- package/out/utils/sealed-db.d.ts +6 -2
- package/out/utils/sealed-db.d.ts.map +1 -1
- package/out/utils/sealed-db.js +6 -2
- package/out/utils/sealed-db.js.map +1 -1
- package/out/utils/stats.d.ts +9 -3
- package/out/utils/stats.d.ts.map +1 -1
- package/out/utils/stats.js +11 -5
- package/out/utils/stats.js.map +1 -1
- package/package.json +2 -2
- package/pipeline/index.ts +5 -1
- package/pipeline/reconcile-lookups.ts +3 -0
- package/pipeline/reconcile.ts +65 -24
- package/pipeline/runtime-pipeline.ts +95 -46
- package/pipeline/span-logit-aggregation.ts +7 -2
- package/pipeline/span-proposer.ts +95 -34
- package/pipeline/types.ts +88 -19
- package/policy/proposal-collection.ts +4 -3
- package/policy/registry.ts +13 -3
- package/resolver/index.ts +1 -0
- package/resolver/types.ts +95 -30
- package/resources/LocaleIndex.ts +2 -2
- package/resources/ResourceMapCache.ts +3 -2
- package/resources/collections.ts +4 -1
- package/resources/languages/index.ts +2 -1
- package/resources/libpostal.ts +6 -3
- package/resources/set.ts +6 -6
- package/resources/whosonfirst/DataSourceCache.ts +2 -24
- package/resources/whosonfirst/PlacetypeDataSource.ts +2 -2
- package/resources/whosonfirst/backoff.ts +39 -0
- package/resources/whosonfirst/loader.ts +2 -1
- package/resources/whosonfirst/placetypes/Placetype.ts +9 -6
- package/resources/whosonfirst/placetypes/admin.ts +12 -7
- package/resources/whosonfirst/placetypes/definition.ts +6 -6
- package/resources/whosonfirst/placetypes/graph.ts +0 -0
- package/resources/whosonfirst/placetypes/mermaid.ts +5 -2
- package/resources/whosonfirst/placetypes/tree.ts +1 -1
- package/routing/index.ts +5 -1
- package/scripting/utils/index.ts +3 -1
- package/tokenization/Span.ts +1 -1
- package/tokenization/normalizer.ts +11 -11
- package/tools/download-libpostal-resources.ts +1 -0
- package/tools/download-ssl-address.ts +19 -7
- package/tools/generate-language-types.ts +12 -4
- package/types/Classification.ts +5 -0
- package/types/classifier.ts +27 -9
- package/types/component.ts +9 -5
- package/utils/data-root.ts +3 -1
- package/utils/hash.ts +6 -2
- package/utils/jsonl.ts +11 -3
- package/utils/python-json.ts +13 -4
- package/utils/python-random.ts +17 -7
- package/utils/repo.ts +8 -0
- package/utils/sealed-db.ts +10 -2
- package/utils/stats.ts +11 -5
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
Alpha2LanguageCode,
|
|
8
|
+
type Alpha2LanguageCode,
|
|
9
9
|
type Alpha3bLanguageCode,
|
|
10
10
|
Alpha3bToAlpha2,
|
|
11
11
|
isAlpha2LanguageCode,
|
|
@@ -36,13 +36,17 @@ export interface WOFBaseProperties {
|
|
|
36
36
|
"edtf:cessation"?: string
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Name kinds Who's On First records per language, in descending preference — a preferred name wins over a variant,
|
|
41
|
+
* which wins over a colloquial one.
|
|
42
|
+
*/
|
|
39
43
|
export const WOFNameKinds = ["preferred", "variant", "colloquial", "abbr", "short"] as const
|
|
44
|
+
|
|
40
45
|
export type WOFNameKind = (typeof WOFNameKinds)[number]
|
|
46
|
+
|
|
41
47
|
export type LanguageSpecificKey = `name:${Alpha3bLanguageCode}_x_${WOFNameKind}`
|
|
42
48
|
|
|
43
|
-
export type WOFLanguageProperties =
|
|
44
|
-
[key in LanguageSpecificKey]?: string | string[]
|
|
45
|
-
}
|
|
49
|
+
export type WOFLanguageProperties = Partial<Record<LanguageSpecificKey, string | string[]>>
|
|
46
50
|
|
|
47
51
|
export type WOFProperties = WOFBaseProperties & WOFLanguageProperties
|
|
48
52
|
|
|
@@ -132,6 +136,7 @@ export function pluckPlacetypeSpec({
|
|
|
132
136
|
|
|
133
137
|
const population =
|
|
134
138
|
typeof wofPopulation === "number" ? wofPopulation : typeof gnPopulation === "number" ? gnPopulation : undefined
|
|
139
|
+
|
|
135
140
|
const isCurrent = mzIsCurrent === undefined ? undefined : mzIsCurrent !== 0 && mzIsCurrent !== "0"
|
|
136
141
|
|
|
137
142
|
return {
|
|
@@ -145,12 +150,12 @@ export function pluckPlacetypeSpec({
|
|
|
145
150
|
latitude: typeof latitude === "number" ? latitude : undefined,
|
|
146
151
|
longitude: typeof longitude === "number" ? longitude : undefined,
|
|
147
152
|
population,
|
|
148
|
-
concordances: concordances && Object.keys(concordances).length
|
|
153
|
+
concordances: concordances && Object.keys(concordances).length ? concordances : undefined,
|
|
149
154
|
isCurrent,
|
|
150
155
|
isDeprecated: !!edtfDeprecated,
|
|
151
156
|
isCeased: !!edtfCessation,
|
|
152
|
-
isSuperseded: !!(superseded_by && superseded_by.length
|
|
153
|
-
isSuperseding: !!(supersedes && supersedes.length
|
|
157
|
+
isSuperseded: !!(superseded_by && superseded_by.length),
|
|
158
|
+
isSuperseding: !!(supersedes && supersedes.length),
|
|
154
159
|
lastmodified: typeof lastmodified === "number" ? lastmodified : undefined,
|
|
155
160
|
}
|
|
156
161
|
}
|
|
@@ -64,9 +64,7 @@ export type WhosOnFirstPlacetype =
|
|
|
64
64
|
| "venue"
|
|
65
65
|
| "wing"
|
|
66
66
|
|
|
67
|
-
export type PlacetypeLocalizationRecord =
|
|
68
|
-
[languageCode: string]: string | undefined
|
|
69
|
-
}
|
|
67
|
+
export type PlacetypeLocalizationRecord = Record<string, string | undefined>
|
|
70
68
|
|
|
71
69
|
export interface PlacetypeDefinition {
|
|
72
70
|
/**
|
|
@@ -99,7 +97,11 @@ export interface PlacetypeDefinition {
|
|
|
99
97
|
parent?: string[]
|
|
100
98
|
}
|
|
101
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Namespace prefix on Who's On First property keys (`wof:id`, `wof:placetype`).
|
|
102
|
+
*/
|
|
102
103
|
export const WOFPrefix = "wof:"
|
|
104
|
+
|
|
103
105
|
export type WOFPrefix = typeof WOFPrefix
|
|
104
106
|
|
|
105
107
|
/**
|
|
@@ -130,6 +132,4 @@ export function normalizePlacetypeDefinition(
|
|
|
130
132
|
/**
|
|
131
133
|
* A record of placetype definitions, keyed by Placetype id.
|
|
132
134
|
*/
|
|
133
|
-
export type PlacetypeDefinitionRecord =
|
|
134
|
-
[id: number]: Omit<PlacetypeDefinition, "id"> | undefined
|
|
135
|
-
}
|
|
135
|
+
export type PlacetypeDefinitionRecord = Record<number, Omit<PlacetypeDefinition, "id"> | undefined>
|
|
Binary file
|
|
@@ -8,7 +8,7 @@ import { rgb } from "d3-color"
|
|
|
8
8
|
import { interpolateViridis } from "d3-scale-chromatic"
|
|
9
9
|
|
|
10
10
|
import { type PlacetypeRole, PlacetypeRoles } from "./definition.ts"
|
|
11
|
-
import { Placetype } from "./Placetype.ts"
|
|
11
|
+
import type { Placetype } from "./Placetype.ts"
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Mermaid's `classDef` parser uses commas to separate style properties, so an `rgb(r, g, b)` value (which
|
|
@@ -52,7 +52,9 @@ const PlacetypeRoleText = {
|
|
|
52
52
|
export type InterpolateColorCallback = (t: number) => string
|
|
53
53
|
|
|
54
54
|
export interface GenerateMermaidMarkupOptions {
|
|
55
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Restrict descendants to the given roles. Default: all roles.
|
|
57
|
+
*/
|
|
56
58
|
roles?: Iterable<PlacetypeRole>
|
|
57
59
|
/**
|
|
58
60
|
* Edge color interpolator. Each edge is colored by its child node's depth from the root: `t = (childDepth - 1) /
|
|
@@ -154,6 +156,7 @@ export function generateMermaidMarkup(placetype: Placetype, options: GenerateMer
|
|
|
154
156
|
|
|
155
157
|
lines.push(` ${node.name} --> ${child.name}:::${child.role}`)
|
|
156
158
|
lines.push(` linkStyle ${edgeIdx} stroke:${edgeColor}`)
|
|
159
|
+
|
|
157
160
|
edgeIdx++
|
|
158
161
|
|
|
159
162
|
if (visited.has(child.name)) continue
|
package/routing/index.ts
CHANGED
|
@@ -61,6 +61,10 @@ export type ExtractURLPatternPathname<I extends URLPatternPathnameInit | string>
|
|
|
61
61
|
/**
|
|
62
62
|
* A record of path parameter names to their raw values.
|
|
63
63
|
*/
|
|
64
|
+
// The mapped form is not interchangeable with Record here. The key is a deferred generic, and only
|
|
65
|
+
// the mapped type keeps the extracted parameter names resolvable at each call site; Record collapses
|
|
66
|
+
// them and every `params.stateCode` access in tile-worker stops type-checking.
|
|
67
|
+
// oxlint-disable-next-line typescript/consistent-indexed-object-style -- deferred generic key
|
|
64
68
|
export type URLPatternPathParameters<I extends URLPatternPathnameInit | string, V extends string | number = string> = {
|
|
65
69
|
[key in ExtractURLPatternPathnameParams<I>]: V
|
|
66
70
|
}
|
|
@@ -79,7 +83,6 @@ const URLPatternComponents = [
|
|
|
79
83
|
/**
|
|
80
84
|
* A URL pattern with path parameters.
|
|
81
85
|
*/
|
|
82
|
-
// @ts-ignore: Property 'URLPattern' does not exist
|
|
83
86
|
export class URLRoutePattern<I extends URLPatternPathnameInit | string = string> extends URLPattern {
|
|
84
87
|
public override toString(): string {
|
|
85
88
|
return JSON.stringify(this.toJSON(), null, "\t")
|
|
@@ -156,6 +159,7 @@ export class URLRoutePattern<I extends URLPatternPathnameInit | string = string>
|
|
|
156
159
|
normalizedParamValue +
|
|
157
160
|
pathname.slice(paramPatternIndex + paramPattern.length)
|
|
158
161
|
|
|
162
|
+
// oxlint-disable-next-line typescript/no-dynamic-delete -- removing one key from a plain record; the object is not on a hot path
|
|
159
163
|
delete remainingParams[paramName]
|
|
160
164
|
}
|
|
161
165
|
|
package/scripting/utils/index.ts
CHANGED
|
@@ -96,7 +96,9 @@ export function childEnv(overrides: Record<string, string | undefined> = {}): No
|
|
|
96
96
|
return { ...process.env, ...overrides }
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* The path of the executing script (`argv[1]`) — for commands that re-spawn or reference their own CLI entry.
|
|
101
|
+
*/
|
|
100
102
|
export function scriptEntryPath(): string {
|
|
101
103
|
// oxlint-disable-next-line sister-software/no-process-globals
|
|
102
104
|
return process.argv[1]!
|
package/tokenization/Span.ts
CHANGED
|
@@ -11,15 +11,15 @@ import regenerate from "regenerate"
|
|
|
11
11
|
* normalization.
|
|
12
12
|
*/
|
|
13
13
|
const CombiningDiacriticalPattern = regenerate()
|
|
14
|
-
.add(
|
|
15
|
-
.addRange(
|
|
16
|
-
.addRange(
|
|
17
|
-
.addRange(
|
|
18
|
-
.addRange(
|
|
19
|
-
.addRange(
|
|
20
|
-
.addRange(
|
|
21
|
-
.add(
|
|
22
|
-
.add(
|
|
14
|
+
.add(0x20_0d) // ZERO WIDTH JOINER (U+200D)
|
|
15
|
+
.addRange(0x03_00, 0x03_6f) // Combining Diacritical Marks
|
|
16
|
+
.addRange(0x1a_b0, 0x1a_ff) // Combining Diacritical Marks Extended
|
|
17
|
+
.addRange(0x1d_c0, 0x1d_ff) // Combining Diacritical Marks Supplement
|
|
18
|
+
.addRange(0x20_d0, 0x20_ff) // Combining Diacritical Marks for Symbols
|
|
19
|
+
.addRange(0xfe_00, 0xfe_0f) // Variation Selectors
|
|
20
|
+
.addRange(0xfe_20, 0xfe_2f) // Combining Half Marks
|
|
21
|
+
.add(0x30_99) // Combining Dakuten
|
|
22
|
+
.add(0x30_9a) // Combining Handakuten
|
|
23
23
|
.toRegExp("g")
|
|
24
24
|
|
|
25
25
|
export interface TextNormalizerReplaceClause {
|
|
@@ -84,11 +84,11 @@ export class TextNormalizer implements TextNormalizerInit {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
if (this.removeHyphen) {
|
|
87
|
-
input = input.
|
|
87
|
+
input = input.replaceAll("-", " ")
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
if (this.removeSpaces) {
|
|
91
|
-
input = input.
|
|
91
|
+
input = input.replaceAll(" ", "")
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
return input
|
|
@@ -32,15 +32,23 @@ import { corePackagePath } from "@mailwoman/core/utils"
|
|
|
32
32
|
|
|
33
33
|
const BASE_URL = "https://chromium-i18n.appspot.com/ssl-address/data"
|
|
34
34
|
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Flag-shaped options for {@linkcode downloadSSLAddress}.
|
|
37
|
+
*/
|
|
36
38
|
export interface DownloadSSLAddressOptions {
|
|
37
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Destination directory. Default: the checked-in `core/data/chromium-i18n/ssl-address`.
|
|
41
|
+
*/
|
|
38
42
|
outDir?: string
|
|
39
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Parallel per-country fetches. Default 8.
|
|
45
|
+
*/
|
|
40
46
|
concurrency?: number
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Fetch the `~`-delimited country list and return it as an array of ISO codes.
|
|
51
|
+
*/
|
|
44
52
|
async function fetchCountryCodes(): Promise<string[]> {
|
|
45
53
|
const res = await fetch(BASE_URL, { signal: AbortSignal.timeout(60_000) })
|
|
46
54
|
|
|
@@ -50,7 +58,9 @@ async function fetchCountryCodes(): Promise<string[]> {
|
|
|
50
58
|
return (data.countries ?? "").split("~").filter(Boolean)
|
|
51
59
|
}
|
|
52
60
|
|
|
53
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Fetch a single country's metadata record and write its raw JSON body to `<outDir>/<cc>.json`.
|
|
63
|
+
*/
|
|
54
64
|
async function fetchCountry(cc: string, outDir: string): Promise<void> {
|
|
55
65
|
const res = await fetch(`${BASE_URL}/${cc}`, { signal: AbortSignal.timeout(60_000) })
|
|
56
66
|
|
|
@@ -75,6 +85,7 @@ export async function downloadSSLAddress(
|
|
|
75
85
|
|
|
76
86
|
let nextSlot = 0
|
|
77
87
|
let failures = 0
|
|
88
|
+
|
|
78
89
|
const workers = Array.from({ length: Math.min(concurrency, codes.length) }, async () => {
|
|
79
90
|
while (true) {
|
|
80
91
|
const slot = nextSlot++
|
|
@@ -85,12 +96,13 @@ export async function downloadSSLAddress(
|
|
|
85
96
|
try {
|
|
86
97
|
await fetchCountry(cc, outDir)
|
|
87
98
|
report?.(` ✓ ${cc}`)
|
|
88
|
-
} catch (
|
|
99
|
+
} catch (error) {
|
|
89
100
|
failures++
|
|
90
|
-
report?.(` ✗ ${cc}: ${(
|
|
101
|
+
report?.(` ✗ ${cc}: ${(error as Error).message}`)
|
|
91
102
|
}
|
|
92
103
|
}
|
|
93
104
|
})
|
|
105
|
+
|
|
94
106
|
await Promise.all(workers)
|
|
95
107
|
|
|
96
108
|
report?.(`=== done: ${codes.length - failures}/${codes.length} written, ${failures} failed`)
|
|
@@ -16,19 +16,27 @@ import { pascalCase } from "change-case"
|
|
|
16
16
|
|
|
17
17
|
import { repoRootPath, resourceDictionaryPath } from "../utils/index.ts"
|
|
18
18
|
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Options for {@linkcode generateLanguageTypes}.
|
|
21
|
+
*/
|
|
20
22
|
export interface GenerateLanguageTypesOptions {
|
|
21
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Output path override. Default: `core/resources/languages/types.gen.ts` (the committed types).
|
|
25
|
+
*/
|
|
22
26
|
out?: string
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Summary returned by {@linkcode generateLanguageTypes}.
|
|
31
|
+
*/
|
|
26
32
|
export interface GenerateLanguageTypesSummary {
|
|
27
33
|
languages: number
|
|
28
34
|
outPath: string
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Regenerate the committed language-code types from `internal/languages.csv`.
|
|
39
|
+
*/
|
|
32
40
|
export async function generateLanguageTypes(
|
|
33
41
|
options: GenerateLanguageTypesOptions = {},
|
|
34
42
|
report?: (line: string) => void
|
package/types/Classification.ts
CHANGED
|
@@ -88,7 +88,9 @@ export type VisibleClassification = typeof VisibleClassification extends Set<inf
|
|
|
88
88
|
export function isVisibleClassification(
|
|
89
89
|
match: ClassificationMatch
|
|
90
90
|
): match is ClassificationMatch & { classification: VisibleClassification }
|
|
91
|
+
|
|
91
92
|
export function isVisibleClassification(classification: Classification): classification is VisibleClassification
|
|
93
|
+
|
|
92
94
|
export function isVisibleClassification(input: Classification | ClassificationMatch): input is VisibleClassification {
|
|
93
95
|
const classification = typeof input === "string" ? input : input.classification
|
|
94
96
|
|
|
@@ -96,8 +98,11 @@ export function isVisibleClassification(input: Classification | ClassificationMa
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
export type ClassificationMap = Map<VisibleClassification, string[]>
|
|
101
|
+
|
|
99
102
|
export type ClassificationConfidenceMap = Map<VisibleClassification, number>
|
|
103
|
+
|
|
100
104
|
export type ClassificationConfidenceRecord = Record<VisibleClassification, number | undefined>
|
|
105
|
+
|
|
101
106
|
export type ClassificationRecord = Partial<Record<VisibleClassification, string[]>>
|
|
102
107
|
|
|
103
108
|
/**
|
package/types/classifier.ts
CHANGED
|
@@ -42,16 +42,24 @@ export type ClassificationProposalSource = "rule" | "neural" | "merged"
|
|
|
42
42
|
* downstream code can identify the origin of each proposal without consulting external state.
|
|
43
43
|
*/
|
|
44
44
|
export interface ClassificationProposal {
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Span this proposal applies to.
|
|
47
|
+
*/
|
|
46
48
|
span: Span
|
|
47
49
|
|
|
48
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Component type the classifier thinks this span is.
|
|
52
|
+
*/
|
|
49
53
|
component: ComponentTag
|
|
50
54
|
|
|
51
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Classifier confidence in [0, 1].
|
|
57
|
+
*/
|
|
52
58
|
confidence: number
|
|
53
59
|
|
|
54
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Provenance — which classifier family produced this proposal.
|
|
62
|
+
*/
|
|
55
63
|
source: ClassificationProposalSource
|
|
56
64
|
|
|
57
65
|
/**
|
|
@@ -78,13 +86,19 @@ export interface ClassificationProposal {
|
|
|
78
86
|
* Per-request context handed to a classifier.
|
|
79
87
|
*/
|
|
80
88
|
export interface ClassifierContext {
|
|
81
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Locale for this classification request, if known.
|
|
91
|
+
*/
|
|
82
92
|
locale?: string
|
|
83
93
|
|
|
84
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Proposals already produced for this request (for composites).
|
|
96
|
+
*/
|
|
85
97
|
prior?: readonly ClassificationProposal[]
|
|
86
98
|
|
|
87
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Cancellation signal.
|
|
101
|
+
*/
|
|
88
102
|
signal?: AbortSignal
|
|
89
103
|
}
|
|
90
104
|
|
|
@@ -95,7 +109,9 @@ export interface ClassifierContext {
|
|
|
95
109
|
* warming up an ONNX session) belongs in the optional `ready()` step.
|
|
96
110
|
*/
|
|
97
111
|
export interface ProposalClassifier {
|
|
98
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Stable identifier. Used as `source_id` on emitted proposals.
|
|
114
|
+
*/
|
|
99
115
|
readonly id: string
|
|
100
116
|
|
|
101
117
|
/**
|
|
@@ -111,7 +127,9 @@ export interface ProposalClassifier {
|
|
|
111
127
|
*/
|
|
112
128
|
readonly locales: readonly (string | "*")[]
|
|
113
129
|
|
|
114
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* Optional async pre-flight.
|
|
132
|
+
*/
|
|
115
133
|
ready?(): Promise<void>
|
|
116
134
|
|
|
117
135
|
/**
|
package/types/component.ts
CHANGED
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
* - Street-level (Phase 2): house_number, street, street_prefix*, street_suffix, intersection_a/b, unit
|
|
25
25
|
* - Venue-level (Phase 3): venue, attention, po_box
|
|
26
26
|
* - FR-specific: cedex
|
|
27
|
-
* - JP-specific (Phase
|
|
28
|
-
* building_number, building_name
|
|
27
|
+
* - JP-specific (ACTIVATED at CJK Phase 2, 2026-07-29 — the JP char model's 47-label head trains against them; the Latin
|
|
28
|
+
* model never emits them): prefecture, municipality, district, block, sub_block, building_number, building_name
|
|
29
29
|
*/
|
|
30
30
|
export const COMPONENT_TAGS = [
|
|
31
31
|
// Universal
|
|
@@ -50,7 +50,7 @@ export const COMPONENT_TAGS = [
|
|
|
50
50
|
"po_box",
|
|
51
51
|
// FR-specific
|
|
52
52
|
"cedex",
|
|
53
|
-
// JP-specific (Phase
|
|
53
|
+
// JP-specific (ACTIVATED at CJK Phase 2 — the stage3-jp label set; Latin models never emit these)
|
|
54
54
|
"prefecture",
|
|
55
55
|
"municipality",
|
|
56
56
|
"district",
|
|
@@ -60,7 +60,9 @@ export const COMPONENT_TAGS = [
|
|
|
60
60
|
"building_name",
|
|
61
61
|
] as const
|
|
62
62
|
|
|
63
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Union of every recognized address component tag.
|
|
65
|
+
*/
|
|
64
66
|
export type ComponentTag = (typeof COMPONENT_TAGS)[number]
|
|
65
67
|
|
|
66
68
|
/**
|
|
@@ -71,5 +73,7 @@ export type ComponentTag = (typeof COMPONENT_TAGS)[number]
|
|
|
71
73
|
*/
|
|
72
74
|
export const BIO_LABELS = ["O", ...COMPONENT_TAGS.flatMap((tag) => [`B-${tag}`, `I-${tag}`] as const)] as const
|
|
73
75
|
|
|
74
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Union of every BIO label.
|
|
78
|
+
*/
|
|
75
79
|
export type BIOLabel = (typeof BIO_LABELS)[number]
|
package/utils/data-root.ts
CHANGED
|
@@ -21,7 +21,9 @@ import { $public } from "../env/index.ts"
|
|
|
21
21
|
*/
|
|
22
22
|
const DEFAULT_MAILWOMAN_DATA_ROOT = "/mnt/playpen/mailwoman-data"
|
|
23
23
|
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The Mailwoman data root: `$MAILWOMAN_DATA_ROOT` when set, else the lab default.
|
|
26
|
+
*/
|
|
25
27
|
export function mailwomanDataRoot(): string {
|
|
26
28
|
return $public.MAILWOMAN_DATA_ROOT ?? DEFAULT_MAILWOMAN_DATA_ROOT
|
|
27
29
|
}
|
package/utils/hash.ts
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
import { createHash } from "node:crypto"
|
|
11
11
|
import { createReadStream } from "node:fs"
|
|
12
12
|
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Streaming SHA-256 of a file, hex-encoded.
|
|
15
|
+
*/
|
|
14
16
|
export async function sha256File(path: string): Promise<string> {
|
|
15
17
|
const hash = createHash("sha256")
|
|
16
18
|
|
|
@@ -21,7 +23,9 @@ export async function sha256File(path: string): Promise<string> {
|
|
|
21
23
|
return hash.digest("hex")
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* SHA-256 of in-memory content, hex-encoded.
|
|
28
|
+
*/
|
|
25
29
|
export function sha256Hex(data: string | NodeJS.ArrayBufferView): string {
|
|
26
30
|
return createHash("sha256").update(data).digest("hex")
|
|
27
31
|
}
|
package/utils/jsonl.ts
CHANGED
|
@@ -12,7 +12,9 @@ import { readFileSync, writeFileSync } from "node:fs"
|
|
|
12
12
|
|
|
13
13
|
import { TextSpliterator } from "spliterator"
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Read an entire JSONL file into memory. Blank and whitespace-only lines are skipped.
|
|
17
|
+
*/
|
|
16
18
|
export function readJSONL<T>(path: string): T[] {
|
|
17
19
|
return readFileSync(path, "utf8")
|
|
18
20
|
.split("\n")
|
|
@@ -20,21 +22,27 @@ export function readJSONL<T>(path: string): T[] {
|
|
|
20
22
|
.map((line) => JSON.parse(line) as T)
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Write rows as JSONL (one `JSON.stringify` per line, trailing newline). Returns the row count.
|
|
27
|
+
*/
|
|
24
28
|
export function writeJSONL(path: string, rows: Iterable<unknown>): number {
|
|
25
29
|
let count = 0
|
|
26
30
|
let out = ""
|
|
27
31
|
|
|
28
32
|
for (const row of rows) {
|
|
29
33
|
out += JSON.stringify(row) + "\n"
|
|
34
|
+
|
|
30
35
|
count++
|
|
31
36
|
}
|
|
37
|
+
|
|
32
38
|
writeFileSync(path, out, "utf8")
|
|
33
39
|
|
|
34
40
|
return count
|
|
35
41
|
}
|
|
36
42
|
|
|
37
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Stream a JSONL file row-by-row without loading it whole. Blank lines are skipped.
|
|
45
|
+
*/
|
|
38
46
|
export async function* iterateJSONL<T>(path: string): AsyncIterable<T> {
|
|
39
47
|
for await (const line of TextSpliterator.fromAsync(path)) {
|
|
40
48
|
if (!line.trim()) continue
|
package/utils/python-json.ts
CHANGED
|
@@ -26,11 +26,15 @@
|
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
export interface PyJSONOptions {
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Escape non-ASCII as `\uXXXX` (Python `ensure_ascii`). Defaults to `true`, matching Python.
|
|
31
|
+
*/
|
|
30
32
|
ensureAscii?: boolean
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Serialize one string the way Python's json does (then optionally `ensure_ascii`-escape it).
|
|
37
|
+
*/
|
|
34
38
|
function serializeString(value: string, ensureAscii: boolean): string {
|
|
35
39
|
// JSON.stringify handles the quote/backslash/control escaping identically to Python's json.
|
|
36
40
|
const out = JSON.stringify(value)
|
|
@@ -48,7 +52,9 @@ function serializeString(value: string, ensureAscii: boolean): string {
|
|
|
48
52
|
return escaped
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Serialize one finite/non-finite number the way Python's json does.
|
|
57
|
+
*/
|
|
52
58
|
function serializeNumber(value: number): string {
|
|
53
59
|
if (Number.isFinite(value)) return JSON.stringify(value)
|
|
54
60
|
|
|
@@ -82,10 +88,13 @@ function serialize(value: unknown, ensureAscii: boolean): string {
|
|
|
82
88
|
|
|
83
89
|
return "{" + parts.join(", ") + "}"
|
|
84
90
|
}
|
|
91
|
+
|
|
85
92
|
throw new TypeError(`pyJSONDumps: unsupported value of type ${t}`)
|
|
86
93
|
}
|
|
87
94
|
|
|
88
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* `json.dumps(value)` — single line, `(", ", ": ")` separators, `ensure_ascii` per options.
|
|
97
|
+
*/
|
|
89
98
|
export function pyJSONDumps(value: unknown, options: PyJSONOptions = {}): string {
|
|
90
99
|
return serialize(value, options.ensureAscii ?? true)
|
|
91
100
|
}
|
package/utils/python-random.ts
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* uniform `choice`, with-replacement `choices`.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Seeded `random.Random`-equivalent. Backed by mulberry32 (a 32-bit stateful generator).
|
|
20
|
+
*/
|
|
19
21
|
export class SeededRandom {
|
|
20
22
|
#state: number
|
|
21
23
|
|
|
@@ -24,26 +26,34 @@ export class SeededRandom {
|
|
|
24
26
|
this.#state = seed >>> 0 || 1
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Float in `[0, 1)`. Mirrors Python `random.random()`.
|
|
31
|
+
*/
|
|
28
32
|
random(): number {
|
|
29
|
-
let t = (this.#state +=
|
|
33
|
+
let t = (this.#state += 0x6d_2b_79_f5)
|
|
30
34
|
t = Math.imul(t ^ (t >>> 15), t | 1)
|
|
31
35
|
t ^= t + Math.imul(t ^ (t >>> 7), t | 61)
|
|
32
36
|
|
|
33
|
-
return ((t ^ (t >>> 14)) >>> 0) /
|
|
37
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4_294_967_296
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Integer in `[lo, hi]` inclusive. Mirrors Python `random.randint(lo, hi)`.
|
|
42
|
+
*/
|
|
37
43
|
randint(lo: number, hi: number): number {
|
|
38
44
|
return lo + Math.floor(this.random() * (hi - lo + 1))
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* One uniformly-chosen element. Mirrors Python `random.choice(seq)`.
|
|
49
|
+
*/
|
|
42
50
|
choice<T>(seq: readonly T[]): T {
|
|
43
51
|
return seq[Math.floor(this.random() * seq.length)]!
|
|
44
52
|
}
|
|
45
53
|
|
|
46
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* `k` elements chosen with replacement. Mirrors Python `random.choices(seq, k=k)`.
|
|
56
|
+
*/
|
|
47
57
|
choices<T>(seq: readonly T[], k: number): T[] {
|
|
48
58
|
const out: T[] = []
|
|
49
59
|
|
package/utils/repo.ts
CHANGED
|
@@ -19,12 +19,15 @@ import { createPathBuilderResolver, createPathResolver, type Join, type PathBuil
|
|
|
19
19
|
* Compiled directory name for TS output files.
|
|
20
20
|
*/
|
|
21
21
|
export const OutDirectoryName = "out"
|
|
22
|
+
|
|
22
23
|
export type OutDirectoryName = typeof OutDirectoryName
|
|
23
24
|
|
|
24
25
|
const RepoRootAlias = "mailwoman" as const
|
|
26
|
+
|
|
25
27
|
type RepoRootAlias = typeof RepoRootAlias
|
|
26
28
|
|
|
27
29
|
const PathReflection = ["core", "out", "utils"] as const
|
|
30
|
+
|
|
28
31
|
type PathReflection = typeof PathReflection
|
|
29
32
|
|
|
30
33
|
/**
|
|
@@ -47,6 +50,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url)) as Join<[RepoRootAlias
|
|
|
47
50
|
const __isCompiledTree = basename(resolve(__dirname, "..")) === OutDirectoryName
|
|
48
51
|
const __upCount = __isCompiledTree ? PathReflection.length : PathReflection.length - 1
|
|
49
52
|
const RepoRootAbsolutePath = resolve(__dirname, ...Array.from({ length: __upCount }, () => ".."))
|
|
53
|
+
|
|
50
54
|
type RepoRootAbsolutePath = RepoRootAlias
|
|
51
55
|
|
|
52
56
|
/**
|
|
@@ -70,6 +74,10 @@ export const repoRootPath = createPathResolver<RepoRootAlias>(RepoRootAbsolutePa
|
|
|
70
74
|
* the JS without any post-install copy step.
|
|
71
75
|
*/
|
|
72
76
|
const CorePackageAbsolutePath = resolve(__dirname, "..", __isCompiledTree ? ".." : "")
|
|
77
|
+
/**
|
|
78
|
+
* Path builder rooted at `@mailwoman/core`, so data under `core/data/` resolves the same in source and compiled trees.
|
|
79
|
+
* See the `__isCompiledTree` note in this file before reaching across that boundary.
|
|
80
|
+
*/
|
|
73
81
|
export const corePackagePathBuilder = createPathBuilderResolver<RepoRootAlias>(CorePackageAbsolutePath)
|
|
74
82
|
|
|
75
83
|
/**
|