@kensio/pinyinjs 1.8.6 → 1.9.1

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.
Files changed (132) hide show
  1. package/data/core.entries +27 -27
  2. package/data/core.freq +0 -0
  3. package/data/core.keys +1 -1
  4. package/data/full.counts +0 -0
  5. package/data/full.entries +4139 -4139
  6. package/data/full.freq +0 -0
  7. package/data/manifest.json +11 -11
  8. package/data/script.map +3 -2
  9. package/data/standard.entries +385 -385
  10. package/data/standard.freq +0 -0
  11. package/data/standard.keys +1 -1
  12. package/dist/decode/chang-context.d.ts +4 -0
  13. package/dist/decode/chang-context.d.ts.map +1 -1
  14. package/dist/decode/chang-context.js +16 -2
  15. package/dist/decode/chang-context.js.map +1 -1
  16. package/dist/decode/chang-rule.d.ts.map +1 -1
  17. package/dist/decode/chang-rule.js +6 -0
  18. package/dist/decode/chang-rule.js.map +1 -1
  19. package/dist/decode/chang-span.d.ts +37 -0
  20. package/dist/decode/chang-span.d.ts.map +1 -0
  21. package/dist/decode/chang-span.js +100 -0
  22. package/dist/decode/chang-span.js.map +1 -0
  23. package/dist/decode/chong-frames.d.ts +9 -0
  24. package/dist/decode/chong-frames.d.ts.map +1 -0
  25. package/dist/decode/chong-frames.js +58 -0
  26. package/dist/decode/chong-frames.js.map +1 -0
  27. package/dist/decode/ding-frames.d.ts +8 -0
  28. package/dist/decode/ding-frames.d.ts.map +1 -0
  29. package/dist/decode/ding-frames.js +54 -0
  30. package/dist/decode/ding-frames.js.map +1 -0
  31. package/dist/decode/dominant-readings.d.ts +55 -0
  32. package/dist/decode/dominant-readings.d.ts.map +1 -0
  33. package/dist/decode/dominant-readings.js +67 -0
  34. package/dist/decode/dominant-readings.js.map +1 -0
  35. package/dist/decode/dominant-rule.d.ts +24 -0
  36. package/dist/decode/dominant-rule.d.ts.map +1 -0
  37. package/dist/decode/dominant-rule.js +122 -0
  38. package/dist/decode/dominant-rule.js.map +1 -0
  39. package/dist/decode/guo-rule.d.ts.map +1 -1
  40. package/dist/decode/guo-rule.js +12 -0
  41. package/dist/decode/guo-rule.js.map +1 -1
  42. package/dist/decode/hao-rule.d.ts +16 -0
  43. package/dist/decode/hao-rule.d.ts.map +1 -0
  44. package/dist/decode/hao-rule.js +61 -0
  45. package/dist/decode/hao-rule.js.map +1 -0
  46. package/dist/decode/ji-frames.d.ts +9 -0
  47. package/dist/decode/ji-frames.d.ts.map +1 -0
  48. package/dist/decode/ji-frames.js +71 -0
  49. package/dist/decode/ji-frames.js.map +1 -0
  50. package/dist/decode/jiao-rule.d.ts +5 -6
  51. package/dist/decode/jiao-rule.d.ts.map +1 -1
  52. package/dist/decode/jiao-rule.js +39 -3
  53. package/dist/decode/jiao-rule.js.map +1 -1
  54. package/dist/decode/jie-frames.d.ts +6 -0
  55. package/dist/decode/jie-frames.d.ts.map +1 -0
  56. package/dist/decode/jie-frames.js +94 -0
  57. package/dist/decode/jie-frames.js.map +1 -0
  58. package/dist/decode/liang-frames.d.ts +6 -0
  59. package/dist/decode/liang-frames.d.ts.map +1 -0
  60. package/dist/decode/liang-frames.js +112 -0
  61. package/dist/decode/liang-frames.js.map +1 -0
  62. package/dist/decode/polyphone-rules.d.ts +2 -1
  63. package/dist/decode/polyphone-rules.d.ts.map +1 -1
  64. package/dist/decode/polyphone-rules.js +2 -1
  65. package/dist/decode/polyphone-rules.js.map +1 -1
  66. package/dist/decode/reading-rules.d.ts +3 -1
  67. package/dist/decode/reading-rules.d.ts.map +1 -1
  68. package/dist/decode/reading-rules.js +9 -2
  69. package/dist/decode/reading-rules.js.map +1 -1
  70. package/dist/decode/reduplication-readings.d.ts +26 -0
  71. package/dist/decode/reduplication-readings.d.ts.map +1 -0
  72. package/dist/decode/reduplication-readings.js +48 -0
  73. package/dist/decode/reduplication-readings.js.map +1 -0
  74. package/dist/decode/reduplication-rule.d.ts +1 -1
  75. package/dist/decode/reduplication-rule.d.ts.map +1 -1
  76. package/dist/decode/reduplication-rule.js +2 -41
  77. package/dist/decode/reduplication-rule.js.map +1 -1
  78. package/dist/decode/shu-frames.d.ts +6 -0
  79. package/dist/decode/shu-frames.d.ts.map +1 -0
  80. package/dist/decode/shu-frames.js +102 -0
  81. package/dist/decode/shu-frames.js.map +1 -0
  82. package/dist/decode/split-infix.d.ts +25 -0
  83. package/dist/decode/split-infix.d.ts.map +1 -0
  84. package/dist/decode/split-infix.js +134 -0
  85. package/dist/decode/split-infix.js.map +1 -0
  86. package/dist/decode/split-rule.d.ts +11 -0
  87. package/dist/decode/split-rule.d.ts.map +1 -1
  88. package/dist/decode/split-rule.js +17 -4
  89. package/dist/decode/split-rule.js.map +1 -1
  90. package/dist/decode/tiao-frames.d.ts +6 -0
  91. package/dist/decode/tiao-frames.d.ts.map +1 -0
  92. package/dist/decode/tiao-frames.js +60 -0
  93. package/dist/decode/tiao-frames.js.map +1 -0
  94. package/dist/decode/verbal-frame.d.ts +68 -0
  95. package/dist/decode/verbal-frame.d.ts.map +1 -0
  96. package/dist/decode/verbal-frame.js +76 -0
  97. package/dist/decode/verbal-frame.js.map +1 -0
  98. package/dist/decode/verbal-held.d.ts +12 -0
  99. package/dist/decode/verbal-held.d.ts.map +1 -0
  100. package/dist/decode/verbal-held.js +63 -0
  101. package/dist/decode/verbal-held.js.map +1 -0
  102. package/dist/decode/verbal-rule.d.ts +31 -0
  103. package/dist/decode/verbal-rule.d.ts.map +1 -0
  104. package/dist/decode/verbal-rule.js +100 -0
  105. package/dist/decode/verbal-rule.js.map +1 -0
  106. package/dist/decode/xiang-frames.d.ts +6 -0
  107. package/dist/decode/xiang-frames.d.ts.map +1 -0
  108. package/dist/decode/xiang-frames.js +65 -0
  109. package/dist/decode/xiang-frames.js.map +1 -0
  110. package/dist/decode/zhuan-frames.d.ts +6 -0
  111. package/dist/decode/zhuan-frames.d.ts.map +1 -0
  112. package/dist/decode/zhuan-frames.js +97 -0
  113. package/dist/decode/zhuan-frames.js.map +1 -0
  114. package/dist/dictionary/character-defaults.d.ts.map +1 -1
  115. package/dist/dictionary/character-defaults.js +4 -1
  116. package/dist/dictionary/character-defaults.js.map +1 -1
  117. package/dist/dictionary/character-readings.d.ts.map +1 -1
  118. package/dist/dictionary/character-readings.js +9 -0
  119. package/dist/dictionary/character-readings.js.map +1 -1
  120. package/dist/dictionary/free-readings.d.ts +70 -0
  121. package/dist/dictionary/free-readings.d.ts.map +1 -0
  122. package/dist/dictionary/free-readings.js +108 -0
  123. package/dist/dictionary/free-readings.js.map +1 -0
  124. package/dist/dictionary/frequency-table.d.ts +8 -0
  125. package/dist/dictionary/frequency-table.d.ts.map +1 -1
  126. package/dist/dictionary/frequency-table.js +11 -1
  127. package/dist/dictionary/frequency-table.js.map +1 -1
  128. package/dist/index.d.ts +1 -1
  129. package/dist/index.d.ts.map +1 -1
  130. package/dist/index.js +1 -1
  131. package/dist/index.js.map +1 -1
  132. 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,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AChB,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;AAoEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAa9B,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"}
@@ -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,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;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAC,OAAoB,EAAE,EAAU;IACtD,OAAO,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAC9C,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAS,UAAU,CAAC,OAAoB,EAAE,IAAyB;IACjE,IAAI,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CACjC,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CACpB,MAAM,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;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,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;gBACjE,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,MAAM,CAAC;QACb,CAAC;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,9 @@
1
+ import { type VerbalFrame } from "./verbal-frame.js";
2
+ /**
3
+ * 系 read `jì` where it is tying something.
4
+ *
5
+ * 繫 is the form 繁體 ties with, and Unihan gives it `xì` alone, so only 系
6
+ * is here.
7
+ */
8
+ export declare const JI_FRAME: VerbalFrame;
9
+ //# sourceMappingURL=ji-frames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ji-frames.d.ts","sourceRoot":"","sources":["../../src/decode/ji-frames.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAC;AAmE3B;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,WAMtB,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { isBareAt, startsWithAny, syllableOf, charactersOf, } from "./verbal-frame.js";
2
+ /**
3
+ * What follows a 系 that is tying: a complement or aspect.
4
+ *
5
+ * 系上 reads `jì` already through the full tier's word. 在 is in for 把绳子系在
6
+ * 树上 and 把船系在码头上. A department or a system followed by 在 is the one
7
+ * shape this gets wrong, and none of the corpus lines has it.
8
+ */
9
+ const COMPLEMENT = new Set([
10
+ "好",
11
+ "上",
12
+ "紧",
13
+ "牢",
14
+ "住",
15
+ "着",
16
+ "著",
17
+ "了",
18
+ "在",
19
+ "得",
20
+ ]);
21
+ /**
22
+ * What is tied: 系领带, 系安全带, 系鞋带, 系围裙.
23
+ */
24
+ const TIED = [
25
+ "领带",
26
+ "鞋带",
27
+ "安全带",
28
+ "围裙",
29
+ "围巾",
30
+ "绳子",
31
+ "带子",
32
+ "丝带",
33
+ "腰带",
34
+ "皮带",
35
+ "头绳",
36
+ "红领巾",
37
+ "蝴蝶结",
38
+ ];
39
+ /**
40
+ * Whether the 系 at a position is tying something.
41
+ */
42
+ function isTyingAt(context, at) {
43
+ return (isBareAt(context, at + 1, COMPLEMENT) ||
44
+ startsWithAny(context, at + 1, TIED));
45
+ }
46
+ /**
47
+ * The characters that bind it into a compound reading it otherwise.
48
+ *
49
+ * Bound before it: 关系, 联系, 连系, 维系, 体系, 星系 and the other nouns
50
+ * ending in it, so 我们联系上他们 is not read as tying. Bound after it: 系统,
51
+ * 系列, 系数.
52
+ */
53
+ const BOUND_BEFORE = charactersOf("关關联聯连連维維体體派星直世谱譜嫡旁菌根水语語品恒恆阳陽河院");
54
+ /**
55
+ * The characters after it that bind it into such a compound.
56
+ */
57
+ const BOUND_AFTER = charactersOf("统統列数數");
58
+ /**
59
+ * 系 read `jì` where it is tying something.
60
+ *
61
+ * 繫 is the form 繁體 ties with, and Unihan gives it `xì` alone, so only 系
62
+ * is here.
63
+ */
64
+ export const JI_FRAME = {
65
+ characters: new Set(["系"]),
66
+ reading: syllableOf("jì"),
67
+ boundBefore: BOUND_BEFORE,
68
+ boundAfter: BOUND_AFTER,
69
+ isVerbalAt: isTyingAt,
70
+ };
71
+ //# sourceMappingURL=ji-frames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ji-frames.js","sourceRoot":"","sources":["../../src/decode/ji-frames.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EACR,aAAa,EACb,UAAU,EAEV,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;CACJ,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,IAAI,GAAG;IACX,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;CACN,CAAC;AAEF;;GAEG;AACH,SAAS,SAAS,CAAC,OAAoB,EAAE,EAAU;IACjD,OAAO,CACL,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC;QACrC,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CACrC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,YAAY,CAC/B,gCAAgC,CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAgB;IACnC,UAAU,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC;IACzB,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,SAAS;CACtB,CAAC"}
@@ -1,9 +1,3 @@
1
- /**
2
- * Whether a 教 is teaching or is the noun 教.
3
- *
4
- * Teaching takes an object or is followed by aspect, and only a verb takes
5
- * either, so the tags around it are the evidence.
6
- */
7
1
  import type { Syllable } from "../syllable/syllable.js";
8
2
  import { type EdgeContext, type EdgeRule } from "./rules.js";
9
3
  /**
@@ -56,6 +50,11 @@ export declare function isTeachingAt(context: EdgeContext, at: number): boolean;
56
50
  * 教室 reached through a bad split, and a 教 used as a bare noun — and 9 are
57
51
  * misses, where jieba tags the object something this does not name.
58
52
  *
53
+ * {@link SKILL_TAGS}, the adverbial 地 and asking every word after the 教
54
+ * rather than the longest came later still, from a page of example sentences
55
+ * (教游泳, 教孩子们, 兢兢业业地教了). Over the same lines they move 3 more in
56
+ * the full tier and 2 in the standard tier, all corrections.
57
+ *
59
58
  * {@link GOVERNING} is four of that 162 and was added later: 能教教我,
60
59
  * 要教一節課, 也會教像拉丁語, 這在學校是不教的. 有 is pointedly outside it,
61
60
  * since 有教无类 is `yǒujiào wúlèi`.
@@ -1 +1 @@
1
- {"version":3,"file":"jiao-rule.d.ts","sourceRoot":"","sources":["../../src/decode/jiao-rule.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAI9D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aAA8C,CAAC;AAkCvE;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAUtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,aAAa,EAAE,QAiB3B,CAAC"}
1
+ {"version":3,"file":"jiao-rule.d.ts","sourceRoot":"","sources":["../../src/decode/jiao-rule.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAI9D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aAA8C,CAAC;AA+DvE;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAUtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,aAAa,EAAE,QAiB3B,CAAC"}
@@ -1,4 +1,11 @@
1
- import { ASPECT, PARTICLE_TAG, tagOf, wordEndingAt, wordStartingAt, } from "./rules.js";
1
+ /**
2
+ * Whether a 教 is teaching or is the noun 教.
3
+ *
4
+ * Teaching takes an object or is followed by aspect, and only a verb takes
5
+ * either, so the tags around it are the evidence.
6
+ */
7
+ import { toCharacters } from "../script/characters.js";
8
+ import { ASPECT, PARTICLE_TAG, tagOf, wordEndingAt, wordsStartingAt, } from "./rules.js";
2
9
  /**
3
10
  * Whether a syllable is `jiāo`, the verbal reading of 教.
4
11
  */
@@ -13,6 +20,30 @@ export function isJiao(syllable) {
13
20
  * only 教 with a place tag after it over the corpus is 教青局, an office.
14
21
  */
15
22
  export const TAUGHT_TAGS = new Set(["r", "n", "nz", "nr", "nt", "ng"]);
23
+ /**
24
+ * What a 教 that is teaching a skill governs: the verb for the skill.
25
+ *
26
+ * 教游泳, 教阅读, 教唱歌. jieba tags 游泳 `vn` and 阅读 `v`, and a verb word
27
+ * after a bare 教 is what is taught. A single character is not enough. The
28
+ * core tier holds no 教育, 教练 or 教会, and the 育, 练 and 会 after its bare
29
+ * 教 are the second halves of those words.
30
+ */
31
+ const SKILL_TAGS = new Set(["v", "vn"]);
32
+ /**
33
+ * Whether a word names something a 教 can teach: a person, a thing or a skill.
34
+ */
35
+ function isTaught(context, word) {
36
+ const tag = tagOf(context, word);
37
+ return (TAUGHT_TAGS.has(tag) ||
38
+ (SKILL_TAGS.has(tag) && toCharacters(word).length > 1));
39
+ }
40
+ /**
41
+ * The particle that turns what is before it into an adverb of the verb after.
42
+ *
43
+ * jieba tags 地 `uv` along with the other particles, and a verb does follow
44
+ * this one: 她兢兢业业地教了多年书.
45
+ */
46
+ const ADVERBIAL = "地";
16
47
  /**
17
48
  * The words that can only be governing a verb, whatever comes after them.
18
49
  *
@@ -56,12 +87,12 @@ const GOVERNING = new Set([
56
87
  */
57
88
  export function isTeachingAt(context, at) {
58
89
  const before = wordEndingAt(context, at);
59
- if (tagOf(context, before).startsWith(PARTICLE_TAG)) {
90
+ if (before !== ADVERBIAL && tagOf(context, before).startsWith(PARTICLE_TAG)) {
60
91
  return false;
61
92
  }
62
93
  return (GOVERNING.has(before ?? "") ||
63
94
  ASPECT.has(context.characters[at + 1] ?? "") ||
64
- TAUGHT_TAGS.has(tagOf(context, wordStartingAt(context, at + 1))));
95
+ wordsStartingAt(context, at + 1).some((word) => isTaught(context, word)));
65
96
  }
66
97
  /**
67
98
  * 教 read as `jiāo` where it is teaching rather than a religion.
@@ -90,6 +121,11 @@ export function isTeachingAt(context, at) {
90
121
  * 教室 reached through a bad split, and a 教 used as a bare noun — and 9 are
91
122
  * misses, where jieba tags the object something this does not name.
92
123
  *
124
+ * {@link SKILL_TAGS}, the adverbial 地 and asking every word after the 教
125
+ * rather than the longest came later still, from a page of example sentences
126
+ * (教游泳, 教孩子们, 兢兢业业地教了). Over the same lines they move 3 more in
127
+ * the full tier and 2 in the standard tier, all corrections.
128
+ *
93
129
  * {@link GOVERNING} is four of that 162 and was added later: 能教教我,
94
130
  * 要教一節課, 也會教像拉丁語, 這在學校是不教的. 有 is pointedly outside it,
95
131
  * since 有教无类 is `yǒujiào wúlèi`.
@@ -1 +1 @@
1
- {"version":3,"file":"jiao-rule.js","sourceRoot":"","sources":["../../src/decode/jiao-rule.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,MAAM,EACN,YAAY,EAGZ,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,QAA8B;IACnD,OAAO,CACL,QAAQ,EAAE,OAAO,KAAK,GAAG,IAAI,QAA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IAAI,EAAE,CAAC;QAC5C,eAAe,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CACzE,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAa;IACrC,IAAI,EAAE,eAAe;IACrB,UAAU,EAAE,CAAC,OAAoB,EAAE,EAAE;QACnC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;gBAChE,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,MAAM,CAAC;QACb,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,KAAK,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI;YAC3C,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5B,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;YAClC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,MAAM,CAAC;IACb,CAAC;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type VerbalFrame } from "./verbal-frame.js";
2
+ /**
3
+ * 结 read `jiē` where it bears fruit.
4
+ */
5
+ export declare const JIE_FRAME: VerbalFrame;
6
+ //# sourceMappingURL=jie-frames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jie-frames.d.ts","sourceRoot":"","sources":["../../src/decode/jie-frames.ts"],"names":[],"mappings":"AASA,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAkF/E;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,WAMvB,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Whether a 结 is bearing fruit or is tying, forming or ending something.
3
+ *
4
+ * `jiē` bears fruit and `jié` does nearly everything else: 结婚, 结冰, 结疤,
5
+ * 结为兄弟. Both are verbs, and what tells them apart is the object, which for
6
+ * `jiē` is fruit.
7
+ */
8
+ import { toCharacters } from "../script/characters.js";
9
+ import { tagOf, wordStartingAt } from "./rules.js";
10
+ import { charactersOf, syllableOf } from "./verbal-frame.js";
11
+ /**
12
+ * The characters that make a word fruit: 果实, 果子, 苹果, 桃儿, 西瓜.
13
+ */
14
+ const FRUIT = new Set([
15
+ "果",
16
+ "桃",
17
+ "瓜",
18
+ "籽",
19
+ "梨",
20
+ "枣",
21
+ "杏",
22
+ "莓",
23
+ "橘",
24
+ "柿",
25
+ "李",
26
+ ]);
27
+ /**
28
+ * The complements and aspect that may stand between the 结 and its fruit:
29
+ * 结满了, 结出, 结上.
30
+ *
31
+ * Taken a character at a time, since 上好的桃儿 holds 上好 as a word and the
32
+ * decode reads 上 and 好 apart.
33
+ */
34
+ const BETWEEN = new Set(["满", "出", "上", "下", "了", "过", "過", "着", "著"]);
35
+ /**
36
+ * The tags of the words describing the fruit: adjectives, numerals, measure
37
+ * words and 的. A verb or a noun that is not fruit ends the search, so 结了婚
38
+ * never reaches a 苹果 later on.
39
+ */
40
+ function isDescribingTag(tag) {
41
+ return /^(a|b|m|q|u|z|d)/u.test(tag);
42
+ }
43
+ /**
44
+ * How far past the 结 the fruit may be, in words.
45
+ */
46
+ const REACH = 5;
47
+ /**
48
+ * Whether the 结 at a position has fruit for its object.
49
+ */
50
+ function isBearingAt(context, at) {
51
+ let from = at + 1;
52
+ for (let step = 0; step < REACH; step++) {
53
+ const character = context.characters[from] ?? "";
54
+ if (BETWEEN.has(character)) {
55
+ from++;
56
+ continue;
57
+ }
58
+ const word = wordStartingAt(context, from);
59
+ if (word === undefined) {
60
+ return false;
61
+ }
62
+ const characters = toCharacters(word);
63
+ if (characters.some((character) => FRUIT.has(character))) {
64
+ return true;
65
+ }
66
+ if (!isDescribingTag(tagOf(context, word))) {
67
+ return false;
68
+ }
69
+ from += characters.length;
70
+ }
71
+ return false;
72
+ }
73
+ /**
74
+ * The characters that bind it into a compound reading it otherwise.
75
+ *
76
+ * Bound after it: 果. 结果 is "the result" far more often than it is
77
+ * bearing fruit, and the core tier does not hold it.
78
+ */
79
+ const BOUND_BEFORE = new Set();
80
+ /**
81
+ * The characters after it that bind it into such a compound.
82
+ */
83
+ const BOUND_AFTER = charactersOf("果");
84
+ /**
85
+ * 结 read `jiē` where it bears fruit.
86
+ */
87
+ export const JIE_FRAME = {
88
+ characters: new Set(["结", "結"]),
89
+ reading: syllableOf("jiē"),
90
+ boundBefore: BOUND_BEFORE,
91
+ boundAfter: BOUND_AFTER,
92
+ isVerbalAt: isBearingAt,
93
+ };
94
+ //# sourceMappingURL=jie-frames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jie-frames.js","sourceRoot":"","sources":["../../src/decode/jie-frames.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAoB,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAoB,MAAM,mBAAmB,CAAC;AAE/E;;GAEG;AACH,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC;IACpB,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;CACJ,CAAC,CAAC;AAEH;;;;;;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,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,YAAY,GAAwB,IAAI,GAAG,EAAE,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAgB;IACpC,UAAU,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC/B,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC;IAC1B,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,WAAW;CACxB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type VerbalFrame } from "./verbal-frame.js";
2
+ /**
3
+ * 量 read `liáng` where it is measuring.
4
+ */
5
+ export declare const LIANG_FRAME: VerbalFrame;
6
+ //# sourceMappingURL=liang-frames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liang-frames.d.ts","sourceRoot":"","sources":["../../src/decode/liang-frames.ts"],"names":[],"mappings":"AAcA,OAAO,EAIL,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAC;AA2G3B;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,WAMzB,CAAC"}