@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.
Files changed (131) hide show
  1. package/dist/decode/chang-context.d.ts +4 -0
  2. package/dist/decode/chang-context.d.ts.map +1 -1
  3. package/dist/decode/chang-context.js +16 -2
  4. package/dist/decode/chang-context.js.map +1 -1
  5. package/dist/decode/chang-rule.d.ts.map +1 -1
  6. package/dist/decode/chang-rule.js +6 -0
  7. package/dist/decode/chang-rule.js.map +1 -1
  8. package/dist/decode/chang-span.d.ts +37 -0
  9. package/dist/decode/chang-span.d.ts.map +1 -0
  10. package/dist/decode/chang-span.js +100 -0
  11. package/dist/decode/chang-span.js.map +1 -0
  12. package/dist/decode/chong-frames.d.ts +9 -0
  13. package/dist/decode/chong-frames.d.ts.map +1 -0
  14. package/dist/decode/chong-frames.js +58 -0
  15. package/dist/decode/chong-frames.js.map +1 -0
  16. package/dist/decode/de-rule.d.ts +1 -0
  17. package/dist/decode/de-rule.d.ts.map +1 -1
  18. package/dist/decode/de-rule.js +1 -0
  19. package/dist/decode/de-rule.js.map +1 -1
  20. package/dist/decode/ding-frames.d.ts +8 -0
  21. package/dist/decode/ding-frames.d.ts.map +1 -0
  22. package/dist/decode/ding-frames.js +54 -0
  23. package/dist/decode/ding-frames.js.map +1 -0
  24. package/dist/decode/dominant-readings.d.ts +55 -0
  25. package/dist/decode/dominant-readings.d.ts.map +1 -0
  26. package/dist/decode/dominant-readings.js +67 -0
  27. package/dist/decode/dominant-readings.js.map +1 -0
  28. package/dist/decode/dominant-rule.d.ts +24 -0
  29. package/dist/decode/dominant-rule.d.ts.map +1 -0
  30. package/dist/decode/dominant-rule.js +122 -0
  31. package/dist/decode/dominant-rule.js.map +1 -0
  32. package/dist/decode/guo-rule.d.ts.map +1 -1
  33. package/dist/decode/guo-rule.js +12 -0
  34. package/dist/decode/guo-rule.js.map +1 -1
  35. package/dist/decode/hao-rule.d.ts +16 -0
  36. package/dist/decode/hao-rule.d.ts.map +1 -0
  37. package/dist/decode/hao-rule.js +61 -0
  38. package/dist/decode/hao-rule.js.map +1 -0
  39. package/dist/decode/hua-rule.d.ts +17 -0
  40. package/dist/decode/hua-rule.d.ts.map +1 -0
  41. package/dist/decode/hua-rule.js +83 -0
  42. package/dist/decode/hua-rule.js.map +1 -0
  43. package/dist/decode/hua-speaking.d.ts +29 -0
  44. package/dist/decode/hua-speaking.d.ts.map +1 -0
  45. package/dist/decode/hua-speaking.js +79 -0
  46. package/dist/decode/hua-speaking.js.map +1 -0
  47. package/dist/decode/hua-words.d.ts +73 -0
  48. package/dist/decode/hua-words.d.ts.map +1 -0
  49. package/dist/decode/hua-words.js +161 -0
  50. package/dist/decode/hua-words.js.map +1 -0
  51. package/dist/decode/ji-frames.d.ts +9 -0
  52. package/dist/decode/ji-frames.d.ts.map +1 -0
  53. package/dist/decode/ji-frames.js +71 -0
  54. package/dist/decode/ji-frames.js.map +1 -0
  55. package/dist/decode/jiao-rule.d.ts +5 -6
  56. package/dist/decode/jiao-rule.d.ts.map +1 -1
  57. package/dist/decode/jiao-rule.js +39 -3
  58. package/dist/decode/jiao-rule.js.map +1 -1
  59. package/dist/decode/jie-frames.d.ts +6 -0
  60. package/dist/decode/jie-frames.d.ts.map +1 -0
  61. package/dist/decode/jie-frames.js +94 -0
  62. package/dist/decode/jie-frames.js.map +1 -0
  63. package/dist/decode/liang-frames.d.ts +6 -0
  64. package/dist/decode/liang-frames.d.ts.map +1 -0
  65. package/dist/decode/liang-frames.js +112 -0
  66. package/dist/decode/liang-frames.js.map +1 -0
  67. package/dist/decode/measure-rule.d.ts +31 -0
  68. package/dist/decode/measure-rule.d.ts.map +1 -0
  69. package/dist/decode/measure-rule.js +87 -0
  70. package/dist/decode/measure-rule.js.map +1 -0
  71. package/dist/decode/polyphone-rules.d.ts +2 -1
  72. package/dist/decode/polyphone-rules.d.ts.map +1 -1
  73. package/dist/decode/polyphone-rules.js +2 -1
  74. package/dist/decode/polyphone-rules.js.map +1 -1
  75. package/dist/decode/reading-rules.d.ts +6 -32
  76. package/dist/decode/reading-rules.d.ts.map +1 -1
  77. package/dist/decode/reading-rules.js +14 -90
  78. package/dist/decode/reading-rules.js.map +1 -1
  79. package/dist/decode/reduplication-readings.d.ts +26 -0
  80. package/dist/decode/reduplication-readings.d.ts.map +1 -0
  81. package/dist/decode/reduplication-readings.js +48 -0
  82. package/dist/decode/reduplication-readings.js.map +1 -0
  83. package/dist/decode/reduplication-rule.d.ts +1 -1
  84. package/dist/decode/reduplication-rule.d.ts.map +1 -1
  85. package/dist/decode/reduplication-rule.js +2 -41
  86. package/dist/decode/reduplication-rule.js.map +1 -1
  87. package/dist/decode/shu-frames.d.ts +6 -0
  88. package/dist/decode/shu-frames.d.ts.map +1 -0
  89. package/dist/decode/shu-frames.js +102 -0
  90. package/dist/decode/shu-frames.js.map +1 -0
  91. package/dist/decode/split-infix.d.ts +25 -0
  92. package/dist/decode/split-infix.d.ts.map +1 -0
  93. package/dist/decode/split-infix.js +134 -0
  94. package/dist/decode/split-infix.js.map +1 -0
  95. package/dist/decode/split-rule.d.ts +11 -0
  96. package/dist/decode/split-rule.d.ts.map +1 -1
  97. package/dist/decode/split-rule.js +17 -4
  98. package/dist/decode/split-rule.js.map +1 -1
  99. package/dist/decode/tiao-frames.d.ts +6 -0
  100. package/dist/decode/tiao-frames.d.ts.map +1 -0
  101. package/dist/decode/tiao-frames.js +60 -0
  102. package/dist/decode/tiao-frames.js.map +1 -0
  103. package/dist/decode/verbal-frame.d.ts +68 -0
  104. package/dist/decode/verbal-frame.d.ts.map +1 -0
  105. package/dist/decode/verbal-frame.js +76 -0
  106. package/dist/decode/verbal-frame.js.map +1 -0
  107. package/dist/decode/verbal-held.d.ts +12 -0
  108. package/dist/decode/verbal-held.d.ts.map +1 -0
  109. package/dist/decode/verbal-held.js +63 -0
  110. package/dist/decode/verbal-held.js.map +1 -0
  111. package/dist/decode/verbal-rule.d.ts +31 -0
  112. package/dist/decode/verbal-rule.d.ts.map +1 -0
  113. package/dist/decode/verbal-rule.js +100 -0
  114. package/dist/decode/verbal-rule.js.map +1 -0
  115. package/dist/decode/xiang-frames.d.ts +6 -0
  116. package/dist/decode/xiang-frames.d.ts.map +1 -0
  117. package/dist/decode/xiang-frames.js +65 -0
  118. package/dist/decode/xiang-frames.js.map +1 -0
  119. package/dist/decode/zhuan-frames.d.ts +6 -0
  120. package/dist/decode/zhuan-frames.d.ts.map +1 -0
  121. package/dist/decode/zhuan-frames.js +97 -0
  122. package/dist/decode/zhuan-frames.js.map +1 -0
  123. package/dist/dictionary/frequency-table.d.ts +8 -0
  124. package/dist/dictionary/frequency-table.d.ts.map +1 -1
  125. package/dist/dictionary/frequency-table.js +11 -1
  126. package/dist/dictionary/frequency-table.js.map +1 -1
  127. package/dist/index.d.ts +1 -1
  128. package/dist/index.d.ts.map +1 -1
  129. package/dist/index.js +1 -1
  130. package/dist/index.js.map +1 -1
  131. package/package.json +1 -1
@@ -0,0 +1,161 @@
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 const DE_HUA = new Set(["的话", "的話"]);
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 const AFTER_NOUN = new Set(["吗", "嗎", "里", "裡", "裏"]);
15
+ /** The verbs of speaking whose object 话 is: 说的话, 讲过的话. */
16
+ export const SPEAKING = new Set(["说", "說", "讲", "講"]);
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 const NOT_SPEAKING = new Set([
24
+ "听讲",
25
+ "聽講",
26
+ "演讲",
27
+ "演講",
28
+ "听说",
29
+ "聽說",
30
+ "小说",
31
+ "小說",
32
+ ]);
33
+ /**
34
+ * What asks for an opinion before 我说, 要我说的话 being *if you ask me*.
35
+ */
36
+ export const ASKING = new Set(["要", "依", "让", "讓"]);
37
+ /**
38
+ * What can stand between a verb of speaking and the 的 of its object.
39
+ *
40
+ * 过, 出来, 了 and 不完 are the verb's own, and 所 makes the verb the modifier.
41
+ */
42
+ export const SPEAKING_TAIL = new Set([
43
+ "过",
44
+ "過",
45
+ "出",
46
+ "来",
47
+ "來",
48
+ "了",
49
+ "不",
50
+ "完",
51
+ ]);
52
+ /**
53
+ * The manners a speaker can ask after, which make 说的话 the conditional.
54
+ *
55
+ * 我这么说的话是不是像个傻瓜 is *if I put it like this*, and the 说 here is
56
+ * saying it that way rather than saying the words.
57
+ */
58
+ export const MANNER = new Set([
59
+ "这么",
60
+ "這麼",
61
+ "那么",
62
+ "那麼",
63
+ "这样",
64
+ "這樣",
65
+ "那样",
66
+ "那樣",
67
+ ]);
68
+ /**
69
+ * The modifiers that pick out words of a kind after a verb of speaking.
70
+ *
71
+ * 说这样的话 is saying such things, where 这样的话 alone is *in that case*.
72
+ */
73
+ export const KIND = new Set([
74
+ ...MANNER,
75
+ "同样",
76
+ "同樣",
77
+ "这种",
78
+ "這種",
79
+ "那种",
80
+ "那種",
81
+ ]);
82
+ /**
83
+ * The pronouns that make 的话 someone's words: 他的话, 听妈妈的话.
84
+ *
85
+ * Personal pronouns only. 这样 is tagged a pronoun as well, and 这样的话 is the
86
+ * conditional far more often than it is anything else.
87
+ */
88
+ export const PERSONS = new Set([
89
+ "我",
90
+ "你",
91
+ "他",
92
+ "她",
93
+ "您",
94
+ "我们",
95
+ "我們",
96
+ "你们",
97
+ "你們",
98
+ "他们",
99
+ "他們",
100
+ "她们",
101
+ "她們",
102
+ "咱们",
103
+ "咱們",
104
+ "别人",
105
+ "別人",
106
+ "人家",
107
+ "大家",
108
+ ]);
109
+ /** The tags of a noun that can own its words: 老师, 汤姆. */
110
+ export const OWNER_TAGS = /^(?:n|nr|nrfg|nrt)$/u;
111
+ /**
112
+ * The verbs whose object is somebody's words, 听他的话 and 相信你的话.
113
+ *
114
+ * Each takes what was said rather than an action, which is why 帮助我的话 and
115
+ * 陪我的话 stay conditional while 相信我的话 does not. 把, 对 and 因为 are in for
116
+ * the same reason: 把你的话转告给他, 对我的话充耳不闻 and 因为他的话 have the
117
+ * words as their object.
118
+ */
119
+ export const RECEIVING = new Set([
120
+ "听",
121
+ "聽",
122
+ "听见",
123
+ "聽見",
124
+ "听到",
125
+ "聽到",
126
+ "听从",
127
+ "聽從",
128
+ "聆听",
129
+ "聆聽",
130
+ "相信",
131
+ "怀疑",
132
+ "懷疑",
133
+ "收回",
134
+ "引用",
135
+ "回味",
136
+ "转告",
137
+ "轉告",
138
+ "听懂",
139
+ "聽懂",
140
+ "听不懂",
141
+ "聽不懂",
142
+ "判断",
143
+ "判斷",
144
+ "记得",
145
+ "記得",
146
+ "因为",
147
+ "因為",
148
+ "照",
149
+ "把",
150
+ "对",
151
+ "對",
152
+ ]);
153
+ /** What can negate a receiving verb inside a word of its own: 不听, 没听. */
154
+ export const NEGATION = /^[不没沒]/u;
155
+ /** The characters a receiving verb can carry before its object: 听了, 听完了. */
156
+ export const RECEIVING_TAIL = new Set(["了", "完"]);
157
+ /**
158
+ * When the words were said, which a conditional cannot be about: 刚才的话.
159
+ */
160
+ export const EARLIER = new Set(["刚才", "剛才", "刚刚", "剛剛"]);
161
+ //# sourceMappingURL=hua-words.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hua-words.js","sourceRoot":"","sources":["../../src/decode/hua-words.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,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AI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC,CAAC;AAEH,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IAC/B,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;CACJ,CAAC,CAAC;AAEH,yEAAyE;AACzE,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAElC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,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,QAAQ,CAAC,KAAK,KAAK,KAAK,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,CAC7E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,OAAoB,EAAE,EAAU;IAC3D,M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AAC,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;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEvE;;;;GAIG;AACH,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,KAAK,GAAG,CAAC,CAAC;AAEhB;;GAEG;AACH,SAAS,WAAW,CAAC,OAAoB,EAAE,EAAU;IACnD,IAAI,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;IAClB,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACjD,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,IAAI,EAAE,CAAC;YACP,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YACzD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;YAC3C,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC;IAC5B,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"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Whether a 量 is measuring something or is an amount.
3
+ *
4
+ * The verb is `liáng` and the noun `liàng`. The noun stands on its own mostly
5
+ * as the tail of a compound the dictionary lacks: 乘客量, 排放量, 信息量. The
6
+ * verb has someone doing the measuring in front of it and the thing measured,
7
+ * or 了 or 一下, after it.
8
+ */
9
+ import { tagOf, wordEndingAt, wordStartingAt, } from "./rules.js";
10
+ import { isBareAt, startsWithAny, syllableOf, charactersOf, } from "./verbal-frame.js";
11
+ /**
12
+ * What a measuring 量 takes straight after it: aspect, or how often.
13
+ *
14
+ * 量了我的体温, 量一下门的宽度, 我每六小时量一次体温. 量过 is left out, because
15
+ * 需求量过大 is "the demand is too great".
16
+ */
17
+ const ASPECT = new Set(["了", "着"]);
18
+ /**
19
+ * How many times, which only a verb is followed by.
20
+ */
21
+ const TIMES = ["一下", "一次", "一遍"];
22
+ /**
23
+ * What is measured: the body's readings and a thing's dimensions.
24
+ *
25
+ * 量体温, 量血压, 量门的宽度. The 的 of the last is what this cannot see past,
26
+ * so the word has to stand straight after the 量.
27
+ */
28
+ const MEASURED = [
29
+ "体温",
30
+ "血压",
31
+ "身高",
32
+ "体重",
33
+ "脉搏",
34
+ "尺寸",
35
+ "长度",
36
+ "宽度",
37
+ "高度",
38
+ "厚度",
39
+ "深度",
40
+ "直径",
41
+ "腰围",
42
+ "胸围",
43
+ "距离",
44
+ "面积",
45
+ "温度",
46
+ ];
47
+ /**
48
+ * What can come straight before a 量 that is measuring.
49
+ *
50
+ * Asking someone to (请, 帮), being in the middle of it (正在), and the modals
51
+ * (要, 会, 可以). None of these makes a compound with 量. 能 does, which is
52
+ * why it is out.
53
+ */
54
+ const BEFORE = new Set([
55
+ "请",
56
+ "帮",
57
+ "给",
58
+ "正在",
59
+ "再",
60
+ "先",
61
+ "要",
62
+ "会",
63
+ "可以",
64
+ ]);
65
+ /**
66
+ * The tag prefix jieba gives a noun.
67
+ */
68
+ const NOUN_TAG = "n";
69
+ /**
70
+ * Whether the 量 at a position is measuring.
71
+ *
72
+ * Where nothing after it says so, the word in front of it has to, and
73
+ * something measurable has to follow: 正在量病人的脉搏.
74
+ */
75
+ function isMeasuringAt(context, at) {
76
+ const { characters } = context;
77
+ if (isBareAt(context, at + 1, ASPECT) ||
78
+ startsWithAny(context, at + 1, TIMES) ||
79
+ startsWithAny(context, at + 1, MEASURED) ||
80
+ characters[at + 1] === "量" ||
81
+ characters[at - 1] === "量") {
82
+ return true;
83
+ }
84
+ const before = wordEndingAt(context, at);
85
+ return (before !== undefined &&
86
+ BEFORE.has(before) &&
87
+ tagOf(context, wordStartingAt(context, at + 1)).startsWith(NOUN_TAG));
88
+ }
89
+ /**
90
+ * The characters that bind it into a compound reading it otherwise.
91
+ *
92
+ * Bound before it: 打量, 商量, 能量, 测量, 考量 and the rest of the compounds
93
+ * reading it `liàng` or as the tail of a verb of their own. Bound after it:
94
+ * 量力, 量产, 量子, 量词. 能 is a modal as well, and 你能量一下吗 is lost to
95
+ * 能量, which is the commoner by far.
96
+ */
97
+ const BOUND_BEFORE = charactersOf("打商思估掂酌衡丈测測考能力质質数數重容含流产產销銷雨剂劑胆膽热熱音尽盡大少适適总總增计計度用储儲存变變等限降雪电電光当當");
98
+ /**
99
+ * The characters after it that bind it into such a compound.
100
+ */
101
+ const BOUND_AFTER = charactersOf("力产產子词詞刑化级級表程变變");
102
+ /**
103
+ * 量 read `liáng` where it is measuring.
104
+ */
105
+ export const LIANG_FRAME = {
106
+ characters: new Set(["量"]),
107
+ reading: syllableOf("liáng"),
108
+ boundBefore: BOUND_BEFORE,
109
+ boundAfter: BOUND_AFTER,
110
+ isVerbalAt: isMeasuringAt,
111
+ };
112
+ //# sourceMappingURL=liang-frames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liang-frames.js","sourceRoot":"","sources":["../../src/decode/liang-frames.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAEL,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,QAAQ,EACR,aAAa,EACb,UAAU,EAEV,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEnC;;GAEG;AACH,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,QAAQ,GAAG;IACf,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;IACrB,GAAG;IACH,GAAG;IACH,GAAG;IACH,IAAI;IACJ,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,IAAI;CACL,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB;;;;;GAKG;AACH,SAAS,aAAa,CAAC,OAAoB,EAAE,EAAU;IACrD,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,IACE,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QACjC,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC;QACrC,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC;QACxC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG;QAC1B,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,EAC1B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACzC,OAAO,CACL,MAAM,KAAK,SAAS;QACpB,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;QAClB,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CACrE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,YAAY,CAC/B,8DAA8D,CAC/D,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,UAAU,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;IAC5B,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,aAAa;CAC1B,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { type EdgeRule } from "./rules.js";
2
+ /**
3
+ * A 量词 with a number in front of it does not start the next word.
4
+ *
5
+ * 三个人 is three people and came out `sān gèrén`, three *personals*, because
6
+ * 个人 is a common noun and nothing weighed it against the 个 belonging to the
7
+ * 三 in front of it. The same swallow takes 一杯水 into 杯水, 两家俱乐部 into
8
+ * 家俱 and 一天天 into 天天; digits reach it too, since a run decoded after a
9
+ * number sees that number — see `decodeRun` — so 2个人 is the same case.
10
+ *
11
+ * What makes it decidable is that the dictionary tags the 量词: 个, 次, 天, 位,
12
+ * 杯 and 匹 are `q`, while the characters that only look like measure words in
13
+ * this position are not — 分 is `v`, 部 and 成 are `n`, 年 and 点 are `m`. So
14
+ * 五分钟, 三部分, 五成分, 五年级 and 三点钟 are untouched, and those are exactly
15
+ * the words a blanket rule would break. A word that is itself a 量词 is kept as
16
+ * well, since 分钟 and 点钟 are units rather than something being counted.
17
+ *
18
+ * Only the edge *starting at the 量词* is forbidden, so a number and its
19
+ * measure written solid survive whole where the dictionary has them: 一辈子 and
20
+ * 一会儿 are entries covering the number too, and the decode still reaches them.
21
+ *
22
+ * Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
23
+ * rules were sized against, it forbids 561 edges across 144 shapes — 个人 203
24
+ * of them, then 杯水, 天一, 口气, 些小 and 家人 — and moves 53 decodes, since
25
+ * most of what it takes away the cost model was not going to choose anyway.
26
+ * Three of the 53 are wrong: 一批评, 这一名词 and 六七股灾, where the 一 and the
27
+ * 六七 count nothing and no tag says so. Exactly one reading changes over the
28
+ * corpus and it is a fix, 下了两天雨 having read 天雨 as `tiān yù`.
29
+ */
30
+ export declare const COUNTED_MEASURE: EdgeRule;
31
+ //# sourceMappingURL=measure-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measure-rule.d.ts","sourceRoot":"","sources":["../../src/decode/measure-rule.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,QAAQ,EAGd,MAAM,YAAY,CAAC;AAsCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,eAAe,EAAE,QAuB7B,CAAC"}