@kensio/pinyinjs 1.10.2 → 1.10.4
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 +3 -3
- package/data/core.entries +27 -23
- package/data/core.freq +0 -0
- package/data/core.keys +4 -0
- package/data/full.counts +0 -0
- package/data/full.entries +38 -34
- package/data/full.freq +0 -0
- package/data/full.keys +4 -0
- package/data/manifest.json +12 -12
- package/data/standard.entries +27 -23
- package/data/standard.freq +0 -0
- package/data/standard.keys +4 -0
- package/dist/decode/li-frames.d.ts +29 -0
- package/dist/decode/li-frames.d.ts.map +1 -0
- package/dist/decode/li-frames.js +84 -0
- package/dist/decode/li-frames.js.map +1 -0
- package/dist/decode/particle-rule.d.ts +8 -10
- package/dist/decode/particle-rule.d.ts.map +1 -1
- package/dist/decode/particle-rule.js +67 -1
- package/dist/decode/particle-rule.js.map +1 -1
- package/dist/decode/script-context.d.ts +28 -0
- package/dist/decode/script-context.d.ts.map +1 -0
- package/dist/decode/script-context.js +45 -0
- package/dist/decode/script-context.js.map +1 -0
- package/dist/decode/script-words.d.ts +3 -13
- package/dist/decode/script-words.d.ts.map +1 -1
- package/dist/decode/script-words.js +9 -27
- package/dist/decode/script-words.js.map +1 -1
- package/dist/decode/script.d.ts.map +1 -1
- package/dist/decode/script.js +3 -14
- package/dist/decode/script.js.map +1 -1
- package/dist/dictionary/reference-readings.d.ts.map +1 -1
- package/dist/dictionary/reference-readings.js +43 -5
- package/dist/dictionary/reference-readings.js.map +1 -1
- package/package.json +1 -1
package/data/standard.entries
CHANGED
|
@@ -73,6 +73,7 @@ she4
|
|
|
73
73
|
tiao3
|
|
74
74
|
lian2
|
|
75
75
|
mian3 tian3
|
|
76
|
+
weng1
|
|
76
77
|
sa4
|
|
77
78
|
tuo2
|
|
78
79
|
hun2
|
|
@@ -7824,7 +7825,7 @@ juan4 zg
|
|
|
7824
7825
|
zong1 zg
|
|
7825
7826
|
ju4 ag
|
|
7826
7827
|
a
|
|
7827
|
-
qian4 zg
|
|
7828
|
+
qian4 zg qing4
|
|
7828
7829
|
n
|
|
7829
7830
|
ni2 nr p
|
|
7830
7831
|
lun2 ns
|
|
@@ -21325,10 +21326,10 @@ pi2 zg pi4
|
|
|
21325
21326
|
qing1 zg
|
|
21326
21327
|
ju4 zg
|
|
21327
21328
|
kong1 zg
|
|
21328
|
-
tang3 chong3
|
|
21329
|
+
tang3 chong3 shang3
|
|
21329
21330
|
dong1 zg
|
|
21330
21331
|
dai4 zg
|
|
21331
|
-
tan4 zg
|
|
21332
|
+
tan4 zg tan2
|
|
21332
21333
|
an3
|
|
21333
21334
|
chu4 zg
|
|
21334
21335
|
beng3
|
|
@@ -24907,7 +24908,7 @@ tuo3 dang5 tuo3 dang4 a
|
|
|
24907
24908
|
v
|
|
24908
24909
|
v
|
|
24909
24910
|
feng1
|
|
24910
|
-
yuan2 zg
|
|
24911
|
+
yuan2 zg wan4
|
|
24911
24912
|
fang2 zg fang1
|
|
24912
24913
|
v
|
|
24913
24914
|
v
|
|
@@ -25370,7 +25371,7 @@ wei2 zg
|
|
|
25370
25371
|
di4
|
|
25371
25372
|
rou2
|
|
25372
25373
|
mei3
|
|
25373
|
-
ruan3
|
|
25374
|
+
ruan3 nen4
|
|
25374
25375
|
wo4 zg
|
|
25375
25376
|
chun1 zg
|
|
25376
25377
|
miao2
|
|
@@ -25392,7 +25393,7 @@ mei4 zg
|
|
|
25392
25393
|
n
|
|
25393
25394
|
yuan4 zg yuan2
|
|
25394
25395
|
zheng1 zg
|
|
25395
|
-
shi4
|
|
25396
|
+
shi4 ti2
|
|
25396
25397
|
xie4
|
|
25397
25398
|
tuo3 zg duo4
|
|
25398
25399
|
mao4
|
|
@@ -26417,7 +26418,7 @@ yi2 zg
|
|
|
26417
26418
|
jing3 zg
|
|
26418
26419
|
mi4 nr fu2
|
|
26419
26420
|
zhu3 zg
|
|
26420
|
-
dang4 g
|
|
26421
|
+
dang4 g tan4
|
|
26421
26422
|
zong1 nr zong5
|
|
26422
26423
|
n
|
|
26423
26424
|
n
|
|
@@ -35163,7 +35164,7 @@ yi4 you2 wei4 jin4 i
|
|
|
35163
35164
|
n
|
|
35164
35165
|
n
|
|
35165
35166
|
n
|
|
35166
|
-
kai4 zg he4
|
|
35167
|
+
kai4 zg he4,qi4
|
|
35167
35168
|
dang4
|
|
35168
35169
|
yin1 zg
|
|
35169
35170
|
e4 a
|
|
@@ -38663,7 +38664,7 @@ juan3 qu1 n
|
|
|
38663
38664
|
juan4 lian2 n
|
|
38664
38665
|
v
|
|
38665
38666
|
juan3 fa3 v
|
|
38666
|
-
chen1
|
|
38667
|
+
chen1 tian3
|
|
38667
38668
|
chui2 v
|
|
38668
38669
|
v
|
|
38669
38670
|
i
|
|
@@ -46333,7 +46334,7 @@ kuo4 zg
|
|
|
46333
46334
|
jing4 zg
|
|
46334
46335
|
po5 zg bo2
|
|
46335
46336
|
fu2 g
|
|
46336
|
-
rui2 zg
|
|
46337
|
+
rui2 zg rui3
|
|
46337
46338
|
tong3 zg
|
|
46338
46339
|
jue2 g
|
|
46339
46340
|
xi1 zg
|
|
@@ -53672,7 +53673,7 @@ lian2 ns
|
|
|
53672
53673
|
ns p
|
|
53673
53674
|
n
|
|
53674
53675
|
lan3 v
|
|
53675
|
-
chi2
|
|
53676
|
+
chi2 si1
|
|
53676
53677
|
xuan2 n
|
|
53677
53678
|
n
|
|
53678
53679
|
n
|
|
@@ -57433,7 +57434,7 @@ ma3 nr
|
|
|
57433
57434
|
nrt
|
|
57434
57435
|
wu3 zg
|
|
57435
57436
|
fu1 zg
|
|
57436
|
-
wen2 zg
|
|
57437
|
+
wen2 zg min2
|
|
57437
57438
|
jie4 zg
|
|
57438
57439
|
ya2 zg
|
|
57439
57440
|
fen1 x bin1
|
|
@@ -57555,7 +57556,7 @@ dai4 n
|
|
|
57555
57556
|
dian4 zg
|
|
57556
57557
|
v
|
|
57557
57558
|
dian4 ru4 v
|
|
57558
|
-
xuan2 zg
|
|
57559
|
+
xuan2 zg xian2
|
|
57559
57560
|
xi3 ng
|
|
57560
57561
|
bo1 n
|
|
57561
57562
|
ns p
|
|
@@ -57872,6 +57873,7 @@ li3 xing4 ren4 shi5 li3 xing4 ren4 shi4 l
|
|
|
57872
57873
|
li3 fa3 shi1 n
|
|
57873
57874
|
li3 fa3 dian4 n
|
|
57874
57875
|
xiu4 zg
|
|
57876
|
+
fu2
|
|
57875
57877
|
liu2 ns
|
|
57876
57878
|
n
|
|
57877
57879
|
ns p2
|
|
@@ -58038,6 +58040,7 @@ yao2 j
|
|
|
58038
58040
|
n
|
|
58039
58041
|
ai4 x
|
|
58040
58042
|
bin1
|
|
58043
|
+
shu1 tu1
|
|
58041
58044
|
chang2 zg
|
|
58042
58045
|
kun1
|
|
58043
58046
|
cong1
|
|
@@ -65226,7 +65229,7 @@ jian3 piao2 jian3 pu2 a
|
|
|
65226
65229
|
v
|
|
65227
65230
|
a
|
|
65228
65231
|
pou2 zg
|
|
65229
|
-
bi3 bei1
|
|
65232
|
+
bi3 bei1,pai2
|
|
65230
65233
|
bi4 zg
|
|
65231
65234
|
ge4 zg
|
|
65232
65235
|
yu1
|
|
@@ -72777,7 +72780,7 @@ zi4 zg
|
|
|
72777
72780
|
hui4
|
|
72778
72781
|
sui1
|
|
72779
72782
|
xiang1 ns
|
|
72780
|
-
bi3 x
|
|
72783
|
+
bi3 x pi2
|
|
72781
72784
|
fu2 nrt
|
|
72782
72785
|
n
|
|
72783
72786
|
ns
|
|
@@ -74470,7 +74473,8 @@ suan4 n
|
|
|
74470
74473
|
li4 vg
|
|
74471
74474
|
v
|
|
74472
74475
|
ju3 zg
|
|
74473
|
-
|
|
74476
|
+
xi1
|
|
74477
|
+
bang4 pang2
|
|
74474
74478
|
chu2 zg
|
|
74475
74479
|
huo4
|
|
74476
74480
|
qian4 zg
|
|
@@ -75663,7 +75667,7 @@ rui4 zg
|
|
|
75663
75667
|
ni2 zg
|
|
75664
75668
|
qing1 n
|
|
75665
75669
|
n
|
|
75666
|
-
wei4
|
|
75670
|
+
wei4 wei3
|
|
75667
75671
|
liang3 zg
|
|
75668
75672
|
guo3 n
|
|
75669
75673
|
wan1 v
|
|
@@ -78666,7 +78670,7 @@ an1 v
|
|
|
78666
78670
|
a
|
|
78667
78671
|
xian2
|
|
78668
78672
|
nan2
|
|
78669
|
-
chen2 nr
|
|
78673
|
+
chen2 nr shen4
|
|
78670
78674
|
feng3 feng4 v
|
|
78671
78675
|
feng4 ci4 v
|
|
78672
78676
|
v
|
|
@@ -79995,7 +79999,7 @@ mou2 hua4 n
|
|
|
79995
79999
|
v
|
|
79996
80000
|
i
|
|
79997
80001
|
n
|
|
79998
|
-
chen2 nr
|
|
80002
|
+
chen2 nr shen4
|
|
79999
80003
|
die2 n
|
|
80000
80004
|
n
|
|
80001
80005
|
huang3 ng
|
|
@@ -80331,7 +80335,7 @@ xiu1 x
|
|
|
80331
80335
|
huan2
|
|
80332
80336
|
kun1 zg
|
|
80333
80337
|
he2
|
|
80334
|
-
he2 ng hao2
|
|
80338
|
+
he2 ng hao2,mo4
|
|
80335
80339
|
mo4 g
|
|
80336
80340
|
mao4 ng
|
|
80337
80341
|
i
|
|
@@ -81981,7 +81985,7 @@ zhi3 n
|
|
|
81981
81985
|
ta1 v
|
|
81982
81986
|
yue4
|
|
81983
81987
|
ba4
|
|
81984
|
-
qi2 zg qi4
|
|
81988
|
+
qi2 zg qi4,qi3
|
|
81985
81989
|
yue4 v
|
|
81986
81990
|
v
|
|
81987
81991
|
v
|
|
@@ -87946,7 +87950,7 @@ sui4 zg
|
|
|
87946
87950
|
lu3 zg
|
|
87947
87951
|
juan1 zg
|
|
87948
87952
|
v
|
|
87949
|
-
hui4 zg
|
|
87953
|
+
hui4 zg wei4
|
|
87950
87954
|
yu4 zg
|
|
87951
87955
|
lian2 n
|
|
87952
87956
|
n
|
|
@@ -97941,7 +97945,7 @@ nao2
|
|
|
97941
97945
|
gong3
|
|
97942
97946
|
geng4
|
|
97943
97947
|
ying2
|
|
97944
|
-
run2
|
|
97948
|
+
run2 shun4
|
|
97945
97949
|
cha2
|
|
97946
97950
|
mu3
|
|
97947
97951
|
xi4
|
package/data/standard.freq
CHANGED
|
Binary file
|
package/data/standard.keys
CHANGED
|
@@ -73,6 +73,7 @@ B
|
|
|
73
73
|
䠷
|
|
74
74
|
䥥
|
|
75
75
|
䩄
|
|
76
|
+
䩺
|
|
76
77
|
䬃
|
|
77
78
|
䭾
|
|
78
79
|
䰟
|
|
@@ -57872,6 +57873,7 @@ B
|
|
|
57872
57873
|
理髮師
|
|
57873
57874
|
理髮店
|
|
57874
57875
|
琇
|
|
57876
|
+
琈
|
|
57875
57877
|
琉
|
|
57876
57878
|
琉球
|
|
57877
57879
|
琉球群岛
|
|
@@ -58038,6 +58040,7 @@ B
|
|
|
58038
58040
|
瑶池
|
|
58039
58041
|
瑷
|
|
58040
58042
|
瑸
|
|
58043
|
+
瑹
|
|
58041
58044
|
瑺
|
|
58042
58045
|
瑻
|
|
58043
58046
|
瑽
|
|
@@ -74470,6 +74473,7 @@ B
|
|
|
74470
74473
|
蒞
|
|
74471
74474
|
蒞臨
|
|
74472
74475
|
蒟
|
|
74476
|
+
蒠
|
|
74473
74477
|
蒡
|
|
74474
74478
|
蒢
|
|
74475
74479
|
蒦
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a 里 standing alone means "in, inside", which 繁體 writes 裡.
|
|
3
|
+
*
|
|
4
|
+
* 里 has two senses that read alike. `lǐ` is the unit of distance and the
|
|
5
|
+
* neighbourhood, written 里 in both scripts (公里, 邻里, 里程, 里长), and `lǐ`
|
|
6
|
+
* is also the locative after a noun, written 裡 (鏡子裡, 房間裡, 冰箱裡). The
|
|
7
|
+
* syllable cannot tell them apart. The character table takes 里 by default,
|
|
8
|
+
* because most of the words that hold 里 are the unit or the neighbourhood.
|
|
9
|
+
* The table converts the locative words it knows (这里, 心里, 家里, 夜里)
|
|
10
|
+
* whole. A 里 the decode leaves as a word of its own has no such word behind
|
|
11
|
+
* it, and is the locative unless a number comes before it: 屋子里 is inside the
|
|
12
|
+
* room, and 走了十里 is ten 里 walked.
|
|
13
|
+
*/
|
|
14
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
15
|
+
import type { ScriptChoice } from "./script-types.js";
|
|
16
|
+
/**
|
|
17
|
+
* Write 裡 where a 里 standing alone means "in, inside".
|
|
18
|
+
*
|
|
19
|
+
* The character table takes 里 by default, which is right for 公里 and 邻里 and
|
|
20
|
+
* wrote 镜子里 as 鏡子里. A 里 the decode left as a word of its own after a
|
|
21
|
+
* noun is the locative. A number before it makes it the unit, and a
|
|
22
|
+
* transliteration syllable either side makes it part of a name. See
|
|
23
|
+
* {@link isInsideAt}.
|
|
24
|
+
*
|
|
25
|
+
* Only a choice that names 裡 as a rival is touched, which confines this to
|
|
26
|
+
* 简→繁: converting into 简体 has nothing to change 里 into.
|
|
27
|
+
*/
|
|
28
|
+
export declare function writeInside(choices: readonly ScriptChoice[], dictionary: Dictionary, characters: readonly string[], from: number): readonly ScriptChoice[];
|
|
29
|
+
//# sourceMappingURL=li-frames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"li-frames.d.ts","sourceRoot":"","sources":["../../src/decode/li-frames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAqFtD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,IAAI,EAAE,MAAM,GACX,SAAS,YAAY,EAAE,CAoBzB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { toCharacters } from "../script/characters.js";
|
|
2
|
+
/**
|
|
3
|
+
* The 繁體 form of the locative.
|
|
4
|
+
*/
|
|
5
|
+
const INSIDE = "裡";
|
|
6
|
+
/**
|
|
7
|
+
* What can come before a 里 that counts distance, in both scripts.
|
|
8
|
+
*
|
|
9
|
+
* The numerals, and the words that stand in for one or round it off: 几里,
|
|
10
|
+
* 数里, 十多里, 十来里, 十余里, 半里.
|
|
11
|
+
*/
|
|
12
|
+
const COUNTING = new Set(toCharacters("〇零一二三四五六七八九十百千万萬两兩廿几幾数數多来來余餘半"));
|
|
13
|
+
/**
|
|
14
|
+
* Transliteration syllables that come before a 里 in a foreign name: 克里斯,
|
|
15
|
+
* 加布里埃尔, 德米特里, 鲍里斯, 恩里科, 胡里奥, 齐里.
|
|
16
|
+
*/
|
|
17
|
+
const NAME_BEFORE = new Set(toCharacters("克布特鲍胡恩夏埃尤荷齐弗杰诺莫默奥艾迪阿伊佩塞贝哈帕茨维格"));
|
|
18
|
+
/**
|
|
19
|
+
* Transliteration syllables that come after a 里 in a foreign name: 里玛,
|
|
20
|
+
* 鲍里斯, 胡里奥, 恩里科, 格里菲斯, 斯特里普, 叶里温.
|
|
21
|
+
*/
|
|
22
|
+
const NAME_AFTER = new Set(toCharacters("斯埃玛奥科希约马奇尔亚诺娜莎欧达雅菲普曼温"));
|
|
23
|
+
/**
|
|
24
|
+
* Whether two characters are a word of their own, which the name syllables
|
|
25
|
+
* are not. 坦克里 and 表格里 end in 克 and 格, and 坦克 and 表格 are nouns.
|
|
26
|
+
*/
|
|
27
|
+
function isWord(dictionary, characters) {
|
|
28
|
+
return (characters.length === 2 &&
|
|
29
|
+
dictionary.lookup(characters.join("")) !== undefined);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether a 里 sits inside a foreign name, between syllables that make no
|
|
33
|
+
* word with what is either side of them.
|
|
34
|
+
*/
|
|
35
|
+
function isInName(dictionary, characters, at) {
|
|
36
|
+
return ((NAME_BEFORE.has(characters[at - 1]) &&
|
|
37
|
+
!isWord(dictionary, characters.slice(at - 2, at))) ||
|
|
38
|
+
(NAME_AFTER.has(characters[at + 1]) &&
|
|
39
|
+
!isWord(dictionary, characters.slice(at + 1, at + 3))));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether the 里 at a position means "in, inside".
|
|
43
|
+
*
|
|
44
|
+
* The caller has already settled that the character is a 里 standing alone.
|
|
45
|
+
* A 里 with nothing before it in the run is left alone, since there is no noun
|
|
46
|
+
* for it to be inside. A run starts after punctuation or any character that is
|
|
47
|
+
* not Han, digits among them, and 5里 is as likely as Facebook里.
|
|
48
|
+
*/
|
|
49
|
+
function isInsideAt(dictionary, characters, at) {
|
|
50
|
+
const before = characters[at - 1];
|
|
51
|
+
return (before !== undefined &&
|
|
52
|
+
!COUNTING.has(before) &&
|
|
53
|
+
!isInName(dictionary, characters, at));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Write 裡 where a 里 standing alone means "in, inside".
|
|
57
|
+
*
|
|
58
|
+
* The character table takes 里 by default, which is right for 公里 and 邻里 and
|
|
59
|
+
* wrote 镜子里 as 鏡子里. A 里 the decode left as a word of its own after a
|
|
60
|
+
* noun is the locative. A number before it makes it the unit, and a
|
|
61
|
+
* transliteration syllable either side makes it part of a name. See
|
|
62
|
+
* {@link isInsideAt}.
|
|
63
|
+
*
|
|
64
|
+
* Only a choice that names 裡 as a rival is touched, which confines this to
|
|
65
|
+
* 简→繁: converting into 简体 has nothing to change 里 into.
|
|
66
|
+
*/
|
|
67
|
+
export function writeInside(choices, dictionary, characters, from) {
|
|
68
|
+
const [choice] = choices;
|
|
69
|
+
if (choices.length !== 1 ||
|
|
70
|
+
choice === undefined ||
|
|
71
|
+
!choice.alternatives.includes(INSIDE) ||
|
|
72
|
+
!isInsideAt(dictionary, characters, from)) {
|
|
73
|
+
return choices;
|
|
74
|
+
}
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
from: choice.from,
|
|
78
|
+
to: INSIDE,
|
|
79
|
+
evidence: "reading",
|
|
80
|
+
alternatives: [choice.to, ...choice.alternatives].filter((form) => form !== INSIDE),
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=li-frames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"li-frames.js","sourceRoot":"","sources":["../../src/decode/li-frames.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,CAAC;AAEnB;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CACtB,YAAY,CAAC,+BAA+B,CAAC,CAC9C,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,GAAG,IAAI,GAAG,CACzB,YAAY,CAAC,+BAA+B,CAAC,CAC9C,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,CACxB,YAAY,CAAC,uBAAuB,CAAC,CACtC,CAAC;AAEF;;;GAGG;AACH,SAAS,MAAM,CACb,UAAsB,EACtB,UAA6B;IAE7B,OAAO,CACL,UAAU,CAAC,MAAM,KAAK,CAAC;QACvB,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CACrD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,QAAQ,CACf,UAAsB,EACtB,UAA6B,EAC7B,EAAU;IAEV,OAAO,CACL,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAClC,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACpD,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YACjC,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CACzD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,UAAU,CACjB,UAAsB,EACtB,UAA6B,EAC7B,EAAU;IAEV,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAClC,OAAO,CACL,MAAM,KAAK,SAAS;QACpB,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC;QACrB,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC,CACtC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CACzB,OAAgC,EAChC,UAAsB,EACtB,UAA6B,EAC7B,IAAY;IAEZ,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;IACzB,IACE,OAAO,CAAC,MAAM,KAAK,CAAC;QACpB,MAAM,KAAK,SAAS;QACpB,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC;QACrC,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,EACzC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO;QACL;YACE,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,EAAE,EAAE,MAAM;YACV,QAAQ,EAAE,SAAS;YACnB,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CACtD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,CAC1B;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The rules about words that begin at an aspect particle or at the adverbial
|
|
3
|
-
* 地.
|
|
4
|
-
*
|
|
5
|
-
* {@link import("./de-rule.js").PARTICLE_DE} and
|
|
6
|
-
* {@link import("./complement-rule.js").COMPLEMENT_DE} settle the same fault for 的 and
|
|
7
|
-
* 得: the full tier keeps keys no source tagged, many of them from the phrase
|
|
8
|
-
* corpus, and one that starts at a particle reads that particle as whatever it
|
|
9
|
-
* is at the head of a phrase.
|
|
10
|
-
*/
|
|
11
1
|
import { type EdgeRule } from "./rules.js";
|
|
12
2
|
/**
|
|
13
3
|
* A word beginning with 着 or 了 does not start where the aspect particle does.
|
|
@@ -35,8 +25,16 @@ export declare const ASPECTUAL_PARTICLE: EdgeRule;
|
|
|
35
25
|
* for a family's place of origin. After an adjective or an adverb 地 is the
|
|
36
26
|
* particle that makes it modify a verb, and reads `de`.
|
|
37
27
|
*
|
|
28
|
+
* Only an untagged key is forbidden there, since a tagged one such as 地方 can
|
|
29
|
+
* follow an adjective as a noun: 这么大地方. After a reduplication any key is
|
|
30
|
+
* forbidden, since the 地 after 一点儿一点儿 or 慢慢 is always the particle.
|
|
31
|
+
* 跟着丈夫一点儿一点儿地学 and 他慢慢地学 came out `dì xué` on the noun 地学.
|
|
32
|
+
*
|
|
38
33
|
* Over the 88,612 sentences of Tatoeba and the 43,367 Chinese Boost 例句 it
|
|
39
34
|
* changes 2 runs in the full tier, both corrections: 惆怅地望着 and 悠哉地坐.
|
|
35
|
+
* The reduplication changes 1 more of the 17,825 distinct runs holding a 地 in
|
|
36
|
+
* Tatoeba, zh.wikipedia and the 47,848 例句 there are now, also a correction:
|
|
37
|
+
* 斷斷續續地下了.
|
|
40
38
|
*/
|
|
41
39
|
export declare const ADVERBIAL_DI: EdgeRule;
|
|
42
40
|
//# sourceMappingURL=particle-rule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle-rule.d.ts","sourceRoot":"","sources":["../../src/decode/particle-rule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"particle-rule.d.ts","sourceRoot":"","sources":["../../src/decode/particle-rule.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,KAAK,QAAQ,EAGd,MAAM,YAAY,CAAC;AAgCpB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAShC,CAAC;AAyEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY,EAAE,QAgB1B,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* corpus, and one that starts at a particle reads that particle as whatever it
|
|
9
9
|
* is at the head of a phrase.
|
|
10
10
|
*/
|
|
11
|
+
import { toCharacters } from "../script/characters.js";
|
|
11
12
|
import { tagOf, wordEndingAt, } from "./rules.js";
|
|
12
13
|
/**
|
|
13
14
|
* Whether an edge is a word of more than one character that no source tagged
|
|
@@ -69,6 +70,56 @@ const DI = new Set(["地"]);
|
|
|
69
70
|
* 地球轨道.
|
|
70
71
|
*/
|
|
71
72
|
const ADVERBIAL_TAGS = /^(?:a|z|d)/u;
|
|
73
|
+
/** The numeral that starts a count said twice over: 一点儿一点儿, 一步一步. */
|
|
74
|
+
const ONE = "一";
|
|
75
|
+
/**
|
|
76
|
+
* The tags of a reduplicated word that says how something is done: 慢慢 and
|
|
77
|
+
* 渐渐 are `d`, 悄悄 and 匆匆 are `z`, and 断断续续 is `i`.
|
|
78
|
+
*/
|
|
79
|
+
const MANNER_TAGS = /^(?:d|z|i)/u;
|
|
80
|
+
/**
|
|
81
|
+
* The reduplicated adverbs that say when or how often rather than how, and
|
|
82
|
+
* stand in front of a 地震 or a 地铁 as readily as in front of the particle.
|
|
83
|
+
*/
|
|
84
|
+
const TEMPORAL_REDUPLICATIONS = new Set([
|
|
85
|
+
"常常",
|
|
86
|
+
"刚刚",
|
|
87
|
+
"剛剛",
|
|
88
|
+
"每每",
|
|
89
|
+
"偏偏",
|
|
90
|
+
"仅仅",
|
|
91
|
+
"僅僅",
|
|
92
|
+
"恰恰",
|
|
93
|
+
]);
|
|
94
|
+
/**
|
|
95
|
+
* Whether the words ending at a position are a reduplication that 地 makes
|
|
96
|
+
* into an adverbial.
|
|
97
|
+
*
|
|
98
|
+
* Two shapes qualify. A count said twice, 一点儿一点儿 or 一步一步, is a
|
|
99
|
+
* manner of doing something and nothing else. A word that is itself
|
|
100
|
+
* reduplicated, 慢慢 or 渐渐, qualifies where its tag makes it an adverb of
|
|
101
|
+
* manner. Repeated characters alone are not enough: 学学 in 大学学地质 ends a
|
|
102
|
+
* 大学, and the 嚐嚐 of 嚐嚐地道的四川菜 is a verb whose object is 地道.
|
|
103
|
+
*/
|
|
104
|
+
function isReduplicatedBefore(context, at) {
|
|
105
|
+
const word = wordEndingAt(context, at);
|
|
106
|
+
if (word === undefined) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const characters = toCharacters(word);
|
|
110
|
+
const length = characters.length;
|
|
111
|
+
if (characters[0] === ONE &&
|
|
112
|
+
length >= 2 &&
|
|
113
|
+
context.characters.slice(at - 2 * length, at - length).join("") === word) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
const isDoubled = (length === 2 || length === 4) &&
|
|
117
|
+
characters[0] === characters[1] &&
|
|
118
|
+
characters[2] === characters[3];
|
|
119
|
+
return (isDoubled &&
|
|
120
|
+
MANNER_TAGS.test(tagOf(context, word)) &&
|
|
121
|
+
!TEMPORAL_REDUPLICATIONS.has(word));
|
|
122
|
+
}
|
|
72
123
|
/**
|
|
73
124
|
* A word beginning with 地 does not start where the adverbial particle does.
|
|
74
125
|
*
|
|
@@ -76,16 +127,31 @@ const ADVERBIAL_TAGS = /^(?:a|z|d)/u;
|
|
|
76
127
|
* for a family's place of origin. After an adjective or an adverb 地 is the
|
|
77
128
|
* particle that makes it modify a verb, and reads `de`.
|
|
78
129
|
*
|
|
130
|
+
* Only an untagged key is forbidden there, since a tagged one such as 地方 can
|
|
131
|
+
* follow an adjective as a noun: 这么大地方. After a reduplication any key is
|
|
132
|
+
* forbidden, since the 地 after 一点儿一点儿 or 慢慢 is always the particle.
|
|
133
|
+
* 跟着丈夫一点儿一点儿地学 and 他慢慢地学 came out `dì xué` on the noun 地学.
|
|
134
|
+
*
|
|
79
135
|
* Over the 88,612 sentences of Tatoeba and the 43,367 Chinese Boost 例句 it
|
|
80
136
|
* changes 2 runs in the full tier, both corrections: 惆怅地望着 and 悠哉地坐.
|
|
137
|
+
* The reduplication changes 1 more of the 17,825 distinct runs holding a 地 in
|
|
138
|
+
* Tatoeba, zh.wikipedia and the 47,848 例句 there are now, also a correction:
|
|
139
|
+
* 斷斷續續地下了.
|
|
81
140
|
*/
|
|
82
141
|
export const ADVERBIAL_DI = {
|
|
83
142
|
name: "adverbial-di",
|
|
84
143
|
verdictFor: (context) => {
|
|
144
|
+
const { characters, edge } = context;
|
|
145
|
+
if (edge.to - edge.from < 2 || !DI.has(characters[edge.from] ?? "")) {
|
|
146
|
+
return "keep";
|
|
147
|
+
}
|
|
148
|
+
if (isReduplicatedBefore(context, edge.from)) {
|
|
149
|
+
return "forbid";
|
|
150
|
+
}
|
|
85
151
|
if (!isUntaggedFrom(context, DI)) {
|
|
86
152
|
return "keep";
|
|
87
153
|
}
|
|
88
|
-
const before = wordEndingAt(context,
|
|
154
|
+
const before = wordEndingAt(context, edge.from);
|
|
89
155
|
return ADVERBIAL_TAGS.test(tagOf(context, before)) ? "forbid" : "keep";
|
|
90
156
|
},
|
|
91
157
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle-rule.js","sourceRoot":"","sources":["../../src/decode/particle-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAGL,KAAK,EACL,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,SAAS,cAAc,CACrB,OAAoB,EACpB,UAA+B;IAE/B,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACzB,OAAO,CACL,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,KAAK,EAAE;QACxB,UAAU,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G,CAAC,IAAI,CAAC,CACnC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAa;IACpC,IAAI,EAAE,cAAc;IACpB,UAAU,EAAE,CAAC,OAAoB,EAAE,EAAE;QACnC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACrC,IAAI,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YACpE,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IAAI,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;YACjC,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IACzE,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Revisiting a converted word in the light of the run around it.
|
|
3
|
+
*
|
|
4
|
+
* The character table decides each character alone, and for a few the words
|
|
5
|
+
* either side are what settle it. `script-words` converts a word on its own
|
|
6
|
+
* evidence, and this is what follows it.
|
|
7
|
+
*/
|
|
8
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
9
|
+
import type { CharacterConversion } from "../script/conversion.js";
|
|
10
|
+
import type { Syllable } from "../syllable/syllable.js";
|
|
11
|
+
import type { ScriptChoice } from "./script-types.js";
|
|
12
|
+
/**
|
|
13
|
+
* What a word in a run is converted against.
|
|
14
|
+
*/
|
|
15
|
+
export interface RunTables {
|
|
16
|
+
readonly dictionary: Dictionary;
|
|
17
|
+
readonly table: ReadonlyMap<string, CharacterConversion>;
|
|
18
|
+
readonly words: ReadonlyMap<string, string>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Convert a word, then revisit its choices in the light of the run around it.
|
|
22
|
+
*
|
|
23
|
+
* The character table decides 干 and 里 alone, and a frame around the word can
|
|
24
|
+
* overrule it: 与你无干 keeps 干 and 镜子里 writes 裡. `from` is where the
|
|
25
|
+
* word starts in `characters`, which are the whole run's.
|
|
26
|
+
*/
|
|
27
|
+
export declare function convertInRun(tables: RunTables, word: string, reading: readonly Syllable[], characters: readonly string[], from: number): readonly ScriptChoice[];
|
|
28
|
+
//# sourceMappingURL=script-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-context.d.ts","sourceRoot":"","sources":["../../src/decode/script-context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACzD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,IAAI,EAAE,MAAM,GACX,SAAS,YAAY,EAAE,CAUzB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CONCERNING, isConcerningAt, isGan } from "./gan-frames.js";
|
|
2
|
+
import { writeInside } from "./li-frames.js";
|
|
3
|
+
import { convertWord } from "./script-words.js";
|
|
4
|
+
/**
|
|
5
|
+
* Convert a word, then revisit its choices in the light of the run around it.
|
|
6
|
+
*
|
|
7
|
+
* The character table decides 干 and 里 alone, and a frame around the word can
|
|
8
|
+
* overrule it: 与你无干 keeps 干 and 镜子里 writes 裡. `from` is where the
|
|
9
|
+
* word starts in `characters`, which are the whole run's.
|
|
10
|
+
*/
|
|
11
|
+
export function convertInRun(tables, word, reading, characters, from) {
|
|
12
|
+
const converted = convertWord(tables.table, tables.words, word, reading);
|
|
13
|
+
const concerning = keepConcerning(converted, tables.dictionary, characters, from, reading);
|
|
14
|
+
return writeInside(concerning, tables.dictionary, characters, from);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Keep 干 where it means "to concern".
|
|
18
|
+
*
|
|
19
|
+
* 干 read `gān` is 乾 when it means dry (干燥, 干货) and stays 干 when it means
|
|
20
|
+
* to concern (干扰, 相干), and the syllable cannot tell the two apart. A word
|
|
21
|
+
* settles most of them. A 干 standing alone at `gān` fell back on 乾, which
|
|
22
|
+
* wrote 与你无干 as 與你無乾 and 干卿底事 as 乾卿底事. The frames that read
|
|
23
|
+
* it `gān` in the first place are the ones that decide it here. See
|
|
24
|
+
* {@link isConcerningAt}.
|
|
25
|
+
*
|
|
26
|
+
* `from` is where the word starts in `characters`, which are the whole run's,
|
|
27
|
+
* since the frames reach past the word.
|
|
28
|
+
*/
|
|
29
|
+
function keepConcerning(choices, dictionary, characters, from, reading) {
|
|
30
|
+
if (reading.length !== choices.length) {
|
|
31
|
+
return choices;
|
|
32
|
+
}
|
|
33
|
+
return choices.map((choice, at) => choice.from === CONCERNING &&
|
|
34
|
+
choice.to !== CONCERNING &&
|
|
35
|
+
isGan(reading[at]) &&
|
|
36
|
+
isConcerningAt(dictionary, characters, from + at)
|
|
37
|
+
? {
|
|
38
|
+
from: choice.from,
|
|
39
|
+
to: CONCERNING,
|
|
40
|
+
evidence: "reading",
|
|
41
|
+
alternatives: [choice.to, ...choice.alternatives].filter((form) => form !== CONCERNING),
|
|
42
|
+
}
|
|
43
|
+
: choice);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=script-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-context.js","sourceRoot":"","sources":["../../src/decode/script-context.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAYhD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAiB,EACjB,IAAY,EACZ,OAA4B,EAC5B,UAA6B,EAC7B,IAAY;IAEZ,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzE,MAAM,UAAU,GAAG,cAAc,CAC/B,SAAS,EACT,MAAM,CAAC,UAAU,EACjB,UAAU,EACV,IAAI,EACJ,OAAO,CACR,CAAC;IACF,OAAO,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,cAAc,CACrB,OAAgC,EAChC,UAAsB,EACtB,UAA6B,EAC7B,IAAY,EACZ,OAA4B;IAE5B,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAChC,MAAM,CAAC,IAAI,KAAK,UAAU;QAC1B,MAAM,CAAC,EAAE,KAAK,UAAU;QACxB,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAClB,cAAc,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC;QAC/C,CAAC,CAAC;YACE,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,EAAE,EAAE,UAAU;YACd,QAAQ,EAAE,SAAS;YACnB,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CACtD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,UAAU,CAC9B;SACF;QACH,CAAC,CAAC,MAAM,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* can show where the conversion was guessing.
|
|
7
7
|
*/
|
|
8
8
|
import type { ScriptChoice, ScriptEvidence, ScriptTarget } from "./script-types.js";
|
|
9
|
-
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
10
9
|
import { type CharacterConversion } from "../script/conversion.js";
|
|
11
10
|
import { type Region } from "../script/glyphs.js";
|
|
12
11
|
import type { Script } from "../script/script.js";
|
|
@@ -23,19 +22,10 @@ export declare function targetOf(target: ScriptTarget): {
|
|
|
23
22
|
*/
|
|
24
23
|
export declare function convertWord(table: ReadonlyMap<string, CharacterConversion>, words: ReadonlyMap<string, string>, word: string, reading: readonly Syllable[]): readonly ScriptChoice[];
|
|
25
24
|
/**
|
|
26
|
-
* Keep
|
|
27
|
-
*
|
|
28
|
-
* 干 read `gān` is 乾 when it means dry (干燥, 干货) and stays 干 when it means
|
|
29
|
-
* to concern (干扰, 相干), and the syllable cannot tell the two apart. A word
|
|
30
|
-
* settles most of them. A 干 standing alone at `gān` fell back on 乾, which
|
|
31
|
-
* wrote 与你无干 as 與你無乾 and 干卿底事 as 乾卿底事. The frames that read
|
|
32
|
-
* it `gān` in the first place are the ones that decide it here. See
|
|
33
|
-
* {@link isConcerningAt}.
|
|
34
|
-
*
|
|
35
|
-
* `from` is where the word starts in `characters`, which are the whole run's,
|
|
36
|
-
* since the frames reach past the word.
|
|
25
|
+
* Keep a word as it stands, which is what a text already in the target script
|
|
26
|
+
* needs. Every character is locked, because none of them was in question.
|
|
37
27
|
*/
|
|
38
|
-
export declare function
|
|
28
|
+
export declare function keepWord(word: string): readonly ScriptChoice[];
|
|
39
29
|
/**
|
|
40
30
|
* Rank what settled a character, strongest evidence first.
|
|
41
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-words.d.ts","sourceRoot":"","sources":["../../src/decode/script-words.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"script-words.d.ts","sourceRoot":"","sources":["../../src/decode/script-words.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAQA;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC/C,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,QAAQ,EAAE,GAC3B,SAAS,YAAY,EAAE,CAuCzB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,YAAY,EAAE,CAO9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,OAAO,EACnB,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,OAAO,GAChB,cAAc,CAQhB"}
|