@kensio/pinyinjs 1.7.6 → 1.7.8
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 +2 -2
- package/data/full.counts +0 -0
- package/data/full.entries +46 -46
- package/data/manifest.json +15 -8
- package/data/script.map +102 -0
- package/data/standard.entries +8 -8
- package/dist/decode/chang-complement.d.ts +19 -0
- package/dist/decode/chang-complement.d.ts.map +1 -0
- package/dist/decode/chang-complement.js +113 -0
- package/dist/decode/chang-complement.js.map +1 -0
- package/dist/decode/chang-context.d.ts +9 -7
- package/dist/decode/chang-context.d.ts.map +1 -1
- package/dist/decode/chang-context.js +36 -3
- package/dist/decode/chang-context.js.map +1 -1
- package/dist/decode/chang-rule.d.ts +25 -15
- package/dist/decode/chang-rule.d.ts.map +1 -1
- package/dist/decode/chang-rule.js +38 -19
- package/dist/decode/chang-rule.js.map +1 -1
- package/dist/decode/convert-pipeline.d.ts.map +1 -1
- package/dist/decode/convert-pipeline.js +3 -3
- package/dist/decode/convert-pipeline.js.map +1 -1
- package/dist/decode/de-rule.d.ts +20 -0
- package/dist/decode/de-rule.d.ts.map +1 -1
- package/dist/decode/de-rule.js +87 -1
- package/dist/decode/de-rule.js.map +1 -1
- package/dist/decode/decode.d.ts +12 -25
- package/dist/decode/decode.d.ts.map +1 -1
- package/dist/decode/decode.js +10 -47
- package/dist/decode/decode.js.map +1 -1
- package/dist/decode/decoders.d.ts +9 -4
- package/dist/decode/decoders.d.ts.map +1 -1
- package/dist/decode/decoders.js +7 -7
- package/dist/decode/decoders.js.map +1 -1
- package/dist/decode/edge-context.d.ts +19 -0
- package/dist/decode/edge-context.d.ts.map +1 -1
- package/dist/decode/edge-context.js +41 -0
- package/dist/decode/edge-context.js.map +1 -1
- package/dist/decode/lattice-decode.d.ts +28 -0
- package/dist/decode/lattice-decode.d.ts.map +1 -0
- package/dist/decode/lattice-decode.js +48 -0
- package/dist/decode/lattice-decode.js.map +1 -0
- package/dist/decode/lattice-slice.d.ts +22 -6
- package/dist/decode/lattice-slice.d.ts.map +1 -1
- package/dist/decode/lattice-slice.js +24 -18
- package/dist/decode/lattice-slice.js.map +1 -1
- package/dist/decode/numbers.d.ts +0 -8
- package/dist/decode/numbers.d.ts.map +1 -1
- package/dist/decode/numbers.js +0 -10
- package/dist/decode/numbers.js.map +1 -1
- package/dist/decode/reading-rules.d.ts +1 -1
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +3 -2
- package/dist/decode/reading-rules.js.map +1 -1
- package/dist/decode/rules.d.ts +1 -1
- package/dist/decode/rules.d.ts.map +1 -1
- package/dist/decode/rules.js +1 -1
- package/dist/decode/rules.js.map +1 -1
- package/dist/decode/run-context.d.ts +33 -0
- package/dist/decode/run-context.d.ts.map +1 -0
- package/dist/decode/run-context.js +47 -0
- package/dist/decode/run-context.js.map +1 -0
- package/dist/decode/run-lattice.d.ts +13 -10
- package/dist/decode/run-lattice.d.ts.map +1 -1
- package/dist/decode/run-lattice.js +15 -12
- package/dist/decode/run-lattice.js.map +1 -1
- package/dist/decode/script-region.d.ts +15 -0
- package/dist/decode/script-region.d.ts.map +1 -0
- package/dist/decode/script-region.js +61 -0
- package/dist/decode/script-region.js.map +1 -0
- package/dist/decode/script-types.d.ts +11 -2
- package/dist/decode/script-types.d.ts.map +1 -1
- package/dist/decode/script-types.js +2 -1
- package/dist/decode/script-types.js.map +1 -1
- package/dist/decode/script-words.d.ts +7 -5
- package/dist/decode/script-words.d.ts.map +1 -1
- package/dist/decode/script-words.js +18 -25
- package/dist/decode/script-words.js.map +1 -1
- package/dist/decode/script.d.ts.map +1 -1
- package/dist/decode/script.js +2 -1
- package/dist/decode/script.js.map +1 -1
- package/dist/dictionary/artifact-claims.d.ts +8 -0
- package/dist/dictionary/artifact-claims.d.ts.map +1 -1
- package/dist/dictionary/artifact-claims.js +11 -1
- package/dist/dictionary/artifact-claims.js.map +1 -1
- package/dist/dictionary/artifact.d.ts.map +1 -1
- package/dist/dictionary/artifact.js +3 -5
- package/dist/dictionary/artifact.js.map +1 -1
- package/dist/dictionary/measure-tone.d.ts +36 -0
- package/dist/dictionary/measure-tone.d.ts.map +1 -0
- package/dist/dictionary/measure-tone.js +139 -0
- package/dist/dictionary/measure-tone.js.map +1 -0
- package/dist/dictionary/merge-types.d.ts +8 -3
- package/dist/dictionary/merge-types.d.ts.map +1 -1
- package/dist/dictionary/merge-types.js.map +1 -1
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +7 -1
- package/dist/dictionary/merge.js.map +1 -1
- package/dist/dictionary/overrides.d.ts +5 -0
- package/dist/dictionary/overrides.d.ts.map +1 -1
- package/dist/dictionary/overrides.js +5 -5
- package/dist/dictionary/overrides.js.map +1 -1
- package/dist/dictionary/script-tables.js +91 -13
- package/dist/dictionary/script-tables.js.map +1 -1
- package/dist/dictionary/source.d.ts +22 -0
- package/dist/dictionary/source.d.ts.map +1 -1
- package/dist/dictionary/source.js +24 -0
- package/dist/dictionary/source.js.map +1 -1
- package/dist/dictionary/word-counts.d.ts +74 -0
- package/dist/dictionary/word-counts.d.ts.map +1 -0
- package/dist/dictionary/word-counts.js +142 -0
- package/dist/dictionary/word-counts.js.map +1 -0
- package/dist/dictionary/word-readings.d.ts.map +1 -1
- package/dist/dictionary/word-readings.js +3 -0
- package/dist/dictionary/word-readings.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/script/glyphs.d.ts +9 -8
- package/dist/script/glyphs.d.ts.map +1 -1
- package/dist/script/glyphs.js +21 -48
- package/dist/script/glyphs.js.map +1 -1
- package/dist/script/reading-splits.d.ts +41 -0
- package/dist/script/reading-splits.d.ts.map +1 -0
- package/dist/script/reading-splits.js +98 -0
- package/dist/script/reading-splits.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The glyph mappings whose answer depends on how the character is read.
|
|
3
|
+
*
|
|
4
|
+
* A merge one standard makes and the other does not is a difference between
|
|
5
|
+
* them, and {@link import("./glyphs.js").HONG_KONG_FORMS} is that difference
|
|
6
|
+
* read off OpenCC's tables. The reading is what the tables cannot carry,
|
|
7
|
+
* because a merge is not always total: 蔘 is a variant of 參 in its `shēn`
|
|
8
|
+
* sense alone, so inverting Taiwan's 蔘 → 參 into a blanket 參 → 蔘 rewrites
|
|
9
|
+
* 參加, 參考, 參觀 and 參差 as well.
|
|
10
|
+
*
|
|
11
|
+
* OpenCC resolves this with a phrase table. We resolve it with the reading,
|
|
12
|
+
* which is the point of difference this feature exists for, and which
|
|
13
|
+
* generalises to words no phrase table lists.
|
|
14
|
+
*
|
|
15
|
+
* A reading names the form written at that reading, and the two entries here
|
|
16
|
+
* point opposite ways, which is what {@link isReadingScoped} is for:
|
|
17
|
+
*
|
|
18
|
+
* - **著** is Hong Kong's form by default and canonical at one reading. Taiwan
|
|
19
|
+
* writes 著 for every sense; Hong Kong splits it, writing 着 for the aspect
|
|
20
|
+
* particle and its relatives and keeping 著 for `zhù`. CC-CEDICT records the
|
|
21
|
+
* same split in its 简体 column — `著 着 [zhe5]` against `著 著 [zhu4]` — which
|
|
22
|
+
* is independent confirmation that the divide is real and where it falls. So
|
|
23
|
+
* 著 stays in the Hong Kong table and this names the exception.
|
|
24
|
+
* - **參** is canonical by default and Hong Kong's form at one reading. Of the
|
|
25
|
+
* four readings CC-CEDICT gives it — `cān`, `cēn`, `shēn`, `sān` — only `shēn`
|
|
26
|
+
* is the ginseng that 蔘 writes, and 參加 is far the commonest of the rest. So
|
|
27
|
+
* 參 is **not** in the Hong Kong table and this is the whole of its mapping.
|
|
28
|
+
*
|
|
29
|
+
* 著's `zhuó` is deliberately absent, and that is not an oversight: CC-CEDICT
|
|
30
|
+
* writes it both ways — `著 着 [zhuo2]` for wearing or applying, `著 著 [zhuo2]`
|
|
31
|
+
* for 執著 — so the reading genuinely does not settle it. It falls through to
|
|
32
|
+
* the default and is reported as uncertain rather than guessed at silently.
|
|
33
|
+
*
|
|
34
|
+
* **Two is the whole list**, and that is measured rather than assumed. Of the
|
|
35
|
+
* 58 mappings, 39 are stated by Hong Kong's own table and 19 are Taiwan merges
|
|
36
|
+
* read backwards, which is the only direction a partial merge can arrive from.
|
|
37
|
+
* Of those 19, 著 and 參 are the only two whose Hong Kong form covers fewer
|
|
38
|
+
* CC-CEDICT readings than the canonical: 著 has five against 着's four, 參 has
|
|
39
|
+
* four against 蔘's one, and the other 17 cover the same readings or more.
|
|
40
|
+
*/
|
|
41
|
+
const READING_SPLITS = new Map([
|
|
42
|
+
["著", new Map([["zhu", "著"]])],
|
|
43
|
+
["參", new Map([["shen", "蔘"]])],
|
|
44
|
+
]);
|
|
45
|
+
/**
|
|
46
|
+
* A reading key ignoring tone and 儿化, which never bear on a glyph choice.
|
|
47
|
+
*
|
|
48
|
+
* Tone is dropped because the split that needs it — 著 — divides `zhù` from
|
|
49
|
+
* `zhe` and `zháo`, and those differ in their vowels as well, so the initial
|
|
50
|
+
* and final are enough and are what sources agree on most.
|
|
51
|
+
*/
|
|
52
|
+
function readingKey(syllable) {
|
|
53
|
+
if (syllable === undefined) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return `${syllable.initial}${syllable.final}`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The form a split writes at a reading, or undefined where none applies.
|
|
60
|
+
*
|
|
61
|
+
* A caller with no syllable gets undefined, which is what sends it to the flat
|
|
62
|
+
* table's answer and makes the choice a guess.
|
|
63
|
+
*/
|
|
64
|
+
export function splitFormAt(character, syllable) {
|
|
65
|
+
return READING_SPLITS.get(character)?.get(readingKey(syllable) ?? "");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Every form a split writes for a character, in the order the table lists them.
|
|
69
|
+
*/
|
|
70
|
+
export function splitFormsOf(character) {
|
|
71
|
+
return [...(READING_SPLITS.get(character)?.values() ?? [])];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Whether a character's regional form depends on how it is read.
|
|
75
|
+
*
|
|
76
|
+
* Exposed so that a conversion can report the choice as uncertain when it had
|
|
77
|
+
* no reading to go on, rather than presenting a default as though it were
|
|
78
|
+
* settled.
|
|
79
|
+
*/
|
|
80
|
+
export function isReadingSensitive(character) {
|
|
81
|
+
return READING_SPLITS.has(character);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Whether a character's Hong Kong form applies at one reading rather than all.
|
|
85
|
+
*
|
|
86
|
+
* The two shapes {@link READING_SPLITS} holds, told apart by what the split
|
|
87
|
+
* writes. A split naming the character itself is an exception to a mapping that
|
|
88
|
+
* otherwise holds, so the flat table keeps it — 著 is 着 in Hong Kong except at
|
|
89
|
+
* `zhù`. A split naming some other form is the whole of the mapping, so the
|
|
90
|
+
* flat table must not carry it, or every reading would take the regional form.
|
|
91
|
+
*
|
|
92
|
+
* Read by the derivation in `scripts/build-data/glyph-tables.ts`, which would
|
|
93
|
+
* otherwise fail the build for a mapping OpenCC makes and this file declines.
|
|
94
|
+
*/
|
|
95
|
+
export function isReadingScoped(character) {
|
|
96
|
+
return splitFormsOf(character).some((form) => form !== character);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=reading-splits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reading-splits.js","sourceRoot":"","sources":["../../src/script/reading-splits.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,cAAc,GAGhB,IAAI,GAAG,CAAC;IACV,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;CAChC,C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