@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
|
@@ -34,13 +34,34 @@
|
|
|
34
34
|
* (see `neural/span-proposer-lexicon.ts`).
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Token count below which an input is too short for its tail position to carry much signal.
|
|
39
|
+
*/
|
|
40
|
+
const SHORT_INPUT_MAX_TOKENS = 3
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Confidence for a tail span in an input too short to clear {@link SHORT_INPUT_MAX_TOKENS}.
|
|
44
|
+
*/
|
|
45
|
+
const SHORT_TAIL_CONFIDENCE = 0.45
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Digits in the first half of a ZIP+4. A hyphen compound with this shape is a postcode, not a house number.
|
|
49
|
+
*/
|
|
50
|
+
const ZIP5_LENGTH = 5
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Confidence at which an ANNOTATION_SPAN is trusted enough to swallow the inner proposals it covers. Below it both
|
|
54
|
+
* readings survive and the reconciler decides.
|
|
55
|
+
*/
|
|
56
|
+
const CONFIDENT_ANNOTATION_MIN = 0.6
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Typed kinds a span proposal may carry. See the module doc for the three cue families.
|
|
60
|
+
*/
|
|
38
61
|
export type ProposedSpanKind =
|
|
39
62
|
/** A balanced `()`/`[]` group whose content reads as an aside about the address. */
|
|
40
63
|
| "ANNOTATION_SPAN"
|
|
41
|
-
/**
|
|
42
|
-
* A balanced quote group — the content is likely a NAME (venue/unit); typing is the classifier's job.
|
|
43
|
-
*/
|
|
64
|
+
/** A balanced quote group — the content is likely a NAME (venue/unit); typing is the classifier's job. */
|
|
44
65
|
| "QUOTED_SPAN"
|
|
45
66
|
/** Delivery-service designator + identifier ("PO Box 19", "GPO Box 2890", "Private Bag 7"). */
|
|
46
67
|
| "PO_BOX_PHRASE"
|
|
@@ -55,12 +76,16 @@ export type ProposedSpanKind =
|
|
|
55
76
|
/** Dual-path SPLIT reading, right side: the house number ("14" of "Flat 2/14"). */
|
|
56
77
|
| "SPLIT_HOUSE_NUMBER"
|
|
57
78
|
|
|
58
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* One typed span proposal. Char offsets into the raw input; `end` exclusive.
|
|
81
|
+
*/
|
|
59
82
|
export interface ProposedSpan {
|
|
60
83
|
start: number
|
|
61
84
|
end: number
|
|
62
85
|
kind: ProposedSpanKind
|
|
63
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* 0..1. Confidence is shape-derived; consumers weight or floor it (it is never a verdict).
|
|
88
|
+
*/
|
|
64
89
|
confidence: number
|
|
65
90
|
/**
|
|
66
91
|
* Alternative readings of ONE surface share a group id (M3 dual-path: the fused and split readings of `2/14` carry
|
|
@@ -83,9 +108,13 @@ export interface SpanProposerLexicon {
|
|
|
83
108
|
* Codex system codes the lexicon was built from ("us", "au", "nz", …) — drives M3 locale conditioning.
|
|
84
109
|
*/
|
|
85
110
|
systems: ReadonlySet<string>
|
|
86
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Leading secondary-unit designator tokens (USPS Pub-28 C2 variants: "apt", "ste", "unit", …).
|
|
113
|
+
*/
|
|
87
114
|
unitDesignators: ReadonlySet<string>
|
|
88
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Level-class designator tokens ("floor", "fl", "bsmt", "ph", …) — typed LEVEL_PHRASE.
|
|
117
|
+
*/
|
|
89
118
|
levelDesignators: ReadonlySet<string>
|
|
90
119
|
/**
|
|
91
120
|
* Descriptive designators ("building", "rear", "side", …) that, inside a bracketed group, read as annotation content
|
|
@@ -99,7 +128,9 @@ export interface SpanProposerLexicon {
|
|
|
99
128
|
deliveryService?: RegExp
|
|
100
129
|
}
|
|
101
130
|
|
|
102
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Empty lexicon — paired-delimiter proposals only.
|
|
133
|
+
*/
|
|
103
134
|
export const EMPTY_SPAN_PROPOSER_LEXICON: SpanProposerLexicon = {
|
|
104
135
|
systems: new Set(),
|
|
105
136
|
unitDesignators: new Set(),
|
|
@@ -107,16 +138,18 @@ export const EMPTY_SPAN_PROPOSER_LEXICON: SpanProposerLexicon = {
|
|
|
107
138
|
weakDesignators: new Set(),
|
|
108
139
|
}
|
|
109
140
|
|
|
110
|
-
|
|
111
|
-
// Tokenization (offset-preserving, punctuation-stripped match bodies)
|
|
112
|
-
// ---------------------------------------------------------------------------
|
|
141
|
+
//#region Tokenization
|
|
113
142
|
|
|
114
143
|
interface RawToken {
|
|
115
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* Whitespace-delimited body as written.
|
|
146
|
+
*/
|
|
116
147
|
body: string
|
|
117
148
|
start: number
|
|
118
149
|
end: number
|
|
119
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* Body with leading/trailing punctuation stripped (for matching); offsets of the stripped core.
|
|
152
|
+
*/
|
|
120
153
|
stripped: string
|
|
121
154
|
strippedStart: number
|
|
122
155
|
strippedEnd: number
|
|
@@ -139,6 +172,7 @@ function tokenize(text: string): RawToken[] {
|
|
|
139
172
|
while (i < text.length && !/\s/.test(text[i]!)) {
|
|
140
173
|
i++
|
|
141
174
|
}
|
|
175
|
+
|
|
142
176
|
const body = text.slice(start, i)
|
|
143
177
|
let s = 0
|
|
144
178
|
let e = body.length
|
|
@@ -150,6 +184,7 @@ function tokenize(text: string): RawToken[] {
|
|
|
150
184
|
while (e > s && EDGE_PUNCT.test(body[e - 1]!)) {
|
|
151
185
|
e--
|
|
152
186
|
}
|
|
187
|
+
|
|
153
188
|
out.push({
|
|
154
189
|
body,
|
|
155
190
|
start,
|
|
@@ -163,9 +198,9 @@ function tokenize(text: string): RawToken[] {
|
|
|
163
198
|
return out
|
|
164
199
|
}
|
|
165
200
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
201
|
+
//#endregion
|
|
202
|
+
|
|
203
|
+
//#region Cue family 1 — paired delimiters (M2)
|
|
169
204
|
|
|
170
205
|
/**
|
|
171
206
|
* Find balanced pairs for one open/close class. Returns null when ANY delimiter of the class is unbalanced (stray
|
|
@@ -188,10 +223,12 @@ function findBalancedPairs(text: string, open: string, close: string): Array<{ o
|
|
|
188
223
|
}
|
|
189
224
|
}
|
|
190
225
|
|
|
191
|
-
return stack.length
|
|
226
|
+
return stack.length ? null : out
|
|
192
227
|
}
|
|
193
228
|
|
|
194
|
-
/**
|
|
229
|
+
/**
|
|
230
|
+
* Same-character quote pairing ("…"): consecutive occurrences pair up; an odd count is unbalanced.
|
|
231
|
+
*/
|
|
195
232
|
function findSameCharPairs(text: string, ch: string): Array<{ open: number; close: number }> | null {
|
|
196
233
|
const positions: number[] = []
|
|
197
234
|
|
|
@@ -224,10 +261,11 @@ function findSameCharPairs(text: string, ch: string): Array<{ open: number; clos
|
|
|
224
261
|
function annotationConfidence(content: string, atEndOfInput: boolean, lexicon: SpanProposerLexicon): number {
|
|
225
262
|
const tokens = content.split(/\s+/).filter(Boolean)
|
|
226
263
|
|
|
227
|
-
if (tokens.length
|
|
264
|
+
if (!tokens.length) return 0
|
|
228
265
|
|
|
229
266
|
if (tokens.length === 2) {
|
|
230
267
|
const lead = tokens[0]!.toLowerCase().replace(/\.$/, "")
|
|
268
|
+
|
|
231
269
|
const strong =
|
|
232
270
|
(lexicon.unitDesignators.has(lead) || lexicon.levelDesignators.has(lead)) && !lexicon.weakDesignators.has(lead)
|
|
233
271
|
|
|
@@ -236,7 +274,7 @@ function annotationConfidence(content: string, atEndOfInput: boolean, lexicon: S
|
|
|
236
274
|
|
|
237
275
|
if (/^[\p{Ll}0-9]/u.test(content)) return 0.9
|
|
238
276
|
|
|
239
|
-
if (atEndOfInput && tokens.length <=
|
|
277
|
+
if (atEndOfInput && tokens.length <= SHORT_INPUT_MAX_TOKENS) return SHORT_TAIL_CONFIDENCE
|
|
240
278
|
|
|
241
279
|
return 0.75
|
|
242
280
|
}
|
|
@@ -261,6 +299,7 @@ function proposePairedDelimiters(text: string, lexicon: SpanProposerLexicon): Pr
|
|
|
261
299
|
|
|
262
300
|
if (!content) continue
|
|
263
301
|
const atEnd = p.close >= lastNonSpace - 1
|
|
302
|
+
|
|
264
303
|
out.push({
|
|
265
304
|
start: p.open,
|
|
266
305
|
end: p.close + 1,
|
|
@@ -278,6 +317,7 @@ function proposePairedDelimiters(text: string, lexicon: SpanProposerLexicon): Pr
|
|
|
278
317
|
// „…“ (low-9 opener, German/Czech): closes with “ — only scanned when a „ is present, so the
|
|
279
318
|
// “ ” class above (which would see a stray “) is skipped for such inputs.
|
|
280
319
|
]
|
|
320
|
+
|
|
281
321
|
const hasLow9 = text.includes("„")
|
|
282
322
|
|
|
283
323
|
for (const [idx, find] of quotePairFinders.entries()) {
|
|
@@ -310,11 +350,13 @@ function proposePairedDelimiters(text: string, lexicon: SpanProposerLexicon): Pr
|
|
|
310
350
|
return out
|
|
311
351
|
}
|
|
312
352
|
|
|
313
|
-
|
|
314
|
-
// Cue family 2 — designator + identifier (the sub-premise grammar)
|
|
315
|
-
// ---------------------------------------------------------------------------
|
|
353
|
+
//#endregion
|
|
316
354
|
|
|
317
|
-
|
|
355
|
+
//#region Cue family 2 — designator + identifier
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Short identifier shapes per the designator grammar: "4B", "500", "#104", "B", "B99".
|
|
359
|
+
*/
|
|
318
360
|
function isShortIdentifier(body: string): boolean {
|
|
319
361
|
return /^#?\d{1,6}[A-Za-z]{0,2}$/.test(body) || /^[A-Za-z]$/.test(body) || /^[A-Za-z]\d{1,4}$/.test(body)
|
|
320
362
|
}
|
|
@@ -339,6 +381,7 @@ function proposeDesignatorPhrases(
|
|
|
339
381
|
// cue family 3 owns punctuated ids
|
|
340
382
|
if (!isShortIdentifier(next.stripped)) continue
|
|
341
383
|
const weak = lexicon.weakDesignators.has(lead)
|
|
384
|
+
|
|
342
385
|
out.push({
|
|
343
386
|
start: tokens[i]!.strippedStart,
|
|
344
387
|
end: next.strippedEnd,
|
|
@@ -366,9 +409,9 @@ function proposeDesignatorPhrases(
|
|
|
366
409
|
return out
|
|
367
410
|
}
|
|
368
411
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
412
|
+
//#endregion
|
|
413
|
+
|
|
414
|
+
//#region Cue family 3 — dual-path numeric punctuation (M3)
|
|
372
415
|
|
|
373
416
|
const SLASH_COMPOUND = /^(\d{1,4}[A-Za-z]?)\/(\d{1,5}[A-Za-z]?)$/
|
|
374
417
|
const HYPHEN_COMPOUND = /^(\d{1,4})-(\d{1,5})$/
|
|
@@ -412,6 +455,7 @@ function proposeNumericReadings(
|
|
|
412
455
|
confidence: 0.85,
|
|
413
456
|
source: "fraction:usps-half-address",
|
|
414
457
|
})
|
|
458
|
+
|
|
415
459
|
continue
|
|
416
460
|
}
|
|
417
461
|
|
|
@@ -420,6 +464,7 @@ function proposeNumericReadings(
|
|
|
420
464
|
if (slash) {
|
|
421
465
|
const leftEnd = t.strippedStart + slash[1]!.length
|
|
422
466
|
const rightStart = leftEnd + 1
|
|
467
|
+
|
|
423
468
|
// Reading A context: a unit/level designator leads ("Unit 4/22", "Flat 2/14" via the
|
|
424
469
|
// leading-shape fallback below). Reading B context: the compound itself leads the address
|
|
425
470
|
// ("3/45 Wattle St" — the AU/NZ bare sub-premise shape, only proposed when those codex
|
|
@@ -435,6 +480,7 @@ function proposeNumericReadings(
|
|
|
435
480
|
if (prevIsDesignator || leadingShape) {
|
|
436
481
|
const group = nextGroup()
|
|
437
482
|
const conf = prevIsDesignator ? (hasAuNz ? 0.85 : 0.6) : 0.7
|
|
483
|
+
|
|
438
484
|
out.push({
|
|
439
485
|
start: prev!.strippedStart,
|
|
440
486
|
end: leftEnd,
|
|
@@ -443,6 +489,7 @@ function proposeNumericReadings(
|
|
|
443
489
|
alternativeGroup: group,
|
|
444
490
|
source: prevIsDesignator ? "slash:designator-split" : "slash:leading-designator-shape",
|
|
445
491
|
})
|
|
492
|
+
|
|
446
493
|
out.push({
|
|
447
494
|
start: rightStart,
|
|
448
495
|
end: t.strippedEnd,
|
|
@@ -451,6 +498,7 @@ function proposeNumericReadings(
|
|
|
451
498
|
alternativeGroup: group,
|
|
452
499
|
source: "slash:designator-split",
|
|
453
500
|
})
|
|
501
|
+
|
|
454
502
|
out.push({
|
|
455
503
|
start: t.strippedStart,
|
|
456
504
|
end: t.strippedEnd,
|
|
@@ -461,6 +509,7 @@ function proposeNumericReadings(
|
|
|
461
509
|
})
|
|
462
510
|
} else if (i === 0 && hasAuNz && tokens.length > 1) {
|
|
463
511
|
const group = nextGroup()
|
|
512
|
+
|
|
464
513
|
out.push({
|
|
465
514
|
start: t.strippedStart,
|
|
466
515
|
end: leftEnd,
|
|
@@ -469,6 +518,7 @@ function proposeNumericReadings(
|
|
|
469
518
|
alternativeGroup: group,
|
|
470
519
|
source: "slash:bare-leading-split",
|
|
471
520
|
})
|
|
521
|
+
|
|
472
522
|
out.push({
|
|
473
523
|
start: rightStart,
|
|
474
524
|
end: t.strippedEnd,
|
|
@@ -477,6 +527,7 @@ function proposeNumericReadings(
|
|
|
477
527
|
alternativeGroup: group,
|
|
478
528
|
source: "slash:bare-leading-split",
|
|
479
529
|
})
|
|
530
|
+
|
|
480
531
|
out.push({
|
|
481
532
|
start: t.strippedStart,
|
|
482
533
|
end: t.strippedEnd,
|
|
@@ -496,6 +547,7 @@ function proposeNumericReadings(
|
|
|
496
547
|
source: "slash:trailing-fused",
|
|
497
548
|
})
|
|
498
549
|
}
|
|
550
|
+
|
|
499
551
|
continue
|
|
500
552
|
}
|
|
501
553
|
|
|
@@ -503,12 +555,13 @@ function proposeNumericReadings(
|
|
|
503
555
|
|
|
504
556
|
if (hyphen) {
|
|
505
557
|
// ZIP+4 shape is a postcode, not a house number — never propose a reading for it.
|
|
506
|
-
if (hyphen[1]!.length ===
|
|
558
|
+
if (hyphen[1]!.length === ZIP5_LENGTH) continue
|
|
507
559
|
const next = i + 1 < tokens.length ? tokens[i + 1] : undefined
|
|
508
560
|
const leftEnd = t.strippedStart + hyphen[1]!.length
|
|
509
561
|
|
|
510
562
|
if (prevIsDesignator) {
|
|
511
563
|
const group = nextGroup()
|
|
564
|
+
|
|
512
565
|
out.push({
|
|
513
566
|
start: prev!.strippedStart,
|
|
514
567
|
end: leftEnd,
|
|
@@ -517,6 +570,7 @@ function proposeNumericReadings(
|
|
|
517
570
|
alternativeGroup: group,
|
|
518
571
|
source: "hyphen:designator-split",
|
|
519
572
|
})
|
|
573
|
+
|
|
520
574
|
out.push({
|
|
521
575
|
start: leftEnd + 1,
|
|
522
576
|
end: t.strippedEnd,
|
|
@@ -525,6 +579,7 @@ function proposeNumericReadings(
|
|
|
525
579
|
alternativeGroup: group,
|
|
526
580
|
source: "hyphen:designator-split",
|
|
527
581
|
})
|
|
582
|
+
|
|
528
583
|
out.push({
|
|
529
584
|
start: t.strippedStart,
|
|
530
585
|
end: t.strippedEnd,
|
|
@@ -552,9 +607,9 @@ function proposeNumericReadings(
|
|
|
552
607
|
return out
|
|
553
608
|
}
|
|
554
609
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
610
|
+
//#endregion
|
|
611
|
+
|
|
612
|
+
//#region Entry point
|
|
558
613
|
|
|
559
614
|
/**
|
|
560
615
|
* Propose typed spans over `text`. Pure and synchronous; safe to run on every parse. Proposals may overlap freely
|
|
@@ -566,18 +621,22 @@ function proposeNumericReadings(
|
|
|
566
621
|
* QUOTED_SPANs is NOT suppressed (quotes wrap names, not asides).
|
|
567
622
|
*/
|
|
568
623
|
export function proposeSpans(text: string, lexicon: SpanProposerLexicon = EMPTY_SPAN_PROPOSER_LEXICON): ProposedSpan[] {
|
|
569
|
-
if (text.length
|
|
624
|
+
if (!text.length) return []
|
|
570
625
|
let groupCounter = 0
|
|
571
626
|
const nextGroup = (): number => groupCounter++
|
|
572
627
|
|
|
573
628
|
const paired = proposePairedDelimiters(text, lexicon)
|
|
574
629
|
const tokens = tokenize(text)
|
|
630
|
+
|
|
575
631
|
const inner = [
|
|
576
632
|
...proposeDesignatorPhrases(text, tokens, lexicon),
|
|
577
633
|
...proposeNumericReadings(tokens, lexicon, nextGroup),
|
|
578
634
|
]
|
|
579
635
|
|
|
580
|
-
const confidentAnnotations = paired.filter(
|
|
636
|
+
const confidentAnnotations = paired.filter(
|
|
637
|
+
(p) => p.kind === "ANNOTATION_SPAN" && p.confidence >= CONFIDENT_ANNOTATION_MIN
|
|
638
|
+
)
|
|
639
|
+
|
|
581
640
|
const survivors = inner.filter((p) => !confidentAnnotations.some((a) => p.start >= a.start && p.end <= a.end))
|
|
582
641
|
|
|
583
642
|
const out = [...paired, ...survivors]
|
|
@@ -585,3 +644,5 @@ export function proposeSpans(text: string, lexicon: SpanProposerLexicon = EMPTY_
|
|
|
585
644
|
|
|
586
645
|
return out
|
|
587
646
|
}
|
|
647
|
+
|
|
648
|
+
//#endregion
|
package/pipeline/types.ts
CHANGED
|
@@ -19,7 +19,9 @@ import type { Section } from "../types/classifier.ts"
|
|
|
19
19
|
|
|
20
20
|
export type LocaleTag = string
|
|
21
21
|
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Optional user-location signal for Stage 6 resolver scoring.
|
|
24
|
+
*/
|
|
23
25
|
export type UserLocation = { lat: number; lon: number } | { country: string } | { region: string; country: string }
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -31,10 +33,18 @@ export type UserLocation = { lat: number; lon: number } | { country: string } |
|
|
|
31
33
|
*/
|
|
32
34
|
export type PlacetypePairPassthrough = object | false
|
|
33
35
|
|
|
34
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Common opts threaded through every stage.
|
|
38
|
+
*/
|
|
35
39
|
export interface PipelineOpts {
|
|
36
40
|
locale?: LocaleTag
|
|
37
41
|
userLocation?: UserLocation
|
|
42
|
+
/**
|
|
43
|
+
* Explicit input register (operator Decision A / GTM B10 — see {@link InputMode}). When unset the pipeline derives it
|
|
44
|
+
* from the kind classifier's verdict via {@link deriveInputMode}. Endpoint wrappers set their register default here
|
|
45
|
+
* (validation/batch → `"formatted"`, autocomplete/demo search → `"fragmented"`).
|
|
46
|
+
*/
|
|
47
|
+
inputMode?: InputMode
|
|
38
48
|
/**
|
|
39
49
|
* Disable fast-path shortcuts; always run the full pipeline. Does NOT bypass the poi_query branch — that's a routing
|
|
40
50
|
* decision (the kind classifier + `stages.poiIntent`), not a fast-path shortcut, so a `poi_query`-classified input
|
|
@@ -54,7 +64,9 @@ export interface PipelineOpts {
|
|
|
54
64
|
* docs/articles/evals/experiments/2026-06-14-reconcile-retirement.md.
|
|
55
65
|
*/
|
|
56
66
|
jointReconcile?: boolean
|
|
57
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Hard cap on lookups the resolver may issue; passed through.
|
|
69
|
+
*/
|
|
58
70
|
resolveOpts?: ResolveOpts
|
|
59
71
|
/**
|
|
60
72
|
* #690: title-case detected all-caps ASCII input before the Stage 3 classifier (helps on all-caps registry/compliance
|
|
@@ -84,23 +96,28 @@ export interface PipelineOpts {
|
|
|
84
96
|
*/
|
|
85
97
|
hardPlaceCountry?: boolean
|
|
86
98
|
/**
|
|
87
|
-
* #743/#194: override the coverage safelist that gates {@link hardPlaceCountry}. Undefined → the
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
99
|
+
* #743/#194: override the coverage safelist that gates {@link hardPlaceCountry}. Undefined → the loaded gazetteer
|
|
100
|
+
* artifact's own coverage manifest (`resolver.artifactCoverage.hardCountrySafelist`) when it carries one, else the
|
|
101
|
+
* built-in `HARD_PLACE_COUNTRY_SAFELIST` fallback (byte-identical for artifacts predating the manifest). Supply a set
|
|
102
|
+
* to test/measure a different coverage frontier — the resolver eval passes the full in-map country set to measure
|
|
103
|
+
* ungated hard-resolve-rates (which is how the production safelist is grown).
|
|
91
104
|
*/
|
|
92
105
|
hardCountrySafelist?: ReadonlySet<string>
|
|
93
106
|
signal?: AbortSignal
|
|
94
107
|
}
|
|
95
108
|
|
|
96
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Minimal structural shape `NormalizedInput` must satisfy. Compatible with @mailwoman/normalize.
|
|
111
|
+
*/
|
|
97
112
|
export interface NormalizedInputLite {
|
|
98
113
|
raw: string
|
|
99
114
|
normalized: string
|
|
100
115
|
appliedLocale?: string
|
|
101
116
|
}
|
|
102
117
|
|
|
103
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Minimal structural shape `QueryShape` must satisfy. Compatible with @mailwoman/query-shape.
|
|
120
|
+
*/
|
|
104
121
|
export interface QueryShapeLite {
|
|
105
122
|
knownFormats: ReadonlyArray<{
|
|
106
123
|
format: string
|
|
@@ -112,7 +129,9 @@ export interface QueryShapeLite {
|
|
|
112
129
|
totalLength?: number
|
|
113
130
|
}
|
|
114
131
|
|
|
115
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Detected (or asserted) locale + alternatives.
|
|
134
|
+
*/
|
|
116
135
|
export interface LocaleHint {
|
|
117
136
|
locale: LocaleTag
|
|
118
137
|
confidence: number
|
|
@@ -120,7 +139,9 @@ export interface LocaleHint {
|
|
|
120
139
|
source: "caller" | "detected" | "ensemble"
|
|
121
140
|
}
|
|
122
141
|
|
|
123
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Kind classifier output.
|
|
144
|
+
*/
|
|
124
145
|
export type QueryKind =
|
|
125
146
|
| "postcode_only"
|
|
126
147
|
| "locality_only"
|
|
@@ -137,6 +158,34 @@ export interface QueryKindResult {
|
|
|
137
158
|
alternatives: ReadonlyArray<{ kind: QueryKind; confidence: number }>
|
|
138
159
|
}
|
|
139
160
|
|
|
161
|
+
/**
|
|
162
|
+
* The input register (operator Decision A, 2026-07-28 — the Option-A evidence-bundle verdict): `fragmented` is the
|
|
163
|
+
* map-search register (a human typing "belleville" or "12 rue de la paix"); `formatted` is the validation/record
|
|
164
|
+
* register (a checkout form or CRM row submitting a full postal address). The evidence-bundle channels feed ONLY in
|
|
165
|
+
* fragmented mode — three training runs showed they lift the fragment register (admin-street homonym +0.765 lower+heal)
|
|
166
|
+
* while degrading full-address parses (the flip census, `.superpowers/sdd/progress.md` 2026-07-28). Explicitly settable
|
|
167
|
+
* on every surface (CLI/API); when unset, {@link deriveInputMode} maps the kind-classifier's verdict. Endpoint defaults
|
|
168
|
+
* (GTM B10): validation/batch/CSV → formatted; autocomplete/demo search → fragmented; plain parse → derived.
|
|
169
|
+
*/
|
|
170
|
+
export type InputMode = "fragmented" | "formatted"
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Map a {@link QueryKind} to its {@link InputMode} register. Multi-component postal specifications
|
|
174
|
+
* (`structured_address`/`po_box`/`intersection`) are the formatted register; single-thing lookups (postcode, locality,
|
|
175
|
+
* landmark, POI, vague) are fragments. NEVER keyed on case — lowercase is the primary user register (operator
|
|
176
|
+
* doctrine).
|
|
177
|
+
*/
|
|
178
|
+
export function deriveInputMode(kind: QueryKind): InputMode {
|
|
179
|
+
switch (kind) {
|
|
180
|
+
case "structured_address":
|
|
181
|
+
case "po_box":
|
|
182
|
+
case "intersection":
|
|
183
|
+
return "formatted"
|
|
184
|
+
default:
|
|
185
|
+
return "fragmented"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
140
189
|
/**
|
|
141
190
|
* The structured POI intent — the pluggable boundary between detection (kind classifier), the executors (Plan 3's
|
|
142
191
|
* poi.db SQL compiler), and the export formats (OverpassQL emitter). Category ids are `@mailwoman/poi-taxonomy` ids
|
|
@@ -148,18 +197,24 @@ export interface POIIntent {
|
|
|
148
197
|
| { kind: "category"; categoryID: string; matched: string }
|
|
149
198
|
| { kind: "brand"; name: string; wikidata?: string; matched: string }
|
|
150
199
|
| { kind: "name"; text: string }
|
|
151
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* Spatial anchor: the split-off remainder text and its parse, when the query carried one.
|
|
202
|
+
*/
|
|
152
203
|
anchor?: {
|
|
153
204
|
text?: string
|
|
154
205
|
tree?: AddressTree
|
|
155
|
-
/**
|
|
206
|
+
/**
|
|
207
|
+
* Caller-supplied bias point ("near me"); executors treat it as the anchor when no tree resolved.
|
|
208
|
+
*/
|
|
156
209
|
biasPoint?: { latitude: number; longitude: number }
|
|
157
210
|
radiusM?: number
|
|
158
211
|
}
|
|
159
212
|
limit?: number
|
|
160
213
|
}
|
|
161
214
|
|
|
162
|
-
/**
|
|
215
|
+
/**
|
|
216
|
+
* One executed POI search result (spec §3.4; produced by the executor, absent pre-execution).
|
|
217
|
+
*/
|
|
163
218
|
export interface POIResult {
|
|
164
219
|
name: string | null
|
|
165
220
|
categoryID: string | null
|
|
@@ -168,7 +223,9 @@ export interface POIResult {
|
|
|
168
223
|
longitude: number
|
|
169
224
|
country: string
|
|
170
225
|
confidence: number
|
|
171
|
-
/**
|
|
226
|
+
/**
|
|
227
|
+
* Overture GERS id — nullable METADATA ONLY, never a key (the #470 rule).
|
|
228
|
+
*/
|
|
172
229
|
gersID: string | null
|
|
173
230
|
/**
|
|
174
231
|
* Read-time WOF ancestry, deepest-first — the paid-down half of the poiQueryKind register row's debt. Attached by the
|
|
@@ -256,6 +313,11 @@ export interface FSTMatcherLike {
|
|
|
256
313
|
|
|
257
314
|
export interface ClassifierOpts {
|
|
258
315
|
queryShape?: QueryShapeLite
|
|
316
|
+
/**
|
|
317
|
+
* The input register (see {@link InputMode}). `formatted` runs the evidence-bundle channels deliberately OFF; the
|
|
318
|
+
* pipeline passes an explicit mode on every parse (caller override or {@link deriveInputMode} of the kind verdict).
|
|
319
|
+
*/
|
|
320
|
+
inputMode?: InputMode
|
|
259
321
|
fst?: FSTMatcherLike
|
|
260
322
|
fstBiasScale?: number
|
|
261
323
|
/**
|
|
@@ -265,9 +327,13 @@ export interface ClassifierOpts {
|
|
|
265
327
|
* `classifier.parse` for measured, opt-in use.
|
|
266
328
|
*/
|
|
267
329
|
fstStreetMorphology?: FSTMatcherLike
|
|
268
|
-
/**
|
|
330
|
+
/**
|
|
331
|
+
* Magnitude overrides for the morphology emission prior — the pipeline always passes the zeroed pair.
|
|
332
|
+
*/
|
|
269
333
|
fstStreetMorphologyOpts?: { biasScale?: number; dependentLocalityPenalty?: number }
|
|
270
|
-
/**
|
|
334
|
+
/**
|
|
335
|
+
* Run the deterministic postcode regex repair pass (v0.7 #35) on the decoded labels.
|
|
336
|
+
*/
|
|
271
337
|
postcodeRepair?: boolean
|
|
272
338
|
/**
|
|
273
339
|
* #690: title-case a detected all-caps ASCII input before the model (all-caps registry/compliance data is partly
|
|
@@ -368,11 +434,11 @@ export interface RuntimePipelineStages {
|
|
|
368
434
|
resolverBackend?: ResolverBackend
|
|
369
435
|
}
|
|
370
436
|
|
|
371
|
-
export
|
|
372
|
-
[stage: string]: number // ms
|
|
373
|
-
}
|
|
437
|
+
export type PipelineTiming = Record<string, number>
|
|
374
438
|
|
|
375
|
-
/**
|
|
439
|
+
/**
|
|
440
|
+
* Result of one `runPipeline` call.
|
|
441
|
+
*/
|
|
376
442
|
export interface PipelineResult {
|
|
377
443
|
input: string
|
|
378
444
|
normalized: NormalizedInputLite
|
|
@@ -386,9 +452,13 @@ export interface PipelineResult {
|
|
|
386
452
|
*/
|
|
387
453
|
phraseProposals: PhraseProposal[]
|
|
388
454
|
tree: AddressTree
|
|
389
|
-
/**
|
|
455
|
+
/**
|
|
456
|
+
* Present only when the poi-intent stage produced an outcome (path === "poi").
|
|
457
|
+
*/
|
|
390
458
|
poiIntent?: POIIntentOutcome
|
|
391
459
|
timing: PipelineTiming
|
|
392
|
-
/**
|
|
460
|
+
/**
|
|
461
|
+
* Which path the coordinator took. `"fast-path"` skipped stages 3-5; `"poi"` took the intent branch.
|
|
462
|
+
*/
|
|
393
463
|
path: "fast-path" | "full" | "poi"
|
|
394
464
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import type { Section } from "../types/classifier.ts"
|
|
20
|
-
import {
|
|
20
|
+
import type { ClassificationProposal, ClassifierContext, ProposalClassifier } from "../types/index.ts"
|
|
21
21
|
import type { PolicyRegistry } from "./policy.ts"
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -37,14 +37,15 @@ export async function collectProposals(
|
|
|
37
37
|
for (const classifier of classifiers) {
|
|
38
38
|
for (const section of sections) {
|
|
39
39
|
tasks.push(
|
|
40
|
-
classifier.classify(section, context).catch((
|
|
41
|
-
console.warn(`[proposal-collection] ${classifier.id} threw on section "${section.body}":`,
|
|
40
|
+
classifier.classify(section, context).catch((error) => {
|
|
41
|
+
console.warn(`[proposal-collection] ${classifier.id} threw on section "${section.body}":`, error)
|
|
42
42
|
|
|
43
43
|
return []
|
|
44
44
|
})
|
|
45
45
|
)
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
|
|
48
49
|
const results = await Promise.all(tasks)
|
|
49
50
|
|
|
50
51
|
return results.flat()
|
package/policy/registry.ts
CHANGED
|
@@ -42,17 +42,23 @@ export class InMemoryPolicyRegistry implements PolicyRegistry {
|
|
|
42
42
|
return registry
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Install a policy entry. Replaces any prior entry with the same key.
|
|
47
|
+
*/
|
|
46
48
|
set(policy: ClassifierPolicy): void {
|
|
47
49
|
this.#entries.set(policyKey(policy.component, policy.locale), policy)
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Remove a policy entry, if present.
|
|
54
|
+
*/
|
|
51
55
|
remove(component: ComponentTag, locale?: string): void {
|
|
52
56
|
this.#entries.delete(policyKey(component, locale))
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* All current entries, in insertion order.
|
|
61
|
+
*/
|
|
56
62
|
entries(): ClassifierPolicy[] {
|
|
57
63
|
return Array.from(this.#entries.values())
|
|
58
64
|
}
|
|
@@ -63,6 +69,7 @@ export class InMemoryPolicyRegistry implements PolicyRegistry {
|
|
|
63
69
|
|
|
64
70
|
if (localized) return localized
|
|
65
71
|
}
|
|
72
|
+
|
|
66
73
|
const global = this.#entries.get(policyKey(component, undefined))
|
|
67
74
|
|
|
68
75
|
if (global) return global
|
|
@@ -127,18 +134,21 @@ function applyPreferenceFilters(
|
|
|
127
134
|
|
|
128
135
|
if (!policy) {
|
|
129
136
|
out.push(...list)
|
|
137
|
+
|
|
130
138
|
continue
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
if (policy.mode === "neural_preferred") {
|
|
134
142
|
const hasNeural = list.some((p) => p.source === "neural")
|
|
135
143
|
out.push(...(hasNeural ? list.filter((p) => p.source !== "rule") : list))
|
|
144
|
+
|
|
136
145
|
continue
|
|
137
146
|
}
|
|
138
147
|
|
|
139
148
|
if (policy.mode === "rule_preferred") {
|
|
140
149
|
const hasRule = list.some((p) => p.source === "rule")
|
|
141
150
|
out.push(...(hasRule ? list.filter((p) => p.source !== "neural") : list))
|
|
151
|
+
|
|
142
152
|
continue
|
|
143
153
|
}
|
|
144
154
|
|