@kensio/pinyinjs 1.2.1 → 1.2.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/CHANGELOG.md +82 -24
- package/README.md +35 -35
- package/dist/decode/convert.d.ts.map +1 -1
- package/dist/decode/convert.js +60 -28
- package/dist/decode/convert.js.map +1 -1
- package/dist/decode/decode.d.ts +12 -2
- package/dist/decode/decode.d.ts.map +1 -1
- package/dist/decode/decode.js +64 -7
- package/dist/decode/decode.js.map +1 -1
- package/dist/decode/reading-rules.d.ts +57 -0
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +178 -1
- package/dist/decode/reading-rules.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/numerals/cardinal.d.ts +15 -1
- package/dist/numerals/cardinal.d.ts.map +1 -1
- package/dist/numerals/cardinal.js +8 -1
- package/dist/numerals/cardinal.js.map +1 -1
- package/dist/numerals/characters.d.ts +9 -0
- package/dist/numerals/characters.d.ts.map +1 -1
- package/dist/numerals/characters.js +18 -0
- package/dist/numerals/characters.js.map +1 -1
- package/dist/numerals/numerals.d.ts.map +1 -1
- package/dist/numerals/numerals.js +12 -4
- package/dist/numerals/numerals.js.map +1 -1
- package/dist/numerals/text.d.ts +18 -5
- package/dist/numerals/text.d.ts.map +1 -1
- package/dist/numerals/text.js +67 -8
- package/dist/numerals/text.js.map +1 -1
- package/package.json +1 -1
package/dist/decode/decode.d.ts
CHANGED
|
@@ -27,8 +27,14 @@ export declare function decodeSpacing(lattice: Lattice): readonly number[];
|
|
|
27
27
|
* Stages 1 to 3 of ALGORITHM.md end to end — build every candidate reading,
|
|
28
28
|
* lock the positions that cannot vary, score the rest — where the greedy
|
|
29
29
|
* baseline commits to the longest match at each position and never revisits it.
|
|
30
|
+
*
|
|
31
|
+
* `before` is 汉字 standing in front of the run that the decode should see and
|
|
32
|
+
* not report: the 汉字 a number written in digits would have been written with.
|
|
33
|
+
* A run is decoded on its own without it, and a run reached that way has no idea
|
|
34
|
+
* what preceded it — 个人 alone is the word `gèrén`, while the 两 of 2个人 makes
|
|
35
|
+
* 两个 the word and leaves 人 to itself.
|
|
30
36
|
*/
|
|
31
|
-
export declare function decodeRun(dictionary: Dictionary, run: string, rules?: readonly EdgeRule[]): readonly DecodedWord[];
|
|
37
|
+
export declare function decodeRun(dictionary: Dictionary, run: string, rules?: readonly EdgeRule[], before?: string): readonly DecodedWord[];
|
|
32
38
|
/**
|
|
33
39
|
* Decode a Han run, keeping what each reading was chosen over.
|
|
34
40
|
*
|
|
@@ -36,6 +42,10 @@ export declare function decodeRun(dictionary: Dictionary, run: string, rules?: r
|
|
|
36
42
|
* candidates kept rather than discarded. Separate because the extra sweep is
|
|
37
43
|
* only worth running for a caller that will use the answer — rendering
|
|
38
44
|
* uncertain readings differently, or reporting them.
|
|
45
|
+
*
|
|
46
|
+
* `before` is the context {@link decodeRun} takes, and means the same here: it
|
|
47
|
+
* is decoded with the run and reported with neither words nor confidence of its
|
|
48
|
+
* own.
|
|
39
49
|
*/
|
|
40
|
-
export declare function decodeRunScored(dictionary: Dictionary, run: string, rules?: readonly EdgeRule[]): readonly ScoredWord[];
|
|
50
|
+
export declare function decodeRunScored(dictionary: Dictionary, run: string, rules?: readonly EdgeRule[], before?: string): readonly ScoredWord[];
|
|
41
51
|
//# sourceMappingURL=decode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/decode/decode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/decode/decode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAAqC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAGjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEzD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,iBAAiB,GAC5B,SAAS,WAAW,EAAE,CAmBxB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAIjE;AAgJD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,SAAS,QAAQ,EAAkB,EAC1C,MAAM,SAAK,GACV,SAAS,WAAW,EAAE,CAOxB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,SAAS,QAAQ,EAAkB,EAC1C,MAAM,SAAK,GACV,SAAS,UAAU,EAAE,CAcvB"}
|
package/dist/decode/decode.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { toCharacters } from "../script/characters.js";
|
|
1
2
|
import { scoreReadings } from "./confidence.js";
|
|
2
|
-
import { buildLattice, cutPoints } from "./lattice.js";
|
|
3
|
+
import { allEdges, buildLattice, cutPoints } from "./lattice.js";
|
|
3
4
|
import { isSettled, projectReadings, settledUnits, unitsOf, } from "./locking.js";
|
|
4
5
|
import { READING_RULES } from "./reading-rules.js";
|
|
5
6
|
import { applyEdgeRules } from "./rules.js";
|
|
@@ -97,17 +98,68 @@ function wordFrom(dictionary, lattice, group) {
|
|
|
97
98
|
function ruledLattice(dictionary, run, rules) {
|
|
98
99
|
return applyEdgeRules(buildLattice(dictionary, run), dictionary, rules);
|
|
99
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether any reading in the lattice would hold the two sides of a join
|
|
103
|
+
* together.
|
|
104
|
+
*
|
|
105
|
+
* A reading of one syllable per character can be cut anywhere; anything else —
|
|
106
|
+
* 儿化, a character with no reading — is a single claim about its whole span,
|
|
107
|
+
* so a claim spanning the join cannot be reported for the run alone. 1点儿事
|
|
108
|
+
* is that case: 一点儿 is one `yìdiǎnr` over the 一 the context supplied and
|
|
109
|
+
* the 点儿 the run did.
|
|
110
|
+
*/
|
|
111
|
+
function isJoinedAt(lattice, at) {
|
|
112
|
+
return allEdges(lattice).some((edge) => edge.from < at &&
|
|
113
|
+
edge.to > at &&
|
|
114
|
+
edge.reading.length !== edge.to - edge.from);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The lattice a run decodes over, with whatever context stands in front of it.
|
|
118
|
+
*
|
|
119
|
+
* The context is dropped where a reading would hold it to the run, leaving the
|
|
120
|
+
* run decoded on its own, which is what it would have been before there was any
|
|
121
|
+
* context to give.
|
|
122
|
+
*/
|
|
123
|
+
function runLattice(dictionary, run, rules, before) {
|
|
124
|
+
const alone = () => ({
|
|
125
|
+
lattice: ruledLattice(dictionary, run, rules),
|
|
126
|
+
at: 0,
|
|
127
|
+
});
|
|
128
|
+
if (before === "") {
|
|
129
|
+
return alone();
|
|
130
|
+
}
|
|
131
|
+
const lattice = ruledLattice(dictionary, before + run, rules);
|
|
132
|
+
const at = toCharacters(before).length;
|
|
133
|
+
return isJoinedAt(lattice, at) ? alone() : { lattice, at };
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Cut a decode of the whole lattice down to the run at the end of it.
|
|
137
|
+
*
|
|
138
|
+
* Everything before `at` was context rather than run — 汉字 a caller put in
|
|
139
|
+
* front so that the decode could see them — and is dropped once it has done its
|
|
140
|
+
* work.
|
|
141
|
+
*/
|
|
142
|
+
function runGroups({ lattice, at }, units) {
|
|
143
|
+
return groupUnits(units.filter((unit) => unit.from >= at), decodeSpacing(lattice).filter((from) => from >= at));
|
|
144
|
+
}
|
|
100
145
|
/**
|
|
101
146
|
* Decode a Han run with the lattice: the recommended path.
|
|
102
147
|
*
|
|
103
148
|
* Stages 1 to 3 of ALGORITHM.md end to end — build every candidate reading,
|
|
104
149
|
* lock the positions that cannot vary, score the rest — where the greedy
|
|
105
150
|
* baseline commits to the longest match at each position and never revisits it.
|
|
151
|
+
*
|
|
152
|
+
* `before` is 汉字 standing in front of the run that the decode should see and
|
|
153
|
+
* not report: the 汉字 a number written in digits would have been written with.
|
|
154
|
+
* A run is decoded on its own without it, and a run reached that way has no idea
|
|
155
|
+
* what preceded it — 个人 alone is the word `gèrén`, while the 两 of 2个人 makes
|
|
156
|
+
* 两个 the word and leaves 人 to itself.
|
|
106
157
|
*/
|
|
107
|
-
export function decodeRun(dictionary, run, rules = READING_RULES) {
|
|
108
|
-
const
|
|
158
|
+
export function decodeRun(dictionary, run, rules = READING_RULES, before = "") {
|
|
159
|
+
const held = runLattice(dictionary, run, rules, before);
|
|
160
|
+
const { lattice } = held;
|
|
109
161
|
const units = decodeReadings(lattice, projectReadings(lattice));
|
|
110
|
-
return
|
|
162
|
+
return runGroups(held, units).map((group) => wordFrom(dictionary, lattice, group));
|
|
111
163
|
}
|
|
112
164
|
/**
|
|
113
165
|
* Decode a Han run, keeping what each reading was chosen over.
|
|
@@ -116,11 +168,16 @@ export function decodeRun(dictionary, run, rules = READING_RULES) {
|
|
|
116
168
|
* candidates kept rather than discarded. Separate because the extra sweep is
|
|
117
169
|
* only worth running for a caller that will use the answer — rendering
|
|
118
170
|
* uncertain readings differently, or reporting them.
|
|
171
|
+
*
|
|
172
|
+
* `before` is the context {@link decodeRun} takes, and means the same here: it
|
|
173
|
+
* is decoded with the run and reported with neither words nor confidence of its
|
|
174
|
+
* own.
|
|
119
175
|
*/
|
|
120
|
-
export function decodeRunScored(dictionary, run, rules = READING_RULES) {
|
|
121
|
-
const
|
|
176
|
+
export function decodeRunScored(dictionary, run, rules = READING_RULES, before = "") {
|
|
177
|
+
const held = runLattice(dictionary, run, rules, before);
|
|
178
|
+
const { lattice } = held;
|
|
122
179
|
const units = scoreReadings(lattice, projectReadings(lattice));
|
|
123
|
-
return
|
|
180
|
+
return runGroups(held, units).map((group) => ({
|
|
124
181
|
word: wordFrom(dictionary, lattice, group),
|
|
125
182
|
confidence: group.flatMap((unit) => unit.reading.map(() => ({
|
|
126
183
|
isLocked: unit.isLocked,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/decode/decode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAmB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAgB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/decode/decode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAmB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAgB,MAAM,cAAc,CAAC;AAC/E,OAAO,EACL,SAAS,EACT,eAAe,EAGf,YAAY,EACZ,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGtE;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB,EAChB,UAA6B;IAE7B,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,MAAM,KAAK,GAAkB,EAAE,CAAC;I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AE/D,OAAO,SAAS,CAAa,IAAI,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxD,IAAI,EAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC;QAC1C,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CACjC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC,CACJ;KACF,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -49,6 +49,63 @@ export declare const MODAL_DE: EdgeRule;
|
|
|
49
49
|
* 门铃儿 and a row of Mongol names transliterated with 儿.
|
|
50
50
|
*/
|
|
51
51
|
export declare const ATTESTED_ERHUA: EdgeRule;
|
|
52
|
+
/**
|
|
53
|
+
* 教 read as `jiāo` where it is teaching rather than a religion.
|
|
54
|
+
*
|
|
55
|
+
* The dictionary stores 教 as `jiào` with `jiāo` as an alternate, and `jiào` is
|
|
56
|
+
* right for the compounds — 教育, 教师, 宗教, 主教 — which are words and reach
|
|
57
|
+
* their reading through the word. What is left is the 教 that stands as a word
|
|
58
|
+
* of its own, and that one is the verb: 他在北京大学教了三年书 came out
|
|
59
|
+
* `jiàole sān nián shū`, and 我教英语, 谁教你法语 and 她教我如何游泳 with it.
|
|
60
|
+
* 教书 is a word and was always `jiāo shū`; nothing carried that across a 了.
|
|
61
|
+
*
|
|
62
|
+
* See {@link isTeachingAt} for what decides it. Forcing the single-character
|
|
63
|
+
* edge is not enough on its own, because a reading spanning two characters
|
|
64
|
+
* carries its own 教 into the position: 王老师教我们汉语 read `jiào` off 师教,
|
|
65
|
+
* and 来教我 off 来教. Those are pairs the dictionary holds with no part of
|
|
66
|
+
* speech and at the cost of a word nothing has ever counted — a reading rather
|
|
67
|
+
* than a word — so a *tagged* word ending in 教 is left alone, which is every
|
|
68
|
+
* one that matters: 任教, 宗教, 主教, 佛教, 传教, 执教, 请教, 家教.
|
|
69
|
+
*
|
|
70
|
+
* Measured over 88,866 lines of Tatoeba and zh.wikipedia, 181 教 decode as a
|
|
71
|
+
* word of their own and every one of them read `jiào`. This moves 158 to
|
|
72
|
+
* `jiāo` and is wrong on three: 统一教创始人, 方法教深思 and 做到了教政分离,
|
|
73
|
+
* where a nominal compound takes an object's shape, the last of them because
|
|
74
|
+
* 做到了 is a word and so the 了 in front is not a particle to look at. Of the
|
|
75
|
+
* 21 it leaves, 8 are right — 诸教中, 教外别传, 董教总, 风教, 教青局 twice, a
|
|
76
|
+
* 教室 reached through a bad split, and a 教 used as a bare noun — and 13 are
|
|
77
|
+
* misses, where jieba tags the object something this does not name.
|
|
78
|
+
*/
|
|
79
|
+
export declare const TEACHING_JIAO: EdgeRule;
|
|
80
|
+
/**
|
|
81
|
+
* A 量词 with a number in front of it does not start the next word.
|
|
82
|
+
*
|
|
83
|
+
* 三个人 is three people and came out `sān gèrén`, three *personals*, because
|
|
84
|
+
* 个人 is a common noun and nothing weighed it against the 个 belonging to the
|
|
85
|
+
* 三 in front of it. The same swallow takes 一杯水 into 杯水, 两家俱乐部 into
|
|
86
|
+
* 家俱 and 一天天 into 天天; digits reach it too, since a run decoded after a
|
|
87
|
+
* number sees that number — see `decodeRun` — so 2个人 is the same case.
|
|
88
|
+
*
|
|
89
|
+
* What makes it decidable is that the dictionary tags the 量词: 个, 次, 天, 位,
|
|
90
|
+
* 杯 and 匹 are `q`, while the characters that only look like measure words in
|
|
91
|
+
* this position are not — 分 is `v`, 部 and 成 are `n`, 年 and 点 are `m`. So
|
|
92
|
+
* 五分钟, 三部分, 五成分, 五年级 and 三点钟 are untouched, and those are exactly
|
|
93
|
+
* the words a blanket rule would break. A word that is itself a 量词 is kept as
|
|
94
|
+
* well, since 分钟 and 点钟 are units rather than something being counted.
|
|
95
|
+
*
|
|
96
|
+
* Only the edge *starting at the 量词* is forbidden, so a number and its
|
|
97
|
+
* measure written solid survive whole where the dictionary has them: 一辈子 and
|
|
98
|
+
* 一会儿 are entries covering the number too, and the decode still reaches them.
|
|
99
|
+
*
|
|
100
|
+
* Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
|
|
101
|
+
* rules were sized against, it forbids 561 edges across 144 shapes — 个人 203
|
|
102
|
+
* of them, then 杯水, 天一, 口气, 些小 and 家人 — and moves 53 decodes, since
|
|
103
|
+
* most of what it takes away the cost model was not going to choose anyway.
|
|
104
|
+
* Three of the 53 are wrong: 一批评, 这一名词 and 六七股灾, where the 一 and the
|
|
105
|
+
* 六七 count nothing and no tag says so. Exactly one reading changes over the
|
|
106
|
+
* corpus and it is a fix, 下了两天雨 having read 天雨 as `tiān yù`.
|
|
107
|
+
*/
|
|
108
|
+
export declare const COUNTED_MEASURE: EdgeRule;
|
|
52
109
|
/**
|
|
53
110
|
* The rules the lattice decode applies, in order.
|
|
54
111
|
*/
|
|
@@ -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":"AAGA,OAAO,EAEL,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAgCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,QAAQ,EAAE,QActB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,EAAE,QAY5B,CAAC;AAqDF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,aAAa,EAAE,QAiB3B,CAAC;AAsCF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,eAAe,EAAE,QAuB7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,QAAQ,EAK5C,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { QUANTITY_CHARACTERS } from "../numerals/characters.js";
|
|
2
|
+
import { toCharacters } from "../script/characters.js";
|
|
1
3
|
import { tagOf, wordEndingAt, wordStartingAt, } from "./rules.js";
|
|
2
4
|
/**
|
|
3
5
|
* Whether a syllable is `děi`, the modal reading of 得.
|
|
@@ -100,8 +102,183 @@ export const ATTESTED_ERHUA = {
|
|
|
100
102
|
return (reading?.at(-1)?.erhua ?? false) ? "forbid" : "keep";
|
|
101
103
|
},
|
|
102
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* Whether a syllable is `jiāo`, the verbal reading of 教.
|
|
107
|
+
*/
|
|
108
|
+
function isJiao(syllable) {
|
|
109
|
+
return (syllable?.initial === "j" && syllable.final === "iao" && syllable.tone === 1);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* What a 教 that is teaching governs: the thing or the person taught.
|
|
113
|
+
*
|
|
114
|
+
* A pronoun, a common noun, a name or one of the tags jieba gives a subject —
|
|
115
|
+
* 教我, 教英语, 教历史, 教孩子, 教玛丽. `ns` is deliberately absent, since the
|
|
116
|
+
* only 教 with a place tag after it over the corpus is 教青局, an office.
|
|
117
|
+
*/
|
|
118
|
+
const TAUGHT_TAGS = new Set(["r", "n", "nz", "nr", "nt", "ng"]);
|
|
119
|
+
/**
|
|
120
|
+
* What follows a 教 that is teaching where no object does: aspect and the
|
|
121
|
+
* complement marker, which only a verb takes.
|
|
122
|
+
*
|
|
123
|
+
* 他教了三年书, 他教过我英语, 她教书教得很快乐. Matched as characters rather
|
|
124
|
+
* than through their tags, because what the dictionary has starting at a 得 is
|
|
125
|
+
* as likely to be 得很 as the particle itself.
|
|
126
|
+
*/
|
|
127
|
+
const ASPECT = new Set(["了", "过", "過", "着", "著", "得"]);
|
|
128
|
+
/**
|
|
129
|
+
* The tag prefix jieba gives a particle, which nothing teaching can follow.
|
|
130
|
+
*/
|
|
131
|
+
const PARTICLE_TAG = "u";
|
|
132
|
+
/**
|
|
133
|
+
* Whether the 教 at a position is teaching something to somebody.
|
|
134
|
+
*
|
|
135
|
+
* The object is what says so, which is the same shape the modal 得 rule takes:
|
|
136
|
+
* a 教 with a pronoun, a noun or a name after it is governing it, and a 教 with
|
|
137
|
+
* 了, 过, 着 or 得 after it is a verb whatever follows that. A particle in front
|
|
138
|
+
* of it rules it out, since a verb does not follow one.
|
|
139
|
+
*/
|
|
140
|
+
function isTeachingAt(context, at) {
|
|
141
|
+
if (tagOf(context, wordEndingAt(context, at)).startsWith(PARTICLE_TAG)) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return (ASPECT.has(context.characters[at + 1] ?? "") ||
|
|
145
|
+
TAUGHT_TAGS.has(tagOf(context, wordStartingAt(context, at + 1))));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 教 read as `jiāo` where it is teaching rather than a religion.
|
|
149
|
+
*
|
|
150
|
+
* The dictionary stores 教 as `jiào` with `jiāo` as an alternate, and `jiào` is
|
|
151
|
+
* right for the compounds — 教育, 教师, 宗教, 主教 — which are words and reach
|
|
152
|
+
* their reading through the word. What is left is the 教 that stands as a word
|
|
153
|
+
* of its own, and that one is the verb: 他在北京大学教了三年书 came out
|
|
154
|
+
* `jiàole sān nián shū`, and 我教英语, 谁教你法语 and 她教我如何游泳 with it.
|
|
155
|
+
* 教书 is a word and was always `jiāo shū`; nothing carried that across a 了.
|
|
156
|
+
*
|
|
157
|
+
* See {@link isTeachingAt} for what decides it. Forcing the single-character
|
|
158
|
+
* edge is not enough on its own, because a reading spanning two characters
|
|
159
|
+
* carries its own 教 into the position: 王老师教我们汉语 read `jiào` off 师教,
|
|
160
|
+
* and 来教我 off 来教. Those are pairs the dictionary holds with no part of
|
|
161
|
+
* speech and at the cost of a word nothing has ever counted — a reading rather
|
|
162
|
+
* than a word — so a *tagged* word ending in 教 is left alone, which is every
|
|
163
|
+
* one that matters: 任教, 宗教, 主教, 佛教, 传教, 执教, 请教, 家教.
|
|
164
|
+
*
|
|
165
|
+
* Measured over 88,866 lines of Tatoeba and zh.wikipedia, 181 教 decode as a
|
|
166
|
+
* word of their own and every one of them read `jiào`. This moves 158 to
|
|
167
|
+
* `jiāo` and is wrong on three: 统一教创始人, 方法教深思 and 做到了教政分离,
|
|
168
|
+
* where a nominal compound takes an object's shape, the last of them because
|
|
169
|
+
* 做到了 is a word and so the 了 in front is not a particle to look at. Of the
|
|
170
|
+
* 21 it leaves, 8 are right — 诸教中, 教外别传, 董教总, 风教, 教青局 twice, a
|
|
171
|
+
* 教室 reached through a bad split, and a 教 used as a bare noun — and 13 are
|
|
172
|
+
* misses, where jieba tags the object something this does not name.
|
|
173
|
+
*/
|
|
174
|
+
export const TEACHING_JIAO = {
|
|
175
|
+
name: "teaching-jiao",
|
|
176
|
+
verdictFor: (context) => {
|
|
177
|
+
const { edge } = context;
|
|
178
|
+
if (edge.text === "教") {
|
|
179
|
+
return isJiao(edge.reading[0]) && isTeachingAt(context, edge.from)
|
|
180
|
+
? "force"
|
|
181
|
+
: "keep";
|
|
182
|
+
}
|
|
183
|
+
return edge.partOfSpeech === "" &&
|
|
184
|
+
edge.text.endsWith("教") &&
|
|
185
|
+
edge.reading.length === edge.to - edge.from &&
|
|
186
|
+
!isJiao(edge.reading.at(-1)) &&
|
|
187
|
+
isTeachingAt(context, edge.to - 1)
|
|
188
|
+
? "forbid"
|
|
189
|
+
: "keep";
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* The tag the dictionary gives a 量词.
|
|
194
|
+
*/
|
|
195
|
+
const MEASURE = "q";
|
|
196
|
+
/**
|
|
197
|
+
* The mark that makes the number after it a position rather than a count.
|
|
198
|
+
*
|
|
199
|
+
* 第三集团军 is the Third Army Group and not three 集团军, so the 集 the
|
|
200
|
+
* dictionary tags `q` is counting nothing and 集团军 is a word like any other.
|
|
201
|
+
*/
|
|
202
|
+
const ORDINAL = "第";
|
|
203
|
+
/**
|
|
204
|
+
* Where the number counting the character at a position starts, or undefined
|
|
205
|
+
* where nothing counts it.
|
|
206
|
+
*
|
|
207
|
+
* Two things stop a numeral in front of a 量词 from counting it. An ordinal
|
|
208
|
+
* names a position, so 第十级别 is the tenth 级别 rather than ten 级; and a
|
|
209
|
+
* numeral inside a longer word belongs to that word, so the 一 of 唯一道路 is
|
|
210
|
+
* counting no 道 and the 二 of 十二月 no 月.
|
|
211
|
+
*/
|
|
212
|
+
function countedFrom(context, at) {
|
|
213
|
+
const { characters } = context;
|
|
214
|
+
let from = at;
|
|
215
|
+
while (from > 0 && QUANTITY_CHARACTERS.has(characters[from - 1] ?? "")) {
|
|
216
|
+
from--;
|
|
217
|
+
}
|
|
218
|
+
if (from === at || characters[from - 1] === ORDINAL) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
const before = wordEndingAt(context, at);
|
|
222
|
+
const held = before === undefined ? at : at - toCharacters(before).length;
|
|
223
|
+
return held < from ? undefined : from;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* A 量词 with a number in front of it does not start the next word.
|
|
227
|
+
*
|
|
228
|
+
* 三个人 is three people and came out `sān gèrén`, three *personals*, because
|
|
229
|
+
* 个人 is a common noun and nothing weighed it against the 个 belonging to the
|
|
230
|
+
* 三 in front of it. The same swallow takes 一杯水 into 杯水, 两家俱乐部 into
|
|
231
|
+
* 家俱 and 一天天 into 天天; digits reach it too, since a run decoded after a
|
|
232
|
+
* number sees that number — see `decodeRun` — so 2个人 is the same case.
|
|
233
|
+
*
|
|
234
|
+
* What makes it decidable is that the dictionary tags the 量词: 个, 次, 天, 位,
|
|
235
|
+
* 杯 and 匹 are `q`, while the characters that only look like measure words in
|
|
236
|
+
* this position are not — 分 is `v`, 部 and 成 are `n`, 年 and 点 are `m`. So
|
|
237
|
+
* 五分钟, 三部分, 五成分, 五年级 and 三点钟 are untouched, and those are exactly
|
|
238
|
+
* the words a blanket rule would break. A word that is itself a 量词 is kept as
|
|
239
|
+
* well, since 分钟 and 点钟 are units rather than something being counted.
|
|
240
|
+
*
|
|
241
|
+
* Only the edge *starting at the 量词* is forbidden, so a number and its
|
|
242
|
+
* measure written solid survive whole where the dictionary has them: 一辈子 and
|
|
243
|
+
* 一会儿 are entries covering the number too, and the decode still reaches them.
|
|
244
|
+
*
|
|
245
|
+
* Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
|
|
246
|
+
* rules were sized against, it forbids 561 edges across 144 shapes — 个人 203
|
|
247
|
+
* of them, then 杯水, 天一, 口气, 些小 and 家人 — and moves 53 decodes, since
|
|
248
|
+
* most of what it takes away the cost model was not going to choose anyway.
|
|
249
|
+
* Three of the 53 are wrong: 一批评, 这一名词 and 六七股灾, where the 一 and the
|
|
250
|
+
* 六七 count nothing and no tag says so. Exactly one reading changes over the
|
|
251
|
+
* corpus and it is a fix, 下了两天雨 having read 天雨 as `tiān yù`.
|
|
252
|
+
*/
|
|
253
|
+
export const COUNTED_MEASURE = {
|
|
254
|
+
name: "counted-measure",
|
|
255
|
+
verdictFor: (context) => {
|
|
256
|
+
const { characters, edge } = context;
|
|
257
|
+
// A reading of a different length from its span says something about how
|
|
258
|
+
// the characters are read rather than only about where they break: 份儿 is
|
|
259
|
+
// `fènr` over two characters, and taking the edge away would take the 儿化
|
|
260
|
+
// with it.
|
|
261
|
+
if (edge.to - edge.from < 2 ||
|
|
262
|
+
edge.reading.length !== edge.to - edge.from) {
|
|
263
|
+
return "keep";
|
|
264
|
+
}
|
|
265
|
+
const counted = countedFrom(context, edge.from);
|
|
266
|
+
if (counted === undefined) {
|
|
267
|
+
return "keep";
|
|
268
|
+
}
|
|
269
|
+
return tagOf(context, characters[edge.from]) === MEASURE &&
|
|
270
|
+
edge.partOfSpeech !== MEASURE
|
|
271
|
+
? "forbid"
|
|
272
|
+
: "keep";
|
|
273
|
+
},
|
|
274
|
+
};
|
|
103
275
|
/**
|
|
104
276
|
* The rules the lattice decode applies, in order.
|
|
105
277
|
*/
|
|
106
|
-
export const READING_RULES = [
|
|
278
|
+
export const READING_RULES = [
|
|
279
|
+
MODAL_DE,
|
|
280
|
+
TEACHING_JIAO,
|
|
281
|
+
ATTESTED_ERHUA,
|
|
282
|
+
COUNTED_MEASURE,
|
|
283
|
+
];
|
|
107
284
|
//# sourceMappingURL=reading-rules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reading-rules.js","sourceRoot":"","sources":["../../src/decode/reading-rules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reading-rules.js","sourceRoot":"","sources":["../../src/decode/reading-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAGL,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,SAAS,KAAK,CAAC,QAA8B;IAC3C,OAAO,CACL,QAAQ,EAAE,OAAO,KAAK,GAAG,IAAI,QAAQ,CAAC,KAAK,KAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,eAAe,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,CAAC,OAAoB,EAAE,EAAE;QACnC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK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CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IAC1E,OAAO,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,eAAe,GAAa;IACvC,IAAI,EAAE,iBAAiB;IACvB,UAAU,EAAE,CAAC,OAAoB,EAAE,EAAE;QACnC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACrC,yEAAyE;QACzE,yEAAyE;QACzE,yEAAyE;QACzE,WAAW;QACX,IACE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAC3C,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC,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;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAwB;IAChD,QAAQ;IACR,aAAa;IACb,cAAc;IACd,eAAe;CAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -42,13 +42,13 @@ export { isSettled, projectReadings, settledUnits, unitsOf, } from "./decode/loc
|
|
|
42
42
|
export type { ReadingProjection, ReadingUnit } from "./decode/locking.js";
|
|
43
43
|
export { applyEdgeRules, tagOf, wordEndingAt, wordStartingAt, } from "./decode/rules.js";
|
|
44
44
|
export type { EdgeContext, EdgeRule, EdgeVerdict } from "./decode/rules.js";
|
|
45
|
-
export { ATTESTED_ERHUA, MODAL_DE, READING_RULES, } from "./decode/reading-rules.js";
|
|
45
|
+
export { ATTESTED_ERHUA, COUNTED_MEASURE, MODAL_DE, READING_RULES, TEACHING_JIAO, } from "./decode/reading-rules.js";
|
|
46
46
|
export { readingCost, shortestPath, spacingCost } from "./decode/viterbi.js";
|
|
47
47
|
export type { CostOf } from "./decode/viterbi.js";
|
|
48
48
|
export type { DecodedWord, ScoredWord, WordSeparator } from "./decode/word.js";
|
|
49
49
|
export { cardinalHanzi, LARGEST_CARDINAL } from "./numerals/cardinal.js";
|
|
50
50
|
export type { CardinalOptions } from "./numerals/cardinal.js";
|
|
51
|
-
export { DIGIT_CHARACTERS, numeralSyllable, UNIT_VALUES, yaoSyllable, } from "./numerals/characters.js";
|
|
51
|
+
export { DIGIT_CHARACTERS, numeralSyllable, QUANTITY_CHARACTERS, UNIT_VALUES, yaoSyllable, } from "./numerals/characters.js";
|
|
52
52
|
export { fractionHanzi, numeralHanzi, percentHanzi, readNumeral, readNumeralHanzi, } from "./numerals/numerals.js";
|
|
53
53
|
export type { NumeralOptions, NumeralStyle } from "./numerals/numerals.js";
|
|
54
54
|
export { isBopomofo, readBopomofo, writeBopomofo, writeBopomofoWord, } from "./transcription/bopomofo.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EACL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AO,EACL,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,GACR,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EACL,UAAU,EACV,eAAe,EACf,YAAY,EACZ,aAAa,EACb,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EACL,aAAa,EACb,cAAc,EACd,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC/E,YAAY,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,10 +26,10 @@ export { decodeGreedily } from "./decode/greedy.js";
|
|
|
26
26
|
export { allEdges, buildLattice, cutPoints, READING_CHARGE, } from "./decode/lattice.js";
|
|
27
27
|
export { isSettled, projectReadings, settledUnits, unitsOf, } from "./decode/locking.js";
|
|
28
28
|
export { applyEdgeRules, tagOf, wordEndingAt, wordStartingAt, } from "./decode/rules.js";
|
|
29
|
-
export { ATTESTED_ERHUA, MODAL_DE, READING_RULES, } from "./decode/reading-rules.js";
|
|
29
|
+
export { ATTESTED_ERHUA, COUNTED_MEASURE, MODAL_DE, READING_RULES, TEACHING_JIAO, } from "./decode/reading-rules.js";
|
|
30
30
|
export { readingCost, shortestPath, spacingCost } from "./decode/viterbi.js";
|
|
31
31
|
export { cardinalHanzi, LARGEST_CARDINAL } from "./numerals/cardinal.js";
|
|
32
|
-
export { DIGIT_CHARACTERS, numeralSyllable, UNIT_VALUES, yaoSyllable, } from "./numerals/characters.js";
|
|
32
|
+
export { DIGIT_CHARACTERS, numeralSyllable, QUANTITY_CHARACTERS, UNIT_VALUES, yaoSyllable, } from "./numerals/characters.js";
|
|
33
33
|
export { fractionHanzi, numeralHanzi, percentHanzi, readNumeral, readNumeralHanzi, } from "./numerals/numerals.js";
|
|
34
34
|
export { isBopomofo, readBopomofo, writeBopomofo, writeBopomofoWord, } from "./transcription/bopomofo.js";
|
|
35
35
|
export { readWadeGiles, readWadeGilesLoosely, writeWadeGiles, writeWadeGilesSpelling, writeWadeGilesWord, } from "./transcription/wade-giles.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,YAAY,GACb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,UAAU,GACX,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE,OAAO,EACL,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,SAAS,GACV,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,iBAAiB,EACjB,cAAc,GACf,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAOrD,OAAO,EACL,iBAAiB,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ions {
|
|
|
16
16
|
*
|
|
17
17
|
* None of them touches a 2 that is not a multiplier of a big unit: 12 is
|
|
18
18
|
* 十二, 20 is 二十, 200 is 二百, and 120,000 is 十二万, where the 二 is the
|
|
19
|
-
* units digit of 12.
|
|
19
|
+
* units digit of 12. A lone 2 in front of what it counts is {@link counts}
|
|
20
|
+
* rather than this.
|
|
20
21
|
*/
|
|
21
22
|
readonly liang?: "always" | "leading" | "never";
|
|
23
|
+
/**
|
|
24
|
+
* Whether the number stands immediately in front of something it counts.
|
|
25
|
+
*
|
|
26
|
+
* Only a lone 2 changes, and it is not a variable choice the way
|
|
27
|
+
* {@link liang} is: 两个西瓜 and 两个人 are what the language has, and 二个 is
|
|
28
|
+
* simply wrong. Nothing about the number says whether it is counting, so the
|
|
29
|
+
* caller says, which is the same division of labour the numeral style has.
|
|
30
|
+
*
|
|
31
|
+
* Off by default, because a number with nothing after it is not counting
|
|
32
|
+
* anything: 2 on its own is 二, and so is the 2 of 第2次, which names rather
|
|
33
|
+
* than counts. `liang: "never"` still overrides it.
|
|
34
|
+
*/
|
|
35
|
+
readonly counts?: boolean;
|
|
22
36
|
}
|
|
23
37
|
/**
|
|
24
38
|
* The largest number this can write, being four groups of four digits.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cardinal.d.ts","sourceRoot":"","sources":["../../src/numerals/cardinal.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B
|
|
1
|
+
{"version":3,"file":"cardinal.d.ts","sourceRoot":"","sources":["../../src/numerals/cardinal.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;IAChD;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAoBD;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAe,CAAC;AAwE7C;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAAoB,GAC5B,MAAM,CA0CR"}
|
|
@@ -83,7 +83,14 @@ export function cardinalHanzi(value, options = {}) {
|
|
|
83
83
|
if (value === 0) {
|
|
84
84
|
return "零";
|
|
85
85
|
}
|
|
86
|
-
const { liang = "always" } = options;
|
|
86
|
+
const { liang = "always", counts = false } = options;
|
|
87
|
+
// A lone 2 counting something is 两 and nothing else: 两个西瓜. It is the
|
|
88
|
+
// only value this touches, since the 二 of 十二个 or 一万零二个 is a digit
|
|
89
|
+
// inside a larger number rather than the number standing in front of the
|
|
90
|
+
// 量词.
|
|
91
|
+
if (value === 2 && counts && isLiang(liang, true)) {
|
|
92
|
+
return "两";
|
|
93
|
+
}
|
|
87
94
|
const groups = [];
|
|
88
95
|
for (let rest = value; rest > 0; rest = Math.floor(rest / 10_000)) {
|
|
89
96
|
groups.push(rest % 10_000);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cardinal.js","sourceRoot":"","sources":["../../src/numerals/cardinal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"cardinal.js","sourceRoot":"","sources":["../../src/numerals/cardinal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAuCnD;;GAEG;AACH,MAAM,MAAM,GAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,GAAsB,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB;;GAEG;AACH,MAAM,CAAC,MAAM,gBAA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CAAC;IACjB,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3C,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,EAAE;YAC7B,SAAS,EAAE,EAAE,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC;YACnC,KAAK;SACN,CAAC,CAAC;QACH,0EAA0E;QAC1E,wDAAwD;QACxD,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,GAAG,GAAG,OAAO,KAAK,EAAE,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,MAAM,SAAS,GAAG,EAAE,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3C,MAAM,IAAI,GACR,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;QACxE,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,OAAO,CAAC;IACxC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -11,6 +11,15 @@ export declare const DIGIT_CHARACTERS = "\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u5
|
|
|
11
11
|
* thousand-grouped: 12,345 is 一万二千三百四十五, one 万 and 2,345.
|
|
12
12
|
*/
|
|
13
13
|
export declare const UNIT_VALUES: ReadonlyMap<string, number>;
|
|
14
|
+
/**
|
|
15
|
+
* The 汉字 a quantity is written with: the digits, 两, and the places.
|
|
16
|
+
*
|
|
17
|
+
* Less than {@link numeralSyllable} reads, and deliberately so. 点, 分, 之 and
|
|
18
|
+
* 负 are parts of how a number is *said* rather than quantities in themselves,
|
|
19
|
+
* so a 量词 after one of them is not being counted by it — which is the only
|
|
20
|
+
* question this set is asked.
|
|
21
|
+
*/
|
|
22
|
+
export declare const QUANTITY_CHARACTERS: ReadonlySet<string>;
|
|
14
23
|
/**
|
|
15
24
|
* Read one numeral character.
|
|
16
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"characters.d.ts","sourceRoot":"","sources":["../../src/numerals/characters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"characters.d.ts","sourceRoot":"","sources":["../../src/numerals/characters.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,iEAAe,CAAC;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAMlD,CAAC;AAyCH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAQlD,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAGvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAElD"}
|