@kensio/pinyinjs 1.9.0 → 1.9.2
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/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/de-rule.d.ts +1 -0
- package/dist/decode/de-rule.d.ts.map +1 -1
- package/dist/decode/de-rule.js +1 -0
- package/dist/decode/de-rule.js.map +1 -1
- 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/hua-rule.d.ts +17 -0
- package/dist/decode/hua-rule.d.ts.map +1 -0
- package/dist/decode/hua-rule.js +83 -0
- package/dist/decode/hua-rule.js.map +1 -0
- package/dist/decode/hua-speaking.d.ts +29 -0
- package/dist/decode/hua-speaking.d.ts.map +1 -0
- package/dist/decode/hua-speaking.js +79 -0
- package/dist/decode/hua-speaking.js.map +1 -0
- package/dist/decode/hua-words.d.ts +73 -0
- package/dist/decode/hua-words.d.ts.map +1 -0
- package/dist/decode/hua-words.js +161 -0
- package/dist/decode/hua-words.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/measure-rule.d.ts +31 -0
- package/dist/decode/measure-rule.d.ts.map +1 -0
- package/dist/decode/measure-rule.js +87 -0
- package/dist/decode/measure-rule.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 +6 -32
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +14 -90
- 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/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,87 @@
|
|
|
1
|
+
import { QUANTITY_CHARACTERS } from "../numerals/characters.js";
|
|
2
|
+
import { toCharacters } from "../script/characters.js";
|
|
3
|
+
import { tagOf, wordEndingAt, } from "./rules.js";
|
|
4
|
+
/**
|
|
5
|
+
* The tag the dictionary gives a 量词.
|
|
6
|
+
*/
|
|
7
|
+
const MEASURE = "q";
|
|
8
|
+
/**
|
|
9
|
+
* The mark that makes the number after it a position rather than a count.
|
|
10
|
+
*
|
|
11
|
+
* 第三集团军 is the Third Army Group and not three 集团军, so the 集 the
|
|
12
|
+
* dictionary tags `q` is counting nothing and 集团军 is a word like any other.
|
|
13
|
+
*/
|
|
14
|
+
const ORDINAL = "第";
|
|
15
|
+
/**
|
|
16
|
+
* Where the number counting the character at a position starts, or undefined
|
|
17
|
+
* where nothing counts it.
|
|
18
|
+
*
|
|
19
|
+
* Two things stop a numeral in front of a 量词 from counting it. An ordinal
|
|
20
|
+
* names a position, so 第十级别 is the tenth 级别 rather than ten 级; and a
|
|
21
|
+
* numeral inside a longer word belongs to that word, so the 一 of 唯一道路 is
|
|
22
|
+
* counting no 道 and the 二 of 十二月 no 月.
|
|
23
|
+
*/
|
|
24
|
+
function countedFrom(context, at) {
|
|
25
|
+
const { characters } = context;
|
|
26
|
+
let from = at;
|
|
27
|
+
while (from > 0 && QUANTITY_CHARACTERS.has(characters[from - 1] ?? "")) {
|
|
28
|
+
from--;
|
|
29
|
+
}
|
|
30
|
+
if (from === at || characters[from - 1] === ORDINAL) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const before = wordEndingAt(context, at);
|
|
34
|
+
const held = before === undefined ? at : at - toCharacters(before).length;
|
|
35
|
+
return held < from ? undefined : from;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A 量词 with a number in front of it does not start the next word.
|
|
39
|
+
*
|
|
40
|
+
* 三个人 is three people and came out `sān gèrén`, three *personals*, because
|
|
41
|
+
* 个人 is a common noun and nothing weighed it against the 个 belonging to the
|
|
42
|
+
* 三 in front of it. The same swallow takes 一杯水 into 杯水, 两家俱乐部 into
|
|
43
|
+
* 家俱 and 一天天 into 天天; digits reach it too, since a run decoded after a
|
|
44
|
+
* number sees that number — see `decodeRun` — so 2个人 is the same case.
|
|
45
|
+
*
|
|
46
|
+
* What makes it decidable is that the dictionary tags the 量词: 个, 次, 天, 位,
|
|
47
|
+
* 杯 and 匹 are `q`, while the characters that only look like measure words in
|
|
48
|
+
* this position are not — 分 is `v`, 部 and 成 are `n`, 年 and 点 are `m`. So
|
|
49
|
+
* 五分钟, 三部分, 五成分, 五年级 and 三点钟 are untouched, and those are exactly
|
|
50
|
+
* the words a blanket rule would break. A word that is itself a 量词 is kept as
|
|
51
|
+
* well, since 分钟 and 点钟 are units rather than something being counted.
|
|
52
|
+
*
|
|
53
|
+
* Only the edge *starting at the 量词* is forbidden, so a number and its
|
|
54
|
+
* measure written solid survive whole where the dictionary has them: 一辈子 and
|
|
55
|
+
* 一会儿 are entries covering the number too, and the decode still reaches them.
|
|
56
|
+
*
|
|
57
|
+
* Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
|
|
58
|
+
* rules were sized against, it forbids 561 edges across 144 shapes — 个人 203
|
|
59
|
+
* of them, then 杯水, 天一, 口气, 些小 and 家人 — and moves 53 decodes, since
|
|
60
|
+
* most of what it takes away the cost model was not going to choose anyway.
|
|
61
|
+
* Three of the 53 are wrong: 一批评, 这一名词 and 六七股灾, where the 一 and the
|
|
62
|
+
* 六七 count nothing and no tag says so. Exactly one reading changes over the
|
|
63
|
+
* corpus and it is a fix, 下了两天雨 having read 天雨 as `tiān yù`.
|
|
64
|
+
*/
|
|
65
|
+
export const COUNTED_MEASURE = {
|
|
66
|
+
name: "counted-measure",
|
|
67
|
+
verdictFor: (context) => {
|
|
68
|
+
const { characters, edge } = context;
|
|
69
|
+
// A reading of a different length from its span says something about how
|
|
70
|
+
// the characters are read rather than only about where they break: 份儿 is
|
|
71
|
+
// `fènr` over two characters, and taking the edge away would take the 儿化
|
|
72
|
+
// with it.
|
|
73
|
+
if (edge.to - edge.from < 2 ||
|
|
74
|
+
edge.reading.length !== edge.to - edge.from) {
|
|
75
|
+
return "keep";
|
|
76
|
+
}
|
|
77
|
+
const counted = countedFrom(context, edge.from);
|
|
78
|
+
if (counted === undefined) {
|
|
79
|
+
return "keep";
|
|
80
|
+
}
|
|
81
|
+
return tagOf(context, characters[edge.from]) === MEASURE &&
|
|
82
|
+
edge.partOfSpeech !== MEASURE
|
|
83
|
+
? "forbid"
|
|
84
|
+
: "keep";
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=measure-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measure-rule.js","sourceRoot":"","sources":["../../src/decode/measure-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAGL,KAAK,EACL,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,OAAoB,EAAE,EAAU;IACnD,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,IAAI,IAAI,GAAG,EAAE,CA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AAC,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,OAAO;YACtD,IAAI,CAAC,YAAY,KAAK,OAAO;YAC7B,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,MAAM,CAAC;IACb,CAAC;CACF,CAAC"}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 弹 is `tán` or `dàn`, and which one a text means is a question about the
|
|
5
5
|
* neighbours rather than about the character. 长 is the same question and has
|
|
6
|
-
* a file of its own. The other rules in `reading-rules.ts` are about particles
|
|
6
|
+
* a file of its own, and 好学 is the same question asked of a word. The other rules in `reading-rules.ts` are about particles
|
|
7
7
|
* and 儿化, which is a different kind of evidence.
|
|
8
8
|
*/
|
|
9
9
|
export { ADJECTIVAL_CHANG } from "./chang-rule.js";
|
|
10
10
|
export { PLAYING_TAN } from "./tan-rule.js";
|
|
11
|
+
export { EASY_HAO } from "./hao-rule.js";
|
|
11
12
|
//# sourceMappingURL=polyphone-rules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyphone-rules.d.ts","sourceRoot":"","sources":["../../src/decode/polyphone-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"polyphone-rules.d.ts","sourceRoot":"","sources":["../../src/decode/polyphone-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 弹 is `tán` or `dàn`, and which one a text means is a question about the
|
|
5
5
|
* neighbours rather than about the character. 长 is the same question and has
|
|
6
|
-
* a file of its own. The other rules in `reading-rules.ts` are about particles
|
|
6
|
+
* a file of its own, and 好学 is the same question asked of a word. The other rules in `reading-rules.ts` are about particles
|
|
7
7
|
* and 儿化, which is a different kind of evidence.
|
|
8
8
|
*/
|
|
9
9
|
export { ADJECTIVAL_CHANG } from "./chang-rule.js";
|
|
10
10
|
export { PLAYING_TAN } from "./tan-rule.js";
|
|
11
|
+
export { EASY_HAO } from "./hao-rule.js";
|
|
11
12
|
//# sourceMappingURL=polyphone-rules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyphone-rules.js","sourceRoot":"","sources":["../../src/decode/polyphone-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"polyphone-rules.js","sourceRoot":"","sources":["../../src/decode/polyphone-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export { MODAL_DE, PARTICLE_DE, POTENTIAL_DE } from "./de-rule.js";
|
|
1
|
+
export { MODAL_DE, NOUN_HUA, PARTICLE_DE, POTENTIAL_DE } from "./de-rule.js";
|
|
2
2
|
export { TAXI_DI } from "./taxi-rule.js";
|
|
3
|
+
export { COUNTED_MEASURE } from "./measure-rule.js";
|
|
3
4
|
export { EXPERIENTIAL_GUO } from "./guo-rule.js";
|
|
4
5
|
export { TEACHING_JIAO } from "./jiao-rule.js";
|
|
6
|
+
export { DOMINANT_READING } from "./dominant-rule.js";
|
|
5
7
|
export { SEPARATED_COMPOUND } from "./split-rule.js";
|
|
6
8
|
export { RETURNING_HUAN } from "./huan-rule.js";
|
|
7
9
|
export { CONCERNING_GAN } from "./gan-rule.js";
|
|
@@ -9,7 +11,8 @@ export { COUNTING_ZHI } from "./zhi-rule.js";
|
|
|
9
11
|
export { POTENTIAL_LIAO } from "./liao-rule.js";
|
|
10
12
|
export { OBTAINING_DE } from "./obtain-rule.js";
|
|
11
13
|
export { REDUPLICATED_VERB } from "./reduplication-rule.js";
|
|
12
|
-
|
|
14
|
+
export { VERBAL_READING } from "./verbal-rule.js";
|
|
15
|
+
import type { EdgeRule } from "./rules.js";
|
|
13
16
|
/**
|
|
14
17
|
* 儿 does not stand on its own where the dictionary attests the 儿化.
|
|
15
18
|
*
|
|
@@ -31,36 +34,7 @@ import { type EdgeRule } from "./rules.js";
|
|
|
31
34
|
* 门铃儿 and a row of Mongol names transliterated with 儿.
|
|
32
35
|
*/
|
|
33
36
|
export declare const ATTESTED_ERHUA: EdgeRule;
|
|
34
|
-
|
|
35
|
-
* A 量词 with a number in front of it does not start the next word.
|
|
36
|
-
*
|
|
37
|
-
* 三个人 is three people and came out `sān gèrén`, three *personals*, because
|
|
38
|
-
* 个人 is a common noun and nothing weighed it against the 个 belonging to the
|
|
39
|
-
* 三 in front of it. The same swallow takes 一杯水 into 杯水, 两家俱乐部 into
|
|
40
|
-
* 家俱 and 一天天 into 天天; digits reach it too, since a run decoded after a
|
|
41
|
-
* number sees that number — see `decodeRun` — so 2个人 is the same case.
|
|
42
|
-
*
|
|
43
|
-
* What makes it decidable is that the dictionary tags the 量词: 个, 次, 天, 位,
|
|
44
|
-
* 杯 and 匹 are `q`, while the characters that only look like measure words in
|
|
45
|
-
* this position are not — 分 is `v`, 部 and 成 are `n`, 年 and 点 are `m`. So
|
|
46
|
-
* 五分钟, 三部分, 五成分, 五年级 and 三点钟 are untouched, and those are exactly
|
|
47
|
-
* the words a blanket rule would break. A word that is itself a 量词 is kept as
|
|
48
|
-
* well, since 分钟 and 点钟 are units rather than something being counted.
|
|
49
|
-
*
|
|
50
|
-
* Only the edge *starting at the 量词* is forbidden, so a number and its
|
|
51
|
-
* measure written solid survive whole where the dictionary has them: 一辈子 and
|
|
52
|
-
* 一会儿 are entries covering the number too, and the decode still reaches them.
|
|
53
|
-
*
|
|
54
|
-
* Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
|
|
55
|
-
* rules were sized against, it forbids 561 edges across 144 shapes — 个人 203
|
|
56
|
-
* of them, then 杯水, 天一, 口气, 些小 and 家人 — and moves 53 decodes, since
|
|
57
|
-
* most of what it takes away the cost model was not going to choose anyway.
|
|
58
|
-
* Three of the 53 are wrong: 一批评, 这一名词 and 六七股灾, where the 一 and the
|
|
59
|
-
* 六七 count nothing and no tag says so. Exactly one reading changes over the
|
|
60
|
-
* corpus and it is a fix, 下了两天雨 having read 天雨 as `tiān yù`.
|
|
61
|
-
*/
|
|
62
|
-
export declare const COUNTED_MEASURE: EdgeRule;
|
|
63
|
-
export { ADJECTIVAL_CHANG, PLAYING_TAN } from "./polyphone-rules.js";
|
|
37
|
+
export { ADJECTIVAL_CHANG, EASY_HAO, PLAYING_TAN } from "./polyphone-rules.js";
|
|
64
38
|
/**
|
|
65
39
|
* The rules the lattice decode applies, in order.
|
|
66
40
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reading-rules.d.ts","sourceRoot":"","sources":["../../src/decode/reading-rules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reading-rules.d.ts","sourceRoot":"","sources":["../../src/decode/reading-rules.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,EAAE,QAY5B,CAAC;AAIF,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,QAAQ,EAsB5C,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MODAL_DE, PARTICLE_DE, POTENTIAL_DE } from "./de-rule.js";
|
|
1
|
+
import { MODAL_DE, NOUN_HUA, PARTICLE_DE, POTENTIAL_DE } from "./de-rule.js";
|
|
3
2
|
import { TAXI_DI } from "./taxi-rule.js";
|
|
3
|
+
import { COUNTED_MEASURE } from "./measure-rule.js";
|
|
4
4
|
import { EXPERIENTIAL_GUO } from "./guo-rule.js";
|
|
5
5
|
import { TEACHING_JIAO } from "./jiao-rule.js";
|
|
6
|
+
import { DOMINANT_READING } from "./dominant-rule.js";
|
|
6
7
|
import { SEPARATED_COMPOUND } from "./split-rule.js";
|
|
7
8
|
import { RETURNING_HUAN } from "./huan-rule.js";
|
|
8
9
|
import { CONCERNING_GAN } from "./gan-rule.js";
|
|
@@ -10,10 +11,13 @@ import { COUNTING_ZHI } from "./zhi-rule.js";
|
|
|
10
11
|
import { POTENTIAL_LIAO } from "./liao-rule.js";
|
|
11
12
|
import { OBTAINING_DE } from "./obtain-rule.js";
|
|
12
13
|
import { REDUPLICATED_VERB } from "./reduplication-rule.js";
|
|
13
|
-
|
|
14
|
+
import { VERBAL_READING } from "./verbal-rule.js";
|
|
15
|
+
export { MODAL_DE, NOUN_HUA, PARTICLE_DE, POTENTIAL_DE } from "./de-rule.js";
|
|
14
16
|
export { TAXI_DI } from "./taxi-rule.js";
|
|
17
|
+
export { COUNTED_MEASURE } from "./measure-rule.js";
|
|
15
18
|
export { EXPERIENTIAL_GUO } from "./guo-rule.js";
|
|
16
19
|
export { TEACHING_JIAO } from "./jiao-rule.js";
|
|
20
|
+
export { DOMINANT_READING } from "./dominant-rule.js";
|
|
17
21
|
export { SEPARATED_COMPOUND } from "./split-rule.js";
|
|
18
22
|
export { RETURNING_HUAN } from "./huan-rule.js";
|
|
19
23
|
export { CONCERNING_GAN } from "./gan-rule.js";
|
|
@@ -21,8 +25,7 @@ export { COUNTING_ZHI } from "./zhi-rule.js";
|
|
|
21
25
|
export { POTENTIAL_LIAO } from "./liao-rule.js";
|
|
22
26
|
export { OBTAINING_DE } from "./obtain-rule.js";
|
|
23
27
|
export { REDUPLICATED_VERB } from "./reduplication-rule.js";
|
|
24
|
-
|
|
25
|
-
import { tagOf, wordEndingAt, } from "./rules.js";
|
|
28
|
+
export { VERBAL_READING } from "./verbal-rule.js";
|
|
26
29
|
/**
|
|
27
30
|
* 儿 does not stand on its own where the dictionary attests the 儿化.
|
|
28
31
|
*
|
|
@@ -56,91 +59,8 @@ export const ATTESTED_ERHUA = {
|
|
|
56
59
|
return (reading?.at(-1)?.erhua ?? false) ? "forbid" : "keep";
|
|
57
60
|
},
|
|
58
61
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*/
|
|
62
|
-
const MEASURE = "q";
|
|
63
|
-
/**
|
|
64
|
-
* The mark that makes the number after it a position rather than a count.
|
|
65
|
-
*
|
|
66
|
-
* 第三集团军 is the Third Army Group and not three 集团军, so the 集 the
|
|
67
|
-
* dictionary tags `q` is counting nothing and 集团军 is a word like any other.
|
|
68
|
-
*/
|
|
69
|
-
const ORDINAL = "第";
|
|
70
|
-
/**
|
|
71
|
-
* Where the number counting the character at a position starts, or undefined
|
|
72
|
-
* where nothing counts it.
|
|
73
|
-
*
|
|
74
|
-
* Two things stop a numeral in front of a 量词 from counting it. An ordinal
|
|
75
|
-
* names a position, so 第十级别 is the tenth 级别 rather than ten 级; and a
|
|
76
|
-
* numeral inside a longer word belongs to that word, so the 一 of 唯一道路 is
|
|
77
|
-
* counting no 道 and the 二 of 十二月 no 月.
|
|
78
|
-
*/
|
|
79
|
-
function countedFrom(context, at) {
|
|
80
|
-
const { characters } = context;
|
|
81
|
-
let from = at;
|
|
82
|
-
while (from > 0 && QUANTITY_CHARACTERS.has(characters[from - 1] ?? "")) {
|
|
83
|
-
from--;
|
|
84
|
-
}
|
|
85
|
-
if (from === at || characters[from - 1] === ORDINAL) {
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
const before = wordEndingAt(context, at);
|
|
89
|
-
const held = before === undefined ? at : at - toCharacters(before).length;
|
|
90
|
-
return held < from ? undefined : from;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* A 量词 with a number in front of it does not start the next word.
|
|
94
|
-
*
|
|
95
|
-
* 三个人 is three people and came out `sān gèrén`, three *personals*, because
|
|
96
|
-
* 个人 is a common noun and nothing weighed it against the 个 belonging to the
|
|
97
|
-
* 三 in front of it. The same swallow takes 一杯水 into 杯水, 两家俱乐部 into
|
|
98
|
-
* 家俱 and 一天天 into 天天; digits reach it too, since a run decoded after a
|
|
99
|
-
* number sees that number — see `decodeRun` — so 2个人 is the same case.
|
|
100
|
-
*
|
|
101
|
-
* What makes it decidable is that the dictionary tags the 量词: 个, 次, 天, 位,
|
|
102
|
-
* 杯 and 匹 are `q`, while the characters that only look like measure words in
|
|
103
|
-
* this position are not — 分 is `v`, 部 and 成 are `n`, 年 and 点 are `m`. So
|
|
104
|
-
* 五分钟, 三部分, 五成分, 五年级 and 三点钟 are untouched, and those are exactly
|
|
105
|
-
* the words a blanket rule would break. A word that is itself a 量词 is kept as
|
|
106
|
-
* well, since 分钟 and 点钟 are units rather than something being counted.
|
|
107
|
-
*
|
|
108
|
-
* Only the edge *starting at the 量词* is forbidden, so a number and its
|
|
109
|
-
* measure written solid survive whole where the dictionary has them: 一辈子 and
|
|
110
|
-
* 一会儿 are entries covering the number too, and the decode still reaches them.
|
|
111
|
-
*
|
|
112
|
-
* Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
|
|
113
|
-
* rules were sized against, it forbids 561 edges across 144 shapes — 个人 203
|
|
114
|
-
* of them, then 杯水, 天一, 口气, 些小 and 家人 — and moves 53 decodes, since
|
|
115
|
-
* most of what it takes away the cost model was not going to choose anyway.
|
|
116
|
-
* Three of the 53 are wrong: 一批评, 这一名词 and 六七股灾, where the 一 and the
|
|
117
|
-
* 六七 count nothing and no tag says so. Exactly one reading changes over the
|
|
118
|
-
* corpus and it is a fix, 下了两天雨 having read 天雨 as `tiān yù`.
|
|
119
|
-
*/
|
|
120
|
-
export const COUNTED_MEASURE = {
|
|
121
|
-
name: "counted-measure",
|
|
122
|
-
verdictFor: (context) => {
|
|
123
|
-
const { characters, edge } = context;
|
|
124
|
-
// A reading of a different length from its span says something about how
|
|
125
|
-
// the characters are read rather than only about where they break: 份儿 is
|
|
126
|
-
// `fènr` over two characters, and taking the edge away would take the 儿化
|
|
127
|
-
// with it.
|
|
128
|
-
if (edge.to - edge.from < 2 ||
|
|
129
|
-
edge.reading.length !== edge.to - edge.from) {
|
|
130
|
-
return "keep";
|
|
131
|
-
}
|
|
132
|
-
const counted = countedFrom(context, edge.from);
|
|
133
|
-
if (counted === undefined) {
|
|
134
|
-
return "keep";
|
|
135
|
-
}
|
|
136
|
-
return tagOf(context, characters[edge.from]) === MEASURE &&
|
|
137
|
-
edge.partOfSpeech !== MEASURE
|
|
138
|
-
? "forbid"
|
|
139
|
-
: "keep";
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
import { ADJECTIVAL_CHANG, PLAYING_TAN } from "./polyphone-rules.js";
|
|
143
|
-
export { ADJECTIVAL_CHANG, PLAYING_TAN } from "./polyphone-rules.js";
|
|
62
|
+
import { ADJECTIVAL_CHANG, EASY_HAO, PLAYING_TAN } from "./polyphone-rules.js";
|
|
63
|
+
export { ADJECTIVAL_CHANG, EASY_HAO, PLAYING_TAN } from "./polyphone-rules.js";
|
|
144
64
|
/**
|
|
145
65
|
* The rules the lattice decode applies, in order.
|
|
146
66
|
*/
|
|
@@ -149,6 +69,7 @@ export const READING_RULES = [
|
|
|
149
69
|
PARTICLE_DE,
|
|
150
70
|
POTENTIAL_DE,
|
|
151
71
|
TAXI_DI,
|
|
72
|
+
NOUN_HUA,
|
|
152
73
|
TEACHING_JIAO,
|
|
153
74
|
ATTESTED_ERHUA,
|
|
154
75
|
COUNTED_MEASURE,
|
|
@@ -162,5 +83,8 @@ export const READING_RULES = [
|
|
|
162
83
|
COUNTING_ZHI,
|
|
163
84
|
POTENTIAL_LIAO,
|
|
164
85
|
OBTAINING_DE,
|
|
86
|
+
VERBAL_READING,
|
|
87
|
+
DOMINANT_READING,
|
|
88
|
+
EASY_HAO,
|
|
165
89
|
];
|
|
166
90
|
//# sourceMappingURL=reading-rules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reading-rules.js","sourceRoot":"","sources":["../../src/decode/reading-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reading-rules.js","sourceRoot":"","sources":["../../src/decode/reading-rules.ts"],"names":[],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,OAAO;IACP,QAAQ;IACR,aAAa;IACb,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,WAAW;IACX,gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB;IACjB,cAAc;IACd,cAAc;IACd,YAAY;IACZ,cAAc;IACd,YAAY;IACZ,cAAc;IACd,gBAAgB;IAChB,QAAQ;CACT,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The verbs the reduplication rule reads, and the reading each takes.
|
|
3
|
+
*/
|
|
4
|
+
import { type Syllable } from "../syllable/syllable.js";
|
|
5
|
+
/**
|
|
6
|
+
* The polyphones whose verbal reading is not their default.
|
|
7
|
+
*
|
|
8
|
+
* The default is the reading a character takes in most text. For these that
|
|
9
|
+
* reading is a noun (数 `shù`, 种 `zhǒng`, 量 `liàng`), an adjective (凉
|
|
10
|
+
* `liáng`), another verb (转 `zhuǎn`, which changes where `zhuàn` spins) or the
|
|
11
|
+
* reading their compounds take (教 `jiào`, 弹 `dàn`, 削 `xuē`). A
|
|
12
|
+
* reduplicated character is a verb, and the verbal reading is the one it
|
|
13
|
+
* wants.
|
|
14
|
+
*
|
|
15
|
+
* 卷 is in for its tail. Its default is already `juǎn`, and 卷一卷 read the
|
|
16
|
+
* second half `juàn` off 一卷, a word the dictionary tags `m`.
|
|
17
|
+
*
|
|
18
|
+
* Written out by hand because the dictionary has no tag per reading. The
|
|
19
|
+
* nearest thing it holds is the reduplicated word itself, and that is the
|
|
20
|
+
* wrong evidence. Of the 19 AA keys in the standard tier whose first syllable
|
|
21
|
+
* differs from the character's default, 数数 (in both scripts) is the only
|
|
22
|
+
* verb said twice. The rest are literary reduplicatives (查查 `zhāzhā`, 拜拜 `báibái`, 累累
|
|
23
|
+
* `léiléi`), and reading 查一查 off 查查 would turn a correct `chá` into `zhā`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const VERBAL_READINGS: ReadonlyMap<string, Syllable>;
|
|
26
|
+
//# sourceMappingURL=reduplication-readings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reduplication-readings.d.ts","sourceRoot":"","sources":["../../src/decode/reduplication-readings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CA0BzD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The verbs the reduplication rule reads, and the reading each takes.
|
|
3
|
+
*/
|
|
4
|
+
import { readSyllable } from "../syllable/syllable.js";
|
|
5
|
+
/**
|
|
6
|
+
* The polyphones whose verbal reading is not their default.
|
|
7
|
+
*
|
|
8
|
+
* The default is the reading a character takes in most text. For these that
|
|
9
|
+
* reading is a noun (数 `shù`, 种 `zhǒng`, 量 `liàng`), an adjective (凉
|
|
10
|
+
* `liáng`), another verb (转 `zhuǎn`, which changes where `zhuàn` spins) or the
|
|
11
|
+
* reading their compounds take (教 `jiào`, 弹 `dàn`, 削 `xuē`). A
|
|
12
|
+
* reduplicated character is a verb, and the verbal reading is the one it
|
|
13
|
+
* wants.
|
|
14
|
+
*
|
|
15
|
+
* 卷 is in for its tail. Its default is already `juǎn`, and 卷一卷 read the
|
|
16
|
+
* second half `juàn` off 一卷, a word the dictionary tags `m`.
|
|
17
|
+
*
|
|
18
|
+
* Written out by hand because the dictionary has no tag per reading. The
|
|
19
|
+
* nearest thing it holds is the reduplicated word itself, and that is the
|
|
20
|
+
* wrong evidence. Of the 19 AA keys in the standard tier whose first syllable
|
|
21
|
+
* differs from the character's default, 数数 (in both scripts) is the only
|
|
22
|
+
* verb said twice. The rest are literary reduplicatives (查查 `zhāzhā`, 拜拜 `báibái`, 累累
|
|
23
|
+
* `léiléi`), and reading 查一查 off 查查 would turn a correct `chá` into `zhā`.
|
|
24
|
+
*/
|
|
25
|
+
export const VERBAL_READINGS = new Map([
|
|
26
|
+
["数", "shǔ"],
|
|
27
|
+
["數", "shǔ"],
|
|
28
|
+
["凉", "liàng"],
|
|
29
|
+
["涼", "liàng"],
|
|
30
|
+
["种", "zhòng"],
|
|
31
|
+
["種", "zhòng"],
|
|
32
|
+
["教", "jiāo"],
|
|
33
|
+
["弹", "tán"],
|
|
34
|
+
["彈", "tán"],
|
|
35
|
+
["卷", "juǎn"],
|
|
36
|
+
["削", "xiāo"],
|
|
37
|
+
["量", "liáng"],
|
|
38
|
+
["转", "zhuàn"],
|
|
39
|
+
["轉", "zhuàn"],
|
|
40
|
+
].map(([character, text]) => {
|
|
41
|
+
const syllable = readSyllable(text);
|
|
42
|
+
/* c8 ignore next 3 -- every reading above is a syllable */
|
|
43
|
+
if (syllable === undefined) {
|
|
44
|
+
throw new Error(`${text} is not a syllable`);
|
|
45
|
+
}
|
|
46
|
+
return [character, syllable];
|
|
47
|
+
}));
|
|
48
|
+
//# sourceMappingURL=reduplication-readings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reduplication-readings.js","sourceRoot":"","sources":["../../src/decode/reduplication-readings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAiB,MAAM,yBAAyB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkC,IAAI,GAAG,CAEjE;IACE,CAAC,GAAG,EAAE,KAAK,CAAC;IACZ,CAAC,GAAG,EAAE,KAAK,CAAC;IACZ,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,KAAK,CAAC;IACZ,CAAC,GAAG,EAAE,KAAK,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;CAEjB,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;IAC1B,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACpC,2DAA2D;IAC3D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,oBAAoB,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -10,7 +10,7 @@ import { type EdgeRule } from "./rules.js";
|
|
|
10
10
|
* The same shape split other verbs down the middle. 弹了弹 read `tán le dàn`,
|
|
11
11
|
* because the 弹 rule saw the 了 after the first half and nothing after the
|
|
12
12
|
* second. 教了教 read `jiāo le jiào` for the same reason. See
|
|
13
|
-
* {@link VERBAL_READINGS} for the characters and {@link reduplicatedAt} for
|
|
13
|
+
* {@link import("./reduplication-readings.js").VERBAL_READINGS} for the characters and {@link reduplicatedAt} for
|
|
14
14
|
* the shapes turned away.
|
|
15
15
|
*
|
|
16
16
|
* Over 88,866 lines of Tatoeba and zh.wikipedia, A了A and A一A appear 107
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduplication-rule.d.ts","sourceRoot":"","sources":["../../src/decode/reduplication-rule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reduplication-rule.d.ts","sourceRoot":"","sources":["../../src/decode/reduplication-rule.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAyFpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAc/B,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { isSameSyllable } from "../dictionary/entry.js";
|
|
8
8
|
import { QUANTITY_CHARACTERS } from "../numerals/characters.js";
|
|
9
9
|
import { toCharacters } from "../script/characters.js";
|
|
10
|
-
import {
|
|
10
|
+
import { VERBAL_READINGS } from "./reduplication-readings.js";
|
|
11
11
|
import { tagOf, wordsEndingAt, wordsStartingAt, } from "./rules.js";
|
|
12
12
|
/**
|
|
13
13
|
* What can stand between the halves of a reduplicated verb.
|
|
@@ -17,45 +17,6 @@ import { tagOf, wordsEndingAt, wordsStartingAt, } from "./rules.js";
|
|
|
17
17
|
* {@link reduplicatedAt} turns that shape away by the numeral in front.
|
|
18
18
|
*/
|
|
19
19
|
const INFIX = new Set(["了", "一"]);
|
|
20
|
-
/**
|
|
21
|
-
* The polyphones whose verbal reading is not their default.
|
|
22
|
-
*
|
|
23
|
-
* The default is the reading a character takes in most text. For these that
|
|
24
|
-
* reading is a noun (数 `shù`, 种 `zhǒng`), an adjective (凉 `liáng`) or the
|
|
25
|
-
* reading their compounds take (教 `jiào`, 弹 `dàn`, 削 `xuē`). A
|
|
26
|
-
* reduplicated character is a verb, and the verbal reading is the one it
|
|
27
|
-
* wants.
|
|
28
|
-
*
|
|
29
|
-
* 卷 is in for its tail. Its default is already `juǎn`, and 卷一卷 read the
|
|
30
|
-
* second half `juàn` off 一卷, a word the dictionary tags `m`.
|
|
31
|
-
*
|
|
32
|
-
* Written out by hand because the dictionary has no tag per reading. The
|
|
33
|
-
* nearest thing it holds is the reduplicated word itself, and that is the
|
|
34
|
-
* wrong evidence. Of the 19 AA keys in the standard tier whose first syllable
|
|
35
|
-
* differs from the character's default, 数数 (in both scripts) is the only
|
|
36
|
-
* verb said twice. The rest are literary reduplicatives (查查 `zhāzhā`, 拜拜 `báibái`, 累累
|
|
37
|
-
* `léiléi`), and reading 查一查 off 查查 would turn a correct `chá` into `zhā`.
|
|
38
|
-
*/
|
|
39
|
-
const VERBAL_READINGS = new Map([
|
|
40
|
-
["数", "shǔ"],
|
|
41
|
-
["數", "shǔ"],
|
|
42
|
-
["凉", "liàng"],
|
|
43
|
-
["涼", "liàng"],
|
|
44
|
-
["种", "zhòng"],
|
|
45
|
-
["種", "zhòng"],
|
|
46
|
-
["教", "jiāo"],
|
|
47
|
-
["弹", "tán"],
|
|
48
|
-
["彈", "tán"],
|
|
49
|
-
["卷", "juǎn"],
|
|
50
|
-
["削", "xiāo"],
|
|
51
|
-
].map(([character, text]) => {
|
|
52
|
-
const syllable = readSyllable(text);
|
|
53
|
-
/* c8 ignore next 3 -- every reading above is a syllable */
|
|
54
|
-
if (syllable === undefined) {
|
|
55
|
-
throw new Error(`${text} is not a syllable`);
|
|
56
|
-
}
|
|
57
|
-
return [character, syllable];
|
|
58
|
-
}));
|
|
59
20
|
/**
|
|
60
21
|
* Whether a tagged word of more than one character starts or ends at a
|
|
61
22
|
* position.
|
|
@@ -130,7 +91,7 @@ function readsAgainst(context) {
|
|
|
130
91
|
* The same shape split other verbs down the middle. 弹了弹 read `tán le dàn`,
|
|
131
92
|
* because the 弹 rule saw the 了 after the first half and nothing after the
|
|
132
93
|
* second. 教了教 read `jiāo le jiào` for the same reason. See
|
|
133
|
-
* {@link VERBAL_READINGS} for the characters and {@link reduplicatedAt} for
|
|
94
|
+
* {@link import("./reduplication-readings.js").VERBAL_READINGS} for the characters and {@link reduplicatedAt} for
|
|
134
95
|
* the shapes turned away.
|
|
135
96
|
*
|
|
136
97
|
* Over 88,866 lines of Tatoeba and zh.wikipedia, A了A and A一A appear 107
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduplication-rule.js","sourceRoot":"","sources":["../../src/decode/reduplication-rule.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;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