@kensio/pinyinjs 1.8.6 → 1.9.1
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/data/core.entries +27 -27
- package/data/core.freq +0 -0
- package/data/core.keys +1 -1
- package/data/full.counts +0 -0
- package/data/full.entries +4139 -4139
- package/data/full.freq +0 -0
- package/data/manifest.json +11 -11
- package/data/script.map +3 -2
- package/data/standard.entries +385 -385
- package/data/standard.freq +0 -0
- package/data/standard.keys +1 -1
- package/dist/decode/chang-context.d.ts +4 -0
- package/dist/decode/chang-context.d.ts.map +1 -1
- package/dist/decode/chang-context.js +16 -2
- package/dist/decode/chang-context.js.map +1 -1
- package/dist/decode/chang-rule.d.ts.map +1 -1
- package/dist/decode/chang-rule.js +6 -0
- package/dist/decode/chang-rule.js.map +1 -1
- package/dist/decode/chang-span.d.ts +37 -0
- package/dist/decode/chang-span.d.ts.map +1 -0
- package/dist/decode/chang-span.js +100 -0
- package/dist/decode/chang-span.js.map +1 -0
- package/dist/decode/chong-frames.d.ts +9 -0
- package/dist/decode/chong-frames.d.ts.map +1 -0
- package/dist/decode/chong-frames.js +58 -0
- package/dist/decode/chong-frames.js.map +1 -0
- package/dist/decode/ding-frames.d.ts +8 -0
- package/dist/decode/ding-frames.d.ts.map +1 -0
- package/dist/decode/ding-frames.js +54 -0
- package/dist/decode/ding-frames.js.map +1 -0
- package/dist/decode/dominant-readings.d.ts +55 -0
- package/dist/decode/dominant-readings.d.ts.map +1 -0
- package/dist/decode/dominant-readings.js +67 -0
- package/dist/decode/dominant-readings.js.map +1 -0
- package/dist/decode/dominant-rule.d.ts +24 -0
- package/dist/decode/dominant-rule.d.ts.map +1 -0
- package/dist/decode/dominant-rule.js +122 -0
- package/dist/decode/dominant-rule.js.map +1 -0
- package/dist/decode/guo-rule.d.ts.map +1 -1
- package/dist/decode/guo-rule.js +12 -0
- package/dist/decode/guo-rule.js.map +1 -1
- package/dist/decode/hao-rule.d.ts +16 -0
- package/dist/decode/hao-rule.d.ts.map +1 -0
- package/dist/decode/hao-rule.js +61 -0
- package/dist/decode/hao-rule.js.map +1 -0
- package/dist/decode/ji-frames.d.ts +9 -0
- package/dist/decode/ji-frames.d.ts.map +1 -0
- package/dist/decode/ji-frames.js +71 -0
- package/dist/decode/ji-frames.js.map +1 -0
- package/dist/decode/jiao-rule.d.ts +5 -6
- package/dist/decode/jiao-rule.d.ts.map +1 -1
- package/dist/decode/jiao-rule.js +39 -3
- package/dist/decode/jiao-rule.js.map +1 -1
- package/dist/decode/jie-frames.d.ts +6 -0
- package/dist/decode/jie-frames.d.ts.map +1 -0
- package/dist/decode/jie-frames.js +94 -0
- package/dist/decode/jie-frames.js.map +1 -0
- package/dist/decode/liang-frames.d.ts +6 -0
- package/dist/decode/liang-frames.d.ts.map +1 -0
- package/dist/decode/liang-frames.js +112 -0
- package/dist/decode/liang-frames.js.map +1 -0
- package/dist/decode/polyphone-rules.d.ts +2 -1
- package/dist/decode/polyphone-rules.d.ts.map +1 -1
- package/dist/decode/polyphone-rules.js +2 -1
- package/dist/decode/polyphone-rules.js.map +1 -1
- package/dist/decode/reading-rules.d.ts +3 -1
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +9 -2
- package/dist/decode/reading-rules.js.map +1 -1
- package/dist/decode/reduplication-readings.d.ts +26 -0
- package/dist/decode/reduplication-readings.d.ts.map +1 -0
- package/dist/decode/reduplication-readings.js +48 -0
- package/dist/decode/reduplication-readings.js.map +1 -0
- package/dist/decode/reduplication-rule.d.ts +1 -1
- package/dist/decode/reduplication-rule.d.ts.map +1 -1
- package/dist/decode/reduplication-rule.js +2 -41
- package/dist/decode/reduplication-rule.js.map +1 -1
- package/dist/decode/shu-frames.d.ts +6 -0
- package/dist/decode/shu-frames.d.ts.map +1 -0
- package/dist/decode/shu-frames.js +102 -0
- package/dist/decode/shu-frames.js.map +1 -0
- package/dist/decode/split-infix.d.ts +25 -0
- package/dist/decode/split-infix.d.ts.map +1 -0
- package/dist/decode/split-infix.js +134 -0
- package/dist/decode/split-infix.js.map +1 -0
- package/dist/decode/split-rule.d.ts +11 -0
- package/dist/decode/split-rule.d.ts.map +1 -1
- package/dist/decode/split-rule.js +17 -4
- package/dist/decode/split-rule.js.map +1 -1
- package/dist/decode/tiao-frames.d.ts +6 -0
- package/dist/decode/tiao-frames.d.ts.map +1 -0
- package/dist/decode/tiao-frames.js +60 -0
- package/dist/decode/tiao-frames.js.map +1 -0
- package/dist/decode/verbal-frame.d.ts +68 -0
- package/dist/decode/verbal-frame.d.ts.map +1 -0
- package/dist/decode/verbal-frame.js +76 -0
- package/dist/decode/verbal-frame.js.map +1 -0
- package/dist/decode/verbal-held.d.ts +12 -0
- package/dist/decode/verbal-held.d.ts.map +1 -0
- package/dist/decode/verbal-held.js +63 -0
- package/dist/decode/verbal-held.js.map +1 -0
- package/dist/decode/verbal-rule.d.ts +31 -0
- package/dist/decode/verbal-rule.d.ts.map +1 -0
- package/dist/decode/verbal-rule.js +100 -0
- package/dist/decode/verbal-rule.js.map +1 -0
- package/dist/decode/xiang-frames.d.ts +6 -0
- package/dist/decode/xiang-frames.d.ts.map +1 -0
- package/dist/decode/xiang-frames.js +65 -0
- package/dist/decode/xiang-frames.js.map +1 -0
- package/dist/decode/zhuan-frames.d.ts +6 -0
- package/dist/decode/zhuan-frames.d.ts.map +1 -0
- package/dist/decode/zhuan-frames.js +97 -0
- package/dist/decode/zhuan-frames.js.map +1 -0
- package/dist/dictionary/character-defaults.d.ts.map +1 -1
- package/dist/dictionary/character-defaults.js +4 -1
- package/dist/dictionary/character-defaults.js.map +1 -1
- package/dist/dictionary/character-readings.d.ts.map +1 -1
- package/dist/dictionary/character-readings.js +9 -0
- package/dist/dictionary/character-readings.js.map +1 -1
- package/dist/dictionary/free-readings.d.ts +70 -0
- package/dist/dictionary/free-readings.d.ts.map +1 -0
- package/dist/dictionary/free-readings.js +108 -0
- package/dist/dictionary/free-readings.js.map +1 -0
- package/dist/dictionary/frequency-table.d.ts +8 -0
- package/dist/dictionary/frequency-table.d.ts.map +1 -1
- package/dist/dictionary/frequency-table.js +11 -1
- package/dist/dictionary/frequency-table.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reading rule for characters whose verb reads differently from the rest
|
|
3
|
+
* of them: 量, 数, 调, 系, 转, 钉, 结, 相 and 冲.
|
|
4
|
+
*/
|
|
5
|
+
import { isSameSyllable } from "../dictionary/entry.js";
|
|
6
|
+
import { CHONG_FRAME } from "./chong-frames.js";
|
|
7
|
+
import { DING_FRAME } from "./ding-frames.js";
|
|
8
|
+
import { JI_FRAME } from "./ji-frames.js";
|
|
9
|
+
import { JIE_FRAME } from "./jie-frames.js";
|
|
10
|
+
import { LIANG_FRAME } from "./liang-frames.js";
|
|
11
|
+
import { SHU_FRAME } from "./shu-frames.js";
|
|
12
|
+
import { TIAO_FRAME } from "./tiao-frames.js";
|
|
13
|
+
import { isBoundAt } from "./verbal-frame.js";
|
|
14
|
+
import { isHeldAgainst } from "./verbal-held.js";
|
|
15
|
+
import { XIANG_FRAME } from "./xiang-frames.js";
|
|
16
|
+
import { ZHUAN_FRAME } from "./zhuan-frames.js";
|
|
17
|
+
/**
|
|
18
|
+
* Every frame, one to a character.
|
|
19
|
+
*/
|
|
20
|
+
export const VERBAL_FRAMES = [
|
|
21
|
+
LIANG_FRAME,
|
|
22
|
+
SHU_FRAME,
|
|
23
|
+
TIAO_FRAME,
|
|
24
|
+
JI_FRAME,
|
|
25
|
+
ZHUAN_FRAME,
|
|
26
|
+
DING_FRAME,
|
|
27
|
+
JIE_FRAME,
|
|
28
|
+
XIANG_FRAME,
|
|
29
|
+
CHONG_FRAME,
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* The frames by the characters they read.
|
|
33
|
+
*/
|
|
34
|
+
const FRAMES_BY_CHARACTER = new Map(VERBAL_FRAMES.flatMap((frame) => [...frame.characters].map((character) => [character, frame])));
|
|
35
|
+
/**
|
|
36
|
+
* The frame saying the character at a position is its verb, or undefined.
|
|
37
|
+
*/
|
|
38
|
+
function frameAt(context, at) {
|
|
39
|
+
/* c8 ignore next -- the position is inside the run */
|
|
40
|
+
const frame = FRAMES_BY_CHARACTER.get(context.characters[at] ?? "");
|
|
41
|
+
if (frame === undefined ||
|
|
42
|
+
isBoundAt(context, at, frame) ||
|
|
43
|
+
isHeldAgainst(context, at, frame.reading) ||
|
|
44
|
+
!frame.isVerbalAt(context, at)) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return frame;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The verb's reading for nine characters where the sentence uses the verb.
|
|
51
|
+
*
|
|
52
|
+
* Each of them is stored with another reading first, and for the same reason:
|
|
53
|
+
* the commoner reading in a corpus is the one inside words. 量 is `liàng` in
|
|
54
|
+
* 数量, 质量 and 词汇量, 数 is `shù` in 数字 and 数十, 调 is `diào` in 调查, 系
|
|
55
|
+
* is `xì` in 关系, and so on. A word carries its own reading, so what the
|
|
56
|
+
* default decides is the character standing on its own, and in running text
|
|
57
|
+
* that is as often the verb as anything. 我妈妈量了我的体温 came out with
|
|
58
|
+
* `liàng`, 你能数到十吗 with `shù` and 请把音量调低一点 with `diào`.
|
|
59
|
+
*
|
|
60
|
+
* The verb is told apart by its neighbours, a different set for each
|
|
61
|
+
* character, so each has a frame of its own in a file of its own. They share
|
|
62
|
+
* how the verdict is given, which is the way {@link import("./zhi-rule.js").COUNTING_ZHI}
|
|
63
|
+
* gives it: where a frame holds, the edge of the character alone reading the
|
|
64
|
+
* verb is forced, and an edge of several characters reading it some other way
|
|
65
|
+
* is forbidden. A tagged word holding the character with another reading is
|
|
66
|
+
* left alone, since 词汇量 and 关系 decide their own.
|
|
67
|
+
*
|
|
68
|
+
* The reading the frame names has to be among the character's readings for
|
|
69
|
+
* the rule to do anything. Unihan gives 繫 and 釘 no `jì` and no `dìng`, so
|
|
70
|
+
* those two forms are left out until the data has them.
|
|
71
|
+
*/
|
|
72
|
+
export const VERBAL_READING = {
|
|
73
|
+
name: "verbal-reading",
|
|
74
|
+
verdictFor: (context) => {
|
|
75
|
+
const { edge } = context;
|
|
76
|
+
if (edge.reading.length !== edge.to - edge.from) {
|
|
77
|
+
return "keep";
|
|
78
|
+
}
|
|
79
|
+
let verdict = "keep";
|
|
80
|
+
for (let at = edge.from; at < edge.to; at++) {
|
|
81
|
+
const frame = frameAt(context, at);
|
|
82
|
+
if (frame === undefined) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const here = edge.reading[at - edge.from];
|
|
86
|
+
/* c8 ignore next 3 -- the reading is as long as the span */
|
|
87
|
+
if (here === undefined) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (!isSameSyllable(here, frame.reading)) {
|
|
91
|
+
return edge.to - edge.from === 1 ? "keep" : "forbid";
|
|
92
|
+
}
|
|
93
|
+
if (edge.to - edge.from === 1) {
|
|
94
|
+
verdict = "force";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return verdict;
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=verbal-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verbal-rule.js","sourceRoot":"","sources":["../../src/decode/verbal-rule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO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frames.d.ts","sourceRoot":"","sources":["../../src/decode/xiang-frames.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAoD3B;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,WAMzB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a 相 is a photograph or is "each other".
|
|
3
|
+
*
|
|
4
|
+
* 照相 is `zhàoxiàng` and a word. Taken apart, as in 照了一张相 and 你照的相,
|
|
5
|
+
* the 相 stands on its own and took the commoner `xiāng` of 相信 and 互相.
|
|
6
|
+
*/
|
|
7
|
+
import { QUANTITY_CHARACTERS } from "../numerals/characters.js";
|
|
8
|
+
import { closesTaggedWord, syllableOf, } from "./verbal-frame.js";
|
|
9
|
+
/**
|
|
10
|
+
* The verb of the photograph, in both scripts.
|
|
11
|
+
*/
|
|
12
|
+
const TAKING = "照";
|
|
13
|
+
/**
|
|
14
|
+
* What can stand between 照 and its 相: aspect, a count and 的.
|
|
15
|
+
*
|
|
16
|
+
* 照了一张相, 照张相, 照个相, 照过相, 照的相.
|
|
17
|
+
*/
|
|
18
|
+
const BETWEEN = new Set([
|
|
19
|
+
"了",
|
|
20
|
+
"过",
|
|
21
|
+
"過",
|
|
22
|
+
"的",
|
|
23
|
+
"张",
|
|
24
|
+
"張",
|
|
25
|
+
"个",
|
|
26
|
+
"個",
|
|
27
|
+
"几",
|
|
28
|
+
"幾",
|
|
29
|
+
...QUANTITY_CHARACTERS,
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* How far back the 照 may be.
|
|
33
|
+
*/
|
|
34
|
+
const REACH = 4;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the 相 at a position is the photograph of a 照 before it.
|
|
37
|
+
*
|
|
38
|
+
* A word ending at the 照 takes it away from the 相, which keeps 按照 and
|
|
39
|
+
* 护照 out.
|
|
40
|
+
*/
|
|
41
|
+
function isPhotographAt(context, at) {
|
|
42
|
+
const { characters } = context;
|
|
43
|
+
for (let back = at - 1; back >= Math.max(0, at - REACH); back--) {
|
|
44
|
+
/* c8 ignore next -- the position is inside the run */
|
|
45
|
+
const character = characters[back] ?? "";
|
|
46
|
+
if (character === TAKING) {
|
|
47
|
+
return !closesTaggedWord(context, back + 1);
|
|
48
|
+
}
|
|
49
|
+
if (!BETWEEN.has(character)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 相 read `xiàng` where it is a photograph taken.
|
|
57
|
+
*/
|
|
58
|
+
export const XIANG_FRAME = {
|
|
59
|
+
characters: new Set(["相"]),
|
|
60
|
+
reading: syllableOf("xiàng"),
|
|
61
|
+
boundBefore: new Set(),
|
|
62
|
+
boundAfter: new Set(),
|
|
63
|
+
isVerbalAt: isPhotographAt,
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=xiang-frames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xiang-frames.js","sourceRoot":"","sources":["../../src/decode/xiang-frames.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EACL,gBAAgB,EAChB,UAAU,GAEX,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,CAAC;AAEnB;;;;GAIG;AACH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC;IACtB,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG,mBAAmB;CACvB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,KAAK,GAAG,CAAC,CAAC;AAEhB;;;;;GAKG;AACH,SAAS,cAAc,CAAC,OAAoB,EAAE,EAAU;IACtD,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,KAAK,IAAI,IAAI,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;QAChE,sDAAsD;QACtD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACzC,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,UAAU,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;IAC5B,WAAW,EAAE,IAAI,GAAG,EAAE;IACtB,UAAU,EAAE,IAAI,GAAG,EAAE;IACrB,UAAU,EAAE,cAAc;CAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zhuan-frames.d.ts","sourceRoot":"","sources":["../../src/decode/zhuan-frames.ts"],"names":[],"mappings":"AASA,OAAO,EAKL,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAC;AA2F3B;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,WAMzB,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a 转 is turning round or changing course.
|
|
3
|
+
*
|
|
4
|
+
* `zhuàn` turns round and round, and `zhuǎn` changes: direction (转东南),
|
|
5
|
+
* state (天气转凉), post (转御史大夫) or vehicle (转火车). Both are verbs, so
|
|
6
|
+
* the tag says nothing, and what tells them apart is the motion around them.
|
|
7
|
+
*/
|
|
8
|
+
import { QUANTITY_CHARACTERS } from "../numerals/characters.js";
|
|
9
|
+
import { wordEndingAt } from "./rules.js";
|
|
10
|
+
import { isBareAt, isRunEnd, startsWithAny, syllableOf, charactersOf, } from "./verbal-frame.js";
|
|
11
|
+
/**
|
|
12
|
+
* What going round something is said with, in both scripts: 绕着地球转, 围着你转,
|
|
13
|
+
* 围绕太阳转.
|
|
14
|
+
*/
|
|
15
|
+
const AROUND = ["绕", "繞", "围着", "圍著", "围绕", "圍繞"];
|
|
16
|
+
/**
|
|
17
|
+
* What can close a clause after a 转 that is going round.
|
|
18
|
+
*
|
|
19
|
+
* The end of the run, 的 (世界不是围着你转的), aspect and the sentence
|
|
20
|
+
* particles. 个 is out, since 转个身 is turning round once.
|
|
21
|
+
*/
|
|
22
|
+
const CLOSING = new Set(["的", "了", "着", "呀", "啊", "吧", "呢"]);
|
|
23
|
+
/**
|
|
24
|
+
* What only turning round is followed by.
|
|
25
|
+
*
|
|
26
|
+
* 转起来 (风车转起来), 转得 (转得晕头转向), and 转个不停. 转过身 is turning
|
|
27
|
+
* round once and reads `zhuǎn`, so 过 is out.
|
|
28
|
+
*/
|
|
29
|
+
const SPINNING = ["起来", "得", "个不停"];
|
|
30
|
+
/**
|
|
31
|
+
* The laps a 转 goes round: 转一圈, 转了几圈, 转个圈.
|
|
32
|
+
*/
|
|
33
|
+
const LAP = "圈";
|
|
34
|
+
/**
|
|
35
|
+
* Whether the text after a position is a number of laps, as in 一圈, 了三圈
|
|
36
|
+
* and 个圈.
|
|
37
|
+
*/
|
|
38
|
+
function isLapAt(context, at) {
|
|
39
|
+
const { characters } = context;
|
|
40
|
+
let from = at;
|
|
41
|
+
if (characters[from] === "了" || characters[from] === "个") {
|
|
42
|
+
from++;
|
|
43
|
+
}
|
|
44
|
+
while (QUANTITY_CHARACTERS.has(characters[from] ?? "")) {
|
|
45
|
+
from++;
|
|
46
|
+
}
|
|
47
|
+
return characters[from] === LAP;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* What says a 转 is still at it: 这条流水线每天都在转.
|
|
51
|
+
*/
|
|
52
|
+
const ONGOING = new Set(["在", "正在"]);
|
|
53
|
+
/**
|
|
54
|
+
* Whether the clause before a position says the 转 goes round something.
|
|
55
|
+
*/
|
|
56
|
+
function isAroundBefore(context, at) {
|
|
57
|
+
const before = context.characters.slice(0, at).join("");
|
|
58
|
+
return AROUND.some((word) => before.includes(word));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Whether the 转 at a position is turning round.
|
|
62
|
+
*
|
|
63
|
+
* Going round something and still at it: 地球绕着太阳转, 这条流水线每天都在转.
|
|
64
|
+
*/
|
|
65
|
+
function isTurningAt(context, at) {
|
|
66
|
+
if (startsWithAny(context, at + 1, SPINNING) || isLapAt(context, at + 1)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
const closes = isRunEnd(context, at + 1) || isBareAt(context, at + 1, CLOSING);
|
|
70
|
+
if (!closes) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return (isAroundBefore(context, at) || ONGOING.has(wordEndingAt(context, at) ?? ""));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The characters that bind it into a compound reading it otherwise.
|
|
77
|
+
*
|
|
78
|
+
* Bound before it: 运转, 旋转, 好转, 逆转, 周转 and the other compounds
|
|
79
|
+
* reading it `zhuǎn`, so 绕地球运转 is not read as spinning. 公转 and 自转 read
|
|
80
|
+
* `zhuàn` and are left out.
|
|
81
|
+
*/
|
|
82
|
+
const BOUND_BEFORE = charactersOf("运運旋扭流好逆周回反翻倒婉辗輾急掉");
|
|
83
|
+
/**
|
|
84
|
+
* The characters after it that bind it into such a compound.
|
|
85
|
+
*/
|
|
86
|
+
const BOUND_AFTER = new Set();
|
|
87
|
+
/**
|
|
88
|
+
* 转 read `zhuàn` where it is turning round.
|
|
89
|
+
*/
|
|
90
|
+
export const ZHUAN_FRAME = {
|
|
91
|
+
characters: new Set(["转", "轉"]),
|
|
92
|
+
reading: syllableOf("zhuàn"),
|
|
93
|
+
boundBefore: BOUND_BEFORE,
|
|
94
|
+
boundAfter: BOUND_AFTER,
|
|
95
|
+
isVerbalAt: isTurningAt,
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=zhuan-frames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zhuan-frames.js","sourceRoot":"","sources":["../../src/decode/zhuan-frames.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAoB,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,UAAU,EAEV,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAElD;;;;;GAKG;AACH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEpC;;GAEG;AACH,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB;;;GAGG;AACH,SAAS,OAAO,CAAC,OAAoB,EAAE,EAAU;IAC/C,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,I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AE,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,GAAwB,IAAI,GAAG,EAAE,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,UAAU,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/B,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;IAC5B,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,WAAW;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"character-defaults.d.ts","sourceRoot":"","sources":["../../src/dictionary/character-defaults.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"character-defaults.d.ts","sourceRoot":"","sources":["../../src/dictionary/character-defaults.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAGL,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,QAAQ,GAAG,SAAS,CAEtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC,CAAC;IAC5D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,EACzD,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,GACxD,iBAAiB,CAsDnB"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { countCorpusMass, rankByCorpusMass } from "./corpus-mass.js";
|
|
10
10
|
import { demoteReducedNeutrals, isNeutralAlone, resolveFrequencyTones, } from "./frequency-tones.js";
|
|
11
|
+
import { leadWithFreeReading } from "./free-readings.js";
|
|
11
12
|
import { readAlignedReading, readDictionaryReading } from "./reading.js";
|
|
12
13
|
import { pairScripts, TraditionalTable, } from "./traditional.js";
|
|
13
14
|
/**
|
|
@@ -39,6 +40,8 @@ export function buildCharacterDefaults(sources, cedictByWord, cedictByHant) {
|
|
|
39
40
|
// Unihan ranks the readings and the corpus re-ranks the ones it has seen: a
|
|
40
41
|
// character's default is whichever of its readings the dictionary's own words
|
|
41
42
|
// spend the most of jieba's corpus on, and Unihan's order decides the rest.
|
|
43
|
+
// A character listed in FREE_READINGS then leads with the reading it takes
|
|
44
|
+
// standing alone, which neither ranking can see.
|
|
42
45
|
const mass = countCorpusMass({ phrase, cedict, jieba }, traditional);
|
|
43
46
|
const defaults = new Map();
|
|
44
47
|
let reducedNeutrals = 0;
|
|
@@ -59,7 +62,7 @@ export function buildCharacterDefaults(sources, cedictByWord, cedictByHant) {
|
|
|
59
62
|
.map((reading) => characterSyllable(character, reading))
|
|
60
63
|
.filter((syllable) => syllable !== undefined);
|
|
61
64
|
if (parsed.length > 0) {
|
|
62
|
-
defaults.set(character, rankByCorpusMass(character, parsed, readings.fields, mass));
|
|
65
|
+
defaults.set(character, leadWithFreeReading(character, rankByCorpusMass(character, parsed, readings.fields, mass)));
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
return { traditional, defaults, reducedNeutrals };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"character-defaults.js","sourceRoot":"","sources":["../../src/dictionary/character-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"character-defaults.js","sourceRoot":"","sources":["../../src/dictionary/character-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,WAAW,EAEX,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAiB,EACjB,OAAe;IAEf,OAAO,qBAAqB,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAYD;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAqB,EACrB,YAAyD,EACzD,YAAyD;IAEzD,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC1E,6DAA6D;IAC7D,6EAA6E;IAC7E,wEAAwE;IACxE,uEAAuE;IACvE,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,UAAU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SAAS,EAAE,OAAO,CAAC,CAAC;aACvD,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;QAChD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,QAAQ,CAAC,GAAG,CACV,SAAS,EACT,mBAAmB,CACjB,SAAS,EACT,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAC3D,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"character-readings.d.ts","sourceRoot":"","sources":["../../src/dictionary/character-readings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,eAAO,MAAM,kBAAkB,EAAE,SAAS,cAAc,
|
|
1
|
+
{"version":3,"file":"character-readings.d.ts","sourceRoot":"","sources":["../../src/dictionary/character-readings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,eAAO,MAAM,kBAAkB,EAAE,SAAS,cAAc,EA+BvD,CAAC"}
|
|
@@ -21,5 +21,14 @@ export const CHARACTER_READINGS = [
|
|
|
21
21
|
reads("子", "zǐ", "and a suffix sense is not a claim about the character"),
|
|
22
22
|
reads("夫", "fū", "nor is 大夫's and 丈夫's reduction"),
|
|
23
23
|
reads("吗", "ma", "but a 语气词 CC-CEDICT reads 轻声 alone keeps it"),
|
|
24
|
+
// FREE_READINGS: the free verb or classifier leads, and the compounds that
|
|
25
|
+
// ranked the other reading first keep it.
|
|
26
|
+
reads("剥", "bāo", "the free verb, not 剥削's bō"),
|
|
27
|
+
reads("剥削", "bō xuē", "and the compounds keep the literary reading"),
|
|
28
|
+
reads("切", "qiē", "kHanyuPinlu's qiè is nearly all 一切"),
|
|
29
|
+
reads("一切", "yī qiè", "which keeps it"),
|
|
30
|
+
reads("幢", "zhuàng", "the classifier, not 经幢's banner"),
|
|
31
|
+
reads("脏", "zāng", "dirty, not the organ"),
|
|
32
|
+
reads("心脏", "xīn zàng", "which 心脏 keeps"),
|
|
24
33
|
];
|
|
25
34
|
//# sourceMappingURL=character-readings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"character-readings.js","sourceRoot":"","sources":["../../src/dictionary/character-readings.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,CAAC,MAAM,kBAAkB,GAA8B;IAC3D,oEAAoE;IACpE,wEAAwE;IACxE,0EAA0E;IAC1E,yEAAyE;IACzE,gEAAgE;IAChE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,uCAAuC,CAAC;IAChE,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,6CAA6C,CAAC;IACrE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,gDAAgD,CAAC;IACvE,0EAA0E;IAC1E,wEAAwE;IACxE,0EAA0E;IAC1E,4EAA4E;IAC5E,uDAAuD;IACvD,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,yCAAyC,CAAC;IAC3D,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,+CAA+C,CAAC;IAClE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,4CAA4C,CAAC;IAC9D,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,mDAAmD,CAAC;IAC1E,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,8CAA8C,CAAC;IAChE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,uDAAuD,CAAC;IACzE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,gCAAgC,CAAC;IAClD,KAAK,CAAC,GA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EAAE,gBAAgB,CAAC;IACvC,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,iCAAiC,CAAC;IACvD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type Syllable } from "../syllable/syllable.js";
|
|
2
|
+
/**
|
|
3
|
+
* A character whose reading as a word of its own is not the one it leads with.
|
|
4
|
+
*/
|
|
5
|
+
export interface FreeReading {
|
|
6
|
+
/** The character, in either script. */
|
|
7
|
+
readonly character: string;
|
|
8
|
+
/** The reading it takes standing alone, as tone-marked pinyin. */
|
|
9
|
+
readonly reading: string;
|
|
10
|
+
/** The words that carry the other reading, which is why the sources rank it
|
|
11
|
+
* first. */
|
|
12
|
+
readonly displaces: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Characters that read one way inside words and another standing alone.
|
|
16
|
+
*
|
|
17
|
+
* A character's default is ranked by `kHanyuPinlu` where it lists several
|
|
18
|
+
* readings and by the corpus mass of the dictionary's words where it does not,
|
|
19
|
+
* and both count the character *inside words*. That is the right evidence for
|
|
20
|
+
* most polyphones and the wrong evidence for these, which have a literary
|
|
21
|
+
* reading in their compounds and an everyday one as a free verb or classifier.
|
|
22
|
+
* 剥削, 剥夺 and 剥落 give 剥 `bō`, and a reader peeling an orange says `bāo`.
|
|
23
|
+
* `kHanyuPinlu` counts 切 `qiè` 998 times against `qiē` 70, nearly all of it
|
|
24
|
+
* 一切, and 切土豆 is `qiē`.
|
|
25
|
+
*
|
|
26
|
+
* The compounds are dictionary words and keep their own readings. The default
|
|
27
|
+
* is what a character segmented on its own is read with, which is where these
|
|
28
|
+
* stand as free words, and what an unknown compound is derived from.
|
|
29
|
+
*
|
|
30
|
+
* **What is listed here.** A character whose 现代汉语词典 entry gives the listed
|
|
31
|
+
* reading to its free use and the other to its compounds or a literary sense,
|
|
32
|
+
* found by reading example sentences rather than by a measure. CPP labels
|
|
33
|
+
* news text, where these characters mostly sit inside words, so it is the check
|
|
34
|
+
* that nothing broke rather than the evidence for the list. What is *not*
|
|
35
|
+
* listed is a character whose free uses split, such as 卡 (a card, `kǎ`, and
|
|
36
|
+
* stuck, `qiǎ`) or 背 (the back and to recite, `bèi`, and to carry, `bēi`): a
|
|
37
|
+
* default cannot choose between two free words, and a context rule can. Nor
|
|
38
|
+
* is a character that names and transliterations use on its own: 勒 is `lēi`
|
|
39
|
+
* in 勒得难受 and `lè` in every 希特勒 and 达勒姆 the dictionary lacks, and 盛 is
|
|
40
|
+
* `chéng` in 盛汤 and the surname `Shèng` in 刘盛. Listing either cost CPP 25
|
|
41
|
+
* and 7 cases.
|
|
42
|
+
*
|
|
43
|
+
* **The reading must be one the sources already give the character.** It is
|
|
44
|
+
* moved to the front of the ranking rather than written over it, so a source
|
|
45
|
+
* refresh that dropped it would fail the build rather than leave a reading
|
|
46
|
+
* nothing attests. That is why 剝 and 掙 are missing beside 剥 and 挣: Unihan
|
|
47
|
+
* gives them `bō` and `zhēng` alone.
|
|
48
|
+
*/
|
|
49
|
+
export declare const FREE_READINGS: readonly FreeReading[];
|
|
50
|
+
/**
|
|
51
|
+
* Read a free reading into a syllable, throwing if it is not one.
|
|
52
|
+
*
|
|
53
|
+
* Throwing for the reason {@link import("./overrides.js").readOverrideReading}
|
|
54
|
+
* does: an entry that failed to parse would leave the ranking it was written
|
|
55
|
+
* to correct, and nothing would notice.
|
|
56
|
+
*/
|
|
57
|
+
export declare function freeSyllable(free: FreeReading): Syllable;
|
|
58
|
+
/**
|
|
59
|
+
* The table, keyed by character and parsed into syllables.
|
|
60
|
+
*/
|
|
61
|
+
export declare const FREE_SYLLABLES: ReadonlyMap<string, Syllable>;
|
|
62
|
+
/**
|
|
63
|
+
* Lead a character's ranked readings with its free reading, where it has one.
|
|
64
|
+
*
|
|
65
|
+
* The rest keep the order the ranking gave them. A listed reading the ranking
|
|
66
|
+
* does not hold throws, which is the build failing on a source that stopped
|
|
67
|
+
* attesting it.
|
|
68
|
+
*/
|
|
69
|
+
export declare function leadWithFreeReading(character: string, ranked: readonly Syllable[]): readonly Syllable[];
|
|
70
|
+
//# sourceMappingURL=free-readings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"free-readings.d.ts","sourceRoot":"","sources":["../../src/dictionary/free-readings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;gBACY;IACZ,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EA0B/C,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,QAAQ,CAQxD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAExD,CAAC;AAaF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,SAAS,QAAQ,EAAE,GAC1B,SAAS,QAAQ,EAAE,CAYrB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { readSyllable } from "../syllable/syllable.js";
|
|
2
|
+
/**
|
|
3
|
+
* Characters that read one way inside words and another standing alone.
|
|
4
|
+
*
|
|
5
|
+
* A character's default is ranked by `kHanyuPinlu` where it lists several
|
|
6
|
+
* readings and by the corpus mass of the dictionary's words where it does not,
|
|
7
|
+
* and both count the character *inside words*. That is the right evidence for
|
|
8
|
+
* most polyphones and the wrong evidence for these, which have a literary
|
|
9
|
+
* reading in their compounds and an everyday one as a free verb or classifier.
|
|
10
|
+
* 剥削, 剥夺 and 剥落 give 剥 `bō`, and a reader peeling an orange says `bāo`.
|
|
11
|
+
* `kHanyuPinlu` counts 切 `qiè` 998 times against `qiē` 70, nearly all of it
|
|
12
|
+
* 一切, and 切土豆 is `qiē`.
|
|
13
|
+
*
|
|
14
|
+
* The compounds are dictionary words and keep their own readings. The default
|
|
15
|
+
* is what a character segmented on its own is read with, which is where these
|
|
16
|
+
* stand as free words, and what an unknown compound is derived from.
|
|
17
|
+
*
|
|
18
|
+
* **What is listed here.** A character whose 现代汉语词典 entry gives the listed
|
|
19
|
+
* reading to its free use and the other to its compounds or a literary sense,
|
|
20
|
+
* found by reading example sentences rather than by a measure. CPP labels
|
|
21
|
+
* news text, where these characters mostly sit inside words, so it is the check
|
|
22
|
+
* that nothing broke rather than the evidence for the list. What is *not*
|
|
23
|
+
* listed is a character whose free uses split, such as 卡 (a card, `kǎ`, and
|
|
24
|
+
* stuck, `qiǎ`) or 背 (the back and to recite, `bèi`, and to carry, `bēi`): a
|
|
25
|
+
* default cannot choose between two free words, and a context rule can. Nor
|
|
26
|
+
* is a character that names and transliterations use on its own: 勒 is `lēi`
|
|
27
|
+
* in 勒得难受 and `lè` in every 希特勒 and 达勒姆 the dictionary lacks, and 盛 is
|
|
28
|
+
* `chéng` in 盛汤 and the surname `Shèng` in 刘盛. Listing either cost CPP 25
|
|
29
|
+
* and 7 cases.
|
|
30
|
+
*
|
|
31
|
+
* **The reading must be one the sources already give the character.** It is
|
|
32
|
+
* moved to the front of the ranking rather than written over it, so a source
|
|
33
|
+
* refresh that dropped it would fail the build rather than leave a reading
|
|
34
|
+
* nothing attests. That is why 剝 and 掙 are missing beside 剥 and 挣: Unihan
|
|
35
|
+
* gives them `bō` and `zhēng` alone.
|
|
36
|
+
*/
|
|
37
|
+
export const FREE_READINGS = [
|
|
38
|
+
{ character: "幢", reading: "zhuàng", displaces: "幢幢 and 经幢, a banner" },
|
|
39
|
+
{ character: "抡", reading: "lūn", displaces: "抡材 and 抡元, to select" },
|
|
40
|
+
{ character: "掄", reading: "lūn", displaces: "掄材 and 掄元, to select" },
|
|
41
|
+
{ character: "剥", reading: "bāo", displaces: "剥削, 剥夺 and 剥落" },
|
|
42
|
+
{ character: "削", reading: "xiāo", displaces: "削弱, 削减 and 剥削" },
|
|
43
|
+
{ character: "铺", reading: "pū", displaces: "店铺 and 床铺, the noun" },
|
|
44
|
+
{ character: "鋪", reading: "pū", displaces: "店鋪 and 床鋪, the noun" },
|
|
45
|
+
{ character: "咳", reading: "ké", displaces: "the interjection hāi" },
|
|
46
|
+
{ character: "哄", reading: "hǒng", displaces: "哄堂 and 哄抢, an uproar" },
|
|
47
|
+
{ character: "刨", reading: "páo", displaces: "刨床 and 刨子, a plane" },
|
|
48
|
+
{ character: "攒", reading: "zǎn", displaces: "攒聚 and 攒眉, to gather" },
|
|
49
|
+
{ character: "攢", reading: "zǎn", displaces: "攢聚 and 攢眉, to gather" },
|
|
50
|
+
{ character: "绷", reading: "bēng", displaces: "绷着脸, a stiff face" },
|
|
51
|
+
{ character: "繃", reading: "bēng", displaces: "繃著臉, a stiff face" },
|
|
52
|
+
{ character: "翘", reading: "qiào", displaces: "翘首 and 翘楚" },
|
|
53
|
+
{ character: "翹", reading: "qiào", displaces: "翹首 and 翹楚" },
|
|
54
|
+
{ character: "划", reading: "huá", displaces: "计划, 划分 and 规划" },
|
|
55
|
+
{ character: "劃", reading: "huá", displaces: "計劃, 劃分 and 規劃" },
|
|
56
|
+
{ character: "曲", reading: "qǔ", displaces: "曲线, 弯曲 and 曲折" },
|
|
57
|
+
{ character: "切", reading: "qiē", displaces: "一切, 亲切 and 切实" },
|
|
58
|
+
{ character: "嚼", reading: "jiáo", displaces: "咀嚼, the literary word" },
|
|
59
|
+
{ character: "倔", reading: "juè", displaces: "倔强 and 倔犟" },
|
|
60
|
+
{ character: "脏", reading: "zāng", displaces: "心脏 and 内脏, an organ" },
|
|
61
|
+
{ character: "挣", reading: "zhèng", displaces: "挣扎, to struggle" },
|
|
62
|
+
{ character: "漂", reading: "piāo", displaces: "漂亮 and 漂白" },
|
|
63
|
+
];
|
|
64
|
+
/**
|
|
65
|
+
* Read a free reading into a syllable, throwing if it is not one.
|
|
66
|
+
*
|
|
67
|
+
* Throwing for the reason {@link import("./overrides.js").readOverrideReading}
|
|
68
|
+
* does: an entry that failed to parse would leave the ranking it was written
|
|
69
|
+
* to correct, and nothing would notice.
|
|
70
|
+
*/
|
|
71
|
+
export function freeSyllable(free) {
|
|
72
|
+
const syllable = readSyllable(free.reading);
|
|
73
|
+
if (syllable?.tone === undefined) {
|
|
74
|
+
throw new Error(`free reading for ${free.character} is not a reading: ${free.reading}`);
|
|
75
|
+
}
|
|
76
|
+
return syllable;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The table, keyed by character and parsed into syllables.
|
|
80
|
+
*/
|
|
81
|
+
export const FREE_SYLLABLES = new Map(FREE_READINGS.map((free) => [free.character, freeSyllable(free)]));
|
|
82
|
+
/**
|
|
83
|
+
* Whether two syllables are the same reading, 儿化 aside.
|
|
84
|
+
*/
|
|
85
|
+
function sameReading(left, right) {
|
|
86
|
+
return (left.initial === right.initial &&
|
|
87
|
+
left.final === right.final &&
|
|
88
|
+
left.tone === right.tone);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Lead a character's ranked readings with its free reading, where it has one.
|
|
92
|
+
*
|
|
93
|
+
* The rest keep the order the ranking gave them. A listed reading the ranking
|
|
94
|
+
* does not hold throws, which is the build failing on a source that stopped
|
|
95
|
+
* attesting it.
|
|
96
|
+
*/
|
|
97
|
+
export function leadWithFreeReading(character, ranked) {
|
|
98
|
+
const free = FREE_SYLLABLES.get(character);
|
|
99
|
+
if (free === undefined) {
|
|
100
|
+
return ranked;
|
|
101
|
+
}
|
|
102
|
+
const lead = ranked.find((syllable) => sameReading(syllable, free));
|
|
103
|
+
if (lead === undefined) {
|
|
104
|
+
throw new Error(`free reading for ${character} is not one the sources give it`);
|
|
105
|
+
}
|
|
106
|
+
return [lead, ...ranked.filter((syllable) => syllable !== lead)];
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=free-readings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"free-readings.js","sourceRoot":"","sources":["../../src/dictionary/free-readings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiB,MAAM,yBAAyB,CAAC;AAetE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,qBAAqB,EAAE;IACvE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE;IACrE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE;IACrE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE;IAC9D,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE;IAC/D,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,qBAAqB,EAAE;IACnE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,qBAAqB,EAAE;IACnE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,sBAAsB,EAAE;IACpE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,sBAAsB,EAAE;IACtE,EAAE,SA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C,CAAC,CAAC;IACpE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,oBAAoB,SAAS,iCAAiC,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -108,6 +108,14 @@ export declare function countForQuantising(frequency: number, isProperNoun: bool
|
|
|
108
108
|
* have to be read off the same corpus for the result to mean anything.
|
|
109
109
|
*/
|
|
110
110
|
export declare function derivedWordCharge(total: number, highest: number): number;
|
|
111
|
+
/**
|
|
112
|
+
* The decoding cost of a frequency bucket.
|
|
113
|
+
*
|
|
114
|
+
* What {@link FrequencyTable.costOf} answers for an entry in that bucket, for a
|
|
115
|
+
* caller that wants to ask about a bucket rather than an entry: a rule asking
|
|
116
|
+
* whether an edge is one nobody counted compares its cost against this.
|
|
117
|
+
*/
|
|
118
|
+
export declare function costOfBucket(bucket: number): number;
|
|
111
119
|
/**
|
|
112
120
|
* Quantised word frequencies, packed two to a byte.
|
|
113
121
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frequency-table.d.ts","sourceRoot":"","sources":["../../src/dictionary/frequency-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAIpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,OAAO,GACpB,MAAM,CAER;AAED;;;;;;GAMG;AACH,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;;;;;GAMG;AACH,qBAAa,cAAc;;IACzB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CA4B3D;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAE5D;IAKD;;;OAGG;IACH,OAAO,eAGN;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM9B;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5B;IAED;;OAEG;IACH,SAAS,IAAI,UAAU,CAEtB;CACF"}
|
|
@@ -113,6 +113,16 @@ export function countForQuantising(frequency, isProperNoun) {
|
|
|
113
113
|
export function derivedWordCharge(total, highest) {
|
|
114
114
|
return MAX_BUCKET * (Math.log(total) / Math.log1p(highest) - 1);
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* The decoding cost of a frequency bucket.
|
|
118
|
+
*
|
|
119
|
+
* What {@link FrequencyTable.costOf} answers for an entry in that bucket, for a
|
|
120
|
+
* caller that wants to ask about a bucket rather than an entry: a rule asking
|
|
121
|
+
* whether an edge is one nobody counted compares its cost against this.
|
|
122
|
+
*/
|
|
123
|
+
export function costOfBucket(bucket) {
|
|
124
|
+
return MAX_BUCKET - bucket + WORD_CHARGE;
|
|
125
|
+
}
|
|
116
126
|
/**
|
|
117
127
|
* Quantised word frequencies, packed two to a byte.
|
|
118
128
|
*
|
|
@@ -202,7 +212,7 @@ export class FrequencyTable {
|
|
|
202
212
|
* every extra word in a path pays the charge again.
|
|
203
213
|
*/
|
|
204
214
|
costOf(index) {
|
|
205
|
-
return
|
|
215
|
+
return costOfBucket(this.bucketOf(index));
|
|
206
216
|
}
|
|
207
217
|
/**
|
|
208
218
|
* The packed bytes, ready to be written out.
|