@kensio/pinyinjs 1.9.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/decode/chang-context.d.ts +4 -0
- package/dist/decode/chang-context.d.ts.map +1 -1
- package/dist/decode/chang-context.js +16 -2
- package/dist/decode/chang-context.js.map +1 -1
- package/dist/decode/chang-rule.d.ts.map +1 -1
- package/dist/decode/chang-rule.js +6 -0
- package/dist/decode/chang-rule.js.map +1 -1
- package/dist/decode/chang-span.d.ts +37 -0
- package/dist/decode/chang-span.d.ts.map +1 -0
- package/dist/decode/chang-span.js +100 -0
- package/dist/decode/chang-span.js.map +1 -0
- package/dist/decode/chong-frames.d.ts +9 -0
- package/dist/decode/chong-frames.d.ts.map +1 -0
- package/dist/decode/chong-frames.js +58 -0
- package/dist/decode/chong-frames.js.map +1 -0
- package/dist/decode/de-rule.d.ts +1 -0
- package/dist/decode/de-rule.d.ts.map +1 -1
- package/dist/decode/de-rule.js +1 -0
- package/dist/decode/de-rule.js.map +1 -1
- package/dist/decode/ding-frames.d.ts +8 -0
- package/dist/decode/ding-frames.d.ts.map +1 -0
- package/dist/decode/ding-frames.js +54 -0
- package/dist/decode/ding-frames.js.map +1 -0
- package/dist/decode/dominant-readings.d.ts +55 -0
- package/dist/decode/dominant-readings.d.ts.map +1 -0
- package/dist/decode/dominant-readings.js +67 -0
- package/dist/decode/dominant-readings.js.map +1 -0
- package/dist/decode/dominant-rule.d.ts +24 -0
- package/dist/decode/dominant-rule.d.ts.map +1 -0
- package/dist/decode/dominant-rule.js +122 -0
- package/dist/decode/dominant-rule.js.map +1 -0
- package/dist/decode/guo-rule.d.ts.map +1 -1
- package/dist/decode/guo-rule.js +12 -0
- package/dist/decode/guo-rule.js.map +1 -1
- package/dist/decode/hao-rule.d.ts +16 -0
- package/dist/decode/hao-rule.d.ts.map +1 -0
- package/dist/decode/hao-rule.js +61 -0
- package/dist/decode/hao-rule.js.map +1 -0
- package/dist/decode/hua-rule.d.ts +17 -0
- package/dist/decode/hua-rule.d.ts.map +1 -0
- package/dist/decode/hua-rule.js +83 -0
- package/dist/decode/hua-rule.js.map +1 -0
- package/dist/decode/hua-speaking.d.ts +29 -0
- package/dist/decode/hua-speaking.d.ts.map +1 -0
- package/dist/decode/hua-speaking.js +79 -0
- package/dist/decode/hua-speaking.js.map +1 -0
- package/dist/decode/hua-words.d.ts +73 -0
- package/dist/decode/hua-words.d.ts.map +1 -0
- package/dist/decode/hua-words.js +161 -0
- package/dist/decode/hua-words.js.map +1 -0
- package/dist/decode/ji-frames.d.ts +9 -0
- package/dist/decode/ji-frames.d.ts.map +1 -0
- package/dist/decode/ji-frames.js +71 -0
- package/dist/decode/ji-frames.js.map +1 -0
- package/dist/decode/jiao-rule.d.ts +5 -6
- package/dist/decode/jiao-rule.d.ts.map +1 -1
- package/dist/decode/jiao-rule.js +39 -3
- package/dist/decode/jiao-rule.js.map +1 -1
- package/dist/decode/jie-frames.d.ts +6 -0
- package/dist/decode/jie-frames.d.ts.map +1 -0
- package/dist/decode/jie-frames.js +94 -0
- package/dist/decode/jie-frames.js.map +1 -0
- package/dist/decode/liang-frames.d.ts +6 -0
- package/dist/decode/liang-frames.d.ts.map +1 -0
- package/dist/decode/liang-frames.js +112 -0
- package/dist/decode/liang-frames.js.map +1 -0
- package/dist/decode/measure-rule.d.ts +31 -0
- package/dist/decode/measure-rule.d.ts.map +1 -0
- package/dist/decode/measure-rule.js +87 -0
- package/dist/decode/measure-rule.js.map +1 -0
- package/dist/decode/polyphone-rules.d.ts +2 -1
- package/dist/decode/polyphone-rules.d.ts.map +1 -1
- package/dist/decode/polyphone-rules.js +2 -1
- package/dist/decode/polyphone-rules.js.map +1 -1
- package/dist/decode/reading-rules.d.ts +6 -32
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +14 -90
- package/dist/decode/reading-rules.js.map +1 -1
- package/dist/decode/reduplication-readings.d.ts +26 -0
- package/dist/decode/reduplication-readings.d.ts.map +1 -0
- package/dist/decode/reduplication-readings.js +48 -0
- package/dist/decode/reduplication-readings.js.map +1 -0
- package/dist/decode/reduplication-rule.d.ts +1 -1
- package/dist/decode/reduplication-rule.d.ts.map +1 -1
- package/dist/decode/reduplication-rule.js +2 -41
- package/dist/decode/reduplication-rule.js.map +1 -1
- package/dist/decode/shu-frames.d.ts +6 -0
- package/dist/decode/shu-frames.d.ts.map +1 -0
- package/dist/decode/shu-frames.js +102 -0
- package/dist/decode/shu-frames.js.map +1 -0
- package/dist/decode/split-infix.d.ts +25 -0
- package/dist/decode/split-infix.d.ts.map +1 -0
- package/dist/decode/split-infix.js +134 -0
- package/dist/decode/split-infix.js.map +1 -0
- package/dist/decode/split-rule.d.ts +11 -0
- package/dist/decode/split-rule.d.ts.map +1 -1
- package/dist/decode/split-rule.js +17 -4
- package/dist/decode/split-rule.js.map +1 -1
- package/dist/decode/tiao-frames.d.ts +6 -0
- package/dist/decode/tiao-frames.d.ts.map +1 -0
- package/dist/decode/tiao-frames.js +60 -0
- package/dist/decode/tiao-frames.js.map +1 -0
- package/dist/decode/verbal-frame.d.ts +68 -0
- package/dist/decode/verbal-frame.d.ts.map +1 -0
- package/dist/decode/verbal-frame.js +76 -0
- package/dist/decode/verbal-frame.js.map +1 -0
- package/dist/decode/verbal-held.d.ts +12 -0
- package/dist/decode/verbal-held.d.ts.map +1 -0
- package/dist/decode/verbal-held.js +63 -0
- package/dist/decode/verbal-held.js.map +1 -0
- package/dist/decode/verbal-rule.d.ts +31 -0
- package/dist/decode/verbal-rule.d.ts.map +1 -0
- package/dist/decode/verbal-rule.js +100 -0
- package/dist/decode/verbal-rule.js.map +1 -0
- package/dist/decode/xiang-frames.d.ts +6 -0
- package/dist/decode/xiang-frames.d.ts.map +1 -0
- package/dist/decode/xiang-frames.js +65 -0
- package/dist/decode/xiang-frames.js.map +1 -0
- package/dist/decode/zhuan-frames.d.ts +6 -0
- package/dist/decode/zhuan-frames.d.ts.map +1 -0
- package/dist/decode/zhuan-frames.js +97 -0
- package/dist/decode/zhuan-frames.js.map +1 -0
- package/dist/dictionary/frequency-table.d.ts +8 -0
- package/dist/dictionary/frequency-table.d.ts.map +1 -1
- package/dist/dictionary/frequency-table.js +11 -1
- package/dist/dictionary/frequency-table.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a pair nobody counted may read a function word its rare way.
|
|
3
|
+
*
|
|
4
|
+
* The reading decode prices a word by the edge, so a pair the dictionary holds
|
|
5
|
+
* beats the same two characters read apart whatever the pair says about them.
|
|
6
|
+
* Some pairs are a sense the language barely uses, held by a source and
|
|
7
|
+
* counted by no corpus, and they turn a common function word into its rare
|
|
8
|
+
* reading.
|
|
9
|
+
*/
|
|
10
|
+
import { costOfBucket } from "../dictionary/frequency-table.js";
|
|
11
|
+
import { toCharacters } from "../script/characters.js";
|
|
12
|
+
import { isOnSide, RARE_READINGS } from "./dominant-readings.js";
|
|
13
|
+
import { startsLongerWord, tagOf, wordStartingAt, } from "./rules.js";
|
|
14
|
+
/**
|
|
15
|
+
* The highest frequency bucket a word nobody counted lands in.
|
|
16
|
+
*
|
|
17
|
+
* A key jieba never listed has a count of zero and lands in bucket 0. A key
|
|
18
|
+
* jieba lists without counting carries its default of 3, and bucket 2 runs
|
|
19
|
+
* from 3 to 8. {@link import("../dictionary/frequency-table.js").UNCOUNTED_NAME}
|
|
20
|
+
* gives a name the same default.
|
|
21
|
+
*/
|
|
22
|
+
const UNCOUNTED_BUCKET = 2;
|
|
23
|
+
/**
|
|
24
|
+
* What an edge in {@link UNCOUNTED_BUCKET} costs. Rarer edges cost more.
|
|
25
|
+
*/
|
|
26
|
+
const UNCOUNTED_COST = costOfBucket(UNCOUNTED_BUCKET);
|
|
27
|
+
/**
|
|
28
|
+
* Whether two syllables are the same reading, tone and all.
|
|
29
|
+
*/
|
|
30
|
+
function isSame(left, right) {
|
|
31
|
+
return (right !== undefined &&
|
|
32
|
+
left.initial === right.initial &&
|
|
33
|
+
left.final === right.final &&
|
|
34
|
+
left.tone === right.tone);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The tag prefix jieba gives a noun.
|
|
38
|
+
*/
|
|
39
|
+
const NOUN_TAG = "n";
|
|
40
|
+
/**
|
|
41
|
+
* Whether a pair ending in 都 is a capital's name where it stands.
|
|
42
|
+
*
|
|
43
|
+
* 都 is `dū` at the end of a capital's name and `dōu` in front of what is said
|
|
44
|
+
* of everything before it. A name ends the run (大家习惯把上海称为魔都) or
|
|
45
|
+
* stands in front of a noun (金中都故城). The adverb has a predicate after it,
|
|
46
|
+
* as in 书架上都是书 and 猫在黑暗中都是灰色的.
|
|
47
|
+
*/
|
|
48
|
+
function isCapital(context) {
|
|
49
|
+
const { characters, edge } = context;
|
|
50
|
+
return (edge.to === characters.length ||
|
|
51
|
+
tagOf(context, wordStartingAt(context, edge.to)).startsWith(NOUN_TAG));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The tag prefix jieba gives a verb.
|
|
55
|
+
*/
|
|
56
|
+
const VERB_TAG = "v";
|
|
57
|
+
/**
|
|
58
|
+
* Whether a pair opening with 更 is a compound of its own.
|
|
59
|
+
*
|
|
60
|
+
* 更 the adverb raises what follows it: 会更香, 更易使出, 更适用. 更 the verb
|
|
61
|
+
* *to change* makes compounds with a verb beside it, and 更变 is one no corpus
|
|
62
|
+
* counted. A bare verb after the 更 is the compound's second half. A verb
|
|
63
|
+
* opening a longer word (适用) belongs to that word, and the 更 in front of it
|
|
64
|
+
* is the adverb.
|
|
65
|
+
*/
|
|
66
|
+
function isGengCompound(context) {
|
|
67
|
+
const { characters, edge } = context;
|
|
68
|
+
const second = edge.from + 1;
|
|
69
|
+
return (tagOf(context, characters[second]).startsWith(VERB_TAG) &&
|
|
70
|
+
!startsLongerWord(context, second));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether a pair reads a function word its rare way on the word's own side.
|
|
74
|
+
*/
|
|
75
|
+
function readsRarely(context, characters) {
|
|
76
|
+
return characters.some((character, index) => {
|
|
77
|
+
const rare = RARE_READINGS.get(character);
|
|
78
|
+
if (rare === undefined || !isOnSide(rare.side, index)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if ((character === "都" && isCapital(context)) ||
|
|
82
|
+
(character === "更" && isGengCompound(context))) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return rare.readings.some((reading) => isSame(reading, context.edge.reading[index]));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A pair nobody counted that reads a function word its rare way is taken off
|
|
90
|
+
* the lattice.
|
|
91
|
+
*
|
|
92
|
+
* The reading decode charges per edge, and that charge is what lets 地气 read
|
|
93
|
+
* `dì qì` against the 地 and 气 around it. The charge is the same for a pair
|
|
94
|
+
* no corpus counts. 破的 is CC-CEDICT's *to hit the target*, and it read
|
|
95
|
+
* 气球胀得太大,会破的 as `huì pò dì`. 更香 is `large_pinyin.txt`'s incense
|
|
96
|
+
* clock, 家给 is the 家给人足 of an idiom, 赚得 is that file's reading of a word
|
|
97
|
+
* CC-CEDICT reads `zhuàn dé`, and 上都 and 中都 are the capitals of two
|
|
98
|
+
* dynasties. Each sat in an everyday sentence and took its 的, 更, 给, 赚 or 都.
|
|
99
|
+
*
|
|
100
|
+
* Taking the edge away leaves each character to its own reading, which is the
|
|
101
|
+
* usual one. A counted word keeps its reading (目的, 首都, 京都), and so does a
|
|
102
|
+
* pair of more than two characters (知更鸟, 漫无目的地).
|
|
103
|
+
*
|
|
104
|
+
* Over 88,866 lines of Tatoeba and zh.wikipedia this changes 25 runs in the
|
|
105
|
+
* full tier, and all 25 are corrections. Over both CPP splits it changes 32,
|
|
106
|
+
* and two are wrong (官员俸给 and 北魏国都代郡). CPP's labelled accuracy holds
|
|
107
|
+
* at 91.86%. The standard and core tiers hold none of these pairs.
|
|
108
|
+
*/
|
|
109
|
+
export const DOMINANT_READING = {
|
|
110
|
+
name: "dominant-reading",
|
|
111
|
+
verdictFor: (context) => {
|
|
112
|
+
const { edge } = context;
|
|
113
|
+
const characters = toCharacters(edge.text);
|
|
114
|
+
if (characters.length !== 2 ||
|
|
115
|
+
edge.reading.length !== characters.length ||
|
|
116
|
+
edge.cost < UNCOUNTED_COST) {
|
|
117
|
+
return "keep";
|
|
118
|
+
}
|
|
119
|
+
return readsRarely(context, characters) ? "forbid" : "keep";
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=dominant-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dominant-rule.js","sourceRoot":"","sources":["../../src/decode/dominant-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAGL,gBAAgB,EAChB,KAAK,EACL,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B;;GAEG;AACH,MAAM,cAAc,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;AAEtD;;GAEG;AACH,SAAS,MAAM,CAAC,IAAc,EAAE,KAA2B;IACzD,OAAO,CACL,KAAK,KAAK,SAAS;QACnB,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;QAC9B,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK;QAC1B,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CACzB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,QAA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AAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACpC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAC7C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACxC,IAAI,EAAE,kBAAkB;IACxB,UAAU,EAAE,CAAC,OAAoB,EAAE,EAAE;QACnC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACzB,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,IACE,UAAU,CAAC,MAAM,KAAK,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM;YACzC,IAAI,CAAC,IAAI,GAAG,cAAc,EAC1B,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9D,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guo-rule.d.ts","sourceRoot":"","sources":["../../src/decode/guo-rule.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,QAAQ,EAGd,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"guo-rule.d.ts","sourceRoot":"","sources":["../../src/decode/guo-rule.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,QAAQ,EAGd,MAAM,YAAY,CAAC;AAiFpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAa9B,CAAC"}
|
package/dist/decode/guo-rule.js
CHANGED
|
@@ -20,6 +20,15 @@ const MARKER = new Set(["过", "過"]);
|
|
|
20
20
|
* shape, and jieba tags 检查 `vn`.
|
|
21
21
|
*/
|
|
22
22
|
const VERB_TAG = "v";
|
|
23
|
+
/**
|
|
24
|
+
* The negator jieba tags a verb, in both scripts.
|
|
25
|
+
*
|
|
26
|
+
* 没 is *not have* as well as *not*, so the tag is right, and the 过 after it
|
|
27
|
+
* is still the verb. 考试没过 failed the exam: aspect comes after the verb it
|
|
28
|
+
* marks, and 没 is the negation in front of one, so 没去过 has its 过 after
|
|
29
|
+
* 去. 没有过 is untouched, since 有 is the verb there.
|
|
30
|
+
*/
|
|
31
|
+
const NEGATOR = new Set(["没", "沒"]);
|
|
23
32
|
/**
|
|
24
33
|
* Whether a syllable is toneless `guo`, the reading the marker takes.
|
|
25
34
|
*/
|
|
@@ -36,6 +45,9 @@ function isGuo(syllable) {
|
|
|
36
45
|
* 巴黎.
|
|
37
46
|
*/
|
|
38
47
|
function isVerbEndingAt(context, at) {
|
|
48
|
+
if (NEGATOR.has(context.characters[at - 1] ?? "")) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
39
51
|
return wordsEndingAt(context, at).some((word) => tagOf(context, word).startsWith(VERB_TAG));
|
|
40
52
|
}
|
|
41
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guo-rule.js","sourceRoot":"","sources":["../../src/decode/guo-rule.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAGL,KAAK,EACL,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB;;GAEG;AACH,SAAS,KA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AAC;QACD,OAAO,IAAI,CAAC,YAAY,KAAK,EAAE,IAAI,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC;YAC1D,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,MAAM,CAAC;IACb,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type EdgeRule } from "./rules.js";
|
|
2
|
+
/**
|
|
3
|
+
* 好学 taken apart where it means easy to learn.
|
|
4
|
+
*
|
|
5
|
+
* 德语好学吗 and 法语好学吗 came out `hào xué`, asking whether German is
|
|
6
|
+
* studious. Taking the edge away leaves 好 and 学 to their own readings,
|
|
7
|
+
* `hǎo` and `xué`. 聪明好学, 勤而好学 and 沉静好学 are said of a person and
|
|
8
|
+
* keep the word.
|
|
9
|
+
*
|
|
10
|
+
* Over 88,866 lines of Tatoeba and zh.wikipedia this changes 5 readings in the
|
|
11
|
+
* full tier and 3 in the standard tier, and all are corrections: 德语好学吗,
|
|
12
|
+
* 義大利語好學嗎 and 只要你好好学中文 among them. Nothing moves in the core tier
|
|
13
|
+
* or on either CPP split.
|
|
14
|
+
*/
|
|
15
|
+
export declare const EASY_HAO: EdgeRule;
|
|
16
|
+
//# sourceMappingURL=hao-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hao-rule.d.ts","sourceRoot":"","sources":["../../src/decode/hao-rule.ts"],"names":[],"mappings":"AAQA,OAAO,EAAoB,KAAK,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAsC5E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,EAAE,QAQtB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a 好学 is studious or is easy to learn.
|
|
3
|
+
*
|
|
4
|
+
* The dictionary holds 好学 as `hào xué`, *studious*, the sense jieba counted.
|
|
5
|
+
* CC-CEDICT also gives `hǎo xué`, *easy to learn*, and the merge kept the
|
|
6
|
+
* first. What decides between them is what the 好学 is said of.
|
|
7
|
+
*/
|
|
8
|
+
import { toCharacters } from "../script/characters.js";
|
|
9
|
+
import { wordsEndingAt } from "./rules.js";
|
|
10
|
+
/**
|
|
11
|
+
* The word, in both scripts.
|
|
12
|
+
*/
|
|
13
|
+
const STUDIOUS = new Set(["好学", "好學"]);
|
|
14
|
+
/**
|
|
15
|
+
* The characters that close the name of a language.
|
|
16
|
+
*
|
|
17
|
+
* 德语, 法语, 拉丁语, 中文 and 英文. A language is learned and cannot be
|
|
18
|
+
* studious, so the 好学 after one is easy to learn.
|
|
19
|
+
*/
|
|
20
|
+
const LANGUAGE_ENDINGS = new Set(["语", "語", "文"]);
|
|
21
|
+
/**
|
|
22
|
+
* The character a reduplicated 好好 repeats.
|
|
23
|
+
*/
|
|
24
|
+
const GOOD = "好";
|
|
25
|
+
/**
|
|
26
|
+
* Whether the 好学 starting at a position is said of a language, or is the
|
|
27
|
+
* second 好 of 好好.
|
|
28
|
+
*
|
|
29
|
+
* 只要你好好学中文 has 好好 and then 学. A 好 in front of the 好学 belongs to
|
|
30
|
+
* the first 好, and the pair would read it `hǎohào xué`.
|
|
31
|
+
*/
|
|
32
|
+
function isEasyToLearnAt(context, at) {
|
|
33
|
+
if (context.characters[at - 1] === GOOD) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return wordsEndingAt(context, at).some((word) => toCharacters(word).length > 1 &&
|
|
37
|
+
LANGUAGE_ENDINGS.has(toCharacters(word).at(-1) ?? ""));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 好学 taken apart where it means easy to learn.
|
|
41
|
+
*
|
|
42
|
+
* 德语好学吗 and 法语好学吗 came out `hào xué`, asking whether German is
|
|
43
|
+
* studious. Taking the edge away leaves 好 and 学 to their own readings,
|
|
44
|
+
* `hǎo` and `xué`. 聪明好学, 勤而好学 and 沉静好学 are said of a person and
|
|
45
|
+
* keep the word.
|
|
46
|
+
*
|
|
47
|
+
* Over 88,866 lines of Tatoeba and zh.wikipedia this changes 5 readings in the
|
|
48
|
+
* full tier and 3 in the standard tier, and all are corrections: 德语好学吗,
|
|
49
|
+
* 義大利語好學嗎 and 只要你好好学中文 among them. Nothing moves in the core tier
|
|
50
|
+
* or on either CPP split.
|
|
51
|
+
*/
|
|
52
|
+
export const EASY_HAO = {
|
|
53
|
+
name: "easy-hao",
|
|
54
|
+
verdictFor: (context) => {
|
|
55
|
+
const { edge } = context;
|
|
56
|
+
return STUDIOUS.has(edge.text) && isEasyToLearnAt(context, edge.from)
|
|
57
|
+
? "forbid"
|
|
58
|
+
: "keep";
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=hao-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hao-rule.js","sourceRoot":"","sources":["../../src/decode/hao-rule.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAmC,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5E;;GAEG;AACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,IAAI,GAAG,GAAG,CAAC;AAEjB;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,OAAoB,EAAE,EAAU;IACvD,IAAI,OAAO,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CACpC,CAAC,IAAI,EAAE,EAAE,CACP,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;QAC7B,gBAAgB,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CACxD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;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,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;YACnE,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,MAAM,CAAC;IACb,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type EdgeRule } from "./rules.js";
|
|
2
|
+
/**
|
|
3
|
+
* 的话 is taken off the lattice where the 话 is the noun its 的 modifies.
|
|
4
|
+
*
|
|
5
|
+
* The conditional is the default, since it is what the word is, and the rule
|
|
6
|
+
* names the contexts where it cannot be: a 吗 or 里 after the 话, a time the
|
|
7
|
+
* words were said, a verb of speaking before the 的, a kind of words that verb
|
|
8
|
+
* is saying, a 句 counting them, or a person whose words they are. Taking the edge away leaves 的 and 话
|
|
9
|
+
* to read as themselves, which they already did, so this changes the spacing
|
|
10
|
+
* and the segmentation rather than any syllable: `shuō de huà`, not
|
|
11
|
+
* `shuō dehuà`.
|
|
12
|
+
*
|
|
13
|
+
* Over the 472 distinct lines of Tatoeba, zh.wikipedia and the Chinese Boost
|
|
14
|
+
* example sentences that hold 的话, the full tier read 463 runs as the word.
|
|
15
|
+
*/
|
|
16
|
+
export declare const NOUN_HUA: EdgeRule;
|
|
17
|
+
//# sourceMappingURL=hua-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hua-rule.d.ts","sourceRoot":"","sources":["../../src/decode/hua-rule.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAsDpB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,EAAE,QAkBtB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 话 after a structural 的, which is the noun *words* and not half of 的话.
|
|
3
|
+
*
|
|
4
|
+
* 的话 is a word, the clause-final *if* of 要是下雨的话, and every source counts
|
|
5
|
+
* it. The same two characters are just as often the particle 的 and the noun 话
|
|
6
|
+
* it modifies: 他说的话, 听妈妈的话. The decode had no way to tell the two
|
|
7
|
+
* apart and read every one of them as the conditional, so 你听得懂从我嘴里出来的话吗
|
|
8
|
+
* came out `chūlái dehuà ma`.
|
|
9
|
+
*/
|
|
10
|
+
import { toCharacters } from "../script/characters.js";
|
|
11
|
+
import { tagOf, wordEndingAt, wordsEndingAt, } from "./rules.js";
|
|
12
|
+
import { DE_HUA, AFTER_NOUN, PERSONS, OWNER_TAGS, RECEIVING, NEGATION, RECEIVING_TAIL, EARLIER, } from "./hua-words.js";
|
|
13
|
+
import { at, followsSpeaking, isCounted, saysKind } from "./hua-speaking.js";
|
|
14
|
+
/**
|
|
15
|
+
* Whether the 的 marks whose words they are, 他的话 and 听老师的话.
|
|
16
|
+
*
|
|
17
|
+
* The owner is a person, and it either opens the run with something said about
|
|
18
|
+
* the words after them (他的话让我吃惊) or is the object of a verb that takes
|
|
19
|
+
* words (听妈妈的话, 相信你的话, 听她叔叔的话). A noun owner is a word of two
|
|
20
|
+
* characters or more, since 热的话就脱衣服 is tagged as a noun and is the
|
|
21
|
+
* conditional.
|
|
22
|
+
*
|
|
23
|
+
* A negated verb counts as the verb. 不听 is a word of its own, and
|
|
24
|
+
* 为什么不听我的话 has to find 听 in it.
|
|
25
|
+
*/
|
|
26
|
+
function isOwned(context, from, to) {
|
|
27
|
+
const owner = wordEndingAt(context, from, 3);
|
|
28
|
+
if (owner === undefined) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const isPerson = PERSONS.has(owner);
|
|
32
|
+
if (!isPerson &&
|
|
33
|
+
(toCharacters(owner).length < 2 || !OWNER_TAGS.test(tagOf(context, owner)))) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
let start = from - toCharacters(owner).length;
|
|
37
|
+
if (start === 0) {
|
|
38
|
+
return to < context.characters.length;
|
|
39
|
+
}
|
|
40
|
+
const possessor = wordEndingAt(context, start, 2);
|
|
41
|
+
if (!isPerson && possessor !== undefined && PERSONS.has(possessor)) {
|
|
42
|
+
start -= toCharacters(possessor).length;
|
|
43
|
+
}
|
|
44
|
+
let verb = start;
|
|
45
|
+
while (verb > start - 2 && RECEIVING_TAIL.has(at(context, verb - 1))) {
|
|
46
|
+
verb -= 1;
|
|
47
|
+
}
|
|
48
|
+
return wordsEndingAt(context, verb).some((word) => RECEIVING.has(word) || RECEIVING.has(word.replace(NEGATION, "")));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 的话 is taken off the lattice where the 话 is the noun its 的 modifies.
|
|
52
|
+
*
|
|
53
|
+
* The conditional is the default, since it is what the word is, and the rule
|
|
54
|
+
* names the contexts where it cannot be: a 吗 or 里 after the 话, a time the
|
|
55
|
+
* words were said, a verb of speaking before the 的, a kind of words that verb
|
|
56
|
+
* is saying, a 句 counting them, or a person whose words they are. Taking the edge away leaves 的 and 话
|
|
57
|
+
* to read as themselves, which they already did, so this changes the spacing
|
|
58
|
+
* and the segmentation rather than any syllable: `shuō de huà`, not
|
|
59
|
+
* `shuō dehuà`.
|
|
60
|
+
*
|
|
61
|
+
* Over the 472 distinct lines of Tatoeba, zh.wikipedia and the Chinese Boost
|
|
62
|
+
* example sentences that hold 的话, the full tier read 463 runs as the word.
|
|
63
|
+
*/
|
|
64
|
+
export const NOUN_HUA = {
|
|
65
|
+
name: "noun-hua",
|
|
66
|
+
verdictFor: (context) => {
|
|
67
|
+
const { edge } = context;
|
|
68
|
+
if (!DE_HUA.has(edge.text)) {
|
|
69
|
+
return "keep";
|
|
70
|
+
}
|
|
71
|
+
const { from, to } = edge;
|
|
72
|
+
const before = wordEndingAt(context, from, 2);
|
|
73
|
+
return AFTER_NOUN.has(at(context, to)) ||
|
|
74
|
+
(before !== undefined && EARLIER.has(before)) ||
|
|
75
|
+
followsSpeaking(context, from) ||
|
|
76
|
+
saysKind(context, from) ||
|
|
77
|
+
isCounted(context, from) ||
|
|
78
|
+
isOwned(context, from, to)
|
|
79
|
+
? "forbid"
|
|
80
|
+
: "keep";
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=hua-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hua-rule.js","sourceRoot":"","sources":["../../src/decode/hua-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAGL,KAAK,EACL,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,UAAU,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT,QAAQ,EACR,cAAc,EACd,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7E;;;;;;;;;;;GAWG;AACH,SAAS,OAAO,CAAC,OAAoB,EAAE,IAAY,EAAE,EAAU;IAC7D,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,IACE,C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E;QACnC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;QAC1B,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9C,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACpC,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC7C,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC;YAC9B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;YACvB,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC;YACxB,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;YAC1B,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,MAAM,CAAC;IACb,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type EdgeContext } from "./rules.js";
|
|
2
|
+
/**
|
|
3
|
+
* The character at a position, or the empty string beyond either end.
|
|
4
|
+
*/
|
|
5
|
+
export declare function at(context: EdgeContext, index: number): string;
|
|
6
|
+
/**
|
|
7
|
+
* Whether the 的 is the object marker of a verb of speaking.
|
|
8
|
+
*
|
|
9
|
+
* 说的话, 所说的话, 说过的话 and 说出来的话 all qualify, unless a manner stands in
|
|
10
|
+
* front of the verb or somebody is asked for an opinion: 这么说的话 is *if you
|
|
11
|
+
* put it like that* and 要我说的话 is *if you ask me*.
|
|
12
|
+
*/
|
|
13
|
+
export declare function followsSpeaking(context: EdgeContext, from: number): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the 的 follows a kind of words a verb of speaking is saying.
|
|
16
|
+
*
|
|
17
|
+
* 说这样的话, 说过那样的话 and 讲同样的话.
|
|
18
|
+
*/
|
|
19
|
+
export declare function saysKind(context: EdgeContext, from: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether a 句, or a 些 after a verb of speaking, counts the words.
|
|
22
|
+
*
|
|
23
|
+
* 句 is the classifier of 话 and of little else a 的话 could follow, so one in
|
|
24
|
+
* the few characters before the 的 is counting the head: 一句感谢的话,
|
|
25
|
+
* 说句简单的话. 些 counts anything, 有些人不来的话 among them, so it counts the
|
|
26
|
+
* words only when it is what is said: 说些傻乎乎的话, 说一些下流的话.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isCounted(context: EdgeContext, from: number): boolean;
|
|
29
|
+
//# sourceMappingURL=hua-speaking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hua-speaking.d.ts","sourceRoot":"","sources":["../../src/decode/hua-speaking.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,YAAY,CAAC;AAU5D;;GAEG;AACH,wBAAgB,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAiB3E;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAUpE;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAerE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a verb of speaking says about the 话 after a 的: 说的话, 说这样的话,
|
|
3
|
+
* 说句简单的话.
|
|
4
|
+
*/
|
|
5
|
+
import { toCharacters } from "../script/characters.js";
|
|
6
|
+
import { wordEndingAt } from "./rules.js";
|
|
7
|
+
import { SPEAKING, NOT_SPEAKING, ASKING, SPEAKING_TAIL, MANNER, KIND, } from "./hua-words.js";
|
|
8
|
+
/**
|
|
9
|
+
* The character at a position, or the empty string beyond either end.
|
|
10
|
+
*/
|
|
11
|
+
export function at(context, index) {
|
|
12
|
+
return context.characters[index] ?? "";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Whether the 的 is the object marker of a verb of speaking.
|
|
16
|
+
*
|
|
17
|
+
* 说的话, 所说的话, 说过的话 and 说出来的话 all qualify, unless a manner stands in
|
|
18
|
+
* front of the verb or somebody is asked for an opinion: 这么说的话 is *if you
|
|
19
|
+
* put it like that* and 要我说的话 is *if you ask me*.
|
|
20
|
+
*/
|
|
21
|
+
export function followsSpeaking(context, from) {
|
|
22
|
+
let verb = from - 1;
|
|
23
|
+
while (verb > from - 4 && SPEAKING_TAIL.has(at(context, verb))) {
|
|
24
|
+
verb -= 1;
|
|
25
|
+
}
|
|
26
|
+
if (!SPEAKING.has(at(context, verb))) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
const word = wordEndingAt(context, verb + 1, 2);
|
|
30
|
+
if (word !== undefined && NOT_SPEAKING.has(word)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (ASKING.has(at(context, verb - 2)) && at(context, verb - 1) === "我") {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const manner = wordEndingAt(context, verb, 2);
|
|
37
|
+
return manner === undefined || !MANNER.has(manner);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Whether the 的 follows a kind of words a verb of speaking is saying.
|
|
41
|
+
*
|
|
42
|
+
* 说这样的话, 说过那样的话 and 讲同样的话.
|
|
43
|
+
*/
|
|
44
|
+
export function saysKind(context, from) {
|
|
45
|
+
const kind = wordEndingAt(context, from, 2);
|
|
46
|
+
if (kind === undefined || !KIND.has(kind)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
let verb = from - toCharacters(kind).length - 1;
|
|
50
|
+
if (SPEAKING_TAIL.has(at(context, verb))) {
|
|
51
|
+
verb -= 1;
|
|
52
|
+
}
|
|
53
|
+
return SPEAKING.has(at(context, verb));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether a 句, or a 些 after a verb of speaking, counts the words.
|
|
57
|
+
*
|
|
58
|
+
* 句 is the classifier of 话 and of little else a 的话 could follow, so one in
|
|
59
|
+
* the few characters before the 的 is counting the head: 一句感谢的话,
|
|
60
|
+
* 说句简单的话. 些 counts anything, 有些人不来的话 among them, so it counts the
|
|
61
|
+
* words only when it is what is said: 说些傻乎乎的话, 说一些下流的话.
|
|
62
|
+
*/
|
|
63
|
+
export function isCounted(context, from) {
|
|
64
|
+
for (let index = from - 1; index >= Math.max(0, from - 4); index--) {
|
|
65
|
+
const character = at(context, index);
|
|
66
|
+
if (character === "的") {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (character === "句") {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
if (character === "些") {
|
|
73
|
+
const verb = at(context, index - 1) === "一" ? index - 2 : index - 1;
|
|
74
|
+
return SPEAKING.has(at(context, verb));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=hua-speaking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hua-speaking.js","sourceRoot":"","sources":["../../src/decode/hua-speaking.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAoB,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,aAAa,EACb,MAAM,EACN,IAAI,GACL,MAAM,gBAAgB,CA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C,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words {@link import("./hua-rule.js").NOUN_HUA} reads the context of a
|
|
3
|
+
* 的话 by, in both scripts.
|
|
4
|
+
*/
|
|
5
|
+
/** The two writings of the word, which are all this rule looks at. */
|
|
6
|
+
export declare const DE_HUA: Set<string>;
|
|
7
|
+
/**
|
|
8
|
+
* What follows the noun 话 and cannot follow the conditional.
|
|
9
|
+
*
|
|
10
|
+
* A conditional clause is followed by the clause it conditions, so it is never
|
|
11
|
+
* the thing a 吗 asks about and has no inside for 里 to name: 出来的话吗,
|
|
12
|
+
* 他的话里有文章.
|
|
13
|
+
*/
|
|
14
|
+
export declare const AFTER_NOUN: Set<string>;
|
|
15
|
+
/** The verbs of speaking whose object 话 is: 说的话, 讲过的话. */
|
|
16
|
+
export declare const SPEAKING: Set<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Words ending in a verb of speaking that are not that verb.
|
|
19
|
+
*
|
|
20
|
+
* 听讲 is attending a lecture and 小说 is a novel, and 去听讲的话 is a
|
|
21
|
+
* conditional.
|
|
22
|
+
*/
|
|
23
|
+
export declare const NOT_SPEAKING: Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* What asks for an opinion before 我说, 要我说的话 being *if you ask me*.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ASKING: Set<string>;
|
|
28
|
+
/**
|
|
29
|
+
* What can stand between a verb of speaking and the 的 of its object.
|
|
30
|
+
*
|
|
31
|
+
* 过, 出来, 了 and 不完 are the verb's own, and 所 makes the verb the modifier.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SPEAKING_TAIL: Set<string>;
|
|
34
|
+
/**
|
|
35
|
+
* The manners a speaker can ask after, which make 说的话 the conditional.
|
|
36
|
+
*
|
|
37
|
+
* 我这么说的话是不是像个傻瓜 is *if I put it like this*, and the 说 here is
|
|
38
|
+
* saying it that way rather than saying the words.
|
|
39
|
+
*/
|
|
40
|
+
export declare const MANNER: Set<string>;
|
|
41
|
+
/**
|
|
42
|
+
* The modifiers that pick out words of a kind after a verb of speaking.
|
|
43
|
+
*
|
|
44
|
+
* 说这样的话 is saying such things, where 这样的话 alone is *in that case*.
|
|
45
|
+
*/
|
|
46
|
+
export declare const KIND: Set<string>;
|
|
47
|
+
/**
|
|
48
|
+
* The pronouns that make 的话 someone's words: 他的话, 听妈妈的话.
|
|
49
|
+
*
|
|
50
|
+
* Personal pronouns only. 这样 is tagged a pronoun as well, and 这样的话 is the
|
|
51
|
+
* conditional far more often than it is anything else.
|
|
52
|
+
*/
|
|
53
|
+
export declare const PERSONS: Set<string>;
|
|
54
|
+
/** The tags of a noun that can own its words: 老师, 汤姆. */
|
|
55
|
+
export declare const OWNER_TAGS: RegExp;
|
|
56
|
+
/**
|
|
57
|
+
* The verbs whose object is somebody's words, 听他的话 and 相信你的话.
|
|
58
|
+
*
|
|
59
|
+
* Each takes what was said rather than an action, which is why 帮助我的话 and
|
|
60
|
+
* 陪我的话 stay conditional while 相信我的话 does not. 把, 对 and 因为 are in for
|
|
61
|
+
* the same reason: 把你的话转告给他, 对我的话充耳不闻 and 因为他的话 have the
|
|
62
|
+
* words as their object.
|
|
63
|
+
*/
|
|
64
|
+
export declare const RECEIVING: Set<string>;
|
|
65
|
+
/** What can negate a receiving verb inside a word of its own: 不听, 没听. */
|
|
66
|
+
export declare const NEGATION: RegExp;
|
|
67
|
+
/** The characters a receiving verb can carry before its object: 听了, 听完了. */
|
|
68
|
+
export declare const RECEIVING_TAIL: Set<string>;
|
|
69
|
+
/**
|
|
70
|
+
* When the words were said, which a conditional cannot be about: 刚才的话.
|
|
71
|
+
*/
|
|
72
|
+
export declare const EARLIER: Set<string>;
|
|
73
|
+
//# sourceMappingURL=hua-words.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hua-words.d.ts","sourceRoot":"","sources":["../../src/decode/hua-words.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sEAAsE;AACtE,eAAO,MAAM,MAAM,aAAwB,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,aAAqC,CAAC;AAE7D,0DAA0D;AAC1D,eAAO,MAAM,QAAQ,aAAgC,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,aASvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,aAAgC,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,aAAa,aASxB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,MAAM,aASjB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,IAAI,aAQf,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,OAAO,aAoBlB,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,UAAU,QAAyB,CAAC;AAEjD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,aAiCpB,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,QAAQ,QAAY,CAAC;AAElC,4EAA4E;AAC5E,eAAO,MAAM,cAAc,aAAsB,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,OAAO,aAAoC,CAAC"}
|