@mailwoman/variant-aliases 0.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/data/aliases.json +65 -0
- package/out/index.d.ts +20 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +19 -0
- package/out/index.js.map +1 -0
- package/out/lookup.d.ts +30 -0
- package/out/lookup.d.ts.map +1 -0
- package/out/lookup.js +89 -0
- package/out/lookup.js.map +1 -0
- package/out/types.d.ts +54 -0
- package/out/types.d.ts.map +1 -0
- package/out/types.js +9 -0
- package/out/types.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.1.0",
|
|
3
|
+
"description": "Regional variant aliases — local terms for amenities/brands that differ from the standard global name. Sources: docs/articles/understanding/exotic-poi/regional-variant-queries.md. Format documented in types.ts.",
|
|
4
|
+
"aliases": [
|
|
5
|
+
{ "variant": "servo", "category": "fuel", "locales": ["en-AU", "en-NZ"], "kind": "amenity" },
|
|
6
|
+
{
|
|
7
|
+
"variant": "petrol station",
|
|
8
|
+
"category": "fuel",
|
|
9
|
+
"locales": ["en-GB", "en-IE", "en-AU", "en-NZ", "en-ZA", "en-IN"],
|
|
10
|
+
"kind": "amenity"
|
|
11
|
+
},
|
|
12
|
+
{ "variant": "bodega", "category": "convenience", "locales": ["en-US"], "regionHint": "NYC", "kind": "amenity" },
|
|
13
|
+
{ "variant": "corner shop", "category": "convenience", "locales": ["en-GB", "en-IE"], "kind": "amenity" },
|
|
14
|
+
{ "variant": "depanneur", "category": "convenience", "locales": ["fr-CA"], "kind": "amenity" },
|
|
15
|
+
{ "variant": "dépanneur", "category": "convenience", "locales": ["fr-CA"], "kind": "amenity" },
|
|
16
|
+
{ "variant": "milk bar", "category": "convenience", "locales": ["en-AU"], "kind": "amenity" },
|
|
17
|
+
{ "variant": "off-licence", "category": "alcohol", "locales": ["en-GB", "en-IE"], "kind": "amenity" },
|
|
18
|
+
{ "variant": "off licence", "category": "alcohol", "locales": ["en-GB", "en-IE"], "kind": "amenity" },
|
|
19
|
+
{ "variant": "offie", "category": "alcohol", "locales": ["en-GB"], "kind": "amenity" },
|
|
20
|
+
{ "variant": "bottle shop", "category": "alcohol", "locales": ["en-AU", "en-NZ"], "kind": "amenity" },
|
|
21
|
+
{ "variant": "bottle-o", "category": "alcohol", "locales": ["en-AU"], "kind": "amenity" },
|
|
22
|
+
{ "variant": "bottlo", "category": "alcohol", "locales": ["en-AU"], "kind": "amenity" },
|
|
23
|
+
{
|
|
24
|
+
"variant": "package store",
|
|
25
|
+
"category": "alcohol",
|
|
26
|
+
"locales": ["en-US"],
|
|
27
|
+
"regionHint": "New England",
|
|
28
|
+
"kind": "amenity"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"variant": "packie",
|
|
32
|
+
"category": "alcohol",
|
|
33
|
+
"locales": ["en-US"],
|
|
34
|
+
"regionHint": "New England",
|
|
35
|
+
"kind": "amenity"
|
|
36
|
+
},
|
|
37
|
+
{ "variant": "chemist", "category": "pharmacy", "locales": ["en-GB", "en-AU", "en-NZ"], "kind": "amenity" },
|
|
38
|
+
{
|
|
39
|
+
"variant": "takeaway",
|
|
40
|
+
"category": "restaurant",
|
|
41
|
+
"locales": ["en-GB", "en-AU", "en-NZ", "en-IE"],
|
|
42
|
+
"kind": "amenity"
|
|
43
|
+
},
|
|
44
|
+
{ "variant": "takeout", "category": "restaurant", "locales": ["en-US", "en-CA"], "kind": "amenity" },
|
|
45
|
+
{ "variant": "macca's", "brand": "McDonald's", "locales": ["en-AU", "en-NZ"], "kind": "brand" },
|
|
46
|
+
{ "variant": "maccas", "brand": "McDonald's", "locales": ["en-AU", "en-NZ"], "kind": "brand" },
|
|
47
|
+
{ "variant": "マクド", "brand": "McDonald's", "locales": ["ja-JP"], "regionHint": "Kansai", "kind": "brand" },
|
|
48
|
+
{ "variant": "マック", "brand": "McDonald's", "locales": ["ja-JP"], "regionHint": "Kantō", "kind": "brand" },
|
|
49
|
+
{ "variant": "mcdo", "brand": "McDonald's", "locales": ["fr-FR", "fr-CA", "fr-BE"], "kind": "brand" },
|
|
50
|
+
{ "variant": "mickey d's", "brand": "McDonald's", "locales": ["en-US"], "kind": "brand" },
|
|
51
|
+
{ "variant": "pfk", "brand": "KFC", "locales": ["fr-CA"], "kind": "brand" },
|
|
52
|
+
{ "variant": "hungry jack's", "brand": "Burger King", "locales": ["en-AU"], "kind": "brand" },
|
|
53
|
+
{ "variant": "hungry jacks", "brand": "Burger King", "locales": ["en-AU"], "kind": "brand" },
|
|
54
|
+
{ "variant": "セブンイレブン", "brand": "7-Eleven", "locales": ["ja-JP"], "kind": "brand" },
|
|
55
|
+
{ "variant": "セブイレ", "brand": "7-Eleven", "locales": ["ja-JP"], "kind": "brand" },
|
|
56
|
+
{ "variant": "セブン", "brand": "7-Eleven", "locales": ["ja-JP"], "kind": "brand" },
|
|
57
|
+
{ "variant": "スタバ", "brand": "Starbucks", "locales": ["ja-JP"], "kind": "brand" },
|
|
58
|
+
{ "variant": "スターバックス", "brand": "Starbucks", "locales": ["ja-JP"], "kind": "brand" },
|
|
59
|
+
{ "variant": "ファミマ", "brand": "FamilyMart", "locales": ["ja-JP"], "kind": "brand" },
|
|
60
|
+
{ "variant": "ファミリーマート", "brand": "FamilyMart", "locales": ["ja-JP"], "kind": "brand" },
|
|
61
|
+
{ "variant": "ローソン", "brand": "Lawson", "locales": ["ja-JP"], "kind": "brand" },
|
|
62
|
+
{ "variant": "ドンキ", "brand": "Don Quijote", "locales": ["ja-JP"], "kind": "brand" },
|
|
63
|
+
{ "variant": "ドン・キホーテ", "brand": "Don Quijote", "locales": ["ja-JP"], "kind": "brand" }
|
|
64
|
+
]
|
|
65
|
+
}
|
package/out/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `@mailwoman/variant-aliases` — regional variant alias table for amenity/brand queries.
|
|
7
|
+
*
|
|
8
|
+
* The data file (`data/aliases.json`) catalogs ~35 hand-curated regional terms: "servo" → fuel
|
|
9
|
+
* (en-AU), "マクド" → McDonald's (ja-JP), "PFK" → KFC (fr-CA), etc.
|
|
10
|
+
*
|
|
11
|
+
* See:
|
|
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, gated by locale-gate output).
|
|
17
|
+
*/
|
|
18
|
+
export { VARIANT_ALIAS_VERSION, getAllAliases, lookupVariantAliases } from "./lookup.js";
|
|
19
|
+
export type { AliasLookupResult, AmenityAlias, BrandAlias, VariantAlias, VariantAliasTable, VariantKind, } from "./types.js";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACxF,YAAY,EACX,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,WAAW,GACX,MAAM,YAAY,CAAA"}
|
package/out/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* `@mailwoman/variant-aliases` — regional variant alias table for amenity/brand queries.
|
|
7
|
+
*
|
|
8
|
+
* The data file (`data/aliases.json`) catalogs ~35 hand-curated regional terms: "servo" → fuel
|
|
9
|
+
* (en-AU), "マクド" → McDonald's (ja-JP), "PFK" → KFC (fr-CA), etc.
|
|
10
|
+
*
|
|
11
|
+
* See:
|
|
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, gated by locale-gate output).
|
|
17
|
+
*/
|
|
18
|
+
export { VARIANT_ALIAS_VERSION, getAllAliases, lookupVariantAliases } from "./lookup.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA"}
|
package/out/lookup.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Regional variant alias lookup. Given a token (or short phrase) and a detected locale, return the
|
|
7
|
+
* canonical amenity category or brand it refers to.
|
|
8
|
+
*
|
|
9
|
+
* This is the data-side foundation for #166 (variant alias table + locale-gated category matching).
|
|
10
|
+
* The runtime integration into the kind classifier is v0.6.0+ work.
|
|
11
|
+
*/
|
|
12
|
+
import type { AliasLookupResult, VariantAlias } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Match a query token against the variant alias table, gated by detected locale.
|
|
15
|
+
*
|
|
16
|
+
* Confidence:
|
|
17
|
+
*
|
|
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
|
+
* is intentionally weaker because regional variants are by definition regional.
|
|
21
|
+
* - No match when neither holds.
|
|
22
|
+
*
|
|
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
|
+
*/
|
|
26
|
+
export declare function lookupVariantAliases(text: string, locale: string): AliasLookupResult[];
|
|
27
|
+
/** Pure-data accessor for callers that want to enumerate the table (e.g. corpus synthesis). */
|
|
28
|
+
export declare function getAllAliases(): ReadonlyArray<VariantAlias>;
|
|
29
|
+
export declare const VARIANT_ALIAS_VERSION: string;
|
|
30
|
+
//# sourceMappingURL=lookup.d.ts.map
|
|
@@ -0,0 +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;AAsCpF;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAwBtF;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,IAAI,aAAa,CAAC,YAAY,CAAC,CAE3D;AAED,eAAO,MAAM,qBAAqB,QAAgB,CAAA"}
|
package/out/lookup.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Regional variant alias lookup. Given a token (or short phrase) and a detected locale, return the
|
|
7
|
+
* canonical amenity category or brand it refers to.
|
|
8
|
+
*
|
|
9
|
+
* This is the data-side foundation for #166 (variant alias table + locale-gated category matching).
|
|
10
|
+
* The runtime integration into the kind classifier is v0.6.0+ work.
|
|
11
|
+
*/
|
|
12
|
+
import { readFileSync } from "node:fs";
|
|
13
|
+
import { dirname, resolve } from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
function loadTable() {
|
|
17
|
+
const candidates = [
|
|
18
|
+
resolve(moduleDir, "data/aliases.json"),
|
|
19
|
+
resolve(moduleDir, "../data/aliases.json"),
|
|
20
|
+
resolve(moduleDir, "../../variant-aliases/data/aliases.json"),
|
|
21
|
+
];
|
|
22
|
+
for (const path of candidates) {
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// try next
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
throw new Error("variant-aliases: could not find data/aliases.json");
|
|
31
|
+
}
|
|
32
|
+
const TABLE = loadTable();
|
|
33
|
+
/**
|
|
34
|
+
* Indexed by lowercased variant string for O(1) lookup. Multiple entries can share the same variant
|
|
35
|
+
* key (e.g. ambiguous "takeaway" only matches GB but not AU if both list it differently), so each
|
|
36
|
+
* entry is an array of all aliases that share the key.
|
|
37
|
+
*/
|
|
38
|
+
const INDEX = (() => {
|
|
39
|
+
const map = new Map();
|
|
40
|
+
for (const a of TABLE.aliases) {
|
|
41
|
+
const key = a.variant.toLowerCase();
|
|
42
|
+
const existing = map.get(key) ?? [];
|
|
43
|
+
existing.push(a);
|
|
44
|
+
map.set(key, existing);
|
|
45
|
+
}
|
|
46
|
+
return map;
|
|
47
|
+
})();
|
|
48
|
+
/**
|
|
49
|
+
* Match a query token against the variant alias table, gated by detected locale.
|
|
50
|
+
*
|
|
51
|
+
* Confidence:
|
|
52
|
+
*
|
|
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
|
+
* is intentionally weaker because regional variants are by definition regional.
|
|
56
|
+
* - No match when neither holds.
|
|
57
|
+
*
|
|
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
|
+
*/
|
|
61
|
+
export function lookupVariantAliases(text, locale) {
|
|
62
|
+
const norm = text.trim().toLowerCase();
|
|
63
|
+
if (!norm)
|
|
64
|
+
return [];
|
|
65
|
+
const candidates = INDEX.get(norm);
|
|
66
|
+
if (!candidates || candidates.length === 0)
|
|
67
|
+
return [];
|
|
68
|
+
const language = locale.split(/[-_]/)[0];
|
|
69
|
+
const results = [];
|
|
70
|
+
for (const alias of candidates) {
|
|
71
|
+
if (alias.locales.includes(locale)) {
|
|
72
|
+
results.push({ alias, confidence: 1.0 });
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
// Relaxed match: any locale in `locales` that shares the same language part.
|
|
76
|
+
const langMatch = alias.locales.some((l) => l.split(/[-_]/)[0] === language);
|
|
77
|
+
if (langMatch) {
|
|
78
|
+
results.push({ alias, confidence: 0.5 });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
results.sort((a, b) => b.confidence - a.confidence);
|
|
82
|
+
return results;
|
|
83
|
+
}
|
|
84
|
+
/** Pure-data accessor for callers that want to enumerate the table (e.g. corpus synthesis). */
|
|
85
|
+
export function getAllAliases() {
|
|
86
|
+
return TABLE.aliases;
|
|
87
|
+
}
|
|
88
|
+
export const VARIANT_ALIAS_VERSION = TABLE.version;
|
|
89
|
+
//# sourceMappingURL=lookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,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,OAAO,CAAA;AACrB,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,CAAA"}
|
package/out/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Types for the regional variant alias table.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The semantic kind of a variant — either a generic amenity category or a specific brand.
|
|
10
|
+
*
|
|
11
|
+
* - `amenity` aliases resolve to a category (`fuel`, `pharmacy`, `convenience`, ...). Several
|
|
12
|
+
* variants can map to the same category ("servo" and "petrol station" both → `fuel`).
|
|
13
|
+
* - `brand` aliases resolve to a canonical brand name. Multiple regional variants of the same brand
|
|
14
|
+
* ("Macca's", "McDo", "Mickey D's", "マクド") all map to `McDonald's`.
|
|
15
|
+
*/
|
|
16
|
+
export type VariantKind = "amenity" | "brand";
|
|
17
|
+
export interface VariantAliasBase {
|
|
18
|
+
/** The user-typed variant. Always lowercase for the lookup key (CJK preserved as-is). */
|
|
19
|
+
variant: string;
|
|
20
|
+
/**
|
|
21
|
+
* BCP-47 locale tags where this variant is in active use. Used to gate lookups: only consider an
|
|
22
|
+
* alias when the detected locale matches one of these. A query in `en-US` won't match Australian
|
|
23
|
+
* "servo" because `en-AU` is not in `["en-US"]`.
|
|
24
|
+
*/
|
|
25
|
+
locales: ReadonlyArray<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Free-form regional refinement within the locale (e.g. "NYC", "Kansai", "Quebec"). Not used for
|
|
28
|
+
* matching today; informational. A future enhancement could combine this with a coarse
|
|
29
|
+
* geolocation signal to further disambiguate.
|
|
30
|
+
*/
|
|
31
|
+
regionHint?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AmenityAlias extends VariantAliasBase {
|
|
34
|
+
kind: "amenity";
|
|
35
|
+
/** Canonical amenity category (e.g. `fuel`, `pharmacy`, `convenience`, `alcohol`). */
|
|
36
|
+
category: string;
|
|
37
|
+
}
|
|
38
|
+
export interface BrandAlias extends VariantAliasBase {
|
|
39
|
+
kind: "brand";
|
|
40
|
+
/** Canonical brand display name (e.g. `McDonald's`, `7-Eleven`). */
|
|
41
|
+
brand: string;
|
|
42
|
+
}
|
|
43
|
+
export type VariantAlias = AmenityAlias | BrandAlias;
|
|
44
|
+
export interface VariantAliasTable {
|
|
45
|
+
version: string;
|
|
46
|
+
description: string;
|
|
47
|
+
aliases: ReadonlyArray<VariantAlias>;
|
|
48
|
+
}
|
|
49
|
+
export interface AliasLookupResult {
|
|
50
|
+
alias: VariantAlias;
|
|
51
|
+
/** Confidence in the match. 1.0 = exact locale match. 0.5 = relaxed (locale fallback to language). */
|
|
52
|
+
confidence: number;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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;;;;OAIG;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/out/types.js
ADDED
package/out/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mailwoman/variant-aliases",
|
|
3
|
+
"version": "0.1.0",
|
|
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
|
+
"license": "AGPL-3.0-only",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/sister-software/mailwoman.git",
|
|
9
|
+
"directory": "variant-aliases"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
".": "./out/index.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"out/**/*.js",
|
|
18
|
+
"out/**/*.js.map",
|
|
19
|
+
"out/**/*.d.ts",
|
|
20
|
+
"out/**/*.d.ts.map",
|
|
21
|
+
"data/**/*.json"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
}
|
|
26
|
+
}
|