@mailwoman/variant-aliases 4.16.2 → 5.1.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/lookup.d.ts +4 -4
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +7 -7
- package/out/lookup.js.map +1 -1
- package/out/types.d.ts +9 -10
- package/out/types.d.ts.map +1 -1
- package/package.json +6 -6
package/out/lookup.d.ts
CHANGED
|
@@ -16,12 +16,12 @@ import type { AliasLookupResult, VariantAlias } from "./types.js";
|
|
|
16
16
|
* Confidence:
|
|
17
17
|
*
|
|
18
18
|
* - `1.0` when the detected locale (e.g. `en-AU`) is in the alias's `locales` list.
|
|
19
|
-
* - `0.5` when only the language part matches (e.g. detected `en-IE`, alias supports `en-AU`). This
|
|
20
|
-
*
|
|
19
|
+
* - `0.5` when only the language part matches (e.g. detected `en-IE`, alias supports `en-AU`). This is intentionally
|
|
20
|
+
* weaker because regional variants are by definition regional.
|
|
21
21
|
* - No match when neither holds.
|
|
22
22
|
*
|
|
23
|
-
* Returns ALL matches sorted by confidence descending. Multi-locale variants (like "petrol station"
|
|
24
|
-
*
|
|
23
|
+
* Returns ALL matches sorted by confidence descending. Multi-locale variants (like "petrol station" →
|
|
24
|
+
* en-GB/en-AU/en-NZ/en-ZA) return one entry per locale list — the caller picks.
|
|
25
25
|
*/
|
|
26
26
|
export declare function lookupVariantAliases(text: string, locale: string): AliasLookupResult[];
|
|
27
27
|
/** Pure-data accessor for callers that want to enumerate the table (e.g. corpus synthesis). */
|
package/out/lookup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAA;AAyCpF;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CA4BtF;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,IAAI,aAAa,CAAC,YAAY,CAAC,CAE3D;AAED,eAAO,MAAM,qBAAqB,QAAgB,CAAA"}
|
package/out/lookup.js
CHANGED
|
@@ -31,9 +31,9 @@ function loadTable() {
|
|
|
31
31
|
}
|
|
32
32
|
const TABLE = loadTable();
|
|
33
33
|
/**
|
|
34
|
-
* Indexed by lowercased variant string for O(1) lookup. Multiple entries can share the same variant
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* Indexed by lowercased variant string for O(1) lookup. Multiple entries can share the same variant key (e.g. ambiguous
|
|
35
|
+
* "takeaway" only matches GB but not AU if both list it differently), so each entry is an array of all aliases that
|
|
36
|
+
* share the key.
|
|
37
37
|
*/
|
|
38
38
|
const INDEX = (() => {
|
|
39
39
|
const map = new Map();
|
|
@@ -51,12 +51,12 @@ const INDEX = (() => {
|
|
|
51
51
|
* Confidence:
|
|
52
52
|
*
|
|
53
53
|
* - `1.0` when the detected locale (e.g. `en-AU`) is in the alias's `locales` list.
|
|
54
|
-
* - `0.5` when only the language part matches (e.g. detected `en-IE`, alias supports `en-AU`). This
|
|
55
|
-
*
|
|
54
|
+
* - `0.5` when only the language part matches (e.g. detected `en-IE`, alias supports `en-AU`). This is intentionally
|
|
55
|
+
* weaker because regional variants are by definition regional.
|
|
56
56
|
* - No match when neither holds.
|
|
57
57
|
*
|
|
58
|
-
* Returns ALL matches sorted by confidence descending. Multi-locale variants (like "petrol station"
|
|
59
|
-
*
|
|
58
|
+
* Returns ALL matches sorted by confidence descending. Multi-locale variants (like "petrol station" →
|
|
59
|
+
* en-GB/en-AU/en-NZ/en-ZA) return one entry per locale list — the caller picks.
|
|
60
60
|
*/
|
|
61
61
|
export function lookupVariantAliases(text, locale) {
|
|
62
62
|
const norm = text.trim().toLowerCase();
|
package/out/lookup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAIxC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAEzD,SAAS,SAAS;IACjB,MAAM,UAAU,GAAG;QAClB,OAAO,CAAC,SAAS,EAAE,mBAAmB,CAAC;QACvC,OAAO,CAAC,SAAS,EAAE,sBAAsB,CAAC;QAC1C,OAAO,CAAC,SAAS,EAAE,yCAAyC,CAAC;KAC7D,CAAA;
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAIxC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAEzD,SAAS,SAAS;IACjB,MAAM,UAAU,GAAG;QAClB,OAAO,CAAC,SAAS,EAAE,mBAAmB,CAAC;QACvC,OAAO,CAAC,SAAS,EAAE,sBAAsB,CAAC;QAC1C,OAAO,CAAC,SAAS,EAAE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AC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IACxC,MAAM,OAAO,GAAwB,EAAE,CAAA;IAEvC,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAChC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAA;YACxC,SAAQ;QACT,CAAC;QACD,6EAA6E;QAC7E,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAA;QAE5E,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAA;QACzC,CAAC;IACF,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAA;IAEnD,OAAO,OAAO,CAAA;AACf,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,aAAa;IAC5B,OAAO,KAAK,CAAC,OAAO,CAAA;AACrB,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,CAAA"}
|
package/out/types.d.ts
CHANGED
|
@@ -8,25 +8,24 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* The semantic kind of a variant — either a generic amenity category or a specific brand.
|
|
10
10
|
*
|
|
11
|
-
* - `amenity` aliases resolve to a category (`fuel`, `pharmacy`, `convenience`, ...). Several
|
|
12
|
-
*
|
|
13
|
-
* - `brand` aliases resolve to a canonical brand name. Multiple regional variants of the same brand
|
|
14
|
-
*
|
|
11
|
+
* - `amenity` aliases resolve to a category (`fuel`, `pharmacy`, `convenience`, ...). Several variants can map to the
|
|
12
|
+
* same category ("servo" and "petrol station" both → `fuel`).
|
|
13
|
+
* - `brand` aliases resolve to a canonical brand name. Multiple regional variants of the same brand ("Macca's", "McDo",
|
|
14
|
+
* "Mickey D's", "マクド") all map to `McDonald's`.
|
|
15
15
|
*/
|
|
16
16
|
export type VariantKind = "amenity" | "brand";
|
|
17
17
|
export interface VariantAliasBase {
|
|
18
18
|
/** The user-typed variant. Always lowercase for the lookup key (CJK preserved as-is). */
|
|
19
19
|
variant: string;
|
|
20
20
|
/**
|
|
21
|
-
* BCP-47 locale tags where this variant is in active use. Used to gate lookups: only consider an
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* BCP-47 locale tags where this variant is in active use. Used to gate lookups: only consider an alias when the
|
|
22
|
+
* detected locale matches one of these. A query in `en-US` won't match Australian "servo" because `en-AU` is not in
|
|
23
|
+
* `["en-US"]`.
|
|
24
24
|
*/
|
|
25
25
|
locales: ReadonlyArray<string>;
|
|
26
26
|
/**
|
|
27
|
-
* Free-form regional refinement within the locale (e.g. "NYC", "Kansai", "Quebec"). Not used for
|
|
28
|
-
*
|
|
29
|
-
* geolocation signal to further disambiguate.
|
|
27
|
+
* Free-form regional refinement within the locale (e.g. "NYC", "Kansai", "Quebec"). Not used for matching today;
|
|
28
|
+
* informational. A future enhancement could combine this with a coarse geolocation signal to further disambiguate.
|
|
30
29
|
*/
|
|
31
30
|
regionHint?: string;
|
|
32
31
|
}
|
package/out/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,CAAA;AAE7C,MAAM,WAAW,gBAAgB;IAChC,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC9B
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,CAAA;AAE7C,MAAM,WAAW,gBAAgB;IAChC,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC9B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACrD,IAAI,EAAE,SAAS,CAAA;IACf,sFAAsF;IACtF,QAAQ,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,UAAW,SAAQ,gBAAgB;IACnD,IAAI,EAAE,OAAO,CAAA;IACb,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,UAAU,CAAA;AAEpD,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,YAAY,CAAA;IACnB,sGAAsG;IACtG,UAAU,EAAE,MAAM,CAAA;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/variant-aliases",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Regional variant alias table — local terms for amenities/brands gated by locale. 'servo' → fuel (en-AU), 'マクド' → McDonald's (ja-JP), 'PFK' → KFC (fr-CA).",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -8,11 +8,6 @@
|
|
|
8
8
|
"url": "https://github.com/sister-software/mailwoman.git",
|
|
9
9
|
"directory": "variant-aliases"
|
|
10
10
|
},
|
|
11
|
-
"type": "module",
|
|
12
|
-
"exports": {
|
|
13
|
-
"./package.json": "./package.json",
|
|
14
|
-
".": "./out/index.js"
|
|
15
|
-
},
|
|
16
11
|
"files": [
|
|
17
12
|
"out/**/*.js",
|
|
18
13
|
"out/**/*.js.map",
|
|
@@ -20,6 +15,11 @@
|
|
|
20
15
|
"out/**/*.d.ts.map",
|
|
21
16
|
"data/**/*.json"
|
|
22
17
|
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"exports": {
|
|
20
|
+
"./package.json": "./package.json",
|
|
21
|
+
".": "./out/index.js"
|
|
22
|
+
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
|
25
25
|
}
|