@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
package/resolver/index.ts
CHANGED
|
@@ -11,12 +11,22 @@
|
|
|
11
11
|
* `@mailwoman/codex`.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
export {
|
|
14
|
+
export {
|
|
15
|
+
DEFAULT_PLACETYPE_MAP,
|
|
16
|
+
PLACETYPE_FILTER_GROUPS,
|
|
17
|
+
expandPlacetypeFilter,
|
|
18
|
+
hardCountrySafelistFromCoverage,
|
|
19
|
+
isPlacetypeFallback,
|
|
20
|
+
} from "./types.ts"
|
|
21
|
+
|
|
15
22
|
export type {
|
|
16
23
|
AddressPointHit,
|
|
17
24
|
AddressPointLookup,
|
|
18
25
|
Ancestor,
|
|
19
26
|
CoincidentLocality,
|
|
27
|
+
CountryBBoxFact,
|
|
28
|
+
CountryCoverageFact,
|
|
29
|
+
GazetteerArtifactCoverage,
|
|
20
30
|
InterpolatedPointHit,
|
|
21
31
|
InterpolationLookup,
|
|
22
32
|
PlacetypeMap,
|
package/resolver/types.ts
CHANGED
|
@@ -21,19 +21,33 @@ import type { AddressTree, ComponentTag } from "../decoder/types.ts"
|
|
|
21
21
|
* `ResolvedPlace` is expected.
|
|
22
22
|
*/
|
|
23
23
|
export interface ResolvedPlace {
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Resolver-specific place identifier (e.g. WOF id).
|
|
26
|
+
*/
|
|
25
27
|
id: number | string
|
|
26
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Canonical name of the place as the resolver knows it.
|
|
30
|
+
*/
|
|
27
31
|
name: string
|
|
28
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Resolver's placetype taxonomy label (e.g. WOF's `country` / `region` / `locality`).
|
|
34
|
+
*/
|
|
29
35
|
placetype: string
|
|
30
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* ISO 3166-1 alpha-2 country code, if known.
|
|
38
|
+
*/
|
|
31
39
|
country: string
|
|
32
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Centroid latitude in WGS-84 decimal degrees.
|
|
42
|
+
*/
|
|
33
43
|
lat: number
|
|
34
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Centroid longitude in WGS-84 decimal degrees.
|
|
46
|
+
*/
|
|
35
47
|
lon: number
|
|
36
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Parent place id within the resolver's hierarchy, if any.
|
|
50
|
+
*/
|
|
37
51
|
parent_id?: number | string
|
|
38
52
|
/**
|
|
39
53
|
* Resolver-defined ranking score. Higher = better fit for the query. Scale is implementation- defined; callers should
|
|
@@ -83,6 +97,99 @@ export interface ResolvedPlace {
|
|
|
83
97
|
* Structurally compatible with `PlaceLookup` from `@mailwoman/core/resolver-wof-sqlite` so the latter satisfies this
|
|
84
98
|
* interface without an adapter shim.
|
|
85
99
|
*/
|
|
100
|
+
/**
|
|
101
|
+
* One country's measured hard-filter coverage fact, as recorded at a promote gate. Facts about the gazetteer artifact
|
|
102
|
+
* live IN the artifact (the `country_coverage` table the gazetteer build emits) — code constants are only the fallback
|
|
103
|
+
* for artifacts that predate the manifest.
|
|
104
|
+
*
|
|
105
|
+
* Meaning-of-zero discipline: a country ABSENT from the coverage map was never measured — never "measured and failed".
|
|
106
|
+
* A measured-and-failed country is PRESENT with `hardFilterSafe: false` (e.g. FI at 69.5% hard-resolve), so the
|
|
107
|
+
* negative result is a first-class record, distinguishable from ignorance.
|
|
108
|
+
*/
|
|
109
|
+
export interface CountryCoverageFact {
|
|
110
|
+
/**
|
|
111
|
+
* ISO 3166-1 alpha-2, uppercase.
|
|
112
|
+
*/
|
|
113
|
+
country: string
|
|
114
|
+
/**
|
|
115
|
+
* The promote-gate VERDICT: hard-filtering this country is a pure win (a hard-filter miss is almost always a genuine
|
|
116
|
+
* non-match, not a coverage gap). Stored as a verdict — not re-derived from `hardResolveRate` at read time — because
|
|
117
|
+
* the gate is a judgment over a panel, not a pure rate function (CA cleared at the #928 promote on the
|
|
118
|
+
* postcode-format-prior rationale despite a sub-95% panel resolve rate).
|
|
119
|
+
*/
|
|
120
|
+
hardFilterSafe: boolean
|
|
121
|
+
/**
|
|
122
|
+
* Measured hard-resolve rate (0..1) on the panel named in `source`, when the receipt recorded one.
|
|
123
|
+
*/
|
|
124
|
+
hardResolveRate?: number
|
|
125
|
+
/**
|
|
126
|
+
* Panel size behind `hardResolveRate`, when recorded.
|
|
127
|
+
*/
|
|
128
|
+
sampleSize?: number
|
|
129
|
+
/**
|
|
130
|
+
* ISO-8601 date of the measurement / promote gate.
|
|
131
|
+
*/
|
|
132
|
+
measuredAt: string
|
|
133
|
+
/**
|
|
134
|
+
* The receipt: which panel/gate produced this row (issue + date, human-readable).
|
|
135
|
+
*/
|
|
136
|
+
source: string
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* One country's coarse guard-B bounding box, as carried by the gazetteer artifact's `country_bbox` table.
|
|
141
|
+
*/
|
|
142
|
+
export interface CountryBBoxFact {
|
|
143
|
+
/**
|
|
144
|
+
* ISO 3166-1 alpha-2, uppercase.
|
|
145
|
+
*/
|
|
146
|
+
country: string
|
|
147
|
+
latMin: number
|
|
148
|
+
latMax: number
|
|
149
|
+
lonMin: number
|
|
150
|
+
lonMax: number
|
|
151
|
+
/**
|
|
152
|
+
* Provenance of the box (harness + date).
|
|
153
|
+
*/
|
|
154
|
+
source: string
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Facts a loaded gazetteer artifact declares about itself — read from the artifact's own manifest tables at open time,
|
|
159
|
+
* carried on the {@link ResolverBackend}/{@link Resolver} handle so consumers read the facts from the artifact they are
|
|
160
|
+
* actually resolving against. `undefined` on the handle = the artifact predates the manifest → consumers fall back to
|
|
161
|
+
* the code constants (byte-identical legacy behavior).
|
|
162
|
+
*/
|
|
163
|
+
export interface GazetteerArtifactCoverage {
|
|
164
|
+
/**
|
|
165
|
+
* Country → measured coverage fact. ABSENCE = never measured (meaning-of-zero), never "failed".
|
|
166
|
+
*/
|
|
167
|
+
countryCoverage: ReadonlyMap<string, CountryCoverageFact>
|
|
168
|
+
/**
|
|
169
|
+
* Country → guard-B bbox. ABSENCE = no box → the plausibility guard fails open for that country.
|
|
170
|
+
*/
|
|
171
|
+
countryBBoxes: ReadonlyMap<string, CountryBBoxFact>
|
|
172
|
+
/**
|
|
173
|
+
* Derived at load: the countries whose fact says `hardFilterSafe` — the artifact's hard-country safelist.
|
|
174
|
+
*/
|
|
175
|
+
hardCountrySafelist: ReadonlySet<string>
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Derive the hard-country safelist from coverage facts — the ONE derivation both the reader and the build share.
|
|
180
|
+
*/
|
|
181
|
+
export function hardCountrySafelistFromCoverage(facts: Iterable<CountryCoverageFact>): ReadonlySet<string> {
|
|
182
|
+
const out = new Set<string>()
|
|
183
|
+
|
|
184
|
+
for (const fact of facts) {
|
|
185
|
+
if (fact.hardFilterSafe) {
|
|
186
|
+
out.add(fact.country.toUpperCase())
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return out
|
|
191
|
+
}
|
|
192
|
+
|
|
86
193
|
export interface ResolverBackend {
|
|
87
194
|
findPlace(query: {
|
|
88
195
|
text: string
|
|
@@ -95,7 +202,9 @@ export interface ResolverBackend {
|
|
|
95
202
|
* recovering localities the name-match alone misses. Backends without postcode support ignore it.
|
|
96
203
|
*/
|
|
97
204
|
postcode?: string
|
|
98
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* Proximity-bias points — a SOFT prominence re-rank; backends without support ignore it.
|
|
207
|
+
*/
|
|
99
208
|
bias?: Array<{ lat: number; lon: number; weight?: number }>
|
|
100
209
|
limit?: number
|
|
101
210
|
}): Promise<ResolvedPlace[]>
|
|
@@ -113,9 +222,16 @@ export interface ResolverBackend {
|
|
|
113
222
|
* `ancestors` table.
|
|
114
223
|
*/
|
|
115
224
|
ancestors?(id: number | string): Ancestor[]
|
|
225
|
+
/**
|
|
226
|
+
* Facts the loaded gazetteer artifact declares about itself (its coverage-manifest tables, read at open). OPTIONAL —
|
|
227
|
+
* absent when the artifact predates the manifest, and consumers fall back to the code constants.
|
|
228
|
+
*/
|
|
229
|
+
artifactCoverage?: GazetteerArtifactCoverage
|
|
116
230
|
}
|
|
117
231
|
|
|
118
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* One link in a resolved place's containment lineage ({@link ResolverBackend.ancestors}, #404).
|
|
234
|
+
*/
|
|
119
235
|
export interface Ancestor {
|
|
120
236
|
id: number | string
|
|
121
237
|
placetype: string
|
|
@@ -131,9 +247,13 @@ export interface CoincidentLocality extends ResolvedPlace {
|
|
|
131
247
|
* `city-state` / `capital-seat` / `consolidated-county` — surfaced as `metadata.relationship_type`.
|
|
132
248
|
*/
|
|
133
249
|
relationshipType: string
|
|
134
|
-
/**
|
|
250
|
+
/**
|
|
251
|
+
* Locality population (0 when unknown) — the PRIMARY disambiguator when an admin has several.
|
|
252
|
+
*/
|
|
135
253
|
population: number
|
|
136
|
-
/**
|
|
254
|
+
/**
|
|
255
|
+
* Centroid distance (km) admin↔locality from the relation — the population tiebreak.
|
|
256
|
+
*/
|
|
137
257
|
distanceKm: number
|
|
138
258
|
}
|
|
139
259
|
|
|
@@ -147,9 +267,13 @@ export interface CoincidentLocality extends ResolvedPlace {
|
|
|
147
267
|
export interface AddressPointHit {
|
|
148
268
|
lat: number
|
|
149
269
|
lon: number
|
|
150
|
-
/**
|
|
270
|
+
/**
|
|
271
|
+
* Provenance, e.g. `"overture:NAD"`.
|
|
272
|
+
*/
|
|
151
273
|
source: string
|
|
152
|
-
/**
|
|
274
|
+
/**
|
|
275
|
+
* Pinned data release the point came from, e.g. `"2026-05-20.0"`.
|
|
276
|
+
*/
|
|
153
277
|
release: string
|
|
154
278
|
}
|
|
155
279
|
|
|
@@ -187,11 +311,17 @@ export interface InterpolatedPointHit {
|
|
|
187
311
|
* `address_point` = bracketed between real neighbor points; `tiger_range` = linear within a segment range.
|
|
188
312
|
*/
|
|
189
313
|
method: "address_point" | "tiger_range"
|
|
190
|
-
/**
|
|
314
|
+
/**
|
|
315
|
+
* False when only the opposite side's range contained the number (right block, wrong side).
|
|
316
|
+
*/
|
|
191
317
|
parityMatched?: boolean
|
|
192
|
-
/**
|
|
318
|
+
/**
|
|
319
|
+
* `both` = neighbors bracketed it; `single` = one-sided extrapolation (larger uncertainty).
|
|
320
|
+
*/
|
|
193
321
|
bracket?: "both" | "single"
|
|
194
|
-
/**
|
|
322
|
+
/**
|
|
323
|
+
* Honest uncertainty radius in METERS (half the matched segment length).
|
|
324
|
+
*/
|
|
195
325
|
uncertaintyM: number
|
|
196
326
|
source: string
|
|
197
327
|
release: string
|
|
@@ -204,6 +334,17 @@ export interface InterpolatedPointHit {
|
|
|
204
334
|
*/
|
|
205
335
|
export interface InterpolationLookup {
|
|
206
336
|
find(query: { street: string; number: string; postcode?: string }): InterpolatedPointHit | null
|
|
337
|
+
/**
|
|
338
|
+
* The ARTIFACT's own conformal radius multiplier for `uncertaintyM` (#374), read from the shard's
|
|
339
|
+
* `interp_calibration` metadata table at open time (the pair-index δ/transitionBeta header precedent): the multiplier
|
|
340
|
+
* is a property of the calibration set the artifact was built against, so it ships in the artifact, not in caller
|
|
341
|
+
* code. The resolver applies it as the DEFAULT whenever `ResolveOpts.interpolationRadiusCalibration` is absent.
|
|
342
|
+
* `undefined` (or an implementation without the property) = the artifact carries none — shards built before the
|
|
343
|
+
* metadata table existed; behavior is then exactly the pre-artifact ladder (caller-supplied factor or raw).
|
|
344
|
+
* Implementations must read this at OPEN time (constructor/factory), never per-lookup — `find()` is synchronous by
|
|
345
|
+
* design.
|
|
346
|
+
*/
|
|
347
|
+
readonly radiusCalibration?: number
|
|
207
348
|
}
|
|
208
349
|
|
|
209
350
|
/**
|
|
@@ -216,7 +357,9 @@ export interface InterpolationLookup {
|
|
|
216
357
|
export interface StreetCentroidHit {
|
|
217
358
|
lat: number
|
|
218
359
|
lon: number
|
|
219
|
-
/**
|
|
360
|
+
/**
|
|
361
|
+
* Honest coarse radius in METERS — half the street's bounding-box diagonal.
|
|
362
|
+
*/
|
|
220
363
|
uncertaintyM: number
|
|
221
364
|
source: string
|
|
222
365
|
release: string
|
|
@@ -350,14 +493,20 @@ export interface ResolveOpts {
|
|
|
350
493
|
*/
|
|
351
494
|
interpolation?: InterpolationLookup
|
|
352
495
|
/**
|
|
353
|
-
* Conformal calibration multiplier for the interpolation tier's `uncertainty_m` (#374). The raw radius is
|
|
354
|
-
* matched TIGER segment length — an honest-but-TIGHT prior: a split-conformal calibration on 1562
|
|
355
|
-
* interp hits (2026-06-14) found it covers only ~72% of true errors, and that multiplying by **Q̂ ≈
|
|
356
|
-
* calibrated 90% bound (91.5% empirical). When
|
|
357
|
-
* and preserves the raw value under `uncertainty_raw_m`.
|
|
358
|
-
*
|
|
359
|
-
*
|
|
496
|
+
* Conformal calibration multiplier OVERRIDE for the interpolation tier's `uncertainty_m` (#374). The raw radius is
|
|
497
|
+
* half the matched TIGER segment length — an honest-but-TIGHT prior: a split-conformal calibration on 1562
|
|
498
|
+
* Travis-County interp hits (2026-06-14) found it covers only ~72% of true errors, and that multiplying by **Q̂ ≈
|
|
499
|
+
* 1.70** yields a calibrated 90% bound (91.5% empirical). When a factor applies, `applyInterpolation` reports
|
|
500
|
+
* `uncertainty_m = round(raw × factor)` and preserves the raw value under `uncertainty_raw_m`.
|
|
501
|
+
*
|
|
502
|
+
* The factor is a property of the CALIBRATION SET the artifact was built against, so it ships IN the artifact:
|
|
503
|
+
* {@link InterpolationLookup.radiusCalibration} (the shard's `interp_calibration` metadata table, read at open time)
|
|
504
|
+
* is the default whenever this option is absent. Absent + artifact-silent = raw heuristic (byte-stable — shards
|
|
505
|
+
* predating the metadata table; production callers fall back to their in-code per-region table for those). Report:
|
|
360
506
|
* docs/articles/evals/calibration/2026-06-14-interp-radius-calibration.md.
|
|
507
|
+
*
|
|
508
|
+
* @internal Instrument knob (D3) — measurement decomposition + legacy-shard fallback only; the artifact header IS
|
|
509
|
+
* the shipped calibration. Set it only to override the artifact's value.
|
|
361
510
|
*/
|
|
362
511
|
interpolationRadiusCalibration?: number
|
|
363
512
|
/**
|
|
@@ -450,7 +599,9 @@ export interface ResolveOpts {
|
|
|
450
599
|
*/
|
|
451
600
|
adminCoherence?: boolean
|
|
452
601
|
hierarchyCompletion?: boolean
|
|
453
|
-
/**
|
|
602
|
+
/**
|
|
603
|
+
* @deprecated Renamed to {@link hierarchyCompletion} (#405 generalized #387). Still honored.
|
|
604
|
+
*/
|
|
454
605
|
cityStateFallback?: boolean
|
|
455
606
|
/**
|
|
456
607
|
* Attach each resolved node's ancestor lineage (#404) — the containment chain (county → region → country) the
|
|
@@ -476,6 +627,10 @@ export interface ResolveOpts {
|
|
|
476
627
|
*/
|
|
477
628
|
export type PlacetypeMap = Partial<Record<ComponentTag, string>>
|
|
478
629
|
|
|
630
|
+
/**
|
|
631
|
+
* Placetype equivalences applied when a backend does not supply its own. A `locality` query must also reach `borough`
|
|
632
|
+
* and `localadmin` rows — Brooklyn is a borough, and a strict filter made it unreachable.
|
|
633
|
+
*/
|
|
479
634
|
export const DEFAULT_PLACETYPE_MAP: PlacetypeMap = {
|
|
480
635
|
country: "country",
|
|
481
636
|
region: "region",
|
|
@@ -529,6 +684,7 @@ export const PLACETYPE_FILTER_GROUPS: Readonly<Record<string, readonly string[]>
|
|
|
529
684
|
export function expandPlacetypeFilter(placetypes: null): null
|
|
530
685
|
export function expandPlacetypeFilter(placetypes: readonly string[]): string[]
|
|
531
686
|
export function expandPlacetypeFilter(placetypes: readonly string[] | null): string[] | null
|
|
687
|
+
|
|
532
688
|
export function expandPlacetypeFilter(placetypes: readonly string[] | null): string[] | null {
|
|
533
689
|
if (!placetypes) return null
|
|
534
690
|
const out: string[] = []
|
|
@@ -581,4 +737,10 @@ export function isPlacetypeFallback(requestedPlacetype: string, candidatePlacety
|
|
|
581
737
|
*/
|
|
582
738
|
export interface Resolver {
|
|
583
739
|
resolveTree(tree: AddressTree, opts?: ResolveOpts): Promise<AddressTree>
|
|
740
|
+
/**
|
|
741
|
+
* Facts the loaded gazetteer artifact declares about itself, passed through from the {@link ResolverBackend} so
|
|
742
|
+
* pipeline-level consumers (the hard-country coverage gate, guard-B plausibility) read them from the handle they
|
|
743
|
+
* already hold. Absent = artifact predates the manifest → code-constant fallback.
|
|
744
|
+
*/
|
|
745
|
+
artifactCoverage?: GazetteerArtifactCoverage
|
|
584
746
|
}
|
package/resources/LocaleIndex.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { TextNormalizer } from "../tokenization/normalizer.ts"
|
|
7
|
+
import type { TextNormalizer } from "../tokenization/normalizer.ts"
|
|
8
8
|
import type { Displayable } from "./debugging.ts"
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -49,7 +49,7 @@ export class LocaleIndex<LanguageCodes extends string> extends Map<string, Set<L
|
|
|
49
49
|
* @param languageCodes The language codes to associate with the placename.
|
|
50
50
|
*/
|
|
51
51
|
public add(placename: string, ...languageCodes: LanguageCodes[]): void {
|
|
52
|
-
if (languageCodes.length
|
|
52
|
+
if (!languageCodes.length) {
|
|
53
53
|
throw new Error(`At least one language code must be provided for "${placename}".`)
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
export type DisposableLike = Disposable | AsyncDisposable
|
|
11
11
|
|
|
12
12
|
export type ResourceConstructor<K extends PropertyKey, R extends DisposableLike> = new (key: K) => R
|
|
13
|
+
|
|
13
14
|
export type ResourceFactory<K extends PropertyKey, R extends DisposableLike> = (key: K) => R | Promise<R>
|
|
14
15
|
|
|
15
16
|
export type ResourceFactoryLike<K extends PropertyKey = PropertyKey, R extends DisposableLike = DisposableLike> =
|
|
@@ -58,7 +59,7 @@ export class ResourceMapCache<
|
|
|
58
59
|
/**
|
|
59
60
|
* The human-readable name of the resource.
|
|
60
61
|
*/
|
|
61
|
-
public displayName
|
|
62
|
+
public displayName = "ResourceMapCache"
|
|
62
63
|
|
|
63
64
|
protected readonly factoryLike: F
|
|
64
65
|
|
|
@@ -115,7 +116,7 @@ export class ResourceMapCache<
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
public async [Symbol.asyncDispose]() {
|
|
118
|
-
const resourceKeys = Array.from(super.keys()).
|
|
119
|
+
const resourceKeys = Array.from(super.keys()).toReversed()
|
|
119
120
|
|
|
120
121
|
for (const resourceKey of resourceKeys) {
|
|
121
122
|
this.close(resourceKey)
|
package/resources/collections.ts
CHANGED
|
@@ -27,6 +27,7 @@ export async function* takeInParallel<T, C extends (entry: T) => Promise<unknown
|
|
|
27
27
|
|
|
28
28
|
let iterationResult = await iterator.next()
|
|
29
29
|
|
|
30
|
+
// oxlint-disable-next-line eslint/no-unmodified-loop-condition -- `abortSignal.aborted` is flipped by the controller, not by this loop
|
|
30
31
|
while ((!iterationResult.done || results.size) && !abortSignal?.aborted) {
|
|
31
32
|
for (const [key, result] of results) {
|
|
32
33
|
yield result
|
|
@@ -36,6 +37,7 @@ export async function* takeInParallel<T, C extends (entry: T) => Promise<unknown
|
|
|
36
37
|
|
|
37
38
|
if (runningTasks.size >= batchSize) {
|
|
38
39
|
await Promise.race(runningTasks.values())
|
|
40
|
+
|
|
39
41
|
continue
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -47,6 +49,7 @@ export async function* takeInParallel<T, C extends (entry: T) => Promise<unknown
|
|
|
47
49
|
|
|
48
50
|
const entry = iterationResult.value
|
|
49
51
|
|
|
52
|
+
// oxlint-disable-next-line promise/always-return -- the handle tracks completion, not a value
|
|
50
53
|
const futureResult = callback(entry).then((result) => {
|
|
51
54
|
runningTasks.delete(entry)
|
|
52
55
|
|
|
@@ -87,7 +90,7 @@ export async function* takeAsync<T>(collection: AsyncIterable<T>, batchSize: num
|
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
if (buffer.length
|
|
93
|
+
if (buffer.length) {
|
|
91
94
|
yield buffer
|
|
92
95
|
}
|
|
93
96
|
}
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export * from "./types.gen.ts"
|
|
8
7
|
import { Alpha2LabelMap, Alpha2LanguageCode, Alpha3bLabelMap, type Alpha3bLanguageCode } from "./types.gen.ts"
|
|
9
8
|
|
|
9
|
+
export * from "./types.gen.ts"
|
|
10
|
+
|
|
10
11
|
/**
|
|
11
12
|
* Prefixed languages are those which use a street prefix instead of a suffix.
|
|
12
13
|
*/
|
package/resources/libpostal.ts
CHANGED
|
@@ -8,9 +8,9 @@ import { readdir } from "node:fs/promises"
|
|
|
8
8
|
import { availableParallelism } from "node:os"
|
|
9
9
|
|
|
10
10
|
import { tryStat } from "@mailwoman/core/fs"
|
|
11
|
-
import { Alpha2LanguageCode } from "@mailwoman/core/resources/languages"
|
|
11
|
+
import type { Alpha2LanguageCode } from "@mailwoman/core/resources/languages"
|
|
12
12
|
import { TextNormalizer, type TextNormalizerInit } from "@mailwoman/core/tokenization"
|
|
13
|
-
import { PathBuilder } from "path-ts"
|
|
13
|
+
import type { PathBuilder } from "path-ts"
|
|
14
14
|
import pluralize from "pluralize"
|
|
15
15
|
import { TextSpliterator } from "spliterator"
|
|
16
16
|
|
|
@@ -94,6 +94,7 @@ export async function prepareLocaleIndex(
|
|
|
94
94
|
options?: LibPostalNormalizerInit
|
|
95
95
|
): Promise<LocaleIndex<LibPostalLanguageCode>> {
|
|
96
96
|
const normalizer = new TextNormalizer(options)
|
|
97
|
+
|
|
97
98
|
const index = new LocaleIndex<LibPostalLanguageCode>([], {
|
|
98
99
|
displayName: "libpostal",
|
|
99
100
|
normalizer,
|
|
@@ -107,6 +108,7 @@ export async function prepareLocaleIndex(
|
|
|
107
108
|
|
|
108
109
|
for await (const batch of fileEntries) {
|
|
109
110
|
await Promise.all(
|
|
111
|
+
// oxlint-disable-next-line no-loop-func -- the binding is per-iteration (for-of/for-await) and the batch is awaited before the next
|
|
110
112
|
batch.map(async ({ filePath, languageCode }) => {
|
|
111
113
|
const lines = TextSpliterator.fromAsync(filePath)
|
|
112
114
|
|
|
@@ -127,6 +129,7 @@ export async function prepareLocaleIndex(
|
|
|
127
129
|
|
|
128
130
|
for await (const batch of internalFileEntries) {
|
|
129
131
|
await Promise.all(
|
|
132
|
+
// oxlint-disable-next-line no-loop-func -- the binding is per-iteration (for-of/for-await) and the batch is awaited before the next
|
|
130
133
|
batch.map(async ({ filePath, languageCode }) => {
|
|
131
134
|
const lines = TextSpliterator.fromAsync(filePath)
|
|
132
135
|
|
|
@@ -155,7 +158,7 @@ export async function prepareLocaleIndex(
|
|
|
155
158
|
)
|
|
156
159
|
}
|
|
157
160
|
|
|
158
|
-
if (index.size
|
|
161
|
+
if (!index.size && !inserted) {
|
|
159
162
|
throw new Error(
|
|
160
163
|
`No index matches found for ${filename} in ${libPostalDataDirectory} for languages ${languageCodes}`
|
|
161
164
|
)
|
package/resources/set.ts
CHANGED
|
@@ -29,7 +29,7 @@ export class Sequence<T extends WeakKey> extends Set<T> {
|
|
|
29
29
|
super(nodes)
|
|
30
30
|
|
|
31
31
|
this.#first = nodes[0] ?? null
|
|
32
|
-
this.#last = nodes
|
|
32
|
+
this.#last = nodes.at(-1) ?? null
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -49,7 +49,7 @@ export class Sequence<T extends WeakKey> extends Set<T> {
|
|
|
49
49
|
if (!nodes.length) return this
|
|
50
50
|
|
|
51
51
|
for (const node of nodes) {
|
|
52
|
-
if (
|
|
52
|
+
if (node === undefined || node === null) {
|
|
53
53
|
throw new Error("Attempted to add an undefined or null node to a sequence.")
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -60,7 +60,7 @@ export class Sequence<T extends WeakKey> extends Set<T> {
|
|
|
60
60
|
this.#first = nodes[0]!
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
this.#last = nodes
|
|
63
|
+
this.#last = nodes.at(-1)!
|
|
64
64
|
|
|
65
65
|
return this
|
|
66
66
|
}
|
|
@@ -69,7 +69,7 @@ export class Sequence<T extends WeakKey> extends Set<T> {
|
|
|
69
69
|
* Delete a node from the sequence.
|
|
70
70
|
*/
|
|
71
71
|
public override delete(node: T): boolean {
|
|
72
|
-
if (
|
|
72
|
+
if (node === undefined || node === null) {
|
|
73
73
|
throw new Error("Attempted to delete an undefined or null node from a sequence.")
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -77,7 +77,7 @@ export class Sequence<T extends WeakKey> extends Set<T> {
|
|
|
77
77
|
|
|
78
78
|
if (!deleted) return false
|
|
79
79
|
|
|
80
|
-
if (this.size
|
|
80
|
+
if (!this.size) {
|
|
81
81
|
this.#first = null
|
|
82
82
|
this.#last = null
|
|
83
83
|
} else if (this.#first === node) {
|
|
@@ -104,7 +104,7 @@ export class Sequence<T extends WeakKey> extends Set<T> {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
this.#first = currentEntries[0] ?? null
|
|
107
|
-
this.#last = currentEntries
|
|
107
|
+
this.#last = currentEntries.at(-1) ?? null
|
|
108
108
|
|
|
109
109
|
return this
|
|
110
110
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { mkdirSync } from "node:fs"
|
|
8
|
-
import { setTimeout } from "node:timers/promises"
|
|
9
8
|
|
|
10
9
|
import type { Alpha3bLanguageCode } from "@mailwoman/core/resources/languages"
|
|
11
10
|
import { dirname } from "path-ts"
|
|
@@ -13,6 +12,8 @@ import { dirname } from "path-ts"
|
|
|
13
12
|
import { PlacetypeDataSource, type PlacetypeDataSourceOptions } from "./PlacetypeDataSource.ts"
|
|
14
13
|
import type { WhosOnFirstPlacetype } from "./placetypes/definition.ts"
|
|
15
14
|
|
|
15
|
+
export { tryWithBackoff } from "./backoff.ts"
|
|
16
|
+
|
|
16
17
|
export class DataSourceCache extends DisposableStack {
|
|
17
18
|
#placetypeToLanguage = new Map<WhosOnFirstPlacetype, Map<Alpha3bLanguageCode, PlacetypeDataSource>>()
|
|
18
19
|
|
|
@@ -47,26 +48,3 @@ export class DataSourceCache extends DisposableStack {
|
|
|
47
48
|
return dataSource
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Given a callback, attempt to run it up to `attempts` times.
|
|
53
|
-
*/
|
|
54
|
-
export async function tryWithBackoff<T>(attempts: number, callback: () => T): Promise<T> {
|
|
55
|
-
let lastError: unknown
|
|
56
|
-
|
|
57
|
-
for (let i = 0; i < attempts; i++) {
|
|
58
|
-
try {
|
|
59
|
-
const result = await callback()
|
|
60
|
-
|
|
61
|
-
return result
|
|
62
|
-
} catch (error) {
|
|
63
|
-
lastError = error
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// We try to avoid contention by giving a pause between attempts.
|
|
67
|
-
const delay = Math.floor(Math.random() * 1000) + 1000 * attempts
|
|
68
|
-
await setTimeout(delay)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
throw lastError
|
|
72
|
-
}
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
import { DatabaseSync, type DatabaseSyncOptions, type SQLInputValue } from "node:sqlite"
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
Alpha2LanguageCode,
|
|
10
|
+
type Alpha2LanguageCode,
|
|
11
11
|
type Alpha3bLanguageCode,
|
|
12
12
|
Alpha3bToAlpha2,
|
|
13
13
|
isAlpha3bLanguageCode,
|
|
14
14
|
} from "@mailwoman/core/resources/languages"
|
|
15
15
|
import { PathBuilder, type PathBuilderLike } from "path-ts"
|
|
16
16
|
|
|
17
|
-
import { tryWithBackoff } from "./
|
|
17
|
+
import { tryWithBackoff } from "./backoff.ts"
|
|
18
18
|
import type { WhosOnFirstPlacetype } from "./placetypes/definition.ts"
|
|
19
19
|
|
|
20
20
|
export interface PlacetypeDataSourceOptions<
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file Retry-with-backoff helper for the Who's On First data sources.
|
|
6
|
+
*
|
|
7
|
+
* This lives apart from `DataSourceCache` because both that module and `PlacetypeDataSource` need
|
|
8
|
+
* it, and each already imports the other — putting it in either one closes an import cycle.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { setTimeout } from "node:timers/promises"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Given a callback, attempt to run it up to `attempts` times.
|
|
15
|
+
*
|
|
16
|
+
* @param attempts Maximum number of tries before the last error is rethrown.
|
|
17
|
+
* @param callback The operation to attempt.
|
|
18
|
+
*
|
|
19
|
+
* @returns The callback's result from the first successful attempt.
|
|
20
|
+
*/
|
|
21
|
+
export async function tryWithBackoff<T>(attempts: number, callback: () => T): Promise<T> {
|
|
22
|
+
let lastError: unknown
|
|
23
|
+
|
|
24
|
+
for (let i = 0; i < attempts; i++) {
|
|
25
|
+
try {
|
|
26
|
+
const result = await callback()
|
|
27
|
+
|
|
28
|
+
return result
|
|
29
|
+
} catch (error) {
|
|
30
|
+
lastError = error
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// We try to avoid contention by giving a pause between attempts.
|
|
34
|
+
const delay = Math.floor(Math.random() * 1000) + 1000 * attempts
|
|
35
|
+
await setTimeout(delay)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
throw lastError
|
|
39
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { Alpha3bLanguageCode } from "@mailwoman/core/resources/languages"
|
|
8
|
-
import { TextNormalizer } from "@mailwoman/core/tokenization"
|
|
8
|
+
import type { TextNormalizer } from "@mailwoman/core/tokenization"
|
|
9
9
|
import FastGlob, { type Entry } from "fast-glob"
|
|
10
10
|
import { PathBuilder, type PathBuilderLike } from "path-ts"
|
|
11
11
|
import { TextSpliterator } from "spliterator"
|
|
@@ -21,6 +21,7 @@ import { parsePlacetypeSource } from "./placetypes/admin.ts"
|
|
|
21
21
|
* If a value is present in this index, it means that the value is a valid value in at least one language.
|
|
22
22
|
*/
|
|
23
23
|
export type WhosOnFirstLocaleIndex = Map<string, Set<string>>
|
|
24
|
+
|
|
24
25
|
export type ReadonlyWhosOnFirstIndex = ReadonlyMap<string, ReadonlySet<string>>
|
|
25
26
|
|
|
26
27
|
export interface WOFCacheOptions {
|