@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
package/decoder/build-tree.ts
CHANGED
|
@@ -106,6 +106,7 @@ function flush(open: OpenSpan | null, raw: string, out: AddressNode[], attributi
|
|
|
106
106
|
if (attribution.sourceID !== undefined) {
|
|
107
107
|
node.sourceID = attribution.sourceID
|
|
108
108
|
}
|
|
109
|
+
|
|
109
110
|
out.push(node)
|
|
110
111
|
|
|
111
112
|
return null
|
|
@@ -127,6 +128,7 @@ function emitSpans(raw: string, tokens: DecoderToken[], attribution: BuildTreeOp
|
|
|
127
128
|
// non-whitespace `O` (comma, slash, …) is a genuine separator and still flushes.
|
|
128
129
|
if (open !== null && /^\s*$/.test(raw.slice(tok.start, tok.end))) continue
|
|
129
130
|
open = flush(open, raw, out, attribution)
|
|
131
|
+
|
|
130
132
|
continue
|
|
131
133
|
}
|
|
132
134
|
|
|
@@ -143,10 +145,13 @@ function emitSpans(raw: string, tokens: DecoderToken[], attribution: BuildTreeOp
|
|
|
143
145
|
if (prefix === "B" && open !== null && open.tag === tag && /^\s*$/.test(raw.slice(open.end, tok.start))) {
|
|
144
146
|
open.end = tok.end
|
|
145
147
|
open.confidences.push(tok.confidence)
|
|
148
|
+
|
|
146
149
|
continue
|
|
147
150
|
}
|
|
148
|
-
|
|
151
|
+
|
|
152
|
+
flush(open, raw, out, attribution)
|
|
149
153
|
open = { tag: tag!, start: tok.start, end: tok.end, confidences: [tok.confidence] }
|
|
154
|
+
|
|
150
155
|
continue
|
|
151
156
|
}
|
|
152
157
|
|
|
@@ -178,9 +183,17 @@ function findParent(
|
|
|
178
183
|
for (const parentTag of candidates) {
|
|
179
184
|
const matches = all.filter((s) => s !== span && s.tag === parentTag)
|
|
180
185
|
|
|
181
|
-
if (matches.length
|
|
186
|
+
if (!matches.length) continue
|
|
187
|
+
|
|
188
|
+
let closest = matches[0]!
|
|
189
|
+
|
|
190
|
+
for (const candidate of matches) {
|
|
191
|
+
if (distance(candidate, span) < distance(closest, span)) {
|
|
192
|
+
closest = candidate
|
|
193
|
+
}
|
|
194
|
+
}
|
|
182
195
|
|
|
183
|
-
return
|
|
196
|
+
return closest
|
|
184
197
|
}
|
|
185
198
|
|
|
186
199
|
return null
|
package/decoder/calibration.ts
CHANGED
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
* applies in `flush()`.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* One row of the lookup table: a confidence bin and the calibrated value at its center.
|
|
28
|
+
*/
|
|
27
29
|
export interface CalibrationBin {
|
|
28
30
|
lo: number
|
|
29
31
|
hi: number
|
|
@@ -31,7 +33,9 @@ export interface CalibrationBin {
|
|
|
31
33
|
calibrated: number
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* The full calibration artifact emitted by `fit-isotonic-calibration.py`.
|
|
38
|
+
*/
|
|
35
39
|
export interface CalibrationTable {
|
|
36
40
|
model: string
|
|
37
41
|
model_version: string
|
|
@@ -41,7 +45,9 @@ export interface CalibrationTable {
|
|
|
41
45
|
[key: string]: unknown
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Maps a raw span confidence in [0, 1] to its calibrated probability of correctness.
|
|
50
|
+
*/
|
|
45
51
|
export type Calibrator = (rawConfidence: number) => number
|
|
46
52
|
|
|
47
53
|
/**
|
|
@@ -52,17 +58,19 @@ export type Calibrator = (rawConfidence: number) => number
|
|
|
52
58
|
export function createCalibrator(table: CalibrationTable | CalibrationBin[]): Calibrator {
|
|
53
59
|
const bins = Array.isArray(table) ? table : table.table
|
|
54
60
|
|
|
55
|
-
if (!bins || bins.length
|
|
61
|
+
if (!bins || !bins.length) {
|
|
56
62
|
throw new Error("createCalibrator: empty calibration table")
|
|
57
63
|
}
|
|
64
|
+
|
|
58
65
|
// Sort by center and extract parallel arrays for interpolation.
|
|
66
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
|
|
59
67
|
const sorted = [...bins].sort((a, b) => a.center - b.center)
|
|
60
68
|
const centers = sorted.map((b) => b.center)
|
|
61
|
-
const cals = sorted.map((b) =>
|
|
69
|
+
const cals = sorted.map((b) => clampConfidence(b.calibrated))
|
|
62
70
|
const n = centers.length
|
|
63
71
|
|
|
64
72
|
return (raw: number): number => {
|
|
65
|
-
const x =
|
|
73
|
+
const x = clampConfidence(raw)
|
|
66
74
|
|
|
67
75
|
if (x <= centers[0]!) return cals[0]!
|
|
68
76
|
|
|
@@ -80,6 +88,7 @@ export function createCalibrator(table: CalibrationTable | CalibrationBin[]): Ca
|
|
|
80
88
|
hi = mid
|
|
81
89
|
}
|
|
82
90
|
}
|
|
91
|
+
|
|
83
92
|
const x0 = centers[lo]!
|
|
84
93
|
const x1 = centers[hi]!
|
|
85
94
|
const y0 = cals[lo]!
|
|
@@ -90,7 +99,14 @@ export function createCalibrator(table: CalibrationTable | CalibrationBin[]): Ca
|
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
|
|
93
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Clamp a confidence into `[0, 1]`, mapping NaN to 0.
|
|
104
|
+
*
|
|
105
|
+
* Distinct from `clampFraction` (`@mailwoman/spatial`), which lets NaN through on purpose: a confidence that cannot be
|
|
106
|
+
* computed is no confidence, while an interpolation fraction that cannot be computed must stay detectable rather than
|
|
107
|
+
* silently snapping to a segment's start.
|
|
108
|
+
*/
|
|
109
|
+
export function clampConfidence(v: number): number {
|
|
94
110
|
if (Number.isNaN(v)) return 0
|
|
95
111
|
|
|
96
112
|
if (v < 0) return 0
|
package/decoder/containment.ts
CHANGED
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
import type { ComponentTag } from "../types/component.ts"
|
|
32
32
|
import type { AddressSystem } from "./types.ts"
|
|
33
33
|
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Preferred-parent ordering for each tag. Empty / missing = always root.
|
|
36
|
+
*/
|
|
35
37
|
export const WESTERN_PARENT_OF: Partial<Record<ComponentTag, ComponentTag[]>> = {
|
|
36
38
|
// Universal coarse — containment follows geographic granularity.
|
|
37
39
|
region: ["country"],
|
|
@@ -29,6 +29,7 @@ export function proposalsToTree(raw: string, proposals: readonly ClassificationP
|
|
|
29
29
|
source: p.source,
|
|
30
30
|
sourceID: p.source_id,
|
|
31
31
|
}))
|
|
32
|
+
|
|
32
33
|
roots.sort((a, b) => a.start - b.start)
|
|
33
34
|
|
|
34
35
|
return { raw, roots }
|
|
@@ -60,6 +61,7 @@ export function treeToProposals(
|
|
|
60
61
|
const visit = (node: AddressNode): void => {
|
|
61
62
|
if (!emits || emits.has(node.tag)) {
|
|
62
63
|
const span = { start: node.start, end: node.end, body: node.value } as unknown as Span
|
|
64
|
+
|
|
63
65
|
proposals.push({
|
|
64
66
|
span,
|
|
65
67
|
component: node.tag,
|
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
|
|
41
41
|
import type { ClassificationProposal } from "../types/index.ts"
|
|
42
42
|
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Half-open interval overlap: `[aStart,aEnd)` and `[bStart,bEnd)` share at least one position.
|
|
45
|
+
*/
|
|
44
46
|
function spansOverlap(a: ClassificationProposal["span"], b: ClassificationProposal["span"]): boolean {
|
|
45
47
|
return a.start < b.end && b.start < a.end
|
|
46
48
|
}
|
|
@@ -56,6 +58,7 @@ function spansOverlap(a: ClassificationProposal["span"], b: ClassificationPropos
|
|
|
56
58
|
export function resolveProposalOverlaps(proposals: readonly ClassificationProposal[]): ClassificationProposal[] {
|
|
57
59
|
if (proposals.length <= 1) return [...proposals]
|
|
58
60
|
|
|
61
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
|
|
59
62
|
const ranked = [...proposals].sort((a, b) => {
|
|
60
63
|
if (b.confidence !== a.confidence) return b.confidence - a.confidence // higher confidence first
|
|
61
64
|
const lenA = a.span.end - a.span.start
|
|
@@ -75,5 +78,6 @@ export function resolveProposalOverlaps(proposals: readonly ClassificationPropos
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
|
|
81
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
|
|
78
82
|
return kept.sort((a, b) => a.span.start - b.span.start)
|
|
79
83
|
}
|
|
@@ -17,7 +17,9 @@ import type { ComponentTag } from "../types/component.ts"
|
|
|
17
17
|
import type { AddressNode, AddressTree } from "./types.ts"
|
|
18
18
|
import { type UnknownSpan, unknownSpans } from "./unknown-spans.ts"
|
|
19
19
|
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Options for {@link decodeAsJSON}.
|
|
22
|
+
*/
|
|
21
23
|
export interface SerializeJSONOpts {
|
|
22
24
|
/**
|
|
23
25
|
* Add an `unknown` array of the all-O spans the model left unclassified (#493). Default false — keeps the output
|
|
@@ -44,12 +46,16 @@ function visit(node: AddressNode, out: Partial<Record<ComponentTag, string>>): v
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Project an `AddressTree` to a flat libpostal-style component map.
|
|
51
|
+
*/
|
|
48
52
|
export function decodeAsJSON(tree: AddressTree): Partial<Record<ComponentTag, string>>
|
|
53
|
+
|
|
49
54
|
export function decodeAsJSON(
|
|
50
55
|
tree: AddressTree,
|
|
51
56
|
opts: SerializeJSONOpts
|
|
52
57
|
): Partial<Record<ComponentTag, string>> & { unknown?: UnknownSpan[] }
|
|
58
|
+
|
|
53
59
|
export function decodeAsJSON(
|
|
54
60
|
tree: AddressTree,
|
|
55
61
|
opts: SerializeJSONOpts = {}
|
|
@@ -14,7 +14,9 @@ import type { ComponentTag } from "../types/component.ts"
|
|
|
14
14
|
import type { AddressNode, AddressTree } from "./types.ts"
|
|
15
15
|
import { unknownSpans } from "./unknown-spans.ts"
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Options for {@link decodeAsTuples}.
|
|
19
|
+
*/
|
|
18
20
|
export interface SerializeTuplesOpts {
|
|
19
21
|
/**
|
|
20
22
|
* Interleave `["unknown", value]` tuples for the all-O spans the model left unclassified (#493), in source order.
|
|
@@ -31,9 +33,12 @@ function flatten(node: AddressNode, out: AddressNode[]): void {
|
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Project an `AddressTree` to a source-ordered list of (tag, value) pairs.
|
|
38
|
+
*/
|
|
35
39
|
export function decodeAsTuples(tree: AddressTree): Array<[ComponentTag, string]>
|
|
36
40
|
export function decodeAsTuples(tree: AddressTree, opts: SerializeTuplesOpts): Array<[ComponentTag | "unknown", string]>
|
|
41
|
+
|
|
37
42
|
export function decodeAsTuples(
|
|
38
43
|
tree: AddressTree,
|
|
39
44
|
opts: SerializeTuplesOpts = {}
|
package/decoder/serialize-xml.ts
CHANGED
|
@@ -34,17 +34,29 @@ import type { AddressNode, AddressTree } from "./types.ts"
|
|
|
34
34
|
import { unknownSpans } from "./unknown-spans.ts"
|
|
35
35
|
|
|
36
36
|
export interface SerializeXMLOpts {
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Pretty-print with line breaks and indentation. Default true.
|
|
39
|
+
*/
|
|
38
40
|
pretty?: boolean
|
|
39
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Include `conf` attribute on every component. Default true.
|
|
43
|
+
*/
|
|
40
44
|
includeConf?: boolean
|
|
41
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Include `start` + `end` char-offset attributes. Default true.
|
|
47
|
+
*/
|
|
42
48
|
includeOffsets?: boolean
|
|
43
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Include `src` provenance attribute when the node carries source info. Default true.
|
|
51
|
+
*/
|
|
44
52
|
includeSrc?: boolean
|
|
45
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Include `lat` + `lon` resolver-supplied centroid attrs when set on the node. Default true.
|
|
55
|
+
*/
|
|
46
56
|
includeGeo?: boolean
|
|
47
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Include `place` resolver-supplied normalized place URI when set. Default true.
|
|
59
|
+
*/
|
|
48
60
|
includePlace?: boolean
|
|
49
61
|
/**
|
|
50
62
|
* Include `<alternative>` child elements for each runner-up resolver candidate on the node. When set +
|
|
@@ -63,7 +75,7 @@ export interface SerializeXMLOpts {
|
|
|
63
75
|
}
|
|
64
76
|
|
|
65
77
|
function escapeXml(s: string): string {
|
|
66
|
-
return s.
|
|
78
|
+
return s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """)
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
function srcAttrValue(node: AddressNode): string | null {
|
|
@@ -113,12 +125,12 @@ function attrs(node: AddressNode, opts: Required<SerializeXMLOpts>): string {
|
|
|
113
125
|
|
|
114
126
|
// Multi-role node (#413): a city-state span tagged `region` that also plays `locality` lists every
|
|
115
127
|
// role it holds, primary first — `roles="region locality"`. Emitted only when extra roles exist.
|
|
116
|
-
if (node.interpretations && node.interpretations.length
|
|
128
|
+
if (node.interpretations && node.interpretations.length) {
|
|
117
129
|
const roles = [node.tag, ...node.interpretations.map((i) => i.tag)]
|
|
118
130
|
parts.push(`roles="${escapeXml(roles.join(" "))}"`)
|
|
119
131
|
}
|
|
120
132
|
|
|
121
|
-
return parts.length
|
|
133
|
+
return !parts.length ? "" : " " + parts.join(" ")
|
|
122
134
|
}
|
|
123
135
|
|
|
124
136
|
interface AlternativeLike {
|
|
@@ -131,10 +143,12 @@ interface AlternativeLike {
|
|
|
131
143
|
}
|
|
132
144
|
|
|
133
145
|
function serializeAlternatives(node: AddressNode, indent: string): string {
|
|
134
|
-
if (!node.alternatives || node.alternatives.length
|
|
146
|
+
if (!node.alternatives || !node.alternatives.length) return ""
|
|
147
|
+
|
|
135
148
|
const lines = node.alternatives.map((raw) => {
|
|
136
149
|
const alt = raw as AlternativeLike
|
|
137
150
|
const place = `wof:${alt.id}`
|
|
151
|
+
|
|
138
152
|
const parts = [
|
|
139
153
|
`place="${escapeXml(place)}"`,
|
|
140
154
|
`name="${escapeXml(alt.name)}"`,
|
|
@@ -170,7 +184,9 @@ function serializeNode(node: AddressNode, indent: string, opts: Required<Seriali
|
|
|
170
184
|
return `${indent}<${node.tag}${a}>${text}${nl}${inner}${nl}${indent}</${node.tag}>`
|
|
171
185
|
}
|
|
172
186
|
|
|
173
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* Project an `AddressTree` to nested XML with optional confidence/offset attributes.
|
|
189
|
+
*/
|
|
174
190
|
export function decodeAsXML(tree: AddressTree, opts: SerializeXMLOpts = {}): string {
|
|
175
191
|
const full: Required<SerializeXMLOpts> = {
|
|
176
192
|
pretty: opts.pretty ?? true,
|
|
@@ -182,6 +198,7 @@ export function decodeAsXML(tree: AddressTree, opts: SerializeXMLOpts = {}): str
|
|
|
182
198
|
includeAlternatives: opts.includeAlternatives ?? false,
|
|
183
199
|
includeUnknown: opts.includeUnknown ?? false,
|
|
184
200
|
}
|
|
201
|
+
|
|
185
202
|
const rawAttr = escapeXml(tree.raw)
|
|
186
203
|
const nl = full.pretty ? "\n" : ""
|
|
187
204
|
const indent = full.pretty ? "\t" : ""
|
|
@@ -200,6 +217,7 @@ export function decodeAsXML(tree: AddressTree, opts: SerializeXMLOpts = {}): str
|
|
|
200
217
|
xml: `${indent}<unknown start="${u.start}" end="${u.end}">${escapeXml(u.value)}</unknown>`,
|
|
201
218
|
})
|
|
202
219
|
}
|
|
220
|
+
|
|
203
221
|
entries.sort((a, b) => a.start - b.start)
|
|
204
222
|
}
|
|
205
223
|
|
package/decoder/types.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
import type { BIOLabel, ComponentTag } from "../types/component.ts"
|
|
30
30
|
|
|
31
|
-
export type
|
|
31
|
+
export { type BIOLabel, type ComponentTag } from "../types/component.ts"
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* A single token emitted by the model, paired with its predicted label and confidence.
|
|
@@ -37,15 +37,25 @@ export type { BIOLabel, ComponentTag }
|
|
|
37
37
|
* (SentencePiece's `encode` returns offsets); they are NOT recomputed by the decoder.
|
|
38
38
|
*/
|
|
39
39
|
export interface DecoderToken {
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* The token piece as the tokenizer emitted it (with any leading-space sentinel preserved).
|
|
42
|
+
*/
|
|
41
43
|
piece: string
|
|
42
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Inclusive start char offset in the original raw text.
|
|
46
|
+
*/
|
|
43
47
|
start: number
|
|
44
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Exclusive end char offset in the original raw text.
|
|
50
|
+
*/
|
|
45
51
|
end: number
|
|
46
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* The argmax BIO label for this token.
|
|
54
|
+
*/
|
|
47
55
|
label: BIOLabel
|
|
48
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Softmax confidence for the chosen label, in [0, 1].
|
|
58
|
+
*/
|
|
49
59
|
confidence: number
|
|
50
60
|
}
|
|
51
61
|
|
|
@@ -74,9 +84,13 @@ export interface AddressNode {
|
|
|
74
84
|
* `"neural-v0.3.1-en-us"`, or a resolver-supplied place id like `"wof-admin:101751119"`.
|
|
75
85
|
*/
|
|
76
86
|
sourceID?: string
|
|
77
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Resolver-supplied centroid latitude (Phase 4.3). Optional — only set when a resolver wins.
|
|
89
|
+
*/
|
|
78
90
|
lat?: number
|
|
79
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Resolver-supplied centroid longitude (Phase 4.3). Optional — only set when a resolver wins.
|
|
93
|
+
*/
|
|
80
94
|
lon?: number
|
|
81
95
|
/**
|
|
82
96
|
* Resolver-supplied normalized place URI (Phase 4.3) — `"wof:101751119"` for a WOF place. Distinct from `sourceID`
|
|
@@ -112,13 +126,19 @@ export interface AddressNode {
|
|
|
112
126
|
interpretations?: ReadonlyArray<Interpretation>
|
|
113
127
|
}
|
|
114
128
|
|
|
115
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* One additional role a span plays (#413) — see {@link AddressNode.interpretations}.
|
|
131
|
+
*/
|
|
116
132
|
export interface Interpretation {
|
|
117
133
|
tag: ComponentTag
|
|
118
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Resolver-supplied normalized place URI for this role (e.g. `wof:101909779`).
|
|
136
|
+
*/
|
|
119
137
|
placeID?: string
|
|
120
138
|
sourceID?: string
|
|
121
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Centroid for this role's place (a capital-seat comune differs from its province).
|
|
141
|
+
*/
|
|
122
142
|
lat?: number
|
|
123
143
|
lon?: number
|
|
124
144
|
confidence?: number
|
|
@@ -132,7 +152,9 @@ export interface Interpretation {
|
|
|
132
152
|
* labeled output become roots themselves (e.g. a bare "house_number" with no labeled street parent).
|
|
133
153
|
*/
|
|
134
154
|
export interface AddressTree {
|
|
135
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* The original raw input text — preserved for round-trip and XML root @raw attribute.
|
|
157
|
+
*/
|
|
136
158
|
raw: string
|
|
137
159
|
roots: AddressNode[]
|
|
138
160
|
/**
|
package/decoder/unknown-spans.ts
CHANGED
|
@@ -17,13 +17,19 @@ import type { AddressNode, AddressTree } from "./types.ts"
|
|
|
17
17
|
export interface UnknownSpan {
|
|
18
18
|
kind: "unknown"
|
|
19
19
|
value: string
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Inclusive start char offset into `tree.raw`.
|
|
22
|
+
*/
|
|
21
23
|
start: number
|
|
22
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Exclusive end char offset into `tree.raw`.
|
|
26
|
+
*/
|
|
23
27
|
end: number
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* One tile of the lossless decomposition: a run that some node covers, or an `unknown` gap.
|
|
32
|
+
*/
|
|
27
33
|
export interface LosslessSegment {
|
|
28
34
|
kind: "covered" | "unknown"
|
|
29
35
|
value: string
|
|
@@ -31,13 +37,15 @@ export interface LosslessSegment {
|
|
|
31
37
|
end: number
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Mark every char index `tree.raw` that any node's `[start,end)` covers (nesting overlaps merge naturally).
|
|
42
|
+
*/
|
|
35
43
|
function coveredMask(tree: AddressTree): Uint8Array {
|
|
36
44
|
const len = tree.raw.length
|
|
37
45
|
const covered = new Uint8Array(len)
|
|
38
46
|
const stack: AddressNode[] = [...tree.roots]
|
|
39
47
|
|
|
40
|
-
while (stack.length
|
|
48
|
+
while (stack.length) {
|
|
41
49
|
const n = stack.pop()!
|
|
42
50
|
const lo = Math.max(0, n.start)
|
|
43
51
|
const hi = Math.min(len, n.end)
|
|
@@ -73,6 +81,7 @@ export function losslessSegments(tree: AddressTree): LosslessSegment[] {
|
|
|
73
81
|
while (j < len && !!covered[j] === !!covered[i]) {
|
|
74
82
|
j++
|
|
75
83
|
}
|
|
84
|
+
|
|
76
85
|
out.push({ kind, value: tree.raw.slice(i, j), start: i, end: j })
|
|
77
86
|
i = j
|
|
78
87
|
}
|
package/decoder/validate-tree.ts
CHANGED
|
@@ -56,17 +56,21 @@ export interface TreeValidity {
|
|
|
56
56
|
violations: TreeViolation[]
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Validate an `AddressTree`'s structural coherence. See module docstring.
|
|
61
|
+
*/
|
|
60
62
|
export function validateTree(tree: AddressTree): TreeValidity {
|
|
61
63
|
const violations: TreeViolation[] = []
|
|
62
64
|
// Validate against the tree's own addressing system's hierarchy (defaults to Western).
|
|
63
65
|
const parentOf = containmentFor(tree.system)
|
|
64
66
|
|
|
65
67
|
const present = new Set<ComponentTag>()
|
|
68
|
+
|
|
66
69
|
const collect = (n: AddressNode): void => {
|
|
67
70
|
present.add(n.tag)
|
|
68
71
|
n.children.forEach(collect)
|
|
69
72
|
}
|
|
73
|
+
|
|
70
74
|
tree.roots.forEach(collect)
|
|
71
75
|
|
|
72
76
|
const walk = (node: AddressNode, parent: AddressNode | null): void => {
|
|
@@ -94,6 +98,7 @@ export function validateTree(tree: AddressTree): TreeValidity {
|
|
|
94
98
|
|
|
95
99
|
node.children.forEach((c) => walk(c, node))
|
|
96
100
|
}
|
|
101
|
+
|
|
97
102
|
tree.roots.forEach((r) => walk(r, null))
|
|
98
103
|
|
|
99
104
|
return { valid: violations.length === 0, violations }
|
package/env/index.ts
CHANGED
package/env/load.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { parseEnv } from "node:util"
|
|
|
8
8
|
export function loadEnvFile<T extends object = object>(envFilePath: PathLike): T {
|
|
9
9
|
if (!existsSync(envFilePath)) return {} as T
|
|
10
10
|
|
|
11
|
-
const envFileContent = readFileSync(envFilePath, "
|
|
11
|
+
const envFileContent = readFileSync(envFilePath, "utf8")
|
|
12
12
|
|
|
13
13
|
return parseEnv(envFileContent) as T
|
|
14
14
|
}
|
package/env/paths.ts
CHANGED
package/env/schema.ts
CHANGED
|
@@ -78,13 +78,21 @@ export const PublicEnvSchema = z.object({
|
|
|
78
78
|
|
|
79
79
|
// Eval scripts (`scripts/eval/*`) — diagnostic toggles + DB/probe overrides.
|
|
80
80
|
MAILWOMAN_WOF_HOT_DB: z.string().optional(),
|
|
81
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Override the admin gazetteer used by the default-country test panel.
|
|
83
|
+
*/
|
|
82
84
|
MAILWOMAN_WOF_GLOBAL_DB: z.string().optional(),
|
|
83
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Deployed demo URL for the docs e2e suite (skips the local build+serve machinery).
|
|
87
|
+
*/
|
|
84
88
|
MAILWOMAN_DEMO_URL: z.string().optional(),
|
|
85
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Override the ONNX model exercised by the neural test suites.
|
|
91
|
+
*/
|
|
86
92
|
MAILWOMAN_TEST_ONNX_MODEL: z.string().optional(),
|
|
87
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Override the ONNX model exercised by the capability gate.
|
|
95
|
+
*/
|
|
88
96
|
MAILWOMAN_CAPABILITY_ONNX_MODEL: z.string().optional(),
|
|
89
97
|
MAILWOMAN_DIAG_INTERP: z.string().optional(),
|
|
90
98
|
MAILWOMAN_DUMP_MISS_TAG: z.string().optional(),
|
package/errors/schema.ts
CHANGED
|
@@ -79,7 +79,7 @@ export class ResourceError<S extends StatusCodes = StatusCodes> extends Error {
|
|
|
79
79
|
status = error.status
|
|
80
80
|
break
|
|
81
81
|
case "string":
|
|
82
|
-
status = parseInt(error.status, 10) || this.DefaultStatus
|
|
82
|
+
status = Number.parseInt(error.status, 10) || this.DefaultStatus
|
|
83
83
|
break
|
|
84
84
|
}
|
|
85
85
|
}
|
package/fs/node.ts
CHANGED
|
@@ -4,22 +4,23 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type {
|
|
8
|
-
import { existsSync } from "node:fs"
|
|
7
|
+
import type { Stats } from "node:fs"
|
|
9
8
|
import { stat } from "node:fs/promises"
|
|
10
9
|
|
|
11
10
|
import type { PathBuilderLike } from "path-ts"
|
|
12
11
|
|
|
12
|
+
export { existsSync } from "node:fs"
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
15
|
* Attempts to stat a file or directory.
|
|
15
16
|
*
|
|
16
17
|
* @throws If the path exists but cannot be statted for some reason other than non-existence.
|
|
17
18
|
*/
|
|
18
19
|
export function tryStat(pathBuilderLike: PathBuilderLike): Promise<Stats | null> {
|
|
19
|
-
return stat(pathBuilderLike.toString()).catch((
|
|
20
|
-
if (
|
|
20
|
+
return stat(pathBuilderLike.toString()).catch((error) => {
|
|
21
|
+
if (error.code === "ENOENT") return null
|
|
21
22
|
|
|
22
|
-
throw
|
|
23
|
+
throw error
|
|
23
24
|
})
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -29,10 +30,8 @@ export function tryStat(pathBuilderLike: PathBuilderLike): Promise<Stats | null>
|
|
|
29
30
|
export async function isDirectory(path: PathBuilderLike): Promise<boolean> {
|
|
30
31
|
return tryStat(path)
|
|
31
32
|
.then((stats) => stats?.isDirectory() ?? false)
|
|
32
|
-
.catch((
|
|
33
|
-
if (
|
|
34
|
-
throw
|
|
33
|
+
.catch((error) => {
|
|
34
|
+
if (error.code === "ENOENT") return false
|
|
35
|
+
throw error
|
|
35
36
|
})
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
export { existsSync }
|
package/identifiers.ts
CHANGED
|
@@ -12,16 +12,16 @@ import type { CamelCase, SnakeCase } from "type-fest"
|
|
|
12
12
|
export function smartSnakeCase<T extends string>(name: T): T extends Uppercase<T> ? T : SnakeCase<T> {
|
|
13
13
|
const normalizedName = name
|
|
14
14
|
// Remove periods after capital letters, e.g. "U.S.A." -> "USA"
|
|
15
|
-
.
|
|
15
|
+
.replaceAll(/([A-Z])(\.+)/g, "$1")
|
|
16
16
|
.trim()
|
|
17
17
|
|
|
18
18
|
if (normalizedName.toUpperCase() === normalizedName) {
|
|
19
19
|
return (
|
|
20
20
|
normalizedName
|
|
21
21
|
// Replace all non-word characters with underscores...
|
|
22
|
-
.
|
|
22
|
+
.replaceAll(/\W{1,}/g, "_")
|
|
23
23
|
// ...and then replace all sequences of underscores with a single underscore.
|
|
24
|
-
.
|
|
24
|
+
.replaceAll(/_{2,}/g, "_") as T extends Uppercase<T> ? T : SnakeCase<T>
|
|
25
25
|
)
|
|
26
26
|
}
|
|
27
27
|
|
package/kysley/adapter.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { type Kysely, DialectAdapterBase, type MigrationLockOptions } from "kysely"
|
|
8
8
|
|
|
9
9
|
export class SqliteAdapter extends DialectAdapterBase {
|
|
10
10
|
override get supportsTransactionalDdl(): boolean {
|