@kensio/pinyinjs 1.7.5 → 1.7.7
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 +128 -123
- package/data/full.entries +2637 -2637
- package/data/manifest.json +9 -9
- package/data/script.map +168 -3
- package/data/standard.entries +8 -8
- package/dist/decode/chang-complement.d.ts +19 -0
- package/dist/decode/chang-complement.d.ts.map +1 -0
- package/dist/decode/chang-complement.js +113 -0
- package/dist/decode/chang-complement.js.map +1 -0
- package/dist/decode/chang-context.d.ts +29 -0
- package/dist/decode/chang-context.d.ts.map +1 -0
- package/dist/decode/chang-context.js +99 -0
- package/dist/decode/chang-context.js.map +1 -0
- package/dist/decode/chang-rule.d.ts +47 -0
- package/dist/decode/chang-rule.d.ts.map +1 -0
- package/dist/decode/chang-rule.js +188 -0
- package/dist/decode/chang-rule.js.map +1 -0
- package/dist/decode/confidence.d.ts +11 -3
- package/dist/decode/confidence.d.ts.map +1 -1
- package/dist/decode/confidence.js +11 -3
- package/dist/decode/confidence.js.map +1 -1
- package/dist/decode/convert-pipeline.d.ts.map +1 -1
- package/dist/decode/convert-pipeline.js +5 -4
- package/dist/decode/convert-pipeline.js.map +1 -1
- package/dist/decode/de-rule.d.ts +74 -0
- package/dist/decode/de-rule.d.ts.map +1 -0
- package/dist/decode/de-rule.js +199 -0
- package/dist/decode/de-rule.js.map +1 -0
- package/dist/decode/decode.d.ts +12 -25
- package/dist/decode/decode.d.ts.map +1 -1
- package/dist/decode/decode.js +10 -47
- package/dist/decode/decode.js.map +1 -1
- package/dist/decode/decoders.d.ts +9 -4
- package/dist/decode/decoders.d.ts.map +1 -1
- package/dist/decode/decoders.js +7 -7
- package/dist/decode/decoders.js.map +1 -1
- package/dist/decode/edge-context.d.ts +19 -0
- package/dist/decode/edge-context.d.ts.map +1 -1
- package/dist/decode/edge-context.js +41 -0
- package/dist/decode/edge-context.js.map +1 -1
- package/dist/decode/hint-lattice.d.ts.map +1 -1
- package/dist/decode/hint-lattice.js +17 -3
- package/dist/decode/hint-lattice.js.map +1 -1
- package/dist/decode/jiao-rule.d.ts +9 -3
- package/dist/decode/jiao-rule.d.ts.map +1 -1
- package/dist/decode/jiao-rule.js +44 -5
- package/dist/decode/jiao-rule.js.map +1 -1
- package/dist/decode/lattice-decode.d.ts +28 -0
- package/dist/decode/lattice-decode.d.ts.map +1 -0
- package/dist/decode/lattice-decode.js +48 -0
- package/dist/decode/lattice-decode.js.map +1 -0
- package/dist/decode/lattice-slice.d.ts +22 -6
- package/dist/decode/lattice-slice.d.ts.map +1 -1
- package/dist/decode/lattice-slice.js +24 -18
- package/dist/decode/lattice-slice.js.map +1 -1
- package/dist/decode/lattice-types.d.ts +27 -8
- package/dist/decode/lattice-types.d.ts.map +1 -1
- package/dist/decode/lattice-types.js +27 -8
- package/dist/decode/lattice-types.js.map +1 -1
- package/dist/decode/numbers.d.ts +0 -8
- package/dist/decode/numbers.d.ts.map +1 -1
- package/dist/decode/numbers.js +0 -10
- package/dist/decode/numbers.js.map +1 -1
- package/dist/decode/polyphone-rules.d.ts +7 -27
- package/dist/decode/polyphone-rules.d.ts.map +1 -1
- package/dist/decode/polyphone-rules.js +7 -155
- package/dist/decode/polyphone-rules.js.map +1 -1
- package/dist/decode/reading-rules.d.ts +1 -29
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +5 -69
- package/dist/decode/reading-rules.js.map +1 -1
- package/dist/decode/rules.d.ts +1 -1
- package/dist/decode/rules.d.ts.map +1 -1
- package/dist/decode/rules.js +1 -1
- package/dist/decode/rules.js.map +1 -1
- package/dist/decode/run-context.d.ts +33 -0
- package/dist/decode/run-context.d.ts.map +1 -0
- package/dist/decode/run-context.js +47 -0
- package/dist/decode/run-context.js.map +1 -0
- package/dist/decode/run-lattice.d.ts +13 -10
- package/dist/decode/run-lattice.d.ts.map +1 -1
- package/dist/decode/run-lattice.js +15 -12
- package/dist/decode/run-lattice.js.map +1 -1
- package/dist/decode/run-words.d.ts +17 -0
- package/dist/decode/run-words.d.ts.map +1 -0
- package/dist/decode/run-words.js +29 -0
- package/dist/decode/run-words.js.map +1 -0
- package/dist/decode/sandhi-input.d.ts +30 -0
- package/dist/decode/sandhi-input.d.ts.map +1 -0
- package/dist/decode/sandhi-input.js +35 -0
- package/dist/decode/sandhi-input.js.map +1 -0
- package/dist/decode/sandhi-tones.d.ts +33 -5
- package/dist/decode/sandhi-tones.d.ts.map +1 -1
- package/dist/decode/sandhi-tones.js +59 -8
- package/dist/decode/sandhi-tones.js.map +1 -1
- package/dist/decode/sandhi.d.ts +9 -6
- package/dist/decode/sandhi.d.ts.map +1 -1
- package/dist/decode/sandhi.js +10 -7
- package/dist/decode/sandhi.js.map +1 -1
- package/dist/decode/script-region.d.ts +15 -0
- package/dist/decode/script-region.d.ts.map +1 -0
- package/dist/decode/script-region.js +61 -0
- package/dist/decode/script-region.js.map +1 -0
- package/dist/decode/script-types.d.ts +11 -2
- package/dist/decode/script-types.d.ts.map +1 -1
- package/dist/decode/script-types.js +2 -1
- package/dist/decode/script-types.js.map +1 -1
- package/dist/decode/script-words.d.ts +7 -5
- package/dist/decode/script-words.d.ts.map +1 -1
- package/dist/decode/script-words.js +18 -25
- package/dist/decode/script-words.js.map +1 -1
- package/dist/decode/script.d.ts.map +1 -1
- package/dist/decode/script.js +2 -1
- package/dist/decode/script.js.map +1 -1
- package/dist/decode/write-run.d.ts +0 -7
- package/dist/decode/write-run.d.ts.map +1 -1
- package/dist/decode/write-run.js +4 -39
- package/dist/decode/write-run.js.map +1 -1
- package/dist/dictionary/cedict-senses.d.ts +7 -0
- package/dist/dictionary/cedict-senses.d.ts.map +1 -1
- package/dist/dictionary/cedict-senses.js +12 -0
- package/dist/dictionary/cedict-senses.js.map +1 -1
- package/dist/dictionary/constituent-repair.d.ts +36 -0
- package/dist/dictionary/constituent-repair.d.ts.map +1 -0
- package/dist/dictionary/constituent-repair.js +117 -0
- package/dist/dictionary/constituent-repair.js.map +1 -0
- package/dist/dictionary/measure-tone.d.ts +36 -0
- package/dist/dictionary/measure-tone.d.ts.map +1 -0
- package/dist/dictionary/measure-tone.js +139 -0
- package/dist/dictionary/measure-tone.js.map +1 -0
- package/dist/dictionary/merge-types.d.ts +13 -2
- package/dist/dictionary/merge-types.d.ts.map +1 -1
- package/dist/dictionary/merge-types.js.map +1 -1
- package/dist/dictionary/merge-walk.d.ts +27 -0
- package/dist/dictionary/merge-walk.d.ts.map +1 -0
- package/dist/dictionary/merge-walk.js +49 -0
- package/dist/dictionary/merge-walk.js.map +1 -0
- package/dist/dictionary/merge.d.ts +3 -3
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +24 -28
- package/dist/dictionary/merge.js.map +1 -1
- package/dist/dictionary/overrides.d.ts +5 -0
- package/dist/dictionary/overrides.d.ts.map +1 -1
- package/dist/dictionary/overrides.js +5 -5
- package/dist/dictionary/overrides.js.map +1 -1
- package/dist/dictionary/script-tables.js +91 -13
- package/dist/dictionary/script-tables.js.map +1 -1
- package/dist/dictionary/word-readings.d.ts.map +1 -1
- package/dist/dictionary/word-readings.js +6 -0
- package/dist/dictionary/word-readings.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/dist/script/glyphs.d.ts +9 -8
- package/dist/script/glyphs.d.ts.map +1 -1
- package/dist/script/glyphs.js +21 -48
- package/dist/script/glyphs.js.map +1 -1
- package/dist/script/reading-splits.d.ts +41 -0
- package/dist/script/reading-splits.d.ts.map +1 -0
- package/dist/script/reading-splits.js +98 -0
- package/dist/script/reading-splits.js.map +1 -0
- package/package.json +2 -2
package/data/standard.entries
CHANGED
|
@@ -111,8 +111,8 @@ yi1 xia4 zi5 m
|
|
|
111
111
|
d
|
|
112
112
|
yi1 ge4 jinr4 d
|
|
113
113
|
d
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
m
|
|
115
|
+
m
|
|
116
116
|
l
|
|
117
117
|
d
|
|
118
118
|
i
|
|
@@ -147,8 +147,8 @@ yi1 huir4 m
|
|
|
147
147
|
d
|
|
148
148
|
yi1 ge4 jinr4 d
|
|
149
149
|
d
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
m
|
|
151
|
+
m
|
|
152
152
|
m
|
|
153
153
|
f
|
|
154
154
|
m
|
|
@@ -1125,7 +1125,7 @@ shang4 f shang3,shang5
|
|
|
1125
1125
|
v
|
|
1126
1126
|
b
|
|
1127
1127
|
b
|
|
1128
|
-
t
|
|
1128
|
+
shang4 ge5 yue4 t
|
|
1129
1129
|
ns p
|
|
1130
1130
|
v
|
|
1131
1131
|
v
|
|
@@ -1140,7 +1140,7 @@ shang4 f shang3,shang5
|
|
|
1140
1140
|
j
|
|
1141
1141
|
t
|
|
1142
1142
|
shang4 gong4 v
|
|
1143
|
-
t
|
|
1143
|
+
shang4 ge5 yue4 t
|
|
1144
1144
|
v
|
|
1145
1145
|
t
|
|
1146
1146
|
n
|
|
@@ -48789,9 +48789,9 @@ mu3 n
|
|
|
48789
48789
|
n
|
|
48790
48790
|
mei3 zg
|
|
48791
48791
|
mei3 zg
|
|
48792
|
+
mei3 ge5 r
|
|
48792
48793
|
r
|
|
48793
|
-
r
|
|
48794
|
-
r
|
|
48794
|
+
mei3 ge5 r
|
|
48795
48795
|
l
|
|
48796
48796
|
r
|
|
48797
48797
|
r
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type EdgeContext } from "./rules.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether what follows a 长 is a comparison or an intensifier.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isCompared(context: EdgeContext): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Whether a 长 is being given a measurement.
|
|
8
|
+
*
|
|
9
|
+
* 那条河长三百公里, 隧道长五公里. A quantity after a 长 is how long the thing is,
|
|
10
|
+
* and a growing takes an aspect marker before it can take one — 长了三厘米 —
|
|
11
|
+
* which is the 了 this never sees.
|
|
12
|
+
*
|
|
13
|
+
* A number written in digits reads the same, though nothing here knows the
|
|
14
|
+
* difference. 那条河长300公里 is four runs and the 长 ends the first of them, so
|
|
15
|
+
* the numeral and the 公里 are one run and two runs away; the decode is handed
|
|
16
|
+
* the 汉字 they stand for before this is ever asked. See `convert-pipeline.ts`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isMeasured(context: EdgeContext): boolean;
|
|
19
|
+
//# sourceMappingURL=chang-complement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chang-complement.d.ts","sourceRoot":"","sources":["../../src/decode/chang-complement.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,WAAW,EAA0B,MAAM,YAAY,CAAC;AA2BtE;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CASxD;AA2CD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAcxD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What can follow a 长 that is a length and cannot follow one that is growing.
|
|
3
|
+
*
|
|
4
|
+
* The near-side contexts are in `chang-context.ts`, and each of them has to
|
|
5
|
+
* check this side as well. These two do the opposite: they settle a 长 from what
|
|
6
|
+
* comes after it and ask nothing at all about what comes before.
|
|
7
|
+
*/
|
|
8
|
+
import { toCharacters } from "../script/characters.js";
|
|
9
|
+
import { tagOf, wordsStartingAt } from "./rules.js";
|
|
10
|
+
/**
|
|
11
|
+
* What can only follow a 长 that is a length.
|
|
12
|
+
*
|
|
13
|
+
* A quality can be compared and intensified, and a growing cannot: 长一点 is
|
|
14
|
+
* longer by a bit, 长极了 is extremely long, and 长而美丽 conjoins two
|
|
15
|
+
* adjectives. None of them is something a verb governs, so the near side needs
|
|
16
|
+
* no test at all and these settle a 长 on their own.
|
|
17
|
+
*
|
|
18
|
+
* 得 is pointedly absent even though 长得很 looks like the same shape, because
|
|
19
|
+
* 长得很快 is the growing with its complement and 得 is where that complement
|
|
20
|
+
* hangs. {@link GROWING} in `chang-rule.ts` guards it from the other side.
|
|
21
|
+
*/
|
|
22
|
+
const COMPARED = new Set([
|
|
23
|
+
"而",
|
|
24
|
+
"一点",
|
|
25
|
+
"一點",
|
|
26
|
+
"点",
|
|
27
|
+
"點",
|
|
28
|
+
"一些",
|
|
29
|
+
"些",
|
|
30
|
+
"极了",
|
|
31
|
+
"極了",
|
|
32
|
+
"得多",
|
|
33
|
+
]);
|
|
34
|
+
/**
|
|
35
|
+
* Whether what follows a 长 is a comparison or an intensifier.
|
|
36
|
+
*/
|
|
37
|
+
export function isCompared(context) {
|
|
38
|
+
const { characters, edge } = context;
|
|
39
|
+
for (let length = 1; length <= 2; length++) {
|
|
40
|
+
const after = characters.slice(edge.to, edge.to + length).join("");
|
|
41
|
+
if (COMPARED.has(after)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The tag jieba gives a numeral.
|
|
49
|
+
*/
|
|
50
|
+
const NUMERAL = "m";
|
|
51
|
+
/**
|
|
52
|
+
* The units a length or a duration is given in.
|
|
53
|
+
*
|
|
54
|
+
* Written out rather than taken from the 量词 tag, and the corpus says why: a
|
|
55
|
+
* numeral after a 长 is far more often counting something else. 学校现有通榆和新
|
|
56
|
+
* 长两个校区 counts campuses and 竞争马华总会长一职 counts posts, and both read
|
|
57
|
+
* `zhǎng`. What a 长 can be measured in is a distance or a stretch of time, and
|
|
58
|
+
* that is a closed set.
|
|
59
|
+
*/
|
|
60
|
+
const MEASURED_IN = new Set([
|
|
61
|
+
"米",
|
|
62
|
+
"公里",
|
|
63
|
+
"千米",
|
|
64
|
+
"厘米",
|
|
65
|
+
"毫米",
|
|
66
|
+
"公分",
|
|
67
|
+
"英里",
|
|
68
|
+
"英尺",
|
|
69
|
+
"英寸",
|
|
70
|
+
"尺",
|
|
71
|
+
"寸",
|
|
72
|
+
"里",
|
|
73
|
+
"码",
|
|
74
|
+
"秒",
|
|
75
|
+
"分钟",
|
|
76
|
+
"分鐘",
|
|
77
|
+
"小时",
|
|
78
|
+
"小時",
|
|
79
|
+
"天",
|
|
80
|
+
"周",
|
|
81
|
+
"週",
|
|
82
|
+
"年",
|
|
83
|
+
"世纪",
|
|
84
|
+
"世紀",
|
|
85
|
+
]);
|
|
86
|
+
/**
|
|
87
|
+
* Whether a 长 is being given a measurement.
|
|
88
|
+
*
|
|
89
|
+
* 那条河长三百公里, 隧道长五公里. A quantity after a 长 is how long the thing is,
|
|
90
|
+
* and a growing takes an aspect marker before it can take one — 长了三厘米 —
|
|
91
|
+
* which is the 了 this never sees.
|
|
92
|
+
*
|
|
93
|
+
* A number written in digits reads the same, though nothing here knows the
|
|
94
|
+
* difference. 那条河长300公里 is four runs and the 长 ends the first of them, so
|
|
95
|
+
* the numeral and the 公里 are one run and two runs away; the decode is handed
|
|
96
|
+
* the 汉字 they stand for before this is ever asked. See `convert-pipeline.ts`.
|
|
97
|
+
*/
|
|
98
|
+
export function isMeasured(context) {
|
|
99
|
+
const { characters, edge } = context;
|
|
100
|
+
for (const number of wordsStartingAt(context, edge.to)) {
|
|
101
|
+
if (!tagOf(context, number).startsWith(NUMERAL)) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const at = edge.to + toCharacters(number).length;
|
|
105
|
+
for (let length = 1; length <= 2; length++) {
|
|
106
|
+
if (MEASURED_IN.has(characters.slice(at, at + length).join(""))) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=chang-complement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chang-complement.js","sourceRoot":"","sources":["../../src/decode/chang-complement.ts"],"names":[],"mappings":"AAAA;;;;;;GA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H,MAAM,UAAU,UAAU,CAAC,OAAoB;IAC7C,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACrC,KAAK,MAAM,MAAM,IAAI,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACvD,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAChD,SAAS;QACX,CAAC;QACD,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QACjD,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;YAC3C,IAAI,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBAChE,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type EdgeContext } from "./rules.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a 长 is the whole of what an adverb is scoping.
|
|
4
|
+
*
|
|
5
|
+
* 那座桥不长, 生得又瘦又长, 距离还长. The adverb is the near side and the end of
|
|
6
|
+
* the clause is the far side, and it takes both: 不长 alone is 不长在耳朵外面
|
|
7
|
+
* as readily as it is 不长.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPredicated(context: EdgeContext): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether a 长 is an adjective in front of the noun it modifies.
|
|
12
|
+
*
|
|
13
|
+
* 长头发, 长耳朵, 长胡子, 长裙子. The noun after it says nothing on its own,
|
|
14
|
+
* since 长毛 and 长知识 are a verb and its object wearing the same shape, so the
|
|
15
|
+
* near side has to say the rest. A 量词 or 有 in front of a 长 leaves it nothing
|
|
16
|
+
* to be the verb of: 一个长头发的女生 and 兔子有长耳朵 have their subject
|
|
17
|
+
* already spoken for, and 他长毛了 and 树长叶子 do not.
|
|
18
|
+
*
|
|
19
|
+
* A verb in front is **not** enough, though 他留长头发 wears long hair where
|
|
20
|
+
* 他长头发 grows it. jieba tags 树 a verb and 习惯 a noun, so the tag names
|
|
21
|
+
* neither set: taking every verb read 树长叶子 as an adjective and 教育长邓演达
|
|
22
|
+
* with it.
|
|
23
|
+
*
|
|
24
|
+
* Every word ending at the position is asked rather than the longest, because
|
|
25
|
+
* the longest is 一个 where the 量词 is the 个 inside it. See
|
|
26
|
+
* {@link wordsEndingAt}.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isAttributive(context: EdgeContext): boolean;
|
|
29
|
+
//# sourceMappingURL=chang-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chang-context.d.ts","sourceRoot":"","sources":["../../src/decode/chang-context.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,WAAW,EAIjB,MAAM,YAAY,CAAC;AAqBpB;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAO1D;AAmCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAW3D"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two 长 contexts a degree adverb does not cover.
|
|
3
|
+
*
|
|
4
|
+
* 很 or 太 in front of a 长 settles it on its own, and `chang-rule.ts` says why.
|
|
5
|
+
* These two do not: each names a near side that a verb 长 shares, so each has
|
|
6
|
+
* to check the far side as well.
|
|
7
|
+
*/
|
|
8
|
+
import { QUANTITY_CHARACTERS } from "../numerals/characters.js";
|
|
9
|
+
import { tagOf, wordsEndingAt, wordStartingAt, } from "./rules.js";
|
|
10
|
+
/**
|
|
11
|
+
* The adverbs {@link DEGREE} leaves out, because they scope a verb just as well.
|
|
12
|
+
*
|
|
13
|
+
* 那座桥不长 and 距离还长 are both `cháng`, and the degree set says why it will
|
|
14
|
+
* not have them: 胡子不长在前额上 and 还长有毛 put the
|
|
15
|
+
* same two characters around the verb. What tells the two apart is the other
|
|
16
|
+
* side. A growing 长 governs something — 在前额上, 有毛, 一个包 — while the
|
|
17
|
+
* adjective has nothing left to say, so the clause ends.
|
|
18
|
+
*/
|
|
19
|
+
const SCOPING = new Set(["不", "还", "還", "又", "已经", "已經"]);
|
|
20
|
+
/**
|
|
21
|
+
* What may stand between a predicative 长 and the end of its clause.
|
|
22
|
+
*
|
|
23
|
+
* Only the particles that close one. Everything a verb could govern is
|
|
24
|
+
* therefore excluded by construction, which is the whole of the test.
|
|
25
|
+
*/
|
|
26
|
+
const CLOSING = new Set(["了", "的", "呢", "吗", "嗎", "啊", "呀"]);
|
|
27
|
+
/**
|
|
28
|
+
* Whether a 长 is the whole of what an adverb is scoping.
|
|
29
|
+
*
|
|
30
|
+
* 那座桥不长, 生得又瘦又长, 距离还长. The adverb is the near side and the end of
|
|
31
|
+
* the clause is the far side, and it takes both: 不长 alone is 不长在耳朵外面
|
|
32
|
+
* as readily as it is 不长.
|
|
33
|
+
*/
|
|
34
|
+
export function isPredicated(context) {
|
|
35
|
+
const { characters, edge } = context;
|
|
36
|
+
if (!SCOPING.has(characters[edge.from - 1] ?? "")) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const after = characters[edge.to];
|
|
40
|
+
return after === undefined || CLOSING.has(after);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The tag jieba gives a 量词.
|
|
44
|
+
*/
|
|
45
|
+
const MEASURE = "q";
|
|
46
|
+
/**
|
|
47
|
+
* The tag prefix a noun carries, which is what an attributive 长 modifies.
|
|
48
|
+
*/
|
|
49
|
+
const NOUN_TAG = "n";
|
|
50
|
+
/**
|
|
51
|
+
* The mark that makes the number after it a position rather than a count.
|
|
52
|
+
*/
|
|
53
|
+
const ORDINAL = "第";
|
|
54
|
+
/**
|
|
55
|
+
* Whether the 量词 in front of a position is counting an ordinal.
|
|
56
|
+
*
|
|
57
|
+
* 一个长头发的女生 has its subject spoken for by the 一个, and 第一次长胡子 does
|
|
58
|
+
* not: 第一次 is when the growing happened rather than what is being counted.
|
|
59
|
+
* The walk back over the quantity characters is the same one
|
|
60
|
+
* {@link import("./reading-rules.js").COUNTED_MEASURE} makes, and for the same
|
|
61
|
+
* reason.
|
|
62
|
+
*/
|
|
63
|
+
function isOrdinalPhrase(context, at) {
|
|
64
|
+
const { characters } = context;
|
|
65
|
+
let from = at - 1;
|
|
66
|
+
while (from > 0 && QUANTITY_CHARACTERS.has(characters[from - 1] ?? "")) {
|
|
67
|
+
from--;
|
|
68
|
+
}
|
|
69
|
+
return characters[from - 1] === ORDINAL;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether a 长 is an adjective in front of the noun it modifies.
|
|
73
|
+
*
|
|
74
|
+
* 长头发, 长耳朵, 长胡子, 长裙子. The noun after it says nothing on its own,
|
|
75
|
+
* since 长毛 and 长知识 are a verb and its object wearing the same shape, so the
|
|
76
|
+
* near side has to say the rest. A 量词 or 有 in front of a 长 leaves it nothing
|
|
77
|
+
* to be the verb of: 一个长头发的女生 and 兔子有长耳朵 have their subject
|
|
78
|
+
* already spoken for, and 他长毛了 and 树长叶子 do not.
|
|
79
|
+
*
|
|
80
|
+
* A verb in front is **not** enough, though 他留长头发 wears long hair where
|
|
81
|
+
* 他长头发 grows it. jieba tags 树 a verb and 习惯 a noun, so the tag names
|
|
82
|
+
* neither set: taking every verb read 树长叶子 as an adjective and 教育长邓演达
|
|
83
|
+
* with it.
|
|
84
|
+
*
|
|
85
|
+
* Every word ending at the position is asked rather than the longest, because
|
|
86
|
+
* the longest is 一个 where the 量词 is the 个 inside it. See
|
|
87
|
+
* {@link wordsEndingAt}.
|
|
88
|
+
*/
|
|
89
|
+
export function isAttributive(context) {
|
|
90
|
+
const { edge } = context;
|
|
91
|
+
if (!tagOf(context, wordStartingAt(context, edge.to)).startsWith(NOUN_TAG)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
if (isOrdinalPhrase(context, edge.from)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
return wordsEndingAt(context, edge.from).some((word) => word === "有" || tagOf(context, word) === MEASURE);
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=chang-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chang-context.js","sourceRoot":"","sources":["../../src/decode/chang-context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAEL,KAAK,EACL,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AACH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE1D;;;;;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;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,OAAoB;IAC/C,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACrC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,C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D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type EdgeRule } from "./rules.js";
|
|
2
|
+
/**
|
|
3
|
+
* 长 read as `cháng` where an adverb of degree measures it.
|
|
4
|
+
*
|
|
5
|
+
* The character is stored `zhǎng` with `cháng` as an alternate, and the data
|
|
6
|
+
* says so about the character in isolation: Unihan ranks the readings
|
|
7
|
+
* `zhǎng(1879) cháng(1179)` by corpus count and names `zhǎng` in `kMandarin`.
|
|
8
|
+
* That ranking is doing real work — 署长, 团长, 公安局长, 总会长, 审理长 and
|
|
9
|
+
* the rest reach a bare 长 at the end of a title and read it correctly — so the
|
|
10
|
+
* default is not the thing to change. What is left over is the 长 that is an
|
|
11
|
+
* adjective, and nothing in the cost model can prefer an alternate at a
|
|
12
|
+
* position no word covers: 这篇文章不太长 came out `bú tài zhǎng`.
|
|
13
|
+
*
|
|
14
|
+
* Five contexts settle it, and one of them needs a single side. A 长 that is
|
|
15
|
+
* *growing* is a verb, and a degree adverb cannot modify one — there is no 很长
|
|
16
|
+
* meaning it grew a lot — so 很, 太, 最, 多 and their kin in front of a bare 长
|
|
17
|
+
* make it the adjective whatever follows. {@link DEGREE} is that set.
|
|
18
|
+
*
|
|
19
|
+
* Two more read the far side alone, in `chang-complement.ts`. A quality can be
|
|
20
|
+
* compared, intensified and conjoined where a growing cannot, so 长一点, 长极了
|
|
21
|
+
* and 长而美丽 need nothing in front of them ({@link isCompared}); and a length
|
|
22
|
+
* can be given in metres, so 长三百公里 settles itself ({@link isMeasured}).
|
|
23
|
+
*
|
|
24
|
+
* The last two need both sides, in `chang-context.ts`: {@link isPredicated} for
|
|
25
|
+
* 那座桥不长, {@link isAttributive} for 他有长头发. What those two have in common
|
|
26
|
+
* is that the near side alone would be wrong. 不长 is 不长在耳朵外面 as readily
|
|
27
|
+
* as it is 不长, and a noun after a 长 is 长知识 as readily as 长头发.
|
|
28
|
+
*
|
|
29
|
+
* Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
|
|
30
|
+
* rules were sized against, 379 长 and 長 decode as a word of their own and this
|
|
31
|
+
* moves 125 of them to `cháng`. Nine of the 125 are 长 the run they end could
|
|
32
|
+
* not see past until the decode was given the 汉字 behind the digits after it,
|
|
33
|
+
* as 那条河长300公里 is. Every conversion the last three contexts changed is
|
|
34
|
+
* right: 一个长头发的女生, 一个长毛绒玩具, 没有长胡子的舅舅, 要长一点, 活长点,
|
|
35
|
+
* 已经长极了, 神经棘长而狭窄 and 拉得很长. On CPP's 40 hand-labelled 长 the
|
|
36
|
+
* character stands at 92.50%, against 85.00% with no rule at all.
|
|
37
|
+
*
|
|
38
|
+
* **A verb in front is not one of the contexts**, though 他留长头发 wears long
|
|
39
|
+
* hair where 他长头发 grows it. jieba tags 树 a verb and 习惯 a noun, so no tag
|
|
40
|
+
* names the set, and taking every verb read 树长叶子 and 教育长邓演达 as
|
|
41
|
+
* adjectives.
|
|
42
|
+
*
|
|
43
|
+
* The last piece is {@link GROWN_INTO}, which pushes the opposite way on the one
|
|
44
|
+
* shape the sources get wrong.
|
|
45
|
+
*/
|
|
46
|
+
export declare const ADJECTIVAL_CHANG: EdgeRule;
|
|
47
|
+
//# sourceMappingURL=chang-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chang-rule.d.ts","sourceRoot":"","sources":["../../src/decode/chang-rule.ts"],"names":[],"mappings":"AAUA,OAAO,EAAoB,KAAK,QAAQ,EAAiB,MAAM,YAAY,CAAC;AA+H5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAyB9B,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { isCompared, isMeasured } from "./chang-complement.js";
|
|
2
|
+
import { isAttributive, isPredicated } from "./chang-context.js";
|
|
3
|
+
import { wordsEndingAt } from "./rules.js";
|
|
4
|
+
/**
|
|
5
|
+
* Whether a syllable is `cháng`, the stative reading of 长.
|
|
6
|
+
*/
|
|
7
|
+
function isChang(syllable) {
|
|
8
|
+
return (syllable?.initial === "ch" &&
|
|
9
|
+
syllable.final === "ang" &&
|
|
10
|
+
syllable.tone === 2);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Adverbs that measure a quality rather than modify an action.
|
|
14
|
+
*
|
|
15
|
+
* The discriminating side of the 长 context, and the reason the set is written
|
|
16
|
+
* out rather than taken from a tag: jieba calls 很 `zg` and 多 `m`, so the two
|
|
17
|
+
* commonest members are not adverbs as far as the dictionary is concerned,
|
|
18
|
+
* while 已经, 也, 却 and 就 — which sit in front of the *verb* 长 — are `d`
|
|
19
|
+
* along with the ones wanted here. The tag names the wrong set in both
|
|
20
|
+
* directions, so the set is named directly.
|
|
21
|
+
*
|
|
22
|
+
* Everything here is degree or comparison. 还 and 不 are deliberately absent
|
|
23
|
+
* even though 距离还长 and 那座桥不长 are both `cháng`: they modify verbs as
|
|
24
|
+
* readily as qualities, and 还长有毛 and 胡子不长在前额上 are the same two
|
|
25
|
+
* characters around the verb.
|
|
26
|
+
*
|
|
27
|
+
* Matched against every word ending in front of the 长 rather than the longest
|
|
28
|
+
* one, since 得很 is a word and hides the 很 inside it. See
|
|
29
|
+
* {@link wordsEndingAt}.
|
|
30
|
+
*/
|
|
31
|
+
const DEGREE = new Set([
|
|
32
|
+
"一样",
|
|
33
|
+
"十分",
|
|
34
|
+
"多",
|
|
35
|
+
"多么",
|
|
36
|
+
"好",
|
|
37
|
+
"如此",
|
|
38
|
+
"尽量",
|
|
39
|
+
"很",
|
|
40
|
+
"格外",
|
|
41
|
+
"极",
|
|
42
|
+
"极其",
|
|
43
|
+
"比较",
|
|
44
|
+
"略",
|
|
45
|
+
"相当",
|
|
46
|
+
"真",
|
|
47
|
+
"稍",
|
|
48
|
+
"稍微",
|
|
49
|
+
"越",
|
|
50
|
+
"越来越",
|
|
51
|
+
"这么",
|
|
52
|
+
"这样",
|
|
53
|
+
"那么",
|
|
54
|
+
"那样",
|
|
55
|
+
"更",
|
|
56
|
+
"最",
|
|
57
|
+
"有多",
|
|
58
|
+
"特别",
|
|
59
|
+
"老",
|
|
60
|
+
"够",
|
|
61
|
+
"挺",
|
|
62
|
+
"太",
|
|
63
|
+
"非常",
|
|
64
|
+
]);
|
|
65
|
+
/**
|
|
66
|
+
* What shows a 长 to be growing even with a degree word in front of it.
|
|
67
|
+
*
|
|
68
|
+
* {@link DEGREE} already excludes nearly everything that precedes the verb, so
|
|
69
|
+
* this only has to settle the three shapes reachable from both sets: 真长得很快
|
|
70
|
+
* and 越长得快, where 得 marks the complement; 长着, where the aspect does; and
|
|
71
|
+
* 越长越高, where the correlative makes the 长 the thing that increases.
|
|
72
|
+
*
|
|
73
|
+
* 了 and 的 are pointedly *not* here, and that is the whole use of conditioning
|
|
74
|
+
* on the adverb first. Following a bare 长 either would suggest the verb — 长了
|
|
75
|
+
* 一个大包, 长的很像 — but following an adverb and a 长 they are the sentence
|
|
76
|
+
* particle and the attributive: 时间太长了 and 很长的道路 are both `cháng`, and
|
|
77
|
+
* an earlier draft of this rule that guarded on them read both as `zhǎng`.
|
|
78
|
+
*/
|
|
79
|
+
const GROWING = new Set(["得", "着", "越"]);
|
|
80
|
+
/**
|
|
81
|
+
* What growing produces, as the far half of 越长越X.
|
|
82
|
+
*
|
|
83
|
+
* 越长越高, 越长越大, 越长越胖: each names a dimension that increases *because*
|
|
84
|
+
* something grew, so the 长 in front of it is the verb. The adjectives that go
|
|
85
|
+
* with a length or a duration are pointedly absent — 时间越长越好, 队伍越长越慢
|
|
86
|
+
* — because those are the cases the sources already read correctly.
|
|
87
|
+
*/
|
|
88
|
+
const GROWN_INTO = new Set(["高", "大", "胖", "壮", "结实"]);
|
|
89
|
+
/**
|
|
90
|
+
* Whether an edge is the 越长 of a 越长越X saying something grew.
|
|
91
|
+
*
|
|
92
|
+
* This exists because of a defect in the sources rather than a gap in them.
|
|
93
|
+
* 越长 is a key, read `yuè cháng`, and it is the *only* one of its shape: 越大,
|
|
94
|
+
* 越高, 越好, 越快 and 越多 are all absent, so 越高越好 decodes as two words and
|
|
95
|
+
* 越长越高 reaches for a word nothing else in the paradigm has. It carries no
|
|
96
|
+
* part of speech, which is how the dictionary holds a reading somebody asserted
|
|
97
|
+
* rather than a word anybody counted — the same category {@link TEACHING_JIAO}
|
|
98
|
+
* declines to trust — and it comes from one source, `large_pinyin.txt`, with
|
|
99
|
+
* CC-CEDICT holding no such entry.
|
|
100
|
+
*
|
|
101
|
+
* Taking the edge away leaves the character's own default, which is `zhǎng`,
|
|
102
|
+
* and leaves `cháng` standing as a rival about one bucket dearer. That last
|
|
103
|
+
* part is the point of forbidding rather than forcing: 越长越X is genuinely
|
|
104
|
+
* ambiguous — 孩子越长越漂亮 grows and 头发越长越漂亮 lengthens, and only the
|
|
105
|
+
* subject says which — so the decode should answer with the likelier reading
|
|
106
|
+
* and still report itself as guessing. A forced edge could not.
|
|
107
|
+
*
|
|
108
|
+
* Unlike the rest of this file the shape has no corpus behind it: 越长 occurs
|
|
109
|
+
* three times in the 88,866 lines, and all three are 越来越长 or 说的越长. The
|
|
110
|
+
* word list is therefore small on purpose, and everything outside it is left as
|
|
111
|
+
* the sources have it.
|
|
112
|
+
*/
|
|
113
|
+
function isGrowthCorrelative(context) {
|
|
114
|
+
const { characters, edge } = context;
|
|
115
|
+
return (edge.text === "越长" &&
|
|
116
|
+
edge.partOfSpeech === "" &&
|
|
117
|
+
characters[edge.to] === "越" &&
|
|
118
|
+
GROWN_INTO.has(characters[edge.to + 1] ?? ""));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* 长 read as `cháng` where an adverb of degree measures it.
|
|
122
|
+
*
|
|
123
|
+
* The character is stored `zhǎng` with `cháng` as an alternate, and the data
|
|
124
|
+
* says so about the character in isolation: Unihan ranks the readings
|
|
125
|
+
* `zhǎng(1879) cháng(1179)` by corpus count and names `zhǎng` in `kMandarin`.
|
|
126
|
+
* That ranking is doing real work — 署长, 团长, 公安局长, 总会长, 审理长 and
|
|
127
|
+
* the rest reach a bare 长 at the end of a title and read it correctly — so the
|
|
128
|
+
* default is not the thing to change. What is left over is the 长 that is an
|
|
129
|
+
* adjective, and nothing in the cost model can prefer an alternate at a
|
|
130
|
+
* position no word covers: 这篇文章不太长 came out `bú tài zhǎng`.
|
|
131
|
+
*
|
|
132
|
+
* Five contexts settle it, and one of them needs a single side. A 长 that is
|
|
133
|
+
* *growing* is a verb, and a degree adverb cannot modify one — there is no 很长
|
|
134
|
+
* meaning it grew a lot — so 很, 太, 最, 多 and their kin in front of a bare 长
|
|
135
|
+
* make it the adjective whatever follows. {@link DEGREE} is that set.
|
|
136
|
+
*
|
|
137
|
+
* Two more read the far side alone, in `chang-complement.ts`. A quality can be
|
|
138
|
+
* compared, intensified and conjoined where a growing cannot, so 长一点, 长极了
|
|
139
|
+
* and 长而美丽 need nothing in front of them ({@link isCompared}); and a length
|
|
140
|
+
* can be given in metres, so 长三百公里 settles itself ({@link isMeasured}).
|
|
141
|
+
*
|
|
142
|
+
* The last two need both sides, in `chang-context.ts`: {@link isPredicated} for
|
|
143
|
+
* 那座桥不长, {@link isAttributive} for 他有长头发. What those two have in common
|
|
144
|
+
* is that the near side alone would be wrong. 不长 is 不长在耳朵外面 as readily
|
|
145
|
+
* as it is 不长, and a noun after a 长 is 长知识 as readily as 长头发.
|
|
146
|
+
*
|
|
147
|
+
* Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
|
|
148
|
+
* rules were sized against, 379 长 and 長 decode as a word of their own and this
|
|
149
|
+
* moves 125 of them to `cháng`. Nine of the 125 are 长 the run they end could
|
|
150
|
+
* not see past until the decode was given the 汉字 behind the digits after it,
|
|
151
|
+
* as 那条河长300公里 is. Every conversion the last three contexts changed is
|
|
152
|
+
* right: 一个长头发的女生, 一个长毛绒玩具, 没有长胡子的舅舅, 要长一点, 活长点,
|
|
153
|
+
* 已经长极了, 神经棘长而狭窄 and 拉得很长. On CPP's 40 hand-labelled 长 the
|
|
154
|
+
* character stands at 92.50%, against 85.00% with no rule at all.
|
|
155
|
+
*
|
|
156
|
+
* **A verb in front is not one of the contexts**, though 他留长头发 wears long
|
|
157
|
+
* hair where 他长头发 grows it. jieba tags 树 a verb and 习惯 a noun, so no tag
|
|
158
|
+
* names the set, and taking every verb read 树长叶子 and 教育长邓演达 as
|
|
159
|
+
* adjectives.
|
|
160
|
+
*
|
|
161
|
+
* The last piece is {@link GROWN_INTO}, which pushes the opposite way on the one
|
|
162
|
+
* shape the sources get wrong.
|
|
163
|
+
*/
|
|
164
|
+
export const ADJECTIVAL_CHANG = {
|
|
165
|
+
name: "adjectival-chang",
|
|
166
|
+
verdictFor: (context) => {
|
|
167
|
+
const { characters, edge } = context;
|
|
168
|
+
if (isGrowthCorrelative(context)) {
|
|
169
|
+
return "forbid";
|
|
170
|
+
}
|
|
171
|
+
if (edge.text !== "长" || !isChang(edge.reading[0])) {
|
|
172
|
+
return "keep";
|
|
173
|
+
}
|
|
174
|
+
if (GROWING.has(characters[edge.to] ?? "")) {
|
|
175
|
+
return "keep";
|
|
176
|
+
}
|
|
177
|
+
if (isPredicated(context) ||
|
|
178
|
+
isAttributive(context) ||
|
|
179
|
+
isCompared(context) ||
|
|
180
|
+
isMeasured(context)) {
|
|
181
|
+
return "force";
|
|
182
|
+
}
|
|
183
|
+
return wordsEndingAt(context, edge.from).some((word) => DEGREE.has(word))
|
|
184
|
+
? "force"
|
|
185
|
+
: "keep";
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
//# sourceMappingURL=chang-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chang-rule.js","sourceRoot":"","sources":["../../src/decode/chang-rule.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAmC,a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GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAC9C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACxC,IAAI,EAAE,kBAAkB;IACxB,UAAU,EAAE,CAAC,OAAoB,EAAE,EAAE;QACnC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACrC,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACnD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAC3C,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IACE,YAAY,CAAC,OAAO,CAAC;YACrB,aAAa,CAAC,OAAO,CAAC;YACtB,UAAU,CAAC,OAAO,CAAC;YACnB,UAAU,CAAC,OAAO,CAAC,EACnB,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACvE,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,MAAM,CAAC;IACb,CAAC;CACF,CAAC"}
|
|
@@ -52,9 +52,17 @@ export interface ScoredUnit extends ReadingUnit, ReadingConfidence {
|
|
|
52
52
|
* only be had by rejecting a word the dictionary attests.
|
|
53
53
|
*
|
|
54
54
|
* **Measured** against the CPP dataset's 20,139 hand-labelled polyphones: a
|
|
55
|
-
* reading this reports uncertain is wrong
|
|
56
|
-
* one backed by a word and 1.5% for a locked one. It lands on
|
|
57
|
-
* syllables of everyday text and
|
|
55
|
+
* reading this reports uncertain is wrong 19.9% of the time, against 4.4% for
|
|
56
|
+
* one backed by a word and 1.5% for a locked one. It lands on 17.6% of the
|
|
57
|
+
* syllables of everyday text and 12.6% of encyclopedic text — see ROADMAP.md.
|
|
58
|
+
*
|
|
59
|
+
* What it is not is a graded score, and the threshold is not the lever it
|
|
60
|
+
* looks like. A character's second reading costs one `ALTERNATE_PENALTY`
|
|
61
|
+
* more than its first whatever the real odds are, so nearly every uncertain
|
|
62
|
+
* reading is uncertain by exactly that margin: moving the threshold anywhere
|
|
63
|
+
* between 1.5 and 6 moves the share of everyday text flagged from 16.5% to
|
|
64
|
+
* 17.6%. The flag says a word did not cover the character. It does not say the
|
|
65
|
+
* decode was close.
|
|
58
66
|
*/
|
|
59
67
|
export declare function isUncertain(confidence: ReadingConfidence): boolean;
|
|
60
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confidence.d.ts","sourceRoot":"","sources":["../../src/decode/confidence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAa,KAAK,OAAO,EAAkB,MAAM,cAAc,CAAC;AACvE,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEjB,MAAM,cAAc,CAAC;AAGtB;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;IACtC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AAC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AuBvB"}
|
|
@@ -12,9 +12,17 @@ import { scoreStretch } from "./alternatives.js";
|
|
|
12
12
|
* only be had by rejecting a word the dictionary attests.
|
|
13
13
|
*
|
|
14
14
|
* **Measured** against the CPP dataset's 20,139 hand-labelled polyphones: a
|
|
15
|
-
* reading this reports uncertain is wrong
|
|
16
|
-
* one backed by a word and 1.5% for a locked one. It lands on
|
|
17
|
-
* syllables of everyday text and
|
|
15
|
+
* reading this reports uncertain is wrong 19.9% of the time, against 4.4% for
|
|
16
|
+
* one backed by a word and 1.5% for a locked one. It lands on 17.6% of the
|
|
17
|
+
* syllables of everyday text and 12.6% of encyclopedic text — see ROADMAP.md.
|
|
18
|
+
*
|
|
19
|
+
* What it is not is a graded score, and the threshold is not the lever it
|
|
20
|
+
* looks like. A character's second reading costs one `ALTERNATE_PENALTY`
|
|
21
|
+
* more than its first whatever the real odds are, so nearly every uncertain
|
|
22
|
+
* reading is uncertain by exactly that margin: moving the threshold anywhere
|
|
23
|
+
* between 1.5 and 6 moves the share of everyday text flagged from 16.5% to
|
|
24
|
+
* 17.6%. The flag says a word did not cover the character. It does not say the
|
|
25
|
+
* decode was close.
|
|
18
26
|
*/
|
|
19
27
|
export function isUncertain(confidence) {
|
|
20
28
|
return (confidence.alternatives[0]?.cost ?? Infinity) < READING_CHARGE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confidence.js","sourceRoot":"","sources":["../../src/decode/confidence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAgB,cAAc,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EACL,SAAS,EAGT,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA4CjD
|
|
1
|
+
{"version":3,"file":"confidence.js","sourceRoot":"","sources":["../../src/decode/confidence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAgB,cAAc,EAAE,MAAM,cAAc,CAAC;AACvE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","sourceRoot":"","sources":["../../src/decode/convert-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAU9D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"convert-pipeline.d.ts","sourceRoot":"","sources":["../../src/decode/convert-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAU9D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,aAAa,CAAC;AAG3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,GACtB,SAAS,cAAc,EAAE,CAgF3B"}
|