@mailwoman/core 8.0.0 → 8.2.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 +3 -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 +3 -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 +22 -0
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.js +94 -42
- 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 +82 -23
- 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 +2 -2
- package/out/resolver/index.d.ts.map +1 -1
- package/out/resolver/index.js +1 -1
- package/out/resolver/index.js.map +1 -1
- package/out/resolver/types.d.ts +172 -25
- package/out/resolver/types.d.ts.map +1 -1
- package/out/resolver/types.js +16 -0
- 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 +6 -2
- package/out/types/component.d.ts.map +1 -1
- 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 +118 -42
- package/pipeline/span-logit-aggregation.ts +7 -2
- package/pipeline/span-proposer.ts +95 -34
- package/pipeline/types.ts +93 -23
- package/policy/proposal-collection.ts +4 -3
- package/policy/registry.ts +13 -3
- package/resolver/index.ts +11 -1
- package/resolver/types.ts +187 -25
- 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 +6 -2
- 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
|
@@ -18,11 +18,12 @@ import { prefetchReconcileLookups } from "./reconcile-lookups.ts"
|
|
|
18
18
|
import type { ClassifierCandidate } from "./reconcile.ts"
|
|
19
19
|
import { reconcileSpans } from "./reconcile.ts"
|
|
20
20
|
import { aggregateSpanLogits } from "./span-logit-aggregation.ts"
|
|
21
|
-
import { WORD_CONSISTENCY_SHIP_DEFAULT } from "./types.ts"
|
|
21
|
+
import { WORD_CONSISTENCY_SHIP_DEFAULT, deriveInputMode } from "./types.ts"
|
|
22
22
|
import type {
|
|
23
23
|
AddressClassifier,
|
|
24
24
|
ClassifierOpts,
|
|
25
25
|
FSTMatcherLike,
|
|
26
|
+
InputMode,
|
|
26
27
|
LocaleHint,
|
|
27
28
|
LocaleTag,
|
|
28
29
|
NormalizedInputLite,
|
|
@@ -35,6 +36,19 @@ import type {
|
|
|
35
36
|
RuntimePipelineStages,
|
|
36
37
|
} from "./types.ts"
|
|
37
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Kind confidence required to skip the full pipeline. Set high deliberately: a short-circuit that fires on a wrong kind
|
|
41
|
+
* cannot be recovered downstream, so the cost of being wrong is a whole mis-parse, while the cost of being cautious is
|
|
42
|
+
* one extra pass.
|
|
43
|
+
*/
|
|
44
|
+
const SHORT_CIRCUIT_MIN_CONFIDENCE = 0.95
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Longest `locality_only` input allowed to short-circuit. Past it the query is likely carrying more than a locality
|
|
48
|
+
* name, and the full pipeline should look for what else is in there.
|
|
49
|
+
*/
|
|
50
|
+
const SHORT_CIRCUIT_MAX_LOCALITY_LENGTH = 30
|
|
51
|
+
|
|
38
52
|
/**
|
|
39
53
|
* Known QueryShape format strings that indicate "this token is a postcode". Mirrors the set in
|
|
40
54
|
* `@mailwoman/kind-classifier` — kept duplicated so core/pipeline has no dep on kind-classifier.
|
|
@@ -58,26 +72,35 @@ function isPostcodeFormat(format: string): boolean {
|
|
|
58
72
|
* whole-string country guess is a broader, softer signal than a postcode that pins the country, so it blends more
|
|
59
73
|
* gently with the candidate score.
|
|
60
74
|
*/
|
|
61
|
-
const COARSE_PLACER_ANCHOR_WEIGHT = 1
|
|
75
|
+
const COARSE_PLACER_ANCHOR_WEIGHT = 1
|
|
62
76
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
/**
|
|
78
|
+
* #194: minimum placer confidence to promote the soft country prior to a HARD filter (empty→unresolved). The placer
|
|
79
|
+
* already abstains below 0.9 in-map MASS (open-set rule), but the per-country argmax prob can still be split across
|
|
80
|
+
* neighbours (DK↔NO, EE↔LT↔LV); requiring a high argmax confidence keeps the hard filter to the cases the model is sure
|
|
81
|
+
* of (FI/PL routinely score ~1.0) and leaves the ambiguous ones on the soft path. Deliberately strict — a wrong hard
|
|
82
|
+
* country is the #244 M2 misroute failure.
|
|
83
|
+
*/
|
|
68
84
|
const HARD_PLACE_COUNTRY_MIN_CONF = 0.9
|
|
69
85
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
/**
|
|
87
|
+
* #743/#194 coverage guard: countries whose candidate gazetteer is complete enough that hard-filtering is a PURE WIN —
|
|
88
|
+
* measured hard-resolve-rate ≥ 95% on held-out OpenAddresses points, so a hard-filter "miss → unresolved" is rare and
|
|
89
|
+
* almost always a genuine non-match, not a coverage gap. A confident placement OUTSIDE this set stays on the SOFT
|
|
90
|
+
* prior, so the low-coverage tail (FI/PL/…) keeps its recall until its gazetteer is filled (#193) — the win for covered
|
|
91
|
+
* countries, no recall regression for the rest (DeepSeek-advised, 2026-06-22).
|
|
92
|
+
*
|
|
93
|
+
* FALLBACK ROLE (survey candidate #2, 2026-07-26): this set is now the FALLBACK for gazetteer artifacts that predate
|
|
94
|
+
* the coverage manifest. Facts about the artifact live IN the artifact — the candidate gazetteer's `country_coverage`
|
|
95
|
+
* table carries the per-country promote-gate verdicts + the measured rates (the numbers that used to be trivia in this
|
|
96
|
+
* comment), and a loaded artifact's derived safelist (`resolver.artifactCoverage.hardCountrySafelist`) takes precedence
|
|
97
|
+
* over this constant. The measured record lives in `mailwoman/gazetteer-pipeline/coverage-manifest.ts`
|
|
98
|
+
* (MEASURED_COUNTRY_COVERAGE — grow THAT at promotes; it updates the artifact at rebuild). Precedence: per-call
|
|
99
|
+
* `PipelineOpts.hardCountrySafelist` (the eval's instrument, measures ungated to grow the list) → the loaded artifact's
|
|
100
|
+
* manifest → this constant. Historical receipts now recorded structurally in MEASURED_COUNTRY_COVERAGE: US/FR/DE 100,
|
|
101
|
+
* ES 99.8, NL 97.3, IT 96.8 (in); FI 69.5, PL 77.8 (measured, out); GB + CA at the #928 promote (2026-07-06, OSM
|
|
102
|
+
* panels, night 34); AU with the #244 placer class (2026-07-06).
|
|
103
|
+
*/
|
|
81
104
|
export const HARD_PLACE_COUNTRY_SAFELIST: ReadonlySet<string> = new Set([
|
|
82
105
|
"US",
|
|
83
106
|
"ES",
|
|
@@ -105,12 +128,13 @@ export function isBareLocalityTree(tree: AddressTree): boolean {
|
|
|
105
128
|
let sawLocality = false
|
|
106
129
|
const stack = [...tree.roots]
|
|
107
130
|
|
|
108
|
-
while (stack.length
|
|
131
|
+
while (stack.length) {
|
|
109
132
|
const node = stack.pop()!
|
|
110
133
|
|
|
111
134
|
if (node.tag === "locality") {
|
|
112
135
|
sawLocality = true
|
|
113
136
|
} else if (node.value.trim() !== "") return false
|
|
137
|
+
|
|
114
138
|
stack.push(...node.children)
|
|
115
139
|
}
|
|
116
140
|
|
|
@@ -123,6 +147,10 @@ export function isBareLocalityTree(tree: AddressTree): boolean {
|
|
|
123
147
|
* apply the SAME three gates and can't drift: confidence ≥ {@link HARD_PLACE_COUNTRY_MIN_CONF}, country in the safelist
|
|
124
148
|
* (override or the default {@link HARD_PLACE_COUNTRY_SAFELIST}), and no caller-set hard/default country to respect.
|
|
125
149
|
* Returns the country to hard-filter, or `undefined` to stay on the soft prior.
|
|
150
|
+
*
|
|
151
|
+
* `safelist` precedence is the CALLER's job: pass `perCallOverride ?? resolver.artifactCoverage?.hardCountrySafelist`
|
|
152
|
+
* (the eval instrument first, then the loaded artifact's own manifest) and this gate falls back to the code constant
|
|
153
|
+
* only when both are absent — byte-identical to the pre-manifest behavior.
|
|
126
154
|
*/
|
|
127
155
|
export function hardCountryFor(
|
|
128
156
|
placedCountry: string,
|
|
@@ -146,17 +174,23 @@ function isPostcodeFormatHit(hit: { format: string }): boolean {
|
|
|
146
174
|
return isPostcodeFormat(hit.format)
|
|
147
175
|
}
|
|
148
176
|
|
|
149
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* Pass-through normalize used when no `normalize` stage is wired.
|
|
179
|
+
*/
|
|
150
180
|
function identityNormalize(raw: string, opts?: { locale?: string }): NormalizedInputLite {
|
|
151
181
|
return { raw, normalized: raw, appliedLocale: opts?.locale }
|
|
152
182
|
}
|
|
153
183
|
|
|
154
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* No-op query-shape used when no `computeQueryShape` stage is wired.
|
|
186
|
+
*/
|
|
155
187
|
function emptyQueryShape(): QueryShapeLite {
|
|
156
188
|
return { knownFormats: [] }
|
|
157
189
|
}
|
|
158
190
|
|
|
159
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Default locale detector: trusts the caller's hint, or falls back to `und`.
|
|
193
|
+
*/
|
|
160
194
|
async function defaultDetectLocale(
|
|
161
195
|
_input: NormalizedInputLite,
|
|
162
196
|
_shape: QueryShapeLite,
|
|
@@ -166,13 +200,15 @@ async function defaultDetectLocale(
|
|
|
166
200
|
|
|
167
201
|
return {
|
|
168
202
|
locale,
|
|
169
|
-
confidence: opts?.hint ? 1
|
|
203
|
+
confidence: opts?.hint ? 1 : 0,
|
|
170
204
|
alternatives: [],
|
|
171
205
|
source: opts?.hint ? "caller" : "detected",
|
|
172
206
|
}
|
|
173
207
|
}
|
|
174
208
|
|
|
175
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* Default kind classifier: always returns `structured_address` with low confidence (no fast-path).
|
|
211
|
+
*/
|
|
176
212
|
async function defaultClassifyKind(
|
|
177
213
|
_input: NormalizedInputLite,
|
|
178
214
|
_shape: QueryShapeLite,
|
|
@@ -180,7 +216,7 @@ async function defaultClassifyKind(
|
|
|
180
216
|
): Promise<QueryKindResult> {
|
|
181
217
|
return {
|
|
182
218
|
kind: "structured_address",
|
|
183
|
-
confidence: 0
|
|
219
|
+
confidence: 0,
|
|
184
220
|
alternatives: [],
|
|
185
221
|
}
|
|
186
222
|
}
|
|
@@ -192,14 +228,14 @@ async function defaultClassifyKind(
|
|
|
192
228
|
function canShortCircuit(kind: QueryKindResult, shape: QueryShapeLite, opts?: PipelineOpts): boolean {
|
|
193
229
|
if (opts?.forceFullPipeline) return false
|
|
194
230
|
|
|
195
|
-
if (kind.confidence <
|
|
231
|
+
if (kind.confidence < SHORT_CIRCUIT_MIN_CONFIDENCE) return false
|
|
196
232
|
|
|
197
233
|
if (kind.kind === "postcode_only") {
|
|
198
234
|
return shape.knownFormats.some(isPostcodeFormatHit)
|
|
199
235
|
}
|
|
200
236
|
|
|
201
237
|
if (kind.kind === "locality_only") {
|
|
202
|
-
return (shape.totalLength ?? Infinity) <=
|
|
238
|
+
return (shape.totalLength ?? Infinity) <= SHORT_CIRCUIT_MAX_LOCALITY_LENGTH && shape.characterClass === "alpha"
|
|
203
239
|
}
|
|
204
240
|
|
|
205
241
|
return false
|
|
@@ -304,16 +340,19 @@ export async function runPipeline(
|
|
|
304
340
|
// even when FI is pinned); the hard filter does. Three gates: confidence (ambiguous DK↔NO stay
|
|
305
341
|
// soft), the safelist (only well-covered countries — where a miss is a genuine non-match, not a
|
|
306
342
|
// coverage gap — hard-filter; the low-coverage tail keeps its recall on the soft path), and the
|
|
307
|
-
// caller's own hardCountry/defaultCountry is never overwritten.
|
|
308
|
-
// override
|
|
343
|
+
// caller's own hardCountry/defaultCountry is never overwritten. Safelist precedence: the per-call
|
|
344
|
+
// `hardCountrySafelist` override (the eval measures ungated to grow it) → the loaded gazetteer
|
|
345
|
+
// artifact's own coverage manifest → the code-constant fallback inside hardCountryFor.
|
|
309
346
|
const hardCountry = hardCountryFor(
|
|
310
347
|
placed.country,
|
|
311
348
|
placed.confidence,
|
|
312
349
|
opts?.resolveOpts ?? {},
|
|
313
350
|
opts?.hardPlaceCountry,
|
|
314
|
-
opts?.hardCountrySafelist
|
|
351
|
+
opts?.hardCountrySafelist ?? stages.resolver?.artifactCoverage?.hardCountrySafelist
|
|
315
352
|
)
|
|
353
|
+
|
|
316
354
|
placerAnchorApplied = true
|
|
355
|
+
|
|
317
356
|
effectiveOpts = {
|
|
318
357
|
...opts,
|
|
319
358
|
resolveOpts: {
|
|
@@ -432,6 +471,7 @@ export async function runPipeline(
|
|
|
432
471
|
// to opt back into reconcile (the A/B harnesses do). Report:
|
|
433
472
|
// docs/articles/evals/experiments/2026-06-14-reconcile-retirement.md.
|
|
434
473
|
const jointEnabled = opts?.jointReconcile ?? false
|
|
474
|
+
|
|
435
475
|
const useJointReconcile =
|
|
436
476
|
jointEnabled && phraseProposals.length > 0 && stages.classifier && "parseWithLogits" in stages.classifier
|
|
437
477
|
|
|
@@ -445,6 +485,7 @@ export async function runPipeline(
|
|
|
445
485
|
|
|
446
486
|
throwIfAborted(opts)
|
|
447
487
|
const tClassify = performance.now()
|
|
488
|
+
|
|
448
489
|
const {
|
|
449
490
|
tree: argmaxTree,
|
|
450
491
|
logits,
|
|
@@ -454,6 +495,7 @@ export async function runPipeline(
|
|
|
454
495
|
fst: stages.fst,
|
|
455
496
|
...streetContextGateFor(stages),
|
|
456
497
|
})
|
|
498
|
+
|
|
457
499
|
timing["token-classify"] = performance.now() - tClassify
|
|
458
500
|
|
|
459
501
|
throwIfAborted(opts)
|
|
@@ -471,13 +513,14 @@ export async function runPipeline(
|
|
|
471
513
|
{ labels, text: normalized.normalized }
|
|
472
514
|
)
|
|
473
515
|
|
|
474
|
-
if (classifierTopK.length
|
|
516
|
+
if (classifierTopK.length) {
|
|
475
517
|
// Concordance axes (#478): when the caller wires a backend, one bounded pre-fetch
|
|
476
518
|
// activates the resolver-candidate + parent-chain scoring the reconciler already
|
|
477
519
|
// implements. Absent backend = classifier-only reconcile (byte-stable).
|
|
478
520
|
// Country constraint from the locale gate's BCP-47 tag ("en-US" -> "US"); absent or
|
|
479
521
|
// und-like tags pass no constraint (ranking alone decides — matches resolveTree's default).
|
|
480
522
|
const localeCountry = locale.locale.split("-")[1]?.toUpperCase()
|
|
523
|
+
|
|
481
524
|
const lookups = stages.resolverBackend
|
|
482
525
|
? await prefetchReconcileLookups(
|
|
483
526
|
stages.resolverBackend,
|
|
@@ -486,12 +529,14 @@ export async function runPipeline(
|
|
|
486
529
|
localeCountry && localeCountry.length === 2 ? { defaultCountry: localeCountry } : {}
|
|
487
530
|
)
|
|
488
531
|
: undefined
|
|
532
|
+
|
|
489
533
|
const result = reconcileSpans({
|
|
490
534
|
raw: normalized.normalized,
|
|
491
535
|
phraseProposals,
|
|
492
536
|
classifierTopK,
|
|
493
537
|
...(lookups ? { resolverCandidates: lookups.resolverCandidates, parentChain: lookups.parentChain } : {}),
|
|
494
538
|
})
|
|
539
|
+
|
|
495
540
|
tree = result.tree
|
|
496
541
|
// The reconciler can leave a span uncovered (e.g. it picked the single-token street
|
|
497
542
|
// `Trento` over `Via Trento`, orphaning `Via`). The grouper-audit below would then promote
|
|
@@ -502,10 +547,12 @@ export async function runPipeline(
|
|
|
502
547
|
} else {
|
|
503
548
|
tree = argmaxTree
|
|
504
549
|
}
|
|
550
|
+
|
|
505
551
|
timing["reconcile"] = performance.now() - tReconcile
|
|
506
552
|
} else if (stages.classifier) {
|
|
507
553
|
throwIfAborted(opts)
|
|
508
554
|
const tClassify = performance.now()
|
|
555
|
+
|
|
509
556
|
tree = await safeClassify(
|
|
510
557
|
stages.classifier,
|
|
511
558
|
normalized.normalized,
|
|
@@ -513,12 +560,15 @@ export async function runPipeline(
|
|
|
513
560
|
stages.fst,
|
|
514
561
|
opts?.normalizeCase,
|
|
515
562
|
opts?.placetypePair,
|
|
516
|
-
stages.streetMorphology
|
|
563
|
+
stages.streetMorphology,
|
|
564
|
+
// Decision A: explicit caller register wins; otherwise the kind verdict decides. NEVER case-keyed.
|
|
565
|
+
opts?.inputMode ?? deriveInputMode(kind.kind)
|
|
517
566
|
)
|
|
567
|
+
|
|
518
568
|
timing["token-classify"] = performance.now() - tClassify
|
|
519
569
|
}
|
|
520
570
|
|
|
521
|
-
if (phraseProposals.length
|
|
571
|
+
if (phraseProposals.length && tree.roots.length >= 0) {
|
|
522
572
|
const tAudit = performance.now()
|
|
523
573
|
tree = grouperAudit(tree, phraseProposals, normalized.normalized, auditClassifierTopK)
|
|
524
574
|
timing["grouper-audit"] = performance.now() - tAudit
|
|
@@ -533,6 +583,7 @@ export async function runPipeline(
|
|
|
533
583
|
if (placerAnchorApplied && isBareLocalityTree(tree)) {
|
|
534
584
|
effectiveOpts = opts
|
|
535
585
|
}
|
|
586
|
+
|
|
536
587
|
tree = await safeResolve(stages.resolver, tree, effectiveOpts)
|
|
537
588
|
timing["resolve"] = performance.now() - tResolve
|
|
538
589
|
}
|
|
@@ -563,7 +614,9 @@ function throwIfAborted(opts?: PipelineOpts): void {
|
|
|
563
614
|
}
|
|
564
615
|
}
|
|
565
616
|
|
|
566
|
-
/**
|
|
617
|
+
/**
|
|
618
|
+
* Defensive wrapper: if the classifier throws, return an empty tree rather than abort the pipeline.
|
|
619
|
+
*/
|
|
567
620
|
async function safeClassify(
|
|
568
621
|
classifier: AddressClassifier,
|
|
569
622
|
text: string,
|
|
@@ -571,7 +624,8 @@ async function safeClassify(
|
|
|
571
624
|
fst?: FSTMatcherLike,
|
|
572
625
|
normalizeCase?: boolean,
|
|
573
626
|
placetypePair?: PlacetypePairPassthrough,
|
|
574
|
-
streetMorphology?: FSTMatcherLike
|
|
627
|
+
streetMorphology?: FSTMatcherLike,
|
|
628
|
+
inputMode?: InputMode
|
|
575
629
|
): Promise<AddressTree> {
|
|
576
630
|
try {
|
|
577
631
|
// Postcode regex repair on by default (v0.7 #35, operator-signed). #690 normalizeCase forwards as-is —
|
|
@@ -583,6 +637,7 @@ async function safeClassify(
|
|
|
583
637
|
// no-prior decode), so the classifier's `opts?.placetypePair ?? cfg.placetypePair` resolution is unchanged when absent.
|
|
584
638
|
return await classifier.parse(text, {
|
|
585
639
|
queryShape,
|
|
640
|
+
inputMode,
|
|
586
641
|
fst,
|
|
587
642
|
postcodeRepair: true,
|
|
588
643
|
normalizeCase,
|
|
@@ -603,16 +658,32 @@ async function safeClassify(
|
|
|
603
658
|
*/
|
|
604
659
|
const ZEROED_MORPHOLOGY_OPTS = { biasScale: 0, dependentLocalityPenalty: 0 } as const
|
|
605
660
|
|
|
661
|
+
/**
|
|
662
|
+
* D2 remediation (#1320, ROAD_TO_MAILWOMAN_V8_1_0 §5.2): the pipeline ships the gate at FULL suppression (0.0), not the
|
|
663
|
+
* classifier's 0.25 default. Measured 2026-07-26 on v8.0.0-as-shipped (branch TS == origin/main, FST md5 == published):
|
|
664
|
+
* 0.0 puts FR admin-street-homonym at EXACT P0 parity (159/400 vs 157 at 0.25) with golden us/fr and every other
|
|
665
|
+
* fragment class byte-identical to 0.25 — the "some admin mass for the semi-markov decoder" rationale for 0.25 carried
|
|
666
|
+
* no measured benefit at the pipeline level. Satisfies the D-rule (iron rule 6) ≥P0 clause for #1318.
|
|
667
|
+
*/
|
|
668
|
+
const STREET_CONTEXT_POSITIVE_SCALE = 0
|
|
669
|
+
|
|
606
670
|
function streetContextGateFor(stages: { fst?: FSTMatcherLike; streetMorphology?: FSTMatcherLike }): {
|
|
607
671
|
fstStreetMorphology?: FSTMatcherLike
|
|
608
672
|
fstStreetMorphologyOpts?: { biasScale: number; dependentLocalityPenalty: number }
|
|
673
|
+
fstStreetContextPositiveScale?: number
|
|
609
674
|
} {
|
|
610
675
|
return stages.fst && stages.streetMorphology
|
|
611
|
-
? {
|
|
676
|
+
? {
|
|
677
|
+
fstStreetMorphology: stages.streetMorphology,
|
|
678
|
+
fstStreetMorphologyOpts: { ...ZEROED_MORPHOLOGY_OPTS },
|
|
679
|
+
fstStreetContextPositiveScale: STREET_CONTEXT_POSITIVE_SCALE,
|
|
680
|
+
}
|
|
612
681
|
: {}
|
|
613
682
|
}
|
|
614
683
|
|
|
615
|
-
/**
|
|
684
|
+
/**
|
|
685
|
+
* Defensive wrapper: a grouper failure returns an empty proposal list rather than abort.
|
|
686
|
+
*/
|
|
616
687
|
async function safeGroupPhrases(
|
|
617
688
|
groupPhrases: NonNullable<RuntimePipelineStages["groupPhrases"]>,
|
|
618
689
|
normalized: NormalizedInputLite,
|
|
@@ -626,9 +697,7 @@ async function safeGroupPhrases(
|
|
|
626
697
|
}
|
|
627
698
|
}
|
|
628
699
|
|
|
629
|
-
//
|
|
630
|
-
// Grouper-audit pass
|
|
631
|
-
// ---------------------------------------------------------------------------
|
|
700
|
+
// MARK: Grouper-audit pass
|
|
632
701
|
|
|
633
702
|
const GROUPER_TYPING_PENALTY = 0.55
|
|
634
703
|
|
|
@@ -659,11 +728,12 @@ export function grouperAudit(
|
|
|
659
728
|
text: string,
|
|
660
729
|
classifierTopK?: ClassifierCandidate[]
|
|
661
730
|
): AddressTree {
|
|
662
|
-
if (proposals.length
|
|
731
|
+
if (!proposals.length) return tree
|
|
663
732
|
|
|
664
733
|
const roots = [...tree.roots]
|
|
665
734
|
|
|
666
735
|
const allNodes: Array<{ start: number; end: number }> = []
|
|
736
|
+
|
|
667
737
|
const collectNodes = (nodes: typeof roots): void => {
|
|
668
738
|
for (const n of nodes) {
|
|
669
739
|
allNodes.push({ start: n.start, end: n.end })
|
|
@@ -673,6 +743,7 @@ export function grouperAudit(
|
|
|
673
743
|
}
|
|
674
744
|
}
|
|
675
745
|
}
|
|
746
|
+
|
|
676
747
|
collectNodes(roots)
|
|
677
748
|
|
|
678
749
|
// Index the classifier's single best tag per exact span (start:end) so the audit can defer to it.
|
|
@@ -695,6 +766,7 @@ export function grouperAudit(
|
|
|
695
766
|
// from being shadowed by an earlier-positioned spurious node in `decodeAsJSON` (#425 residual tail).
|
|
696
767
|
const SINGLETON_TAGS: ReadonlySet<ComponentTag> = new Set<ComponentTag>(["locality", "region", "postcode", "country"])
|
|
697
768
|
const presentSingletons = new Set<ComponentTag>()
|
|
769
|
+
|
|
698
770
|
const collectSingletons = (nodes: typeof roots): void => {
|
|
699
771
|
for (const n of nodes) {
|
|
700
772
|
if (SINGLETON_TAGS.has(n.tag)) {
|
|
@@ -706,6 +778,7 @@ export function grouperAudit(
|
|
|
706
778
|
}
|
|
707
779
|
}
|
|
708
780
|
}
|
|
781
|
+
|
|
709
782
|
collectSingletons(roots)
|
|
710
783
|
const dedupeSingletons = classifierTopK !== undefined
|
|
711
784
|
|
|
@@ -725,6 +798,7 @@ export function grouperAudit(
|
|
|
725
798
|
|
|
726
799
|
// Defer to the classifier when it confidently typed this exact span as something else.
|
|
727
800
|
const classifierVerdict = bestTagBySpan.get(`${proposal.span.start}:${proposal.span.end}`)
|
|
801
|
+
|
|
728
802
|
const tag =
|
|
729
803
|
classifierVerdict && classifierVerdict.score >= CLASSIFIER_OVERRIDE_MIN ? classifierVerdict.tag : phraseTag
|
|
730
804
|
|
|
@@ -754,7 +828,9 @@ export function grouperAudit(
|
|
|
754
828
|
return { raw: tree.raw, roots }
|
|
755
829
|
}
|
|
756
830
|
|
|
757
|
-
/**
|
|
831
|
+
/**
|
|
832
|
+
* Defensive wrapper: a resolver failure leaves the classifier tree intact.
|
|
833
|
+
*/
|
|
758
834
|
async function safeResolve(
|
|
759
835
|
resolver: NonNullable<RuntimePipelineStages["resolver"]>,
|
|
760
836
|
tree: AddressTree,
|
|
@@ -85,7 +85,7 @@ export function aggregateSpanLogits(
|
|
|
85
85
|
overlapping.push(t)
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
if (overlapping.length
|
|
88
|
+
if (!overlapping.length) continue
|
|
89
89
|
|
|
90
90
|
// Aggregate softmax probabilities per component tag (strip BIO prefix).
|
|
91
91
|
const tagScores = new Map<string, number>()
|
|
@@ -107,8 +107,10 @@ export function aggregateSpanLogits(
|
|
|
107
107
|
|
|
108
108
|
// Normalize by number of overlapping tokens so longer spans don't auto-win.
|
|
109
109
|
const norm = overlapping.length
|
|
110
|
+
|
|
110
111
|
const sorted = [...tagScores.entries()]
|
|
111
112
|
.map(([tag, score]) => ({ tag, score: score / norm }))
|
|
113
|
+
// oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
|
|
112
114
|
.sort((a, b) => b.score - a.score)
|
|
113
115
|
.slice(0, topK)
|
|
114
116
|
|
|
@@ -136,7 +138,9 @@ function stripBIOPrefix(label: string): string {
|
|
|
136
138
|
return label.slice(dash + 1)
|
|
137
139
|
}
|
|
138
140
|
|
|
139
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Numerically stable softmax over a row of logits.
|
|
143
|
+
*/
|
|
140
144
|
function softmax(row: readonly number[]): number[] {
|
|
141
145
|
let max = row[0]!
|
|
142
146
|
|
|
@@ -144,6 +148,7 @@ function softmax(row: readonly number[]): number[] {
|
|
|
144
148
|
if (row[i]! > max) {
|
|
145
149
|
max = row[i]!
|
|
146
150
|
}
|
|
151
|
+
|
|
147
152
|
const exps = row.map((v) => Math.exp(v - max))
|
|
148
153
|
const sum = exps.reduce((a, b) => a + b, 0)
|
|
149
154
|
|