@leonsilicon/mozillazg-pinyin-data 0.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/README.md +49 -0
- package/package.json +61 -0
- package/pinyin.d.ts +2 -0
- package/pinyin.js +3 -0
- package/pinyin.json +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @leonsilicon/mozillazg-pinyin-data
|
|
2
|
+
|
|
3
|
+
Mapping of Chinese characters to pinyin readings, with **tone numbers** (e.g. `yi1`) instead of diacritics. The data is derived from [mozillazg/pinyin-data](https://github.com/mozillazg/pinyin-data) and converted at build time using [pinyin-tone2](https://www.npmjs.com/package/pinyin-tone2).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @leonsilicon/mozillazg-pinyin-data
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
The package exposes a single subpath, `/pinyin`. Internally it re-exports `pinyin.json` using an import attribute, so consumers can use a plain default import:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import pinyin from "@leonsilicon/mozillazg-pinyin-data/pinyin";
|
|
17
|
+
|
|
18
|
+
pinyin["一"]; // ["yi1", "yi2", "yi4"]
|
|
19
|
+
pinyin["略"]; // ["lve4"]
|
|
20
|
+
pinyin["〇"]; // ["ling2", "yuan2", "xing1"]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
TypeScript:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import pinyin from "@leonsilicon/mozillazg-pinyin-data/pinyin";
|
|
27
|
+
// pinyin is typed as Record<string, string[]>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Tone numbers
|
|
31
|
+
|
|
32
|
+
- Tones 1–4 are appended as a single digit (`a` → `a1`, `a2`, `a3`, `a4`).
|
|
33
|
+
- The neutral tone is written as `5` (e.g. `ma5`).
|
|
34
|
+
- `ü` is written as `v` (e.g. `lüè` → `lve4`).
|
|
35
|
+
- A small number of rare interjection readings on `ê`, `m`, `n` retain their original diacritics because `pinyin-tone2` does not convert them.
|
|
36
|
+
|
|
37
|
+
## Rebuild the data
|
|
38
|
+
|
|
39
|
+
The JSON file is regenerated from `data/pinyin.txt`:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bun run build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This writes `pinyin.json` at the repository root.
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT. The underlying character→pinyin mapping is from [mozillazg/pinyin-data](https://github.com/mozillazg/pinyin-data) (MIT).
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@leonsilicon/mozillazg-pinyin-data",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Mapping of Chinese characters to pinyin (with tone numbers) derived from mozillazg/pinyin-data, distributed as JSON.",
|
|
5
|
+
"homepage": "https://github.com/leonsilicon/mozillazg-pinyin-data#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/leonsilicon/mozillazg-pinyin-data/issues"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "leonsilicon",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/leonsilicon/mozillazg-pinyin-data.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pinyin",
|
|
17
|
+
"chinese",
|
|
18
|
+
"mandarin",
|
|
19
|
+
"hanzi",
|
|
20
|
+
"tone",
|
|
21
|
+
"mozillazg"
|
|
22
|
+
],
|
|
23
|
+
"files": [
|
|
24
|
+
"pinyin.js",
|
|
25
|
+
"pinyin.d.ts",
|
|
26
|
+
"pinyin.json"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
"./pinyin": {
|
|
31
|
+
"types": "./pinyin.d.ts",
|
|
32
|
+
"default": "./pinyin.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "bun run scripts/build.ts",
|
|
41
|
+
"test": "vp test",
|
|
42
|
+
"check": "vp check",
|
|
43
|
+
"prepublishOnly": "bun run scripts/build.ts",
|
|
44
|
+
"prepare": "vp config"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"pinyin-tone2": "^1.1.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^25.6.2",
|
|
51
|
+
"@typescript/native-preview": "7.0.0-dev.20260509.2",
|
|
52
|
+
"bumpp": "^11.1.0",
|
|
53
|
+
"typescript": "^6.0.3",
|
|
54
|
+
"vite-plus": "^0.1.20"
|
|
55
|
+
},
|
|
56
|
+
"overrides": {
|
|
57
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
58
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
|
|
59
|
+
},
|
|
60
|
+
"packageManager": "bun@1.3.14"
|
|
61
|
+
}
|
package/pinyin.d.ts
ADDED
package/pinyin.js
ADDED