@mailwoman/resolver 6.3.0 → 6.4.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/out/index.d.ts +2 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/plausibility.d.ts +56 -0
- package/out/plausibility.d.ts.map +1 -0
- package/out/plausibility.js +82 -0
- package/out/plausibility.js.map +1 -0
- package/package.json +4 -4
package/out/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
export { RemoteResolver, serializableResolveOpts } from "./remote-resolver.ts";
|
|
14
14
|
export type { RemoteResolverOpts, ResolveTreeRequest, ResolveTreeResponse, SerializableResolveOpts, } from "./remote-resolver.ts";
|
|
15
15
|
export { createWOFResolver } from "./resolve.ts";
|
|
16
|
+
export { finestResolvedCoordinate, isImplausibleResolution } from "./plausibility.ts";
|
|
17
|
+
export type { PlausibilityVerdict, ResolvedCoordinate } from "./plausibility.ts";
|
|
16
18
|
export { findRescoreCandidate, hasResolvedPlace } from "./span-rescore.ts";
|
|
17
19
|
export type { RescoreCandidate, SpanRescoreOptions } from "./span-rescore.ts";
|
|
18
20
|
export * from "@mailwoman/core/resolver";
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAC9E,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GACvB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAI7E,cAAc,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAC9E,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GACvB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AACrF,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAI7E,cAAc,0BAA0B,CAAA"}
|
package/out/index.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export { RemoteResolver, serializableResolveOpts } from "./remote-resolver.js";
|
|
14
14
|
export { createWOFResolver } from "./resolve.js";
|
|
15
|
+
export { finestResolvedCoordinate, isImplausibleResolution } from "./plausibility.js";
|
|
15
16
|
export { findRescoreCandidate, hasResolvedPlace } from "./span-rescore.js";
|
|
16
17
|
// The type contract + placetype helpers live in core (pure types, keep core a leaf). Re-export so
|
|
17
18
|
// consumers get the whole surface from `@mailwoman/resolver`.
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAO9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAG1E,kGAAkG;AAClG,8DAA8D;AAC9D,cAAc,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAO9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAErF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAG1E,kGAAkG;AAClG,8DAA8D;AAC9D,cAAc,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Resolution-plausibility guard (#727 / v7 excision arc).
|
|
7
|
+
*
|
|
8
|
+
* The 2026-07-15 coordinate-parity study
|
|
9
|
+
* (`docs/articles/evals/2026-07-15-v7-parity-floor-diagnosis.md`) found the neural parser is
|
|
10
|
+
* coordinate-safe on well-formed input (98.6% within 1 km of the rules parser through the same
|
|
11
|
+
* resolver) but produces a garbage-geocode tail on the bare-fragment / bare-state-name / US-highway
|
|
12
|
+
* classes — inputs like `California` or `6000, NSW, Australia` that resolve to nothing finer than a
|
|
13
|
+
* country centroid.
|
|
14
|
+
*
|
|
15
|
+
* This guard is the cheap post-resolve check for that tail: a resolved tree whose finest resolved
|
|
16
|
+
* place is only a `country` centroid is implausible for a structured address. It reads only the
|
|
17
|
+
* decorated tree — no gazetteer, no extra query — so it is free to run on every resolve. It is
|
|
18
|
+
* deliberately DIRECTION-AGNOSTIC about what the caller does with the signal: serve the result with
|
|
19
|
+
* a low-confidence marker, prefer a sibling parse hypothesis (the #727 k-best rerank), or decline to
|
|
20
|
+
* emit a coordinate. It is NOT a rules-fallback trigger — the v7 excision deletes the rules parser
|
|
21
|
+
* outright (operator ruling 2026-07-15), so no consumer may route through legacy rules on a trip.
|
|
22
|
+
*
|
|
23
|
+
* It deliberately does NOT flag region-tier resolutions: a US state or a province centroid
|
|
24
|
+
* (`Texas` → the TX centroid) is a legitimate coarse geocode, not garbage. Only "resolved no finer
|
|
25
|
+
* than a country" trips it.
|
|
26
|
+
*/
|
|
27
|
+
import type { AddressTree, ComponentTag } from "@mailwoman/core/decoder";
|
|
28
|
+
/** A resolved place lifted off the tree — the coordinate a caller would serve, plus its granularity tag. */
|
|
29
|
+
export interface ResolvedCoordinate {
|
|
30
|
+
tag: ComponentTag;
|
|
31
|
+
lat: number;
|
|
32
|
+
lon: number;
|
|
33
|
+
/** Canonical place URI (`wof:…`) when the resolver supplied one. */
|
|
34
|
+
placeID?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Walk a resolved {@link AddressTree} and return the FINEST resolved place — the node carrying a resolver-supplied
|
|
38
|
+
* coordinate at the deepest granularity tier. Returns `null` when nothing resolved (no node carries a `lat`/`lon`).
|
|
39
|
+
* Ties break toward the first node in document order.
|
|
40
|
+
*/
|
|
41
|
+
export declare function finestResolvedCoordinate(tree: AddressTree): ResolvedCoordinate | null;
|
|
42
|
+
/** Result of {@link isImplausibleResolution} — the boolean plus the reason, for telemetry + fallback logs. */
|
|
43
|
+
export interface PlausibilityVerdict {
|
|
44
|
+
implausible: boolean;
|
|
45
|
+
/** Set when `implausible` is true. `country-centroid` = resolved no finer than a country. */
|
|
46
|
+
reason?: "country-centroid";
|
|
47
|
+
/** The coordinate the verdict was drawn from, when anything resolved. */
|
|
48
|
+
coordinate?: ResolvedCoordinate;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Decide whether a resolved tree's geocode is implausible for a structured address — the cheap guard the v7 hybrid gate
|
|
52
|
+
* runs after routing an input to the neural parser (#38). Trips only when the finest resolved place is a bare `country`
|
|
53
|
+
* centroid; an unresolved tree (nothing to serve) and any region-or-finer resolution are both plausible.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isImplausibleResolution(tree: AddressTree): PlausibilityVerdict;
|
|
56
|
+
//# sourceMappingURL=plausibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plausibility.d.ts","sourceRoot":"","sources":["../plausibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAe,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAqBrF,4GAA4G;AAC5G,MAAM,WAAW,kBAAkB;IAClC,GAAG,EAAE,YAAY,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,GAAG,kBAAkB,GAAG,IAAI,CAwBrF;AAED,8GAA8G;AAC9G,MAAM,WAAW,mBAAmB;IACnC,WAAW,EAAE,OAAO,CAAA;IACpB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAC3B,yEAAyE;IACzE,UAAU,CAAC,EAAE,kBAAkB,CAAA;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,mBAAmB,CAQ9E"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Resolution-plausibility guard (#727 / v7 excision arc).
|
|
7
|
+
*
|
|
8
|
+
* The 2026-07-15 coordinate-parity study
|
|
9
|
+
* (`docs/articles/evals/2026-07-15-v7-parity-floor-diagnosis.md`) found the neural parser is
|
|
10
|
+
* coordinate-safe on well-formed input (98.6% within 1 km of the rules parser through the same
|
|
11
|
+
* resolver) but produces a garbage-geocode tail on the bare-fragment / bare-state-name / US-highway
|
|
12
|
+
* classes — inputs like `California` or `6000, NSW, Australia` that resolve to nothing finer than a
|
|
13
|
+
* country centroid.
|
|
14
|
+
*
|
|
15
|
+
* This guard is the cheap post-resolve check for that tail: a resolved tree whose finest resolved
|
|
16
|
+
* place is only a `country` centroid is implausible for a structured address. It reads only the
|
|
17
|
+
* decorated tree — no gazetteer, no extra query — so it is free to run on every resolve. It is
|
|
18
|
+
* deliberately DIRECTION-AGNOSTIC about what the caller does with the signal: serve the result with
|
|
19
|
+
* a low-confidence marker, prefer a sibling parse hypothesis (the #727 k-best rerank), or decline to
|
|
20
|
+
* emit a coordinate. It is NOT a rules-fallback trigger — the v7 excision deletes the rules parser
|
|
21
|
+
* outright (operator ruling 2026-07-15), so no consumer may route through legacy rules on a trip.
|
|
22
|
+
*
|
|
23
|
+
* It deliberately does NOT flag region-tier resolutions: a US state or a province centroid
|
|
24
|
+
* (`Texas` → the TX centroid) is a legitimate coarse geocode, not garbage. Only "resolved no finer
|
|
25
|
+
* than a country" trips it.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Resolution granularity, coarse → fine. A resolved node's {@link AddressNode.tag} places it on this ladder; the
|
|
29
|
+
* geocode a caller serves comes from the FINEST resolved node. Tags absent here (unit, po_box, intersection halves, …)
|
|
30
|
+
* are treated as street-tier specificity when resolved.
|
|
31
|
+
*/
|
|
32
|
+
const RESOLUTION_TIER = {
|
|
33
|
+
country: 0,
|
|
34
|
+
region: 1,
|
|
35
|
+
subregion: 2,
|
|
36
|
+
dependent_locality: 3,
|
|
37
|
+
locality: 3,
|
|
38
|
+
postcode: 4,
|
|
39
|
+
venue: 4,
|
|
40
|
+
street: 4,
|
|
41
|
+
street_prefix: 4,
|
|
42
|
+
street_suffix: 4,
|
|
43
|
+
house_number: 5,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Walk a resolved {@link AddressTree} and return the FINEST resolved place — the node carrying a resolver-supplied
|
|
47
|
+
* coordinate at the deepest granularity tier. Returns `null` when nothing resolved (no node carries a `lat`/`lon`).
|
|
48
|
+
* Ties break toward the first node in document order.
|
|
49
|
+
*/
|
|
50
|
+
export function finestResolvedCoordinate(tree) {
|
|
51
|
+
let best = null;
|
|
52
|
+
let bestTier = -1;
|
|
53
|
+
const visit = (node) => {
|
|
54
|
+
if (node.lat !== undefined && node.lon !== undefined) {
|
|
55
|
+
const tier = RESOLUTION_TIER[node.tag] ?? 4;
|
|
56
|
+
if (tier > bestTier) {
|
|
57
|
+
bestTier = tier;
|
|
58
|
+
best = { tag: node.tag, lat: node.lat, lon: node.lon, placeID: node.placeID };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const child of node.children) {
|
|
62
|
+
visit(child);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
for (const root of tree.roots) {
|
|
66
|
+
visit(root);
|
|
67
|
+
}
|
|
68
|
+
return best;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Decide whether a resolved tree's geocode is implausible for a structured address — the cheap guard the v7 hybrid gate
|
|
72
|
+
* runs after routing an input to the neural parser (#38). Trips only when the finest resolved place is a bare `country`
|
|
73
|
+
* centroid; an unresolved tree (nothing to serve) and any region-or-finer resolution are both plausible.
|
|
74
|
+
*/
|
|
75
|
+
export function isImplausibleResolution(tree) {
|
|
76
|
+
const coordinate = finestResolvedCoordinate(tree);
|
|
77
|
+
if (coordinate && coordinate.tag === "country") {
|
|
78
|
+
return { implausible: true, reason: "country-centroid", coordinate };
|
|
79
|
+
}
|
|
80
|
+
return { implausible: false, coordinate: coordinate ?? undefined };
|
|
81
|
+
}
|
|
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C,CAAA;IAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,CAAA;IACZ,CAAC;IAED,OAAO,IAAI,CAAA;AACZ,CAAC;AAWD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAiB;IACxD,MAAM,UAAU,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAA;IAEjD,IAAI,UAAU,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAChD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAA;IACrE,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,IAAI,SAAS,EAAE,CAAA;AACnE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/resolver",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "The address resolver: walk an AddressTree, decorate nodes with gazetteer-supplied coordinates + attribution. Backend-agnostic (any ResolverBackend), with the span-rescore + postcode-consistency levers. Lifted out of @mailwoman/core so it can depend on @mailwoman/spatial (haversine) + @mailwoman/codex (USPS directionals) instead of reinventing them; the type contract stays in core so the pipeline composes it without a cycle.",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@mailwoman/codex": "6.
|
|
53
|
-
"@mailwoman/core": "6.
|
|
54
|
-
"@mailwoman/spatial": "6.
|
|
52
|
+
"@mailwoman/codex": "6.4.0",
|
|
53
|
+
"@mailwoman/core": "6.4.0",
|
|
54
|
+
"@mailwoman/spatial": "6.4.0"
|
|
55
55
|
}
|
|
56
56
|
}
|