@kensio/pinyinjs 1.5.1 → 1.5.3
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/CHANGELOG.md +175 -67
- package/README.md +4 -1
- package/data/core.entries +14 -14
- package/data/full.entries +14 -14
- package/data/manifest.json +6 -6
- package/data/standard.entries +14 -14
- package/dist/cli/arguments.d.ts.map +1 -1
- package/dist/cli/arguments.js.map +1 -1
- package/dist/cli/colour.js +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +10 -3
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/environment.d.ts.map +1 -1
- package/dist/cli/environment.js +0 -1
- package/dist/cli/environment.js.map +1 -1
- package/dist/cli/main.js +0 -0
- package/dist/decode/constituents.d.ts +26 -0
- package/dist/decode/constituents.d.ts.map +1 -0
- package/dist/decode/constituents.js +57 -0
- package/dist/decode/constituents.js.map +1 -0
- package/dist/decode/convert.d.ts.map +1 -1
- package/dist/decode/convert.js +11 -2
- package/dist/decode/convert.js.map +1 -1
- package/dist/decode/sandhi.d.ts +18 -1
- package/dist/decode/sandhi.d.ts.map +1 -1
- package/dist/decode/sandhi.js +105 -8
- package/dist/decode/sandhi.js.map +1 -1
- package/dist/dictionary/artifact.d.ts.map +1 -1
- package/dist/dictionary/artifact.js +0 -1
- package/dist/dictionary/artifact.js.map +1 -1
- package/dist/dictionary/dictionary.d.ts.map +1 -1
- package/dist/dictionary/dictionary.js +0 -1
- package/dist/dictionary/dictionary.js.map +1 -1
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +38 -2
- package/dist/dictionary/merge.js.map +1 -1
- package/dist/dictionary/node-source.d.ts.map +1 -1
- package/dist/dictionary/node-source.js +1 -4
- package/dist/dictionary/node-source.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/numerals/numerals.d.ts.map +1 -1
- package/dist/numerals/numerals.js +0 -1
- package/dist/numerals/numerals.js.map +1 -1
- package/dist/numerals/text.d.ts.map +1 -1
- package/dist/numerals/text.js +0 -1
- package/dist/numerals/text.js.map +1 -1
- package/dist/sources/cedict.d.ts +28 -5
- package/dist/sources/cedict.d.ts.map +1 -1
- package/dist/sources/cedict.js +30 -1
- package/dist/sources/cedict.js.map +1 -1
- package/package.json +31 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cedict.d.ts","sourceRoot":"","sources":["../../src/sources/cedict.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;;;;;OAQG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B
|
|
1
|
+
{"version":3,"file":"cedict.d.ts","sourceRoot":"","sources":["../../src/sources/cedict.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;;;;;OAQG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B;;;;;;;OAOG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAoD/D;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAyCvD;AAUD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,SAAS,MAAM,EAAE,CAOnB"}
|
package/dist/sources/cedict.js
CHANGED
|
@@ -6,6 +6,33 @@ const ENTRY_LINE = /^(\S+)\s+(\S+)\s+\[([^\]]*)\]\s+\/(.*)\/\s*$/u;
|
|
|
6
6
|
* A note giving the Taiwan reading, whether standalone or inside a definition.
|
|
7
7
|
*/
|
|
8
8
|
const TAIWAN_READING = /Taiwan pr\. \[([^\]]+)\]/u;
|
|
9
|
+
/**
|
|
10
|
+
* A definition that opens with a pronunciation note, rather than containing one.
|
|
11
|
+
*
|
|
12
|
+
* The distinction CC-CEDICT draws by parenthesising: a note **inside** a sense
|
|
13
|
+
* is written `(Taiwan pr. [sheng1]) able to bear`, and one that qualifies the
|
|
14
|
+
* headword's reading is written bare, as its own definition. The kind of note
|
|
15
|
+
* is not always `Taiwan pr.` — 胺 opens with `colloquial pr. [an1]; Taiwan pr.
|
|
16
|
+
* [an1]` — and the note is not always the whole definition either: 帆's is
|
|
17
|
+
* `Taiwan pr. [fan2], except 帆布[fan1 bu4] canvas` and 傍's offers three
|
|
18
|
+
* readings. All of those are still notes about the headword.
|
|
19
|
+
*/
|
|
20
|
+
const NOTE_DEFINITION = /^[\w.-]+ pr\. \[/u;
|
|
21
|
+
/**
|
|
22
|
+
* How far an entry's `Taiwan pr.` note reaches — see {@link TaiwanReadingScope}.
|
|
23
|
+
*/
|
|
24
|
+
function taiwanScopeOf(definitions) {
|
|
25
|
+
const marked = definitions.filter((definition) => TAIWAN_READING.test(definition));
|
|
26
|
+
if (marked.length === 0) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (marked.some((definition) => NOTE_DEFINITION.test(definition))) {
|
|
30
|
+
return "entry";
|
|
31
|
+
}
|
|
32
|
+
return definitions.findIndex((definition) => TAIWAN_READING.test(definition)) === 0
|
|
33
|
+
? "leading"
|
|
34
|
+
: "sense";
|
|
35
|
+
}
|
|
9
36
|
/**
|
|
10
37
|
* The marker CC-CEDICT uses for a syllable whose pronunciation is unknown.
|
|
11
38
|
*/
|
|
@@ -41,13 +68,15 @@ export function parseCedict(text) {
|
|
|
41
68
|
const taiwanReadings = taiwan?.[1]
|
|
42
69
|
?.split(/\s+/u)
|
|
43
70
|
.filter((reading) => reading !== "");
|
|
71
|
+
const taiwanScope = taiwanScopeOf(definitions);
|
|
44
72
|
entries.push({
|
|
45
73
|
traditional: traditional.normalize("NFC"),
|
|
46
74
|
simplified: simplified.normalize("NFC"),
|
|
47
75
|
readings,
|
|
48
76
|
isProperNoun: isCapitalised(readings[0] ?? ""),
|
|
49
77
|
...(taiwanReadings !== undefined &&
|
|
50
|
-
taiwanReadings.length > 0 &&
|
|
78
|
+
taiwanReadings.length > 0 &&
|
|
79
|
+
taiwanScope !== undefined && { taiwanReadings, taiwanScope }),
|
|
51
80
|
definitions,
|
|
52
81
|
});
|
|
53
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cedict.js","sourceRoot":"","sources":["../../src/sources/cedict.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cedict.js","sourceRoot":"","sources":["../../src/sources/cedict.ts"],"names":[],"mappings":"AAgEA;;GAEG;AACH,MAAM,UAAU,GAAG,+CAA+C,CAAC;AAEnE;;GAEG;AACH,MAAM,cAAc,GAAG,2BAA2B,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAE5C;;GAEG;AACH,SAAS,aAAa,CACpB,WAA8B;IAE9B,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAC/C,cAAc,CAA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gBAAgB,CAC9B,QAA2B;IAE3B,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC7D,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CACzC,KAAK,GAAG,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CACnD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kensio/pinyinjs",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Chinese hanzi to pinyin conversion",
|
|
5
|
-
"repository":
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "https://github.com/KensioSoftware/pinyinjs"
|
|
8
|
-
},
|
|
5
|
+
"repository": "https://github.com/KensioSoftware/pinyinjs",
|
|
9
6
|
"homepage": "https://pinyinjs.dev",
|
|
10
7
|
"bugs": "https://github.com/KensioSoftware/pinyinjs/issues",
|
|
11
8
|
"main": "./dist/index.js",
|
|
@@ -39,30 +36,45 @@
|
|
|
39
36
|
"imports": {
|
|
40
37
|
"#test/*": "./test/*"
|
|
41
38
|
},
|
|
39
|
+
"packageManager": "pnpm@11.17.0+sha512.cca3cea332ad254bb84145f966d19f4879615210346fc92c79a047f23a0d7b3cca3c3792f0076ba1f1831d277efbcf0a9119b31a9a60eca7fb3d6231f331ef72",
|
|
42
40
|
"engines": {
|
|
43
41
|
"node": ">=22.0.0"
|
|
44
42
|
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
45
|
+
"prepack": "pnpm build",
|
|
46
|
+
"cli": "node --import jiti/register src/cli/main.ts",
|
|
47
|
+
"build:check": "tsc -p tsconfig.json --noEmit",
|
|
48
|
+
"fmt": "oxlint --fix . && oxfmt .",
|
|
49
|
+
"lint": "oxlint . && oxfmt --check .",
|
|
50
|
+
"lint:ci": "oxlint --format=github . && oxfmt --check .",
|
|
51
|
+
"fta": "./scripts/sh/fta.sh",
|
|
52
|
+
"pack:check": "./scripts/sh/pack-check.sh",
|
|
53
|
+
"build:data": "node --import jiti/register scripts/build-data/build.ts",
|
|
54
|
+
"fetch:data": "node --import jiti/register scripts/build-data/fetch.ts",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:coverage": "vitest run --coverage",
|
|
57
|
+
"check": "pnpm fmt && pnpm fta && pnpm build && pnpm build:check && pnpm test:coverage",
|
|
58
|
+
"accuracy": "node --import jiti/register scripts/build-data/accuracy.ts",
|
|
59
|
+
"polyphones": "node --import jiti/register scripts/build-data/polyphones.ts",
|
|
60
|
+
"numerals": "node --import jiti/register scripts/build-data/numerals.ts",
|
|
61
|
+
"transcription": "node --import jiti/register scripts/build-data/transcription.ts"
|
|
62
|
+
},
|
|
45
63
|
"devDependencies": {
|
|
46
|
-
"@eslint/js": "^10.0.1",
|
|
47
64
|
"@kensio/smartass": "^1.33.0",
|
|
48
|
-
"@
|
|
65
|
+
"@semantic-release/exec": "7.1.0",
|
|
49
66
|
"@types/lodash": "^4.17.24",
|
|
50
67
|
"@types/node": "^26.0.0",
|
|
51
68
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
52
69
|
"@vitest/coverage-v8": "^4.1.10",
|
|
53
|
-
"
|
|
54
|
-
"eslint": "^10.6.0",
|
|
55
|
-
"eslint-config-prettier": "^10.1.8",
|
|
56
|
-
"eslint-plugin-jsdoc": "^63.0.13",
|
|
57
|
-
"eslint-plugin-no-secrets": "^2.3.3",
|
|
58
|
-
"eslint-plugin-security": "^4.0.1",
|
|
59
|
-
"eslint-plugin-unicorn": "^71.0.0",
|
|
70
|
+
"conventional-changelog-conventionalcommits": "10.2.1",
|
|
60
71
|
"fta-cli": "^3.0.0",
|
|
61
|
-
"globals": "^17.7.0",
|
|
62
72
|
"jiti": "^2.7.0",
|
|
63
|
-
"
|
|
73
|
+
"oxfmt": "^0.62.0",
|
|
74
|
+
"oxlint": "^1.77.0",
|
|
75
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
76
|
+
"semantic-release": "25.0.9",
|
|
64
77
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
65
|
-
"typescript-eslint": "^8.63.0",
|
|
66
78
|
"vitest": "^4.1.10"
|
|
67
79
|
},
|
|
68
80
|
"keywords": [
|
|
@@ -76,23 +88,5 @@
|
|
|
76
88
|
},
|
|
77
89
|
"author": "Kensio Software",
|
|
78
90
|
"license": "Apache-2.0 AND CC-BY-SA-4.0",
|
|
79
|
-
"type": "module"
|
|
80
|
-
|
|
81
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
82
|
-
"cli": "node --import jiti/register src/cli/main.ts",
|
|
83
|
-
"build:check": "tsc -p tsconfig.json --noEmit",
|
|
84
|
-
"fmt": "eslint --fix . && prettier --write .",
|
|
85
|
-
"lint": "eslint . && prettier --check .",
|
|
86
|
-
"fta": "./scripts/sh/fta.sh",
|
|
87
|
-
"pack:check": "./scripts/sh/pack-check.sh",
|
|
88
|
-
"build:data": "node --import jiti/register scripts/build-data/build.ts",
|
|
89
|
-
"fetch:data": "node --import jiti/register scripts/build-data/fetch.ts",
|
|
90
|
-
"test": "vitest run",
|
|
91
|
-
"test:coverage": "vitest run --coverage",
|
|
92
|
-
"check": "pnpm fmt && pnpm fta && pnpm build && pnpm build:check && pnpm test:coverage",
|
|
93
|
-
"accuracy": "node --import jiti/register scripts/build-data/accuracy.ts",
|
|
94
|
-
"polyphones": "node --import jiti/register scripts/build-data/polyphones.ts",
|
|
95
|
-
"numerals": "node --import jiti/register scripts/build-data/numerals.ts",
|
|
96
|
-
"transcription": "node --import jiti/register scripts/build-data/transcription.ts"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
91
|
+
"type": "module"
|
|
92
|
+
}
|