@mailwoman/variant-aliases 9.4.0 → 10.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/lib/index.ts +1 -6
- package/lib/lookup.ts +18 -18
- package/lib/types.ts +21 -12
- package/out/index.d.ts +1 -6
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -6
- package/out/index.js.map +1 -1
- package/out/lookup.d.ts +12 -13
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +18 -18
- package/out/lookup.js.map +1 -1
- package/out/types.d.ts +21 -12
- package/out/types.d.ts.map +1 -1
- package/package.json +13 -18
package/lib/index.ts
CHANGED
|
@@ -8,12 +8,7 @@
|
|
|
8
8
|
* The data file (`data/aliases.json`) catalogs ~35 hand-curated regional terms: "servo" → fuel
|
|
9
9
|
* (en-AU), "マクド" → McDonald's (ja-JP), "PFK" → KFC (fr-CA), etc.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - `docs/articles/understanding/exotic-poi/regional-variant-queries.md` for the linguistic
|
|
14
|
-
* background and the source tables this data is derived from.
|
|
15
|
-
* - Issue #166 for the v0.6.0+ runtime integration plan (kind classifier consumes this table to emit
|
|
16
|
-
* `kind=amenity` / `kind=brand` proposals, filtered by `@mailwoman/locale-hint` output).
|
|
11
|
+
* The runtime uses this table when resolving POI intent.
|
|
17
12
|
*/
|
|
18
13
|
|
|
19
14
|
export { VARIANT_ALIAS_VERSION, getAllAliases, lookupVariantAliases, resolveLocaleScope } from "#lookup"
|
package/lib/lookup.ts
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* Regional variant alias lookup. Given a token (or short phrase) and a detected locale, return the
|
|
7
7
|
* canonical amenity category or brand it refers to.
|
|
8
8
|
*
|
|
9
|
-
* This is the data-side foundation for #166 (variant alias table + locale-restricted category matching).
|
|
10
|
-
* The runtime integration into the kind classifier is v0.6.0+ work.
|
|
11
9
|
*/
|
|
12
10
|
|
|
13
11
|
import { readLocalJSONFile } from "@mailwoman/core/fs/readers"
|
|
@@ -18,8 +16,8 @@ import type { AliasLookupResult, LocaleScopeMatch, VariantAlias, VariantAliasTab
|
|
|
18
16
|
const moduleDir = import.meta.dirname
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* Read the shipped alias table, located by the shared source-tree/`out/` probe
|
|
22
|
-
* `@mailwoman/core/module/packaged-data`.
|
|
19
|
+
* Read the shipped alias table, located by the shared source-tree/`out/` probe
|
|
20
|
+
* in `@mailwoman/core/module/packaged-data`.
|
|
23
21
|
*/
|
|
24
22
|
async function loadTable(): Promise<VariantAliasTable> {
|
|
25
23
|
return readLocalJSONFile<VariantAliasTable>(await resolvePackagedDataPath(moduleDir, "aliases.json"))
|
|
@@ -28,9 +26,10 @@ async function loadTable(): Promise<VariantAliasTable> {
|
|
|
28
26
|
const TABLE = await loadTable()
|
|
29
27
|
|
|
30
28
|
/**
|
|
31
|
-
* Indexed by lowercased variant string for O(1) lookup.
|
|
32
|
-
*
|
|
33
|
-
* share the key.
|
|
29
|
+
* Indexed by lowercased variant string for O(1) lookup.
|
|
30
|
+
*
|
|
31
|
+
* Multiple entries can share the same variant key (e.g. Ambiguous "takeaway" only matches GB
|
|
32
|
+
* but not AU if both list it differently), so each entry is an array of all aliases that share the key.
|
|
34
33
|
*/
|
|
35
34
|
const INDEX: ReadonlyMap<string, ReadonlyArray<VariantAlias>> = (() => {
|
|
36
35
|
const map = new Map<string, VariantAlias[]>()
|
|
@@ -46,15 +45,15 @@ const INDEX: ReadonlyMap<string, ReadonlyArray<VariantAlias>> = (() => {
|
|
|
46
45
|
})()
|
|
47
46
|
|
|
48
47
|
/**
|
|
49
|
-
* Decide how a locale-scoped record answers under a detected locale — the rule every
|
|
50
|
-
* the pipeline follows.
|
|
48
|
+
* Decide how a locale-scoped record answers under a detected locale — the rule every
|
|
49
|
+
* locale-restricted vocabulary in the pipeline follows.
|
|
51
50
|
*
|
|
52
51
|
* - `unscoped` (confidence 1) when the record declares no locales at all.
|
|
53
52
|
* - `exact` (confidence 1) when the detected locale is one the record declares.
|
|
54
|
-
* - `language` (confidence 0.5) when only the language subtag agrees — weaker on purpose,
|
|
55
|
-
* by definition regional.
|
|
56
|
-
* - `null`
|
|
57
|
-
* reached without knowing the region.
|
|
53
|
+
* - `language` (confidence 0.5) when only the language subtag agrees — weaker on purpose,
|
|
54
|
+
* because regional variants are by definition regional.
|
|
55
|
+
* - `null` for every scoped record when the locale is unknown: a phrasing declared
|
|
56
|
+
* regional cannot be reached without knowing the region.
|
|
58
57
|
*/
|
|
59
58
|
export function resolveLocaleScope(
|
|
60
59
|
locales: ReadonlyArray<string> | undefined,
|
|
@@ -79,12 +78,13 @@ export function resolveLocaleScope(
|
|
|
79
78
|
* Confidence:
|
|
80
79
|
*
|
|
81
80
|
* - `1.0` when the detected locale (e.g. `en-AU`) is in the alias's `locales` list.
|
|
82
|
-
* - `0.5` when only the language part matches (e.g.
|
|
83
|
-
* weaker because regional variants are by definition regional.
|
|
81
|
+
* - `0.5` when only the language part matches (e.g. Detected `en-IE`, alias supports `en-AU`).
|
|
82
|
+
* This is intentionally weaker because regional variants are by definition regional.
|
|
84
83
|
* - No match when neither holds.
|
|
85
84
|
*
|
|
86
|
-
*
|
|
87
|
-
* en-GB/en-AU/en-NZ/en-ZA) return
|
|
85
|
+
* @returns all matches sorted by confidence descending.
|
|
86
|
+
* Multi-locale variants (like "petrol station" → en-GB/en-AU/en-NZ/en-ZA) return
|
|
87
|
+
* one entry per locale list — the caller picks.
|
|
88
88
|
*/
|
|
89
89
|
export function lookupVariantAliases(text: string, locale: string): AliasLookupResult[] {
|
|
90
90
|
const norm = text.trim().toLowerCase()
|
|
@@ -111,7 +111,7 @@ export function lookupVariantAliases(text: string, locale: string): AliasLookupR
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* Pure-data accessor for callers that want to enumerate the table (e.g.
|
|
114
|
+
* Pure-data accessor for callers that want to enumerate the table (e.g. Corpus synthesis).
|
|
115
115
|
*/
|
|
116
116
|
export function getAllAliases(): ReadonlyArray<VariantAlias> {
|
|
117
117
|
return TABLE.aliases
|
package/lib/types.ts
CHANGED
|
@@ -9,27 +9,35 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* The semantic kind of a variant — either a generic amenity category or a specific brand.
|
|
11
11
|
*
|
|
12
|
-
* - `amenity` aliases resolve to a category (`fuel`, `pharmacy`, `convenience`, ...).
|
|
13
|
-
* same category ("servo" and "petrol station" both → `fuel`).
|
|
14
|
-
* - `brand` aliases resolve to a canonical brand name.
|
|
15
|
-
* "Mickey D's", "マクド")
|
|
12
|
+
* - `amenity` aliases resolve to a category (`fuel`, `pharmacy`, `convenience`, ...).
|
|
13
|
+
* Several variants can map to the same category ("servo" and "petrol station" both → `fuel`).
|
|
14
|
+
* - `brand` aliases resolve to a canonical brand name.
|
|
15
|
+
* Multiple regional variants of the same brand ("Macca's", "McDo", "Mickey D's", "マクド")
|
|
16
|
+
* all map to `McDonald's`.
|
|
16
17
|
*/
|
|
17
18
|
export type VariantKind = "amenity" | "brand"
|
|
18
19
|
|
|
19
20
|
interface VariantAliasBase {
|
|
20
21
|
/**
|
|
21
|
-
* The user-typed variant.
|
|
22
|
+
* The user-typed variant.
|
|
23
|
+
*
|
|
24
|
+
* Always lowercase for the lookup key (CJK preserved as-is).
|
|
22
25
|
*/
|
|
23
26
|
variant: string
|
|
24
27
|
/**
|
|
25
|
-
* BCP-47 locale tags where this variant is in active use.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
+
* BCP-47 locale tags where this variant is in active use.
|
|
29
|
+
*
|
|
30
|
+
* Used to filter lookups: only consider an alias when the detected locale matches one of these.
|
|
31
|
+
* A query in `en-US` won't match Australian "servo" because `en-AU` is not in `["en-US"]`.
|
|
28
32
|
*/
|
|
29
33
|
locales: ReadonlyArray<string>
|
|
30
34
|
/**
|
|
31
|
-
* Free-form regional refinement within the locale (e.g. "NYC", "Kansai", "Quebec").
|
|
32
|
-
*
|
|
35
|
+
* Free-form regional refinement within the locale (e.g. "NYC", "Kansai", "Quebec").
|
|
36
|
+
*
|
|
37
|
+
* Not used for matching today.
|
|
38
|
+
* Informational.
|
|
39
|
+
*
|
|
40
|
+
* A future enhancement could combine this with a coarse geolocation signal to further disambiguate.
|
|
33
41
|
*/
|
|
34
42
|
regionHint?: string
|
|
35
43
|
}
|
|
@@ -63,8 +71,9 @@ export interface VariantAliasTable {
|
|
|
63
71
|
*
|
|
64
72
|
* - `unscoped` — the record declares no locales and answers under any.
|
|
65
73
|
* - `exact` — the query's locale tag is one the record declares.
|
|
66
|
-
* - `language` — only the language subtag agrees.
|
|
67
|
-
*
|
|
74
|
+
* - `language` — only the language subtag agrees.
|
|
75
|
+
* Weaker on purpose: a regional phrasing reached through its language by
|
|
76
|
+
* itself is a guess about the region.
|
|
68
77
|
*/
|
|
69
78
|
export type LocaleScope = "unscoped" | "exact" | "language"
|
|
70
79
|
|
package/out/index.d.ts
CHANGED
|
@@ -8,12 +8,7 @@
|
|
|
8
8
|
* The data file (`data/aliases.json`) catalogs ~35 hand-curated regional terms: "servo" → fuel
|
|
9
9
|
* (en-AU), "マクド" → McDonald's (ja-JP), "PFK" → KFC (fr-CA), etc.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - `docs/articles/understanding/exotic-poi/regional-variant-queries.md` for the linguistic
|
|
14
|
-
* background and the source tables this data is derived from.
|
|
15
|
-
* - Issue #166 for the v0.6.0+ runtime integration plan (kind classifier consumes this table to emit
|
|
16
|
-
* `kind=amenity` / `kind=brand` proposals, filtered by `@mailwoman/locale-hint` output).
|
|
11
|
+
* The runtime uses this table when resolving POI intent.
|
|
17
12
|
*/
|
|
18
13
|
export { VARIANT_ALIAS_VERSION, getAllAliases, lookupVariantAliases, resolveLocaleScope } from "#lookup";
|
|
19
14
|
export type { AliasLookupResult, AmenityAlias, BrandAlias, LocaleScope, LocaleScopeMatch, VariantAlias, VariantAliasTable, VariantKind, } from "#types";
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAExG,YAAY,EACX,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,WAAW,GACX,MAAM,QAAQ,CAAA"}
|
package/out/index.js
CHANGED
|
@@ -8,12 +8,7 @@
|
|
|
8
8
|
* The data file (`data/aliases.json`) catalogs ~35 hand-curated regional terms: "servo" → fuel
|
|
9
9
|
* (en-AU), "マクド" → McDonald's (ja-JP), "PFK" → KFC (fr-CA), etc.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - `docs/articles/understanding/exotic-poi/regional-variant-queries.md` for the linguistic
|
|
14
|
-
* background and the source tables this data is derived from.
|
|
15
|
-
* - Issue #166 for the v0.6.0+ runtime integration plan (kind classifier consumes this table to emit
|
|
16
|
-
* `kind=amenity` / `kind=brand` proposals, filtered by `@mailwoman/locale-hint` output).
|
|
11
|
+
* The runtime uses this table when resolving POI intent.
|
|
17
12
|
*/
|
|
18
13
|
export { VARIANT_ALIAS_VERSION, getAllAliases, lookupVariantAliases, resolveLocaleScope } from "#lookup";
|
|
19
14
|
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA"}
|
package/out/lookup.d.ts
CHANGED
|
@@ -6,20 +6,18 @@
|
|
|
6
6
|
* Regional variant alias lookup. Given a token (or short phrase) and a detected locale, return the
|
|
7
7
|
* canonical amenity category or brand it refers to.
|
|
8
8
|
*
|
|
9
|
-
* This is the data-side foundation for #166 (variant alias table + locale-restricted category matching).
|
|
10
|
-
* The runtime integration into the kind classifier is v0.6.0+ work.
|
|
11
9
|
*/
|
|
12
10
|
import type { AliasLookupResult, LocaleScopeMatch, VariantAlias } from "#types";
|
|
13
11
|
/**
|
|
14
|
-
* Decide how a locale-scoped record answers under a detected locale — the rule every
|
|
15
|
-
* the pipeline follows.
|
|
12
|
+
* Decide how a locale-scoped record answers under a detected locale — the rule every
|
|
13
|
+
* locale-restricted vocabulary in the pipeline follows.
|
|
16
14
|
*
|
|
17
15
|
* - `unscoped` (confidence 1) when the record declares no locales at all.
|
|
18
16
|
* - `exact` (confidence 1) when the detected locale is one the record declares.
|
|
19
|
-
* - `language` (confidence 0.5) when only the language subtag agrees — weaker on purpose,
|
|
20
|
-
* by definition regional.
|
|
21
|
-
* - `null`
|
|
22
|
-
* reached without knowing the region.
|
|
17
|
+
* - `language` (confidence 0.5) when only the language subtag agrees — weaker on purpose,
|
|
18
|
+
* because regional variants are by definition regional.
|
|
19
|
+
* - `null` for every scoped record when the locale is unknown: a phrasing declared
|
|
20
|
+
* regional cannot be reached without knowing the region.
|
|
23
21
|
*/
|
|
24
22
|
export declare function resolveLocaleScope(locales: ReadonlyArray<string> | undefined, locale: string | undefined): LocaleScopeMatch | null;
|
|
25
23
|
/**
|
|
@@ -28,16 +26,17 @@ export declare function resolveLocaleScope(locales: ReadonlyArray<string> | unde
|
|
|
28
26
|
* Confidence:
|
|
29
27
|
*
|
|
30
28
|
* - `1.0` when the detected locale (e.g. `en-AU`) is in the alias's `locales` list.
|
|
31
|
-
* - `0.5` when only the language part matches (e.g.
|
|
32
|
-
* weaker because regional variants are by definition regional.
|
|
29
|
+
* - `0.5` when only the language part matches (e.g. Detected `en-IE`, alias supports `en-AU`).
|
|
30
|
+
* This is intentionally weaker because regional variants are by definition regional.
|
|
33
31
|
* - No match when neither holds.
|
|
34
32
|
*
|
|
35
|
-
*
|
|
36
|
-
* en-GB/en-AU/en-NZ/en-ZA) return
|
|
33
|
+
* @returns all matches sorted by confidence descending.
|
|
34
|
+
* Multi-locale variants (like "petrol station" → en-GB/en-AU/en-NZ/en-ZA) return
|
|
35
|
+
* one entry per locale list — the caller picks.
|
|
37
36
|
*/
|
|
38
37
|
export declare function lookupVariantAliases(text: string, locale: string): AliasLookupResult[];
|
|
39
38
|
/**
|
|
40
|
-
* Pure-data accessor for callers that want to enumerate the table (e.g.
|
|
39
|
+
* Pure-data accessor for callers that want to enumerate the table (e.g. Corpus synthesis).
|
|
41
40
|
*/
|
|
42
41
|
export declare function getAllAliases(): ReadonlyArray<VariantAlias>;
|
|
43
42
|
/**
|
package/out/lookup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../lib/lookup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../lib/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,YAAY,EAAqB,MAAM,QAAQ,CAAA;AAiClG;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,EAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,GACxB,gBAAgB,GAAG,IAAI,CAYzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAsBtF;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,aAAa,CAAC,YAAY,CAAC,CAE3D;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAAgB,CAAA"}
|
package/out/lookup.js
CHANGED
|
@@ -6,24 +6,23 @@
|
|
|
6
6
|
* Regional variant alias lookup. Given a token (or short phrase) and a detected locale, return the
|
|
7
7
|
* canonical amenity category or brand it refers to.
|
|
8
8
|
*
|
|
9
|
-
* This is the data-side foundation for #166 (variant alias table + locale-restricted category matching).
|
|
10
|
-
* The runtime integration into the kind classifier is v0.6.0+ work.
|
|
11
9
|
*/
|
|
12
10
|
import { readLocalJSONFile } from "@mailwoman/core/fs/readers";
|
|
13
11
|
import { resolvePackagedDataPath } from "@mailwoman/core/module/packaged-data";
|
|
14
12
|
const moduleDir = import.meta.dirname;
|
|
15
13
|
/**
|
|
16
|
-
* Read the shipped alias table, located by the shared source-tree/`out/` probe
|
|
17
|
-
* `@mailwoman/core/module/packaged-data`.
|
|
14
|
+
* Read the shipped alias table, located by the shared source-tree/`out/` probe
|
|
15
|
+
* in `@mailwoman/core/module/packaged-data`.
|
|
18
16
|
*/
|
|
19
17
|
async function loadTable() {
|
|
20
18
|
return readLocalJSONFile(await resolvePackagedDataPath(moduleDir, "aliases.json"));
|
|
21
19
|
}
|
|
22
20
|
const TABLE = await loadTable();
|
|
23
21
|
/**
|
|
24
|
-
* Indexed by lowercased variant string for O(1) lookup.
|
|
25
|
-
*
|
|
26
|
-
* share the key.
|
|
22
|
+
* Indexed by lowercased variant string for O(1) lookup.
|
|
23
|
+
*
|
|
24
|
+
* Multiple entries can share the same variant key (e.g. Ambiguous "takeaway" only matches GB
|
|
25
|
+
* but not AU if both list it differently), so each entry is an array of all aliases that share the key.
|
|
27
26
|
*/
|
|
28
27
|
const INDEX = (() => {
|
|
29
28
|
const map = new Map();
|
|
@@ -36,15 +35,15 @@ const INDEX = (() => {
|
|
|
36
35
|
return map;
|
|
37
36
|
})();
|
|
38
37
|
/**
|
|
39
|
-
* Decide how a locale-scoped record answers under a detected locale — the rule every
|
|
40
|
-
* the pipeline follows.
|
|
38
|
+
* Decide how a locale-scoped record answers under a detected locale — the rule every
|
|
39
|
+
* locale-restricted vocabulary in the pipeline follows.
|
|
41
40
|
*
|
|
42
41
|
* - `unscoped` (confidence 1) when the record declares no locales at all.
|
|
43
42
|
* - `exact` (confidence 1) when the detected locale is one the record declares.
|
|
44
|
-
* - `language` (confidence 0.5) when only the language subtag agrees — weaker on purpose,
|
|
45
|
-
* by definition regional.
|
|
46
|
-
* - `null`
|
|
47
|
-
* reached without knowing the region.
|
|
43
|
+
* - `language` (confidence 0.5) when only the language subtag agrees — weaker on purpose,
|
|
44
|
+
* because regional variants are by definition regional.
|
|
45
|
+
* - `null` for every scoped record when the locale is unknown: a phrasing declared
|
|
46
|
+
* regional cannot be reached without knowing the region.
|
|
48
47
|
*/
|
|
49
48
|
export function resolveLocaleScope(locales, locale) {
|
|
50
49
|
if (!locales)
|
|
@@ -64,12 +63,13 @@ export function resolveLocaleScope(locales, locale) {
|
|
|
64
63
|
* Confidence:
|
|
65
64
|
*
|
|
66
65
|
* - `1.0` when the detected locale (e.g. `en-AU`) is in the alias's `locales` list.
|
|
67
|
-
* - `0.5` when only the language part matches (e.g.
|
|
68
|
-
* weaker because regional variants are by definition regional.
|
|
66
|
+
* - `0.5` when only the language part matches (e.g. Detected `en-IE`, alias supports `en-AU`).
|
|
67
|
+
* This is intentionally weaker because regional variants are by definition regional.
|
|
69
68
|
* - No match when neither holds.
|
|
70
69
|
*
|
|
71
|
-
*
|
|
72
|
-
* en-GB/en-AU/en-NZ/en-ZA) return
|
|
70
|
+
* @returns all matches sorted by confidence descending.
|
|
71
|
+
* Multi-locale variants (like "petrol station" → en-GB/en-AU/en-NZ/en-ZA) return
|
|
72
|
+
* one entry per locale list — the caller picks.
|
|
73
73
|
*/
|
|
74
74
|
export function lookupVariantAliases(text, locale) {
|
|
75
75
|
const norm = text.trim().toLowerCase();
|
|
@@ -89,7 +89,7 @@ export function lookupVariantAliases(text, locale) {
|
|
|
89
89
|
return results;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
* Pure-data accessor for callers that want to enumerate the table (e.g.
|
|
92
|
+
* Pure-data accessor for callers that want to enumerate the table (e.g. Corpus synthesis).
|
|
93
93
|
*/
|
|
94
94
|
export function getAllAliases() {
|
|
95
95
|
return TABLE.aliases;
|
package/out/lookup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../lib/lookup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../lib/lookup.ts"],"names":[],"mappings":"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"}
|
package/out/types.d.ts
CHANGED
|
@@ -8,26 +8,34 @@
|
|
|
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`, ...).
|
|
12
|
-
* same category ("servo" and "petrol station" both → `fuel`).
|
|
13
|
-
* - `brand` aliases resolve to a canonical brand name.
|
|
14
|
-
* "Mickey D's", "マクド")
|
|
11
|
+
* - `amenity` aliases resolve to a category (`fuel`, `pharmacy`, `convenience`, ...).
|
|
12
|
+
* Several variants can map to the same category ("servo" and "petrol station" both → `fuel`).
|
|
13
|
+
* - `brand` aliases resolve to a canonical brand name.
|
|
14
|
+
* Multiple regional variants of the same brand ("Macca's", "McDo", "Mickey D's", "マクド")
|
|
15
|
+
* all map to `McDonald's`.
|
|
15
16
|
*/
|
|
16
17
|
export type VariantKind = "amenity" | "brand";
|
|
17
18
|
interface VariantAliasBase {
|
|
18
19
|
/**
|
|
19
|
-
* The user-typed variant.
|
|
20
|
+
* The user-typed variant.
|
|
21
|
+
*
|
|
22
|
+
* Always lowercase for the lookup key (CJK preserved as-is).
|
|
20
23
|
*/
|
|
21
24
|
variant: string;
|
|
22
25
|
/**
|
|
23
|
-
* BCP-47 locale tags where this variant is in active use.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
+
* BCP-47 locale tags where this variant is in active use.
|
|
27
|
+
*
|
|
28
|
+
* Used to filter lookups: only consider an alias when the detected locale matches one of these.
|
|
29
|
+
* A query in `en-US` won't match Australian "servo" because `en-AU` is not in `["en-US"]`.
|
|
26
30
|
*/
|
|
27
31
|
locales: ReadonlyArray<string>;
|
|
28
32
|
/**
|
|
29
|
-
* Free-form regional refinement within the locale (e.g. "NYC", "Kansai", "Quebec").
|
|
30
|
-
*
|
|
33
|
+
* Free-form regional refinement within the locale (e.g. "NYC", "Kansai", "Quebec").
|
|
34
|
+
*
|
|
35
|
+
* Not used for matching today.
|
|
36
|
+
* Informational.
|
|
37
|
+
*
|
|
38
|
+
* A future enhancement could combine this with a coarse geolocation signal to further disambiguate.
|
|
31
39
|
*/
|
|
32
40
|
regionHint?: string;
|
|
33
41
|
}
|
|
@@ -56,8 +64,9 @@ export interface VariantAliasTable {
|
|
|
56
64
|
*
|
|
57
65
|
* - `unscoped` — the record declares no locales and answers under any.
|
|
58
66
|
* - `exact` — the query's locale tag is one the record declares.
|
|
59
|
-
* - `language` — only the language subtag agrees.
|
|
60
|
-
*
|
|
67
|
+
* - `language` — only the language subtag agrees.
|
|
68
|
+
* Weaker on purpose: a regional phrasing reached through its language by
|
|
69
|
+
* itself is a guess about the region.
|
|
61
70
|
*/
|
|
62
71
|
export type LocaleScope = "unscoped" | "exact" | "language";
|
|
63
72
|
/**
|
package/out/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,CAAA;AAE7C,UAAU,gBAAgB;IACzB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC9B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACrD,IAAI,EAAE,SAAS,CAAA;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,UAAW,SAAQ,gBAAgB;IACnD,IAAI,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,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;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAA;AAE3D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,WAAW,CAAA;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,YAAY,CAAA;IACnB;;OAEG;IACH,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": "10.1.0",
|
|
4
4
|
"description": "Regional variant alias table — local terms for amenities/brands blocked by locale. 'servo' → fuel (en-AU), 'マクド' → McDonald's (ja-JP), 'PFK' → KFC (fr-CA).",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
@@ -14,15 +14,10 @@
|
|
|
14
14
|
"out/**/*.d.ts",
|
|
15
15
|
"out/**/*.d.ts.map",
|
|
16
16
|
"data/**/*.json",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"**/*.ts",
|
|
20
|
-
"**/*.tsx",
|
|
21
|
-
"!*.test.ts",
|
|
22
|
-
"!*.test.tsx",
|
|
17
|
+
"lib/**/*.ts",
|
|
18
|
+
"lib/**/*.tsx",
|
|
23
19
|
"!**/*.test.ts",
|
|
24
|
-
"!**/*.test.tsx"
|
|
25
|
-
"!test/**"
|
|
20
|
+
"!**/*.test.tsx"
|
|
26
21
|
],
|
|
27
22
|
"type": "module",
|
|
28
23
|
"sideEffects": false,
|
|
@@ -40,10 +35,10 @@
|
|
|
40
35
|
"node": "./out/index.js",
|
|
41
36
|
"default": "./out/index.js"
|
|
42
37
|
},
|
|
43
|
-
"
|
|
44
|
-
"types": "./out
|
|
45
|
-
"node": "./out
|
|
46
|
-
"default": "./out
|
|
38
|
+
"./*": {
|
|
39
|
+
"types": "./out/*.d.ts",
|
|
40
|
+
"node": "./out/*.js",
|
|
41
|
+
"default": "./out/*.js"
|
|
47
42
|
}
|
|
48
43
|
},
|
|
49
44
|
"publishConfig": {
|
|
@@ -55,10 +50,10 @@
|
|
|
55
50
|
"node": "./out/index.js",
|
|
56
51
|
"default": "./out/index.js"
|
|
57
52
|
},
|
|
58
|
-
"
|
|
59
|
-
"types": "./out
|
|
60
|
-
"node": "./out
|
|
61
|
-
"default": "./out
|
|
53
|
+
"./*": {
|
|
54
|
+
"types": "./out/*.d.ts",
|
|
55
|
+
"node": "./out/*.js",
|
|
56
|
+
"default": "./out/*.js"
|
|
62
57
|
}
|
|
63
58
|
},
|
|
64
59
|
"imports": {
|
|
@@ -70,6 +65,6 @@
|
|
|
70
65
|
}
|
|
71
66
|
},
|
|
72
67
|
"dependencies": {
|
|
73
|
-
"@mailwoman/core": "
|
|
68
|
+
"@mailwoman/core": "10.1.0"
|
|
74
69
|
}
|
|
75
70
|
}
|