@kensio/pinyinjs 1.7.5 → 1.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +128 -123
  2. package/data/full.entries +2637 -2637
  3. package/data/manifest.json +9 -9
  4. package/data/script.map +168 -3
  5. package/data/standard.entries +8 -8
  6. package/dist/decode/chang-complement.d.ts +19 -0
  7. package/dist/decode/chang-complement.d.ts.map +1 -0
  8. package/dist/decode/chang-complement.js +113 -0
  9. package/dist/decode/chang-complement.js.map +1 -0
  10. package/dist/decode/chang-context.d.ts +29 -0
  11. package/dist/decode/chang-context.d.ts.map +1 -0
  12. package/dist/decode/chang-context.js +99 -0
  13. package/dist/decode/chang-context.js.map +1 -0
  14. package/dist/decode/chang-rule.d.ts +47 -0
  15. package/dist/decode/chang-rule.d.ts.map +1 -0
  16. package/dist/decode/chang-rule.js +188 -0
  17. package/dist/decode/chang-rule.js.map +1 -0
  18. package/dist/decode/confidence.d.ts +11 -3
  19. package/dist/decode/confidence.d.ts.map +1 -1
  20. package/dist/decode/confidence.js +11 -3
  21. package/dist/decode/confidence.js.map +1 -1
  22. package/dist/decode/convert-pipeline.d.ts.map +1 -1
  23. package/dist/decode/convert-pipeline.js +5 -4
  24. package/dist/decode/convert-pipeline.js.map +1 -1
  25. package/dist/decode/de-rule.d.ts +74 -0
  26. package/dist/decode/de-rule.d.ts.map +1 -0
  27. package/dist/decode/de-rule.js +199 -0
  28. package/dist/decode/de-rule.js.map +1 -0
  29. package/dist/decode/decode.d.ts +12 -25
  30. package/dist/decode/decode.d.ts.map +1 -1
  31. package/dist/decode/decode.js +10 -47
  32. package/dist/decode/decode.js.map +1 -1
  33. package/dist/decode/decoders.d.ts +9 -4
  34. package/dist/decode/decoders.d.ts.map +1 -1
  35. package/dist/decode/decoders.js +7 -7
  36. package/dist/decode/decoders.js.map +1 -1
  37. package/dist/decode/edge-context.d.ts +19 -0
  38. package/dist/decode/edge-context.d.ts.map +1 -1
  39. package/dist/decode/edge-context.js +41 -0
  40. package/dist/decode/edge-context.js.map +1 -1
  41. package/dist/decode/hint-lattice.d.ts.map +1 -1
  42. package/dist/decode/hint-lattice.js +17 -3
  43. package/dist/decode/hint-lattice.js.map +1 -1
  44. package/dist/decode/jiao-rule.d.ts +9 -3
  45. package/dist/decode/jiao-rule.d.ts.map +1 -1
  46. package/dist/decode/jiao-rule.js +44 -5
  47. package/dist/decode/jiao-rule.js.map +1 -1
  48. package/dist/decode/lattice-decode.d.ts +28 -0
  49. package/dist/decode/lattice-decode.d.ts.map +1 -0
  50. package/dist/decode/lattice-decode.js +48 -0
  51. package/dist/decode/lattice-decode.js.map +1 -0
  52. package/dist/decode/lattice-slice.d.ts +22 -6
  53. package/dist/decode/lattice-slice.d.ts.map +1 -1
  54. package/dist/decode/lattice-slice.js +24 -18
  55. package/dist/decode/lattice-slice.js.map +1 -1
  56. package/dist/decode/lattice-types.d.ts +27 -8
  57. package/dist/decode/lattice-types.d.ts.map +1 -1
  58. package/dist/decode/lattice-types.js +27 -8
  59. package/dist/decode/lattice-types.js.map +1 -1
  60. package/dist/decode/numbers.d.ts +0 -8
  61. package/dist/decode/numbers.d.ts.map +1 -1
  62. package/dist/decode/numbers.js +0 -10
  63. package/dist/decode/numbers.js.map +1 -1
  64. package/dist/decode/polyphone-rules.d.ts +7 -27
  65. package/dist/decode/polyphone-rules.d.ts.map +1 -1
  66. package/dist/decode/polyphone-rules.js +7 -155
  67. package/dist/decode/polyphone-rules.js.map +1 -1
  68. package/dist/decode/reading-rules.d.ts +1 -29
  69. package/dist/decode/reading-rules.d.ts.map +1 -1
  70. package/dist/decode/reading-rules.js +5 -69
  71. package/dist/decode/reading-rules.js.map +1 -1
  72. package/dist/decode/rules.d.ts +1 -1
  73. package/dist/decode/rules.d.ts.map +1 -1
  74. package/dist/decode/rules.js +1 -1
  75. package/dist/decode/rules.js.map +1 -1
  76. package/dist/decode/run-context.d.ts +33 -0
  77. package/dist/decode/run-context.d.ts.map +1 -0
  78. package/dist/decode/run-context.js +47 -0
  79. package/dist/decode/run-context.js.map +1 -0
  80. package/dist/decode/run-lattice.d.ts +13 -10
  81. package/dist/decode/run-lattice.d.ts.map +1 -1
  82. package/dist/decode/run-lattice.js +15 -12
  83. package/dist/decode/run-lattice.js.map +1 -1
  84. package/dist/decode/run-words.d.ts +17 -0
  85. package/dist/decode/run-words.d.ts.map +1 -0
  86. package/dist/decode/run-words.js +29 -0
  87. package/dist/decode/run-words.js.map +1 -0
  88. package/dist/decode/sandhi-input.d.ts +30 -0
  89. package/dist/decode/sandhi-input.d.ts.map +1 -0
  90. package/dist/decode/sandhi-input.js +35 -0
  91. package/dist/decode/sandhi-input.js.map +1 -0
  92. package/dist/decode/sandhi-tones.d.ts +33 -5
  93. package/dist/decode/sandhi-tones.d.ts.map +1 -1
  94. package/dist/decode/sandhi-tones.js +59 -8
  95. package/dist/decode/sandhi-tones.js.map +1 -1
  96. package/dist/decode/sandhi.d.ts +9 -6
  97. package/dist/decode/sandhi.d.ts.map +1 -1
  98. package/dist/decode/sandhi.js +10 -7
  99. package/dist/decode/sandhi.js.map +1 -1
  100. package/dist/decode/script-region.d.ts +15 -0
  101. package/dist/decode/script-region.d.ts.map +1 -0
  102. package/dist/decode/script-region.js +61 -0
  103. package/dist/decode/script-region.js.map +1 -0
  104. package/dist/decode/script-types.d.ts +11 -2
  105. package/dist/decode/script-types.d.ts.map +1 -1
  106. package/dist/decode/script-types.js +2 -1
  107. package/dist/decode/script-types.js.map +1 -1
  108. package/dist/decode/script-words.d.ts +7 -5
  109. package/dist/decode/script-words.d.ts.map +1 -1
  110. package/dist/decode/script-words.js +18 -25
  111. package/dist/decode/script-words.js.map +1 -1
  112. package/dist/decode/script.d.ts.map +1 -1
  113. package/dist/decode/script.js +2 -1
  114. package/dist/decode/script.js.map +1 -1
  115. package/dist/decode/write-run.d.ts +0 -7
  116. package/dist/decode/write-run.d.ts.map +1 -1
  117. package/dist/decode/write-run.js +4 -39
  118. package/dist/decode/write-run.js.map +1 -1
  119. package/dist/dictionary/cedict-senses.d.ts +7 -0
  120. package/dist/dictionary/cedict-senses.d.ts.map +1 -1
  121. package/dist/dictionary/cedict-senses.js +12 -0
  122. package/dist/dictionary/cedict-senses.js.map +1 -1
  123. package/dist/dictionary/constituent-repair.d.ts +36 -0
  124. package/dist/dictionary/constituent-repair.d.ts.map +1 -0
  125. package/dist/dictionary/constituent-repair.js +117 -0
  126. package/dist/dictionary/constituent-repair.js.map +1 -0
  127. package/dist/dictionary/measure-tone.d.ts +36 -0
  128. package/dist/dictionary/measure-tone.d.ts.map +1 -0
  129. package/dist/dictionary/measure-tone.js +139 -0
  130. package/dist/dictionary/measure-tone.js.map +1 -0
  131. package/dist/dictionary/merge-types.d.ts +13 -2
  132. package/dist/dictionary/merge-types.d.ts.map +1 -1
  133. package/dist/dictionary/merge-types.js.map +1 -1
  134. package/dist/dictionary/merge-walk.d.ts +27 -0
  135. package/dist/dictionary/merge-walk.d.ts.map +1 -0
  136. package/dist/dictionary/merge-walk.js +49 -0
  137. package/dist/dictionary/merge-walk.js.map +1 -0
  138. package/dist/dictionary/merge.d.ts +3 -3
  139. package/dist/dictionary/merge.d.ts.map +1 -1
  140. package/dist/dictionary/merge.js +24 -28
  141. package/dist/dictionary/merge.js.map +1 -1
  142. package/dist/dictionary/overrides.d.ts +5 -0
  143. package/dist/dictionary/overrides.d.ts.map +1 -1
  144. package/dist/dictionary/overrides.js +5 -5
  145. package/dist/dictionary/overrides.js.map +1 -1
  146. package/dist/dictionary/script-tables.js +91 -13
  147. package/dist/dictionary/script-tables.js.map +1 -1
  148. package/dist/dictionary/word-readings.d.ts.map +1 -1
  149. package/dist/dictionary/word-readings.js +6 -0
  150. package/dist/dictionary/word-readings.js.map +1 -1
  151. package/dist/index.d.ts +1 -1
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +1 -1
  154. package/dist/index.js.map +1 -1
  155. package/dist/script/glyphs.d.ts +9 -8
  156. package/dist/script/glyphs.d.ts.map +1 -1
  157. package/dist/script/glyphs.js +21 -48
  158. package/dist/script/glyphs.js.map +1 -1
  159. package/dist/script/reading-splits.d.ts +41 -0
  160. package/dist/script/reading-splits.d.ts.map +1 -0
  161. package/dist/script/reading-splits.js +98 -0
  162. package/dist/script/reading-splits.js.map +1 -0
  163. package/package.json +2 -2
@@ -1,31 +1,11 @@
1
- export { PLAYING_TAN } from "./tan-rule.js";
2
- import { type EdgeRule } from "./rules.js";
3
1
  /**
4
- * 长 read as `cháng` where an adverb of degree measures it.
5
- *
6
- * The character is stored `zhǎng` with `cháng` as an alternate, and the data
7
- * says so about the character in isolation: Unihan ranks the readings
8
- * `zhǎng(1879) cháng(1179)` by corpus count and names `zhǎng` in `kMandarin`.
9
- * That ranking is doing real work — 署长, 团长, 公安局长, 总会长, 审理长 and
10
- * the rest reach a bare 长 at the end of a title and read it correctly — so the
11
- * default is not the thing to change. What is left over is the 长 that is an
12
- * adjective, and nothing in the cost model can prefer an alternate at a
13
- * position no word covers: 这篇文章不太长 came out `bú tài zhǎng`.
14
- *
15
- * The context that separates them is one-sided, as it was for the modal 得. A
16
- * 长 that is *growing* is a verb, and a degree adverb cannot modify one — there
17
- * is no 很长 meaning it grew a lot — so 很, 太, 最, 多 and their kin in front of
18
- * a bare 长 make it the adjective. The other side carries almost nothing: what
19
- * follows an adjectival 长 is a noun (很长时间), a particle (最长的大桥), or the
20
- * end of the sentence (他的腿很长), which is also what follows half the verbs.
2
+ * The rules that settle a polyphone from the words around it.
21
3
  *
22
- * Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
23
- * rules were sized against, 260 长 decode as a word of their own and this moves
24
- * 75 of them to `cháng`, all 75 correctly. On CPP's 40 hand-labelled 长 it takes
25
- * the character from 85.00% to 87.50%, fixing 时间最长 and breaking nothing.
26
- *
27
- * The other half of the rule is {@link GROWN_INTO}, which pushes the opposite
28
- * way on the one shape the sources get wrong.
4
+ * 弹 is `tán` or `dàn`, and which one a text means is a question about the
5
+ * neighbours rather than about the character. 长 is the same question and has
6
+ * a file of its own. The other rules in `reading-rules.ts` are about particles
7
+ * and 儿化, which is a different kind of evidence.
29
8
  */
30
- export declare const ADJECTIVAL_CHANG: EdgeRule;
9
+ export { ADJECTIVAL_CHANG } from "./chang-rule.js";
10
+ export { PLAYING_TAN } from "./tan-rule.js";
31
11
  //# sourceMappingURL=polyphone-rules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"polyphone-rules.d.ts","sourceRoot":"","sources":["../../src/decode/polyphone-rules.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAoB,KAAK,QAAQ,EAAgB,MAAM,YAAY,CAAC;AA2H3E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAgB9B,CAAC"}
1
+ {"version":3,"file":"polyphone-rules.d.ts","sourceRoot":"","sources":["../../src/decode/polyphone-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -1,159 +1,11 @@
1
- export { PLAYING_TAN } from "./tan-rule.js";
2
- import { wordEndingAt } from "./rules.js";
3
- /**
4
- * Whether a syllable is `cháng`, the stative reading of 长.
5
- */
6
- function isChang(syllable) {
7
- return (syllable?.initial === "ch" &&
8
- syllable.final === "ang" &&
9
- syllable.tone === 2);
10
- }
11
- /**
12
- * Adverbs that measure a quality rather than modify an action.
13
- *
14
- * The discriminating side of the 长 context, and the reason the set is written
15
- * out rather than taken from a tag: jieba calls 很 `zg` and 多 `m`, so the two
16
- * commonest members are not adverbs as far as the dictionary is concerned,
17
- * while 已经, 也, 却 and 就 — which sit in front of the *verb* 长 — are `d`
18
- * along with the ones wanted here. The tag names the wrong set in both
19
- * directions, so the set is named directly.
20
- *
21
- * Everything here is degree or comparison. 还 and 不 are deliberately absent
22
- * even though 距离还长 and 那座桥不长 are both `cháng`: they modify verbs as
23
- * readily as qualities, and 还长有毛 and 胡子不长在前额上 are the same two
24
- * characters around the verb.
25
- */
26
- const DEGREE = new Set([
27
- "一样",
28
- "十分",
29
- "多",
30
- "多么",
31
- "好",
32
- "如此",
33
- "尽量",
34
- "很",
35
- "格外",
36
- "极",
37
- "极其",
38
- "比较",
39
- "略",
40
- "相当",
41
- "真",
42
- "稍",
43
- "稍微",
44
- "越",
45
- "越来越",
46
- "这么",
47
- "这样",
48
- "那么",
49
- "那样",
50
- "更",
51
- "最",
52
- "有多",
53
- "特别",
54
- "老",
55
- "够",
56
- "挺",
57
- "太",
58
- "非常",
59
- ]);
60
- /**
61
- * What shows a 长 to be growing even with a degree word in front of it.
62
- *
63
- * {@link DEGREE} already excludes nearly everything that precedes the verb, so
64
- * this only has to settle the three shapes reachable from both sets: 真长得很快
65
- * and 越长得快, where 得 marks the complement; 长着, where the aspect does; and
66
- * 越长越高, where the correlative makes the 长 the thing that increases.
67
- *
68
- * 了 and 的 are pointedly *not* here, and that is the whole use of conditioning
69
- * on the adverb first. Following a bare 长 either would suggest the verb — 长了
70
- * 一个大包, 长的很像 — but following an adverb and a 长 they are the sentence
71
- * particle and the attributive: 时间太长了 and 很长的道路 are both `cháng`, and
72
- * an earlier draft of this rule that guarded on them read both as `zhǎng`.
73
- */
74
- const GROWING = new Set(["得", "着", "越"]);
75
1
  /**
76
- * What growing produces, as the far half of 越长越X.
2
+ * The rules that settle a polyphone from the words around it.
77
3
  *
78
- * 越长越高, 越长越大, 越长越胖: each names a dimension that increases *because*
79
- * something grew, so the 长 in front of it is the verb. The adjectives that go
80
- * with a length or a duration are pointedly absent — 时间越长越好, 队伍越长越慢
81
- * — because those are the cases the sources already read correctly.
4
+ * 弹 is `tán` or `dàn`, and which one a text means is a question about the
5
+ * neighbours rather than about the character. 长 is the same question and has
6
+ * a file of its own. The other rules in `reading-rules.ts` are about particles
7
+ * and 儿化, which is a different kind of evidence.
82
8
  */
83
- const GROWN_INTO = new Set(["高", "大", "胖", "壮", "结实"]);
84
- /**
85
- * Whether an edge is the 越长 of a 越长越X saying something grew.
86
- *
87
- * This exists because of a defect in the sources rather than a gap in them.
88
- * 越长 is a key, read `yuè cháng`, and it is the *only* one of its shape: 越大,
89
- * 越高, 越好, 越快 and 越多 are all absent, so 越高越好 decodes as two words and
90
- * 越长越高 reaches for a word nothing else in the paradigm has. It carries no
91
- * part of speech, which is how the dictionary holds a reading somebody asserted
92
- * rather than a word anybody counted — the same category {@link TEACHING_JIAO}
93
- * declines to trust — and it comes from one source, `large_pinyin.txt`, with
94
- * CC-CEDICT holding no such entry.
95
- *
96
- * Taking the edge away leaves the character's own default, which is `zhǎng`,
97
- * and leaves `cháng` standing as a rival about one bucket dearer. That last
98
- * part is the point of forbidding rather than forcing: 越长越X is genuinely
99
- * ambiguous — 孩子越长越漂亮 grows and 头发越长越漂亮 lengthens, and only the
100
- * subject says which — so the decode should answer with the likelier reading
101
- * and still report itself as guessing. A forced edge could not.
102
- *
103
- * Unlike the rest of this file the shape has no corpus behind it: 越长 occurs
104
- * three times in the 88,866 lines, and all three are 越来越长 or 说的越长. The
105
- * word list is therefore small on purpose, and everything outside it is left as
106
- * the sources have it.
107
- */
108
- function isGrowthCorrelative(context) {
109
- const { characters, edge } = context;
110
- return (edge.text === "越长" &&
111
- edge.partOfSpeech === "" &&
112
- characters[edge.to] === "越" &&
113
- GROWN_INTO.has(characters[edge.to + 1] ?? ""));
114
- }
115
- /**
116
- * 长 read as `cháng` where an adverb of degree measures it.
117
- *
118
- * The character is stored `zhǎng` with `cháng` as an alternate, and the data
119
- * says so about the character in isolation: Unihan ranks the readings
120
- * `zhǎng(1879) cháng(1179)` by corpus count and names `zhǎng` in `kMandarin`.
121
- * That ranking is doing real work — 署长, 团长, 公安局长, 总会长, 审理长 and
122
- * the rest reach a bare 长 at the end of a title and read it correctly — so the
123
- * default is not the thing to change. What is left over is the 长 that is an
124
- * adjective, and nothing in the cost model can prefer an alternate at a
125
- * position no word covers: 这篇文章不太长 came out `bú tài zhǎng`.
126
- *
127
- * The context that separates them is one-sided, as it was for the modal 得. A
128
- * 长 that is *growing* is a verb, and a degree adverb cannot modify one — there
129
- * is no 很长 meaning it grew a lot — so 很, 太, 最, 多 and their kin in front of
130
- * a bare 长 make it the adjective. The other side carries almost nothing: what
131
- * follows an adjectival 长 is a noun (很长时间), a particle (最长的大桥), or the
132
- * end of the sentence (他的腿很长), which is also what follows half the verbs.
133
- *
134
- * Measured over the same 88,866 lines of Tatoeba and zh.wikipedia the other
135
- * rules were sized against, 260 长 decode as a word of their own and this moves
136
- * 75 of them to `cháng`, all 75 correctly. On CPP's 40 hand-labelled 长 it takes
137
- * the character from 85.00% to 87.50%, fixing 时间最长 and breaking nothing.
138
- *
139
- * The other half of the rule is {@link GROWN_INTO}, which pushes the opposite
140
- * way on the one shape the sources get wrong.
141
- */
142
- export const ADJECTIVAL_CHANG = {
143
- name: "adjectival-chang",
144
- verdictFor: (context) => {
145
- const { characters, edge } = context;
146
- if (isGrowthCorrelative(context)) {
147
- return "forbid";
148
- }
149
- if (edge.text !== "长" || !isChang(edge.reading[0])) {
150
- return "keep";
151
- }
152
- if (GROWING.has(characters[edge.to] ?? "")) {
153
- return "keep";
154
- }
155
- const before = wordEndingAt(context, edge.from);
156
- return before !== undefined && DEGREE.has(before) ? "force" : "keep";
157
- },
158
- };
9
+ export { ADJECTIVAL_CHANG } from "./chang-rule.js";
10
+ export { PLAYING_TAN } from "./tan-rule.js";
159
11
  //# sourceMappingURL=polyphone-rules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"polyphone-rules.js","sourceRoot":"","sources":["../../src/decode/polyphone-rules.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAmC,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3E;;GAEG;AACH,SAAS,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IAAI,EAAE,CAAC,CAC9C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACxC,IAAI,EAAE,kBAAkB;IACxB,UAAU,EAAE,CAAC,OAAoB,EAAE,EAAE;QACnC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACrC,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACnD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAC3C,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IACvE,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"polyphone-rules.js","sourceRoot":"","sources":["../../src/decode/polyphone-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -1,34 +1,6 @@
1
+ export { MODAL_DE, PARTICLE_DE, POTENTIAL_DE } from "./de-rule.js";
1
2
  export { TEACHING_JIAO } from "./jiao-rule.js";
2
3
  import { type EdgeRule } from "./rules.js";
3
- /**
4
- * 得 read as `děi` where it is a modal rather than a particle.
5
- *
6
- * One character, three readings, and the dictionary can only carry a default:
7
- * 得 is stored `de` — the structural particle, which is far the commonest — with
8
- * `dé` and `děi` as alternates. Nothing in the cost model can prefer an
9
- * alternate at a position no word covers, so 我得走了 came out `wǒ de zǒule`
10
- * and every other modal 得 with it. This is the case ROADMAP.md was waiting for
11
- * before building stage 4: neither harness could see it, since the gold corpus
12
- * had only 觉得 and CPP's 40 得 cases are labelled `dé` or `de` and never `děi`.
13
- *
14
- * The context is what separates the three, and only one side of it carries
15
- * information. The particle 得 always follows the verb or adjective it attaches
16
- * to (说得好, 跑得快, 累得要命), so a 得 with a *pronoun, adverb or time word*
17
- * in front of it is not that particle. Requiring a verb phrase after it as well
18
- * keeps 得了感冒 and 得了奖 — `dé`, and a real reading of the same character —
19
- * out of it.
20
- *
21
- * Conditioning on what precedes rather than on what follows was measured, not
22
- * assumed: "the word before is not a verb" fires 309 times over 88,866 lines of
23
- * Tatoeba and zh.wikipedia and is wrong about four times in five, because
24
- * jieba tags 下 as `f`, 学 as `n` and 飞 as nothing at all, and 雨下得很大 is a
25
- * particle whatever the tag says. Naming the small closed set of things that
26
- * can precede a modal is the same rule from the other side, and over the same
27
- * text it fires 126 times and is right 122: the four misses are literary 得
28
- * read `dé` after an adverb — 未必得喜悦, 暂得于己, 仅得约, 未得迁还家乡 —
29
- * which nothing short of semantics separates from 必须得承认.
30
- */
31
- export declare const MODAL_DE: EdgeRule;
32
4
  /**
33
5
  * 儿 does not stand on its own where the dictionary attests the 儿化.
34
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"reading-rules.d.ts","sourceRoot":"","sources":["../../src/decode/reading-rules.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAEL,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAgCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,QAAQ,EAAE,QActB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,EAAE,QAY5B,CAAC;AAsCF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,eAAe,EAAE,QAuB7B,CAAC;AAIF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,QAAQ,EAO5C,CAAC"}
1
+ {"version":3,"file":"reading-rules.d.ts","sourceRoot":"","sources":["../../src/decode/reading-rules.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAEL,KAAK,QAAQ,EAGd,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,EAAE,QAY5B,CAAC;AAsCF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,eAAe,EAAE,QAuB7B,CAAC;AAIF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,QAAQ,EAS5C,CAAC"}
@@ -1,76 +1,10 @@
1
1
  import { QUANTITY_CHARACTERS } from "../numerals/characters.js";
2
+ import { MODAL_DE, PARTICLE_DE, POTENTIAL_DE } from "./de-rule.js";
2
3
  import { TEACHING_JIAO } from "./jiao-rule.js";
4
+ export { MODAL_DE, PARTICLE_DE, POTENTIAL_DE } from "./de-rule.js";
3
5
  export { TEACHING_JIAO } from "./jiao-rule.js";
4
6
  import { toCharacters } from "../script/characters.js";
5
- import { tagOf, wordEndingAt, wordStartingAt, } from "./rules.js";
6
- /**
7
- * Whether a syllable is `děi`, the modal reading of 得.
8
- *
9
- * Compared structurally rather than by spelling it out, since a syllable is
10
- * stored as its parts and writing one back is the formatting stage's job.
11
- */
12
- function isDei(syllable) {
13
- return (syllable?.initial === "d" && syllable.final === "ei" && syllable.tone === 3);
14
- }
15
- /**
16
- * What stands in front of a modal 得: a subject, an adverb, or a time word.
17
- *
18
- * 我得走, 你就得去, 我今天得走. The particle 得 cannot follow any of these,
19
- * because it attaches to the predicate it modifies — which is exactly what
20
- * makes this the discriminating side of the context.
21
- */
22
- const SUBJECT_TAGS = new Set(["r", "d", "t"]);
23
- /**
24
- * What follows a modal 得: the verb phrase it governs.
25
- *
26
- * Prepositions and adverbs are in because 我得在八月, 我得先走 and 我得快点 are
27
- * all modal, and what follows the 得 in each is the front of a verb phrase
28
- * rather than a verb.
29
- */
30
- const GOVERNED_TAGS = /^(?:v|p|d|a)/u;
31
- /**
32
- * 得 read as `děi` where it is a modal rather than a particle.
33
- *
34
- * One character, three readings, and the dictionary can only carry a default:
35
- * 得 is stored `de` — the structural particle, which is far the commonest — with
36
- * `dé` and `děi` as alternates. Nothing in the cost model can prefer an
37
- * alternate at a position no word covers, so 我得走了 came out `wǒ de zǒule`
38
- * and every other modal 得 with it. This is the case ROADMAP.md was waiting for
39
- * before building stage 4: neither harness could see it, since the gold corpus
40
- * had only 觉得 and CPP's 40 得 cases are labelled `dé` or `de` and never `děi`.
41
- *
42
- * The context is what separates the three, and only one side of it carries
43
- * information. The particle 得 always follows the verb or adjective it attaches
44
- * to (说得好, 跑得快, 累得要命), so a 得 with a *pronoun, adverb or time word*
45
- * in front of it is not that particle. Requiring a verb phrase after it as well
46
- * keeps 得了感冒 and 得了奖 — `dé`, and a real reading of the same character —
47
- * out of it.
48
- *
49
- * Conditioning on what precedes rather than on what follows was measured, not
50
- * assumed: "the word before is not a verb" fires 309 times over 88,866 lines of
51
- * Tatoeba and zh.wikipedia and is wrong about four times in five, because
52
- * jieba tags 下 as `f`, 学 as `n` and 飞 as nothing at all, and 雨下得很大 is a
53
- * particle whatever the tag says. Naming the small closed set of things that
54
- * can precede a modal is the same rule from the other side, and over the same
55
- * text it fires 126 times and is right 122: the four misses are literary 得
56
- * read `dé` after an adverb — 未必得喜悦, 暂得于己, 仅得约, 未得迁还家乡 —
57
- * which nothing short of semantics separates from 必须得承认.
58
- */
59
- export const MODAL_DE = {
60
- name: "modal-de",
61
- verdictFor: (context) => {
62
- const { edge } = context;
63
- if (edge.text !== "得" || !isDei(edge.reading[0])) {
64
- return "keep";
65
- }
66
- const before = wordEndingAt(context, edge.from);
67
- const after = wordStartingAt(context, edge.to);
68
- return SUBJECT_TAGS.has(tagOf(context, before)) &&
69
- GOVERNED_TAGS.test(tagOf(context, after))
70
- ? "force"
71
- : "keep";
72
- },
73
- };
7
+ import { tagOf, wordEndingAt, } from "./rules.js";
74
8
  /**
75
9
  * 儿 does not stand on its own where the dictionary attests the 儿化.
76
10
  *
@@ -194,6 +128,8 @@ export { ADJECTIVAL_CHANG, PLAYING_TAN } from "./polyphone-rules.js";
194
128
  */
195
129
  export const READING_RULES = [
196
130
  MODAL_DE,
131
+ PARTICLE_DE,
132
+ POTENTIAL_DE,
197
133
  TEACHING_JIAO,
198
134
  ATTESTED_ERHUA,
199
135
  COUNTED_MEASURE,
@@ -1 +1 @@
1
- {"version":3,"file":"reading-rules.js","sourceRoot":"","sources":["../../src/decode/reading-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAGL,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,SAAS,KAAK,CAAC,QAA8B;IAC3C,OAAO,CACL,QAAQ,EAAE,OAAO,KAAK,GAAG,IAAI,Q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OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,OAAO;YACtD,IAAI,CAAC,YAAY,KAAK,OAAO;YAC7B,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,MAAM,CAAC;IACb,CAAC;CACF,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAwB;IAChD,QAAQ;IACR,WAAW;IACX,YAAY;IACZ,aAAa;IACb,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,WAAW;CACZ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { Dictionary } from "../dictionary/dictionary.js";
2
2
  import type { Lattice, LatticeEdge } from "./lattice.js";
3
- export { ASPECT, PARTICLE_TAG, tagOf, wordEndingAt, wordStartingAt, } from "./edge-context.js";
3
+ export { ASPECT, PARTICLE_TAG, tagOf, wordEndingAt, wordsEndingAt, wordStartingAt, wordsStartingAt, } from "./edge-context.js";
4
4
  /**
5
5
  * What a rule can say about one edge.
6
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/decode/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EACL,MAAM,EACN,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;GAOG;AACH,MAA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AE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,WAAW,CAAC;CAC5D;AA+DD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,SAAS,QAAQ,EAAE,GACzB,OAAO,CAsCT"}
@@ -1,4 +1,4 @@
1
- export { ASPECT, PARTICLE_TAG, tagOf, wordEndingAt, wordStartingAt, } from "./edge-context.js";
1
+ export { ASPECT, PARTICLE_TAG, tagOf, wordEndingAt, wordsEndingAt, wordStartingAt, wordsStartingAt, } from "./edge-context.js";
2
2
  /**
3
3
  * Whether every position can still be left, and the end still reached.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/decode/rules.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,mBAAmB,CAAC;AAsC3B;;;;;;;GAOG;AACH,SAAS,aAAa,CAAC,OAAgB;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IAChE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACvB,KAAK,IAAI,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;QACxC,0EAA0E;QAC1E,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAC1C,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,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E,MAAM,EAAE,SAAS,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,KAAK,GAAY;QACrB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACjC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAC7C;KACF,CAAC;IACF,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AAChD,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * What a Han run is handed about the numbers around it.
3
+ *
4
+ * A run is decoded on its own, so the digits either side of it are invisible to
5
+ * it unless something puts them there. This is what puts them there, as the
6
+ * 汉字 they would have been written with.
7
+ */
8
+ import type { NumeralSegment } from "../numerals/text.js";
9
+ import type { DecodeContext } from "./lattice-slice.js";
10
+ import type { TextRun } from "./runs.js";
11
+ /**
12
+ * The 汉字 a number in front of a Han run stands for, for that run's decode.
13
+ *
14
+ * Only the last segment of the run before, because only that one touches the
15
+ * Han: the D of 3D银行 comes between them, and a decode of 银行 that saw 三
16
+ * beside it would be reading a text nobody wrote.
17
+ */
18
+ export declare function numeralBefore(segments: readonly NumeralSegment[]): string;
19
+ /**
20
+ * The same, for the number after a Han run: only the first segment of it.
21
+ */
22
+ export declare function numeralAfter(segments: readonly NumeralSegment[]): string;
23
+ /**
24
+ * The 汉字 either side of a Han run, once the digits around it have been read.
25
+ *
26
+ * 那条河长300公里 is four runs, and the 长 ends the first of them, so a rule
27
+ * asking what the 长 is measured in used to see nothing at all: the numeral is
28
+ * one run away and the 公里 two. This hands the decode what the sentence would
29
+ * have said spelled out, which is the number in front, and the number behind
30
+ * with the Han that carries on from it.
31
+ */
32
+ export declare function contextAround(runs: readonly TextRun[], read: readonly (readonly NumeralSegment[])[], at: number): DecodeContext;
33
+ //# sourceMappingURL=run-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-context.d.ts","sourceRoot":"","sources":["../../src/decode/run-context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAazC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAEzE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAExE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,OAAO,EAAE,EACxB,IAAI,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,EAC5C,EAAE,EAAE,MAAM,GACT,aAAa,CAUf"}
@@ -0,0 +1,47 @@
1
+ import { toCharacters } from "../script/characters.js";
2
+ /**
3
+ * How far past a number a run's decode is allowed to see, in characters.
4
+ *
5
+ * The same four {@link import("./edge-context.js").wordStartingAt} looks ahead
6
+ * by, and for the same reason: four characters is as far as a rule can reach,
7
+ * so carrying more would be lattice nobody reads. A prefix can only take words
8
+ * away and never invent one, so cutting the run here costs the decode nothing
9
+ * it would otherwise have had.
10
+ */
11
+ const READS_AHEAD = 4;
12
+ /**
13
+ * The 汉字 a number in front of a Han run stands for, for that run's decode.
14
+ *
15
+ * Only the last segment of the run before, because only that one touches the
16
+ * Han: the D of 3D银行 comes between them, and a decode of 银行 that saw 三
17
+ * beside it would be reading a text nobody wrote.
18
+ */
19
+ export function numeralBefore(segments) {
20
+ return segments.at(-1)?.hanzi ?? "";
21
+ }
22
+ /**
23
+ * The same, for the number after a Han run: only the first segment of it.
24
+ */
25
+ export function numeralAfter(segments) {
26
+ return segments[0]?.hanzi ?? "";
27
+ }
28
+ /**
29
+ * The 汉字 either side of a Han run, once the digits around it have been read.
30
+ *
31
+ * 那条河长300公里 is four runs, and the 长 ends the first of them, so a rule
32
+ * asking what the 长 is measured in used to see nothing at all: the numeral is
33
+ * one run away and the 公里 two. This hands the decode what the sentence would
34
+ * have said spelled out, which is the number in front, and the number behind
35
+ * with the Han that carries on from it.
36
+ */
37
+ export function contextAround(runs, read, at) {
38
+ const said = numeralAfter(read[at + 1] ?? []);
39
+ const following = runs[at + 2];
40
+ return {
41
+ before: numeralBefore(read[at - 1] ?? []),
42
+ after: said === "" || following?.isHan !== true
43
+ ? said
44
+ : said + toCharacters(following.text).slice(0, READS_AHEAD).join(""),
45
+ };
46
+ }
47
+ //# sourceMappingURL=run-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-context.js","sourceRoot":"","sources":["../../src/decode/run-context.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvD;;;;;;;;GAQG;AACH,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,QAAmC;IAC/D,OAAO,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAAmC;IAC9D,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAwB,EACxB,IAA4C,EAC5C,EAAU;IAEV,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/B,OAAO;QACL,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,KAAK,EACH,IAAI,KAAK,EAAE,IAAI,SAAS,EAAE,KAAK,KAAK,IAAI;YACtC,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;KACzE,CAAC;AACJ,CAAC"}
@@ -29,13 +29,14 @@ export declare function wordFrom(dictionary: Dictionary, lattice: Lattice, group
29
29
  */
30
30
  export declare function ruledLattice(dictionary: Dictionary, run: string, rules: readonly EdgeRule[], hints: ResolvedHints | undefined): Lattice;
31
31
  /**
32
- * Cut a decode of the whole lattice down to the run at the end of it.
32
+ * Cut a decode of the whole lattice down to the run inside it.
33
33
  *
34
- * Everything before `at` was context rather than run — 汉字 a caller put in
35
- * front so that the decode could see them — and is dropped once it has done its
36
- * work.
34
+ * Everything outside `at` and `to` was context rather than run — 汉字 a caller
35
+ * put either side so that the decode could see them — and is dropped once it
36
+ * has done its work. A unit is kept only where it lies wholly inside the run,
37
+ * which is what `isJoinedAt` guarantees for the ones that cannot be cut.
37
38
  */
38
- export declare function runGroups<Unit extends ReadingUnit>({ lattice, at }: RunLattice, units: readonly Unit[]): readonly (readonly Unit[])[];
39
+ export declare function runGroups<Unit extends ReadingUnit>({ lattice, at, to }: RunLattice, units: readonly Unit[]): readonly (readonly Unit[])[];
39
40
  /**
40
41
  * Decode a Han run with the lattice: the recommended path.
41
42
  *
@@ -43,10 +44,12 @@ export declare function runGroups<Unit extends ReadingUnit>({ lattice, at }: Run
43
44
  * lock the positions that cannot vary, score the rest — where the greedy
44
45
  * baseline commits to the longest match at each position and never revisits it.
45
46
  *
46
- * `before` is 汉字 standing in front of the run that the decode should see and
47
- * not report: the 汉字 a number written in digits would have been written with.
48
- * A run is decoded on its own without it, and a run reached that way has no idea
49
- * what preceded it — 个人 alone is the word `gèrén`, while the 两 of 2个人 makes
50
- * 两个 the word and leaves 人 to itself.
47
+ * `before` and `after` are 汉字 standing either side of the run that the decode
48
+ * should see and not report: the 汉字 a number written in digits would have been
49
+ * written with, and whatever carries on from it. A run is decoded on its own
50
+ * without them, and a run reached that way has no idea what surrounded it —
51
+ * 个人 alone is the word `gèrén`, while the 两 of 2个人 makes 两个 the word and
52
+ * leaves 人 to itself, and 那条河长 ends where 那条河长三百公里 goes on to say
53
+ * how long the river is.
51
54
  */
52
55
  //# sourceMappingURL=run-lattice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-lattice.d.ts","sourceRoot":"","sources":["../../src/decode/run-lattice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAShD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,WAAW,EACjD,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,SAAS,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAkB9B;AAED;;GAE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C,EAAE,CAkB9B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,WAAW,EAAE,GAC5B,WAAW,CAiBb;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,KAAK,EAAE,aAAa,GAAG,SAAS,GAC/B,OAAO,CAMT;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,SAAS,WAAW,EAChD,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAC/B,KAAK,EAAE,SAAS,IAAI,EAAE,GACrB,SAAS,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAK9B;AAED;;;;;;;;;;;;;;GAcG"}
@@ -7,7 +7,7 @@ export { runLattice } from "./lattice-slice.js";
7
7
  * is where a lattice is cut down to a run and the words are read back out of
8
8
  * it. `decode.ts` is what asks for one.
9
9
  */
10
- import { decodeSpacing } from "./decode.js";
10
+ import { decodeSpacing } from "./lattice-decode.js";
11
11
  import { applyEdgeRules } from "./rules.js";
12
12
  /**
13
13
  * Gather the reading units into the words the boundaries make of them.
@@ -66,14 +66,15 @@ export function ruledLattice(dictionary, run, rules, hints) {
66
66
  return applyEdgeRules(buildLattice(dictionary, run, hints), dictionary, rules);
67
67
  }
68
68
  /**
69
- * Cut a decode of the whole lattice down to the run at the end of it.
69
+ * Cut a decode of the whole lattice down to the run inside it.
70
70
  *
71
- * Everything before `at` was context rather than run — 汉字 a caller put in
72
- * front so that the decode could see them — and is dropped once it has done its
73
- * work.
71
+ * Everything outside `at` and `to` was context rather than run — 汉字 a caller
72
+ * put either side so that the decode could see them — and is dropped once it
73
+ * has done its work. A unit is kept only where it lies wholly inside the run,
74
+ * which is what `isJoinedAt` guarantees for the ones that cannot be cut.
74
75
  */
75
- export function runGroups({ lattice, at }, units) {
76
- return groupUnits(units.filter((unit) => unit.from >= at), decodeSpacing(lattice).filter((from) => from >= at));
76
+ export function runGroups({ lattice, at, to }, units) {
77
+ return groupUnits(units.filter((unit) => unit.from >= at && unit.to <= to), decodeSpacing(lattice).filter((from) => from >= at && from < to));
77
78
  }
78
79
  /**
79
80
  * Decode a Han run with the lattice: the recommended path.
@@ -82,10 +83,12 @@ export function runGroups({ lattice, at }, units) {
82
83
  * lock the positions that cannot vary, score the rest — where the greedy
83
84
  * baseline commits to the longest match at each position and never revisits it.
84
85
  *
85
- * `before` is 汉字 standing in front of the run that the decode should see and
86
- * not report: the 汉字 a number written in digits would have been written with.
87
- * A run is decoded on its own without it, and a run reached that way has no idea
88
- * what preceded it — 个人 alone is the word `gèrén`, while the 两 of 2个人 makes
89
- * 两个 the word and leaves 人 to itself.
86
+ * `before` and `after` are 汉字 standing either side of the run that the decode
87
+ * should see and not report: the 汉字 a number written in digits would have been
88
+ * written with, and whatever carries on from it. A run is decoded on its own
89
+ * without them, and a run reached that way has no idea what surrounded it —
90
+ * 个人 alone is the word `gèrén`, while the 两 of 2个人 makes 两个 the word and
91
+ * leaves 人 to itself, and 那条河长 ends where 那条河长三百公里 goes on to say
92
+ * how long the river is.
90
93
  */
91
94
  //# sourceMappingURL=run-lattice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-lattice.js","sourceRoot":"","sources":["../../src/decode/run-lattice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,cAAc,CAAC;AAI1D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAC;AAG3D;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACxB,KAAsB,EACtB,UAA6B;IAE7B,MAAM,MAAM,GAAG,IA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