@mailwoman/kind-classifier 4.16.2 → 5.0.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/classify.d.ts +3 -4
- package/out/classify.d.ts.map +1 -1
- package/out/classify.js +3 -4
- package/out/classify.js.map +1 -1
- package/out/rules.d.ts +18 -19
- package/out/rules.d.ts.map +1 -1
- package/out/rules.js +18 -19
- package/out/rules.js.map +1 -1
- package/out/types.d.ts +2 -4
- package/out/types.d.ts.map +1 -1
- package/package.json +9 -9
package/out/classify.d.ts
CHANGED
|
@@ -14,15 +14,14 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { LocaleHint, NormalizedInputLite, QueryKindResult, QueryShapeLike } from "./types.js";
|
|
16
16
|
/**
|
|
17
|
-
* Classify the query shape into a `QueryKind`. Synchronous + pure — produces the same result for
|
|
18
|
-
*
|
|
17
|
+
* Classify the query shape into a `QueryKind`. Synchronous + pure — produces the same result for the same `(input,
|
|
18
|
+
* shape)` pair.
|
|
19
19
|
*/
|
|
20
20
|
export declare function classifyKindSync(input: NormalizedInputLite, shape: QueryShapeLike): QueryKindResult;
|
|
21
21
|
/**
|
|
22
22
|
* Async variant matching the runtime-pipeline's `classifyKind` contract.
|
|
23
23
|
*
|
|
24
|
-
* The locale parameter is accepted for future locale-aware rules (Japanese honorifics, etc.) but
|
|
25
|
-
* not currently used.
|
|
24
|
+
* The locale parameter is accepted for future locale-aware rules (Japanese honorifics, etc.) but not currently used.
|
|
26
25
|
*/
|
|
27
26
|
export declare function classifyKind(input: NormalizedInputLite, shape: QueryShapeLike, _locale?: LocaleHint): Promise<QueryKindResult>;
|
|
28
27
|
//# sourceMappingURL=classify.d.ts.map
|
package/out/classify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../classify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAa,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAiB7G;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,cAAc,GAAG,eAAe,CAcnG;AAED
|
|
1
|
+
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../classify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAa,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAiB7G;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,cAAc,GAAG,eAAe,CAcnG;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CACjC,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,cAAc,EACrB,OAAO,CAAC,EAAE,UAAU,GAClB,OAAO,CAAC,eAAe,CAAC,CAE1B"}
|
package/out/classify.js
CHANGED
|
@@ -23,8 +23,8 @@ const SCORERS = [
|
|
|
23
23
|
{ kind: "vague", score: scoreVague },
|
|
24
24
|
];
|
|
25
25
|
/**
|
|
26
|
-
* Classify the query shape into a `QueryKind`. Synchronous + pure — produces the same result for
|
|
27
|
-
*
|
|
26
|
+
* Classify the query shape into a `QueryKind`. Synchronous + pure — produces the same result for the same `(input,
|
|
27
|
+
* shape)` pair.
|
|
28
28
|
*/
|
|
29
29
|
export function classifyKindSync(input, shape) {
|
|
30
30
|
const scored = SCORERS.map((s) => ({ kind: s.kind, confidence: s.score(input, shape) })).filter((s) => s.confidence > 0);
|
|
@@ -40,8 +40,7 @@ export function classifyKindSync(input, shape) {
|
|
|
40
40
|
/**
|
|
41
41
|
* Async variant matching the runtime-pipeline's `classifyKind` contract.
|
|
42
42
|
*
|
|
43
|
-
* The locale parameter is accepted for future locale-aware rules (Japanese honorifics, etc.) but
|
|
44
|
-
* not currently used.
|
|
43
|
+
* The locale parameter is accepted for future locale-aware rules (Japanese honorifics, etc.) but not currently used.
|
|
45
44
|
*/
|
|
46
45
|
export async function classifyKind(input, shape, _locale) {
|
|
47
46
|
return classifyKindSync(input, shape);
|
package/out/classify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classify.js","sourceRoot":"","sources":["../classify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,kBAAkB,GAClB,MAAM,YAAY,CAAA;AAQnB,MAAM,OAAO,GAA8B;IAC1C,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;IACrC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;IAC9F,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,iBAAiB,EAAE;IAClD,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,iBAAiB,EAAE;IACnD,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,iBAAiB,EAAE;IACnD,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,sBAAsB,EAAE;IAC7D,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE;CACpC,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA0B,EAAE,KAAqB;IACjF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAA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,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,YAAY;KACZ,CAAA;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,KAA0B,EAC1B,KAAqB,EACrB,OAAoB;IAEpB,OAAO,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtC,CAAC"}
|
package/out/rules.d.ts
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { NormalizedInputLite, QueryShapeLike } from "./types.js";
|
|
13
13
|
/**
|
|
14
|
-
* `po_box` rule: high-confidence iff QueryShape detected a po_box format hit. Confidence comes
|
|
15
|
-
*
|
|
14
|
+
* `po_box` rule: high-confidence iff QueryShape detected a po_box format hit. Confidence comes directly from the hit;
|
|
15
|
+
* covers all locale variants (US "PO Box 123", FR "BP 42", etc.).
|
|
16
16
|
*/
|
|
17
17
|
export declare function scorePoBox(_input: NormalizedInputLite, shape: QueryShapeLike): number;
|
|
18
18
|
/**
|
|
@@ -20,48 +20,47 @@ export declare function scorePoBox(_input: NormalizedInputLite, shape: QueryShap
|
|
|
20
20
|
*/
|
|
21
21
|
export declare function scoreIntersection(input: NormalizedInputLite, _shape: QueryShapeLike): number;
|
|
22
22
|
/**
|
|
23
|
-
* `landmark` rule: text begins with a landmark-leader phrase. These inputs are not addresses proper
|
|
24
|
-
*
|
|
23
|
+
* `landmark` rule: text begins with a landmark-leader phrase. These inputs are not addresses proper — they describe a
|
|
24
|
+
* location relative to another place.
|
|
25
25
|
*/
|
|
26
26
|
export declare function scoreLandmark(input: NormalizedInputLite, _shape: QueryShapeLike): number;
|
|
27
27
|
/**
|
|
28
|
-
* `landmark` rule (venue/named-place variant): short capitalized input with no street suffixes, no
|
|
29
|
-
*
|
|
30
|
-
* Field", "Grand Central Terminal".
|
|
28
|
+
* `landmark` rule (venue/named-place variant): short capitalized input with no street suffixes, no postcode hits, and
|
|
29
|
+
* no region abbreviations. Captures "Pier 39", "Empire State Building", "Wrigley Field", "Grand Central Terminal".
|
|
31
30
|
*
|
|
32
|
-
* Fires at moderate confidence (0.65) — below structured_address (0.9) so addresses always win, but
|
|
33
|
-
*
|
|
31
|
+
* Fires at moderate confidence (0.65) — below structured_address (0.9) so addresses always win, but above vague (0.3)
|
|
32
|
+
* so the pipeline can route landmark queries to the venue resolver.
|
|
34
33
|
*/
|
|
35
34
|
export declare function scoreVenueLandmark(input: NormalizedInputLite, shape: QueryShapeLike): number;
|
|
36
35
|
/**
|
|
37
|
-
* Test whether a format string is a postcode variant. Use the set rather than ad-hoc
|
|
38
|
-
*
|
|
36
|
+
* Test whether a format string is a postcode variant. Use the set rather than ad-hoc string-matching to avoid the
|
|
37
|
+
* `us_zip4.endsWith("_zip")` false-negative trap.
|
|
39
38
|
*/
|
|
40
39
|
export declare function isPostcodeFormat(format: string): boolean;
|
|
41
40
|
/**
|
|
42
41
|
* `postcode_only` rule: input is short AND has a postcode format hit covering most of it.
|
|
43
42
|
*
|
|
44
|
-
* The "covering most of it" check is what distinguishes `"10118"` (postcode-only) from `"350 5th
|
|
45
|
-
*
|
|
43
|
+
* The "covering most of it" check is what distinguishes `"10118"` (postcode-only) from `"350 5th Ave 10118"`
|
|
44
|
+
* (structured-address with a postcode in it).
|
|
46
45
|
*/
|
|
47
46
|
export declare function scorePostcodeOnly(input: NormalizedInputLite, shape: QueryShapeLike): number;
|
|
48
47
|
/**
|
|
49
48
|
* `locality_only` rule: short input, alpha-class, single segment, no format hits.
|
|
50
49
|
*
|
|
51
|
-
* Examples: `"Paris"`, `"NYC NY"`, `"Tokyo"`. Distinguishes from `structured_address` (multiple
|
|
52
|
-
*
|
|
50
|
+
* Examples: `"Paris"`, `"NYC NY"`, `"Tokyo"`. Distinguishes from `structured_address` (multiple segments) and `vague`
|
|
51
|
+
* (long or mixed-class).
|
|
53
52
|
*/
|
|
54
53
|
export declare function scoreLocalityOnly(input: NormalizedInputLite, shape: QueryShapeLike): number;
|
|
55
54
|
/**
|
|
56
|
-
* `structured_address` rule: looks like a real multi-component address. Either has multiple
|
|
57
|
-
*
|
|
55
|
+
* `structured_address` rule: looks like a real multi-component address. Either has multiple segments or is long and
|
|
56
|
+
* mixed-class.
|
|
58
57
|
*/
|
|
59
58
|
export declare function scoreStructuredAddress(input: NormalizedInputLite, shape: QueryShapeLike): number;
|
|
60
59
|
/**
|
|
61
60
|
* `vague` rule: nothing else fired with high confidence — input is ambiguous.
|
|
62
61
|
*
|
|
63
|
-
* Returns a moderate baseline so `vague` always shows up as an alternative, even when other rules
|
|
64
|
-
*
|
|
62
|
+
* Returns a moderate baseline so `vague` always shows up as an alternative, even when other rules dominate. The
|
|
63
|
+
* coordinator decides whether to trust vague as the primary kind.
|
|
65
64
|
*/
|
|
66
65
|
export declare function scoreVague(_input: NormalizedInputLite, _shape: QueryShapeLike): number;
|
|
67
66
|
//# sourceMappingURL=rules.d.ts.map
|
package/out/rules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAwBrE;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,cAAc,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAwBrE;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,cAAc,GAAG,MAAM,CAQrF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,CAQ5F;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,CAQxF;AA6BD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,cAAc,GAAG,MAAM,CAkD5F;AAaD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,cAAc,GAAG,MAAM,CAc3F;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,cAAc,GAAG,MAAM,CAe3F;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,cAAc,GAAG,MAAM,CAmBhG;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,CAEtF"}
|
package/out/rules.js
CHANGED
|
@@ -30,8 +30,8 @@ const INTERSECTION_PATTERNS = [
|
|
|
30
30
|
/\b\w+(?:st|nd|rd|th|street|ave|avenue|blvd|boulevard|road|rd|lane|ln)?\s+(?:and|&|@)\s+\w+/i,
|
|
31
31
|
];
|
|
32
32
|
/**
|
|
33
|
-
* `po_box` rule: high-confidence iff QueryShape detected a po_box format hit. Confidence comes
|
|
34
|
-
*
|
|
33
|
+
* `po_box` rule: high-confidence iff QueryShape detected a po_box format hit. Confidence comes directly from the hit;
|
|
34
|
+
* covers all locale variants (US "PO Box 123", FR "BP 42", etc.).
|
|
35
35
|
*/
|
|
36
36
|
export function scorePoBox(_input, shape) {
|
|
37
37
|
const hit = shape.knownFormats.find((f) => f.format === "po_box");
|
|
@@ -53,8 +53,8 @@ export function scoreIntersection(input, _shape) {
|
|
|
53
53
|
return 0;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
* `landmark` rule: text begins with a landmark-leader phrase. These inputs are not addresses proper
|
|
57
|
-
*
|
|
56
|
+
* `landmark` rule: text begins with a landmark-leader phrase. These inputs are not addresses proper — they describe a
|
|
57
|
+
* location relative to another place.
|
|
58
58
|
*/
|
|
59
59
|
export function scoreLandmark(input, _shape) {
|
|
60
60
|
const lc = input.normalized.toLowerCase().trim();
|
|
@@ -91,12 +91,11 @@ const STREET_SUFFIXES = new Set([
|
|
|
91
91
|
"circle",
|
|
92
92
|
]);
|
|
93
93
|
/**
|
|
94
|
-
* `landmark` rule (venue/named-place variant): short capitalized input with no street suffixes, no
|
|
95
|
-
*
|
|
96
|
-
* Field", "Grand Central Terminal".
|
|
94
|
+
* `landmark` rule (venue/named-place variant): short capitalized input with no street suffixes, no postcode hits, and
|
|
95
|
+
* no region abbreviations. Captures "Pier 39", "Empire State Building", "Wrigley Field", "Grand Central Terminal".
|
|
97
96
|
*
|
|
98
|
-
* Fires at moderate confidence (0.65) — below structured_address (0.9) so addresses always win, but
|
|
99
|
-
*
|
|
97
|
+
* Fires at moderate confidence (0.65) — below structured_address (0.9) so addresses always win, but above vague (0.3)
|
|
98
|
+
* so the pipeline can route landmark queries to the venue resolver.
|
|
100
99
|
*/
|
|
101
100
|
export function scoreVenueLandmark(input, shape) {
|
|
102
101
|
const text = input.normalized.trim();
|
|
@@ -152,8 +151,8 @@ const POSTCODE_FORMATS = new Set([
|
|
|
152
151
|
"jp_postcode",
|
|
153
152
|
]);
|
|
154
153
|
/**
|
|
155
|
-
* Test whether a format string is a postcode variant. Use the set rather than ad-hoc
|
|
156
|
-
*
|
|
154
|
+
* Test whether a format string is a postcode variant. Use the set rather than ad-hoc string-matching to avoid the
|
|
155
|
+
* `us_zip4.endsWith("_zip")` false-negative trap.
|
|
157
156
|
*/
|
|
158
157
|
export function isPostcodeFormat(format) {
|
|
159
158
|
return POSTCODE_FORMATS.has(format);
|
|
@@ -161,8 +160,8 @@ export function isPostcodeFormat(format) {
|
|
|
161
160
|
/**
|
|
162
161
|
* `postcode_only` rule: input is short AND has a postcode format hit covering most of it.
|
|
163
162
|
*
|
|
164
|
-
* The "covering most of it" check is what distinguishes `"10118"` (postcode-only) from `"350 5th
|
|
165
|
-
*
|
|
163
|
+
* The "covering most of it" check is what distinguishes `"10118"` (postcode-only) from `"350 5th Ave 10118"`
|
|
164
|
+
* (structured-address with a postcode in it).
|
|
166
165
|
*/
|
|
167
166
|
export function scorePostcodeOnly(input, shape) {
|
|
168
167
|
const len = input.normalized.length;
|
|
@@ -181,8 +180,8 @@ export function scorePostcodeOnly(input, shape) {
|
|
|
181
180
|
/**
|
|
182
181
|
* `locality_only` rule: short input, alpha-class, single segment, no format hits.
|
|
183
182
|
*
|
|
184
|
-
* Examples: `"Paris"`, `"NYC NY"`, `"Tokyo"`. Distinguishes from `structured_address` (multiple
|
|
185
|
-
*
|
|
183
|
+
* Examples: `"Paris"`, `"NYC NY"`, `"Tokyo"`. Distinguishes from `structured_address` (multiple segments) and `vague`
|
|
184
|
+
* (long or mixed-class).
|
|
186
185
|
*/
|
|
187
186
|
export function scoreLocalityOnly(input, shape) {
|
|
188
187
|
const len = input.normalized.length;
|
|
@@ -200,8 +199,8 @@ export function scoreLocalityOnly(input, shape) {
|
|
|
200
199
|
return 0.85;
|
|
201
200
|
}
|
|
202
201
|
/**
|
|
203
|
-
* `structured_address` rule: looks like a real multi-component address. Either has multiple
|
|
204
|
-
*
|
|
202
|
+
* `structured_address` rule: looks like a real multi-component address. Either has multiple segments or is long and
|
|
203
|
+
* mixed-class.
|
|
205
204
|
*/
|
|
206
205
|
export function scoreStructuredAddress(input, shape) {
|
|
207
206
|
const len = input.normalized.length;
|
|
@@ -225,8 +224,8 @@ export function scoreStructuredAddress(input, shape) {
|
|
|
225
224
|
/**
|
|
226
225
|
* `vague` rule: nothing else fired with high confidence — input is ambiguous.
|
|
227
226
|
*
|
|
228
|
-
* Returns a moderate baseline so `vague` always shows up as an alternative, even when other rules
|
|
229
|
-
*
|
|
227
|
+
* Returns a moderate baseline so `vague` always shows up as an alternative, even when other rules dominate. The
|
|
228
|
+
* coordinator decides whether to trust vague as the primary kind.
|
|
230
229
|
*/
|
|
231
230
|
export function scoreVague(_input, _shape) {
|
|
232
231
|
return 0.3;
|
package/out/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,sGAAsG;AACtG,MAAM,gBAAgB,GAAG;IACxB,QAAQ;IACR,MAAM;IACN,aAAa;IACb,UAAU;IACV,SAAS;IACT,QAAQ;IACR,aAAa;IACb,UAAU;IACV,QAAQ;CACR,CAAA;AAED,oGAAoG;AACpG,MAAM,qBAAqB,GAAG;IAC7B,gBAAgB;IAChB,sBAAsB;IACtB,uBAAuB;IACvB,oCAAoC;IACpC,6FAA6F;CAC7F,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,MAA2B,EAAE,KAAqB;IAC5E,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,sGAAsG;AACtG,MAAM,gBAAgB,GAAG;IACxB,QAAQ;IACR,MAAM;IACN,aAAa;IACb,UAAU;IACV,SAAS;IACT,QAAQ;IACR,aAAa;IACb,UAAU;IACV,QAAQ;CACR,CAAA;AAED,oGAAoG;AACpG,MAAM,qBAAqB,GAAG;IAC7B,gBAAgB;IAChB,sBAAsB;IACtB,uBAAuB;IACvB,oCAAoC;IACpC,6FAA6F;CAC7F,CA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c;QAAE,OAAO,GAAG,CAAA;IAExE,6EAA6E;IAC7E,IAAI,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,cAAc,KAAK,cAAc;QAAE,OAAO,IAAI,CAAA;IAErE,4EAA4E;IAC5E,IAAI,QAAQ,IAAI,CAAC;QAAE,OAAO,GAAG,CAAA;IAE7B,wFAAwF;IACxF,IAAI,GAAG,GAAG,EAAE,IAAI,KAAK,CAAC,cAAc,KAAK,cAAc;QAAE,OAAO,GAAG,CAAA;IAEnE,OAAO,CAAC,CAAA;AACT,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAA2B,EAAE,MAAsB;IAC7E,OAAO,GAAG,CAAA;AACX,CAAC"}
|
package/out/types.d.ts
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
/** Re-exports of the canonical types from `@mailwoman/core/pipeline`. */
|
|
7
7
|
export type { LocaleHint, QueryKind, QueryKindResult } from "@mailwoman/core/pipeline";
|
|
8
8
|
/**
|
|
9
|
-
* Minimal `NormalizedInput` shape consumed by `classifyKind`. Compatible with
|
|
10
|
-
* `@mailwoman/normalize`'s output.
|
|
9
|
+
* Minimal `NormalizedInput` shape consumed by `classifyKind`. Compatible with `@mailwoman/normalize`'s output.
|
|
11
10
|
*/
|
|
12
11
|
export interface NormalizedInputLite {
|
|
13
12
|
raw: string;
|
|
@@ -15,8 +14,7 @@ export interface NormalizedInputLite {
|
|
|
15
14
|
appliedLocale?: string;
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
|
-
* Minimal `QueryShape` shape consumed by `classifyKind`. Compatible with `@mailwoman/query-shape`'s
|
|
19
|
-
* output.
|
|
17
|
+
* Minimal `QueryShape` shape consumed by `classifyKind`. Compatible with `@mailwoman/query-shape`'s output.
|
|
20
18
|
*/
|
|
21
19
|
export interface QueryShapeLike {
|
|
22
20
|
knownFormats: ReadonlyArray<{
|
package/out/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yEAAyE;AACzE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAEtF
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yEAAyE;AACzE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAEtF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,YAAY,EAAE,aAAa,CAAC;QAC3B,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;QACpC,UAAU,EAAE,MAAM,CAAA;KAClB,CAAC,CAAA;IACF,QAAQ,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACzD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/kind-classifier",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Stage 2.5 of the runtime pipeline — categorize inputs by query shape (postcode_only / locality_only / structured_address / intersection / po_box / landmark / vague). Rule-based for v1.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
"url": "https://github.com/sister-software/mailwoman.git",
|
|
9
9
|
"directory": "kind-classifier"
|
|
10
10
|
},
|
|
11
|
-
"type": "module",
|
|
12
|
-
"exports": {
|
|
13
|
-
"./package.json": "./package.json",
|
|
14
|
-
".": "./out/index.js"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@mailwoman/core": "4.16.2"
|
|
18
|
-
},
|
|
19
11
|
"files": [
|
|
20
12
|
"out/**/*.js",
|
|
21
13
|
"out/**/*.js.map",
|
|
22
14
|
"out/**/*.d.ts",
|
|
23
15
|
"out/**/*.d.ts.map"
|
|
24
16
|
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"exports": {
|
|
19
|
+
"./package.json": "./package.json",
|
|
20
|
+
".": "./out/index.js"
|
|
21
|
+
},
|
|
25
22
|
"publishConfig": {
|
|
26
23
|
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@mailwoman/core": "5.0.0"
|
|
27
27
|
}
|
|
28
28
|
}
|