@kensio/pinyinjs 1.2.2 → 1.4.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/CHANGELOG.md +116 -3
- package/NOTICE +9 -0
- package/README.md +58 -9
- package/data/core.entries +1 -13
- package/data/core.freq +0 -0
- package/data/core.keys +1 -13
- package/data/full.entries +141 -131
- package/data/full.freq +0 -0
- package/data/full.keys +167 -157
- package/data/manifest.json +24 -9
- package/data/script.map +26543 -0
- package/data/standard.entries +1 -22
- package/data/standard.freq +0 -0
- package/data/standard.keys +2 -23
- package/dist/cli/arguments.d.ts +72 -0
- package/dist/cli/arguments.d.ts.map +1 -1
- package/dist/cli/arguments.js +110 -0
- package/dist/cli/arguments.js.map +1 -1
- package/dist/cli/commands.d.ts +11 -0
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +77 -1
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/environment.d.ts.map +1 -1
- package/dist/cli/environment.js +2 -1
- package/dist/cli/environment.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +21 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/run.d.ts +8 -0
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +11 -1
- package/dist/cli/run.js.map +1 -1
- package/dist/decode/convert.d.ts +10 -0
- package/dist/decode/convert.d.ts.map +1 -1
- package/dist/decode/convert.js +12 -0
- package/dist/decode/convert.js.map +1 -1
- package/dist/decode/script.d.ts +108 -0
- package/dist/decode/script.d.ts.map +1 -0
- package/dist/decode/script.js +195 -0
- package/dist/decode/script.js.map +1 -0
- package/dist/dictionary/dictionary.d.ts +13 -1
- package/dist/dictionary/dictionary.d.ts.map +1 -1
- package/dist/dictionary/dictionary.js +18 -4
- package/dist/dictionary/dictionary.js.map +1 -1
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +23 -3
- package/dist/dictionary/merge.js.map +1 -1
- package/dist/dictionary/script-tables.d.ts +17 -0
- package/dist/dictionary/script-tables.d.ts.map +1 -0
- package/dist/dictionary/script-tables.js +275 -0
- package/dist/dictionary/script-tables.js.map +1 -0
- package/dist/dictionary/source.d.ts +18 -0
- package/dist/dictionary/source.d.ts.map +1 -1
- package/dist/dictionary/source.js +20 -0
- package/dist/dictionary/source.js.map +1 -1
- package/dist/format/slug.d.ts +156 -0
- package/dist/format/slug.d.ts.map +1 -0
- package/dist/format/slug.js +0 -0
- package/dist/format/slug.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/script/conversion.d.ts +102 -0
- package/dist/script/conversion.d.ts.map +1 -0
- package/dist/script/conversion.js +194 -0
- package/dist/script/conversion.js.map +1 -0
- package/dist/script/glyphs.d.ts +95 -0
- package/dist/script/glyphs.d.ts.map +1 -0
- package/dist/script/glyphs.js +236 -0
- package/dist/script/glyphs.js.map +1 -0
- package/dist/sources/opencc.d.ts +32 -0
- package/dist/sources/opencc.d.ts.map +1 -0
- package/dist/sources/opencc.js +50 -0
- package/dist/sources/opencc.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glyphs.js","sourceRoot":"","sources":["../../src/script/glyphs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAU7C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAqB,CAAC;AAEpD;;;;;;;GAOG;AACH,SAAS,SAAS,CAAC,KAAa;IAC9B,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,K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CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,MAAc,EACd,QAAQ,GAAsC,EAAE;IAEhD,IAAI,MAAM,KAAK,cAAc,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3D,OAAO,IAAI,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One OpenCC mapping table: each key with the forms it may be written as.
|
|
3
|
+
*
|
|
4
|
+
* The first value is OpenCC's default, and the rest are alternatives it keeps
|
|
5
|
+
* for the reverse tables it generates. Both matter here: the default is what a
|
|
6
|
+
* conversion takes when it has no other evidence, and the alternatives are what
|
|
7
|
+
* a normalisation has to recognise on input.
|
|
8
|
+
*/
|
|
9
|
+
export type OpenCcTable = ReadonlyMap<string, readonly string[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Read one of OpenCC's dictionary tables.
|
|
12
|
+
*
|
|
13
|
+
* The format is one mapping per line as `key<TAB>value(s)`, values separated by
|
|
14
|
+
* spaces with the first as the default, and `#` starting a comment line.
|
|
15
|
+
*
|
|
16
|
+
* OpenCC also writes directives into those comments — `# @reverse-prefer: 才`
|
|
17
|
+
* tells its own build which value to favour when it generates the reversed
|
|
18
|
+
* table. They are deliberately ignored: we do not use OpenCC's generated
|
|
19
|
+
* reverse tables, and reversing a table here is a decision for the code that
|
|
20
|
+
* knows what it is reversing for. See SCRIPTS-AND-LOCALES.md.
|
|
21
|
+
*
|
|
22
|
+
* Faithful to the file, per the convention in DATA-SOURCES.md: a key mapping to
|
|
23
|
+
* itself is kept rather than dropped as a no-op, because "this character is
|
|
24
|
+
* already standard" and "this character is unknown to the table" are different
|
|
25
|
+
* facts, and only the table can tell them apart.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseOpenCcTable(text: string): OpenCcTable;
|
|
28
|
+
/**
|
|
29
|
+
* The form a table converts a character to, or undefined if it has no opinion.
|
|
30
|
+
*/
|
|
31
|
+
export declare function openCcDefault(table: OpenCcTable, character: string): string | undefined;
|
|
32
|
+
//# sourceMappingURL=opencc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencc.d.ts","sourceRoot":"","sources":["../../src/sources/opencc.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;AAYjE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAsB1D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAEpB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Separator between an OpenCC key and its values.
|
|
3
|
+
*/
|
|
4
|
+
const COLUMN = "\t";
|
|
5
|
+
/**
|
|
6
|
+
* Separator between the values of one key.
|
|
7
|
+
*/
|
|
8
|
+
const VALUE = " ";
|
|
9
|
+
/**
|
|
10
|
+
* Read one of OpenCC's dictionary tables.
|
|
11
|
+
*
|
|
12
|
+
* The format is one mapping per line as `key<TAB>value(s)`, values separated by
|
|
13
|
+
* spaces with the first as the default, and `#` starting a comment line.
|
|
14
|
+
*
|
|
15
|
+
* OpenCC also writes directives into those comments — `# @reverse-prefer: 才`
|
|
16
|
+
* tells its own build which value to favour when it generates the reversed
|
|
17
|
+
* table. They are deliberately ignored: we do not use OpenCC's generated
|
|
18
|
+
* reverse tables, and reversing a table here is a decision for the code that
|
|
19
|
+
* knows what it is reversing for. See SCRIPTS-AND-LOCALES.md.
|
|
20
|
+
*
|
|
21
|
+
* Faithful to the file, per the convention in DATA-SOURCES.md: a key mapping to
|
|
22
|
+
* itself is kept rather than dropped as a no-op, because "this character is
|
|
23
|
+
* already standard" and "this character is unknown to the table" are different
|
|
24
|
+
* facts, and only the table can tell them apart.
|
|
25
|
+
*/
|
|
26
|
+
export function parseOpenCcTable(text) {
|
|
27
|
+
const table = new Map();
|
|
28
|
+
for (const line of text.split("\n")) {
|
|
29
|
+
if (line.startsWith("#")) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const [key, values] = line.trim().split(COLUMN);
|
|
33
|
+
if (key === undefined || key === "" || values === undefined) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const forms = values.split(VALUE).filter((form) => form !== "");
|
|
37
|
+
if (forms.length === 0) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
table.set(key.normalize("NFC"), forms.map((form) => form.normalize("NFC")));
|
|
41
|
+
}
|
|
42
|
+
return table;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The form a table converts a character to, or undefined if it has no opinion.
|
|
46
|
+
*/
|
|
47
|
+
export function openCcDefault(table, character) {
|
|
48
|
+
return table.get(character)?.[0];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=opencc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencc.js","sourceRoot":"","sources":["../../src/sources/opencc.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,MAAM,GAAG,IAAI,CAAC;AAEpB;;GAEG;AACH,MAAM,KAAK,GAAG,GAAG,CAAC;AAElB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,KAAK,GAAG,IAAI,GAAG,EA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