@mailwoman/variant-aliases 10.6.0 → 10.8.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/README.md +61 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @mailwoman/variant-aliases
|
|
2
|
+
|
|
3
|
+
This package maps regional amenity and brand expressions to canonical values using a detected locale.
|
|
4
|
+
|
|
5
|
+
Public library. Install with `npm install @mailwoman/variant-aliases`.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { lookupVariantAliases } from "@mailwoman/variant-aliases"
|
|
11
|
+
|
|
12
|
+
const matches = lookupVariantAliases("servo", "en-AU")
|
|
13
|
+
|
|
14
|
+
for (const { alias, confidence } of matches) {
|
|
15
|
+
const value = alias.kind === "amenity" ? alias.category : alias.brand
|
|
16
|
+
console.log(value, confidence) // fuel 1
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
An amenity alias supplies a category, such as `fuel`. A brand alias supplies a
|
|
21
|
+
display name, such as `McDonald's`. The caller chooses how to use multiple
|
|
22
|
+
matches.
|
|
23
|
+
|
|
24
|
+
## Lookup behavior
|
|
25
|
+
|
|
26
|
+
The lookup trims surrounding whitespace and lowercases the query. It matches
|
|
27
|
+
the entire resulting phrase against the bundled table. It does not extract
|
|
28
|
+
phrases from a longer query or perform fuzzy matching.
|
|
29
|
+
|
|
30
|
+
| Locale relationship | Result |
|
|
31
|
+
| ---------------------- | ----------------- |
|
|
32
|
+
| Exact locale tag | Confidence `1`. |
|
|
33
|
+
| Shared language subtag | Confidence `0.5`. |
|
|
34
|
+
| Different language | No match. |
|
|
35
|
+
|
|
36
|
+
For example, `servo` with `en-US` can still match the Australian entry through
|
|
37
|
+
the language fallback, at confidence `0.5`. Locale comparison is case-sensitive.
|
|
38
|
+
Use consistently cased tags such as `en-AU`. A `regionHint` is descriptive
|
|
39
|
+
metadata and does not filter results.
|
|
40
|
+
|
|
41
|
+
## API and data
|
|
42
|
+
|
|
43
|
+
- `lookupVariantAliases(text, locale)` returns all matches in descending confidence order.
|
|
44
|
+
- `resolveLocaleScope(locales, locale)` exposes the shared locale comparison. A `null` locale list is unrestricted, while a scoped entry with no detected locale returns `null`.
|
|
45
|
+
- `getAllAliases()` returns the bundled records.
|
|
46
|
+
- `VARIANT_ALIAS_VERSION` identifies the data version.
|
|
47
|
+
|
|
48
|
+
The Node entry loads [`data/aliases.json`](data/aliases.json) at module
|
|
49
|
+
initialization. Treat returned table records as read-only. When editing the
|
|
50
|
+
table, update its version and exercise the lookup tests:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
yarn test --run packages/variant-aliases
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The [POI taxonomy package](../poi-taxonomy) provides category and brand lookup
|
|
57
|
+
over its own tables.
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
The package declares `AGPL-3.0-only OR LicenseRef-Commercial`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/variant-aliases",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.8.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": {
|
|
@@ -65,6 +65,6 @@
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@mailwoman/core": "10.
|
|
68
|
+
"@mailwoman/core": "10.8.0"
|
|
69
69
|
}
|
|
70
70
|
}
|