@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
@@ -19,6 +19,30 @@ export function wordEndingAt(context, at, longest = 4) {
19
19
  }
20
20
  return undefined;
21
21
  }
22
+ /**
23
+ * Every word the dictionary has ending at a position, longest first.
24
+ *
25
+ * {@link wordEndingAt} answers with the longest, which is what a rule asking
26
+ * "what word is this" wants. A rule asking whether a *particular* word stands
27
+ * here wants all of them, because the longest match is often a word the rule
28
+ * has no opinion about wrapped around the one it does: 很 is a degree adverb
29
+ * and 得很 is the longest word ending at the same position, so 留得很长 hid its
30
+ * 很 and read `zhǎng`. 一个 hides 个 the same way.
31
+ */
32
+ export function wordsEndingAt(context, at, longest = 4) {
33
+ const held = [];
34
+ for (let length = longest; length > 0; length--) {
35
+ const from = at - length;
36
+ if (from < 0) {
37
+ continue;
38
+ }
39
+ const text = context.characters.slice(from, at).join("");
40
+ if (context.dictionary.lookup(text) !== undefined) {
41
+ held.push(text);
42
+ }
43
+ }
44
+ return held;
45
+ }
22
46
  /**
23
47
  * The word starting at a position, longest first, or undefined.
24
48
  */
@@ -33,6 +57,23 @@ export function wordStartingAt(context, at, longest = 4) {
33
57
  }
34
58
  return undefined;
35
59
  }
60
+ /**
61
+ * Every word the dictionary has starting at a position, longest first.
62
+ *
63
+ * The mirror of {@link wordsEndingAt}, and needed for the same reason: 五公 is a
64
+ * word and hides the 五 inside it, so a rule asking whether a numeral starts
65
+ * here has to be shown all of them.
66
+ */
67
+ export function wordsStartingAt(context, at, longest = 4) {
68
+ const held = [];
69
+ for (let length = longest; length > 0; length--) {
70
+ const text = context.characters.slice(at, at + length).join("");
71
+ if (text !== "" && context.dictionary.lookup(text) !== undefined) {
72
+ held.push(text);
73
+ }
74
+ }
75
+ return held;
76
+ }
36
77
  /**
37
78
  * The part of speech the dictionary gives a word, or the empty string.
38
79
  */
@@ -1 +1 @@
1
- {"version":3,"file":"edge-context.js","sourceRoot":"","sources":["../../src/decode/edge-context.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAoB,EACpB,EAAU,EACV,OAAO,GAAG,CAAC;IAEX,KAAK,IAAI,MAAM,GAAG,OAAO,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;YACb,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzD,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YAClD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAoB,EACpB,EAAU,EACV,OAAO,GAAG,CAAC;IAEX,KAAK,IAAI,MAAM,GAAG,OAAO,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;QAChD,mEAAmE;QACnE,sBAAsB;QACtB,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChE,IAAI,IAAI,KAAK,EAAE,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,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AK,EAAE,aAAa,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,aAAa,CAQf;AAeD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAyF1E"}
1
+ {"version":3,"file":"hint-lattice.d.ts","sourceRoot":"","sources":["../../src/decode/hint-lattice.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,OAAO,EAAoC,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,YAAY,CAAC;AAiB1D;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa,CAK1E;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,aAAa,CAQf;AAeD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAyF1E"}
@@ -1,4 +1,18 @@
1
- import { READING_CHARGE, UNKNOWN_COST, } from "./lattice.js";
1
+ import { READING_CHARGE } from "./lattice.js";
2
+ /**
3
+ * What an edge a hint brought with it costs, in both decodes.
4
+ *
5
+ * Zero, because a caller naming a reading is the strongest evidence the decode
6
+ * has. The other branch of {@link applyHints} says so already by overwriting a
7
+ * dictionary entry's reading where a hint names the same stretch, and an edge
8
+ * with no entry behind it has to say the same thing through its cost.
9
+ *
10
+ * It was {@link import("./lattice-types.js").UNKNOWN_COST} until
11
+ * {@link READING_CHARGE} came down, which worked only while one edge beat two
12
+ * whatever they cost: 玩儿 hinted as `wánr` went back to `wán ér` the moment
13
+ * frequency could speak.
14
+ */
15
+ const HINT_COST = 0;
2
16
  /**
3
17
  * The same hints with every position moved along by an offset.
4
18
  *
@@ -123,8 +137,8 @@ export function applyHints(lattice, hints) {
123
137
  to,
124
138
  text: spanning.characters.join(""),
125
139
  reading: spanning.reading,
126
- cost: UNKNOWN_COST,
127
- readingCost: UNKNOWN_COST + READING_CHARGE,
140
+ cost: HINT_COST,
141
+ readingCost: HINT_COST + READING_CHARGE,
128
142
  isProperNoun: false,
129
143
  partOfSpeech: "",
130
144
  // No dictionary entry backs this one — that is the whole reason it
@@ -1 +1 @@
1
- {"version":3,"file":"hint-lattice.js","sourceRoot":"","sources":["../../src/decode/hint-lattice.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,cAAc,EACd,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,KAAoB,EAAE,EAAU;IACzD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,EAAE,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;KACxE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,KAAoB,EACpB,IAAY,EACZ,MAAc;IAEd,MAAM,EAAE,GAAG,IAAI,GAAG,EAAoB,CAAC;IACvC,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC;QAC5C,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,GAAG,IAAI,GAAG,MAAM,EAAE,CAAC;YACjD,EAAE,CAAC,GAAG,CAAC,QAAQ,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAA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AAI,CAAC,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CACrE,CAAC;YACF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC;YAC3C,OAAO;gBACL,GAAG,SAAS;gBACZ;oBACE,IAAI,EAAE,EAAE;oBACR,EAAE;oBACF,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;oBAClC,OAAO,EAAE,QAAQ,CAAC,OAAO;oBACzB,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,SAAS,GAAG,cAAc;oBACvC,YAAY,EAAE,KAAK;oBACnB,YAAY,EAAE,EAAE;oBAChB,mEAAmE;oBACnE,oEAAoE;oBACpE,sEAAsE;oBACtE,6DAA6D;oBAC7D,OAAO,EAAE,KAAK;iBACf;aACF,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -25,6 +25,8 @@ export declare const TAUGHT_TAGS: Set<string>;
25
25
  * a 教 with a pronoun, a noun or a name after it is governing it, and a 教 with
26
26
  * 了, 过, 着 or 得 after it is a verb whatever follows that. A particle in front
27
27
  * of it rules it out, since a verb does not follow one.
28
+ *
29
+ * {@link GOVERNING} is the case where nothing follows to look at.
28
30
  */
29
31
  export declare function isTeachingAt(context: EdgeContext, at: number): boolean;
30
32
  /**
@@ -46,13 +48,17 @@ export declare function isTeachingAt(context: EdgeContext, at: number): boolean;
46
48
  * one that matters: 任教, 宗教, 主教, 佛教, 传教, 执教, 请教, 家教.
47
49
  *
48
50
  * Measured over 88,866 lines of Tatoeba and zh.wikipedia, 181 教 decode as a
49
- * word of their own and every one of them read `jiào`. This moves 158 to
51
+ * word of their own and every one of them read `jiào`. This moves 162 to
50
52
  * `jiāo` and is wrong on three: 统一教创始人, 方法教深思 and 做到了教政分离,
51
53
  * where a nominal compound takes an object's shape, the last of them because
52
54
  * 做到了 is a word and so the 了 in front is not a particle to look at. Of the
53
- * 21 it leaves, 8 are right — 诸教中, 教外别传, 董教总, 风教, 教青局 twice, a
54
- * 教室 reached through a bad split, and a 教 used as a bare noun — and 13 are
55
+ * 17 it leaves, 8 are right — 诸教中, 教外别传, 董教总, 风教, 教青局 twice, a
56
+ * 教室 reached through a bad split, and a 教 used as a bare noun — and 9 are
55
57
  * misses, where jieba tags the object something this does not name.
58
+ *
59
+ * {@link GOVERNING} is four of that 162 and was added later: 能教教我,
60
+ * 要教一節課, 也會教像拉丁語, 這在學校是不教的. 有 is pointedly outside it,
61
+ * since 有教无类 is `yǒujiào wúlèi`.
56
62
  */
57
63
  export declare const TEACHING_JIAO: EdgeRule;
58
64
  //# sourceMappingURL=jiao-rule.d.ts.map
@@ -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;AAEvE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAQtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,aAAa,EAAE,QAiB3B,CAAC"}
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"}
@@ -13,6 +13,37 @@ export function isJiao(syllable) {
13
13
  * only 教 with a place tag after it over the corpus is 教青局, an office.
14
14
  */
15
15
  export const TAUGHT_TAGS = new Set(["r", "n", "nz", "nr", "nt", "ng"]);
16
+ /**
17
+ * The words that can only be governing a verb, whatever comes after them.
18
+ *
19
+ * The far side of the context, for the 教 that teaches nothing named:
20
+ * 他怎么教,我都学不会, 你没能力教, 这在学校是不教的, 有时也会教. A modal or a
21
+ * negator has to be followed by a verb, so the 教 after one is the verb even
22
+ * where nothing at all follows it.
23
+ *
24
+ * Written out rather than taken from a tag, for the reason the 长 rule gives:
25
+ * jieba calls 会 `v` along with every other verb and 怎么 `r` along with every
26
+ * pronoun, so neither tag names this set.
27
+ */
28
+ const GOVERNING = new Set([
29
+ "不",
30
+ "能",
31
+ "会",
32
+ "會",
33
+ "要",
34
+ "想",
35
+ "该",
36
+ "該",
37
+ "也",
38
+ "别",
39
+ "別",
40
+ "没",
41
+ "沒",
42
+ "怎么",
43
+ "怎麼",
44
+ "怎样",
45
+ "怎樣",
46
+ ]);
16
47
  /**
17
48
  * Whether the 教 at a position is teaching something to somebody.
18
49
  *
@@ -20,12 +51,16 @@ export const TAUGHT_TAGS = new Set(["r", "n", "nz", "nr", "nt", "ng"]);
20
51
  * a 教 with a pronoun, a noun or a name after it is governing it, and a 教 with
21
52
  * 了, 过, 着 or 得 after it is a verb whatever follows that. A particle in front
22
53
  * of it rules it out, since a verb does not follow one.
54
+ *
55
+ * {@link GOVERNING} is the case where nothing follows to look at.
23
56
  */
24
57
  export function isTeachingAt(context, at) {
25
- if (tagOf(context, wordEndingAt(context, at)).startsWith(PARTICLE_TAG)) {
58
+ const before = wordEndingAt(context, at);
59
+ if (tagOf(context, before).startsWith(PARTICLE_TAG)) {
26
60
  return false;
27
61
  }
28
- return (ASPECT.has(context.characters[at + 1] ?? "") ||
62
+ return (GOVERNING.has(before ?? "") ||
63
+ ASPECT.has(context.characters[at + 1] ?? "") ||
29
64
  TAUGHT_TAGS.has(tagOf(context, wordStartingAt(context, at + 1))));
30
65
  }
31
66
  /**
@@ -47,13 +82,17 @@ export function isTeachingAt(context, at) {
47
82
  * one that matters: 任教, 宗教, 主教, 佛教, 传教, 执教, 请教, 家教.
48
83
  *
49
84
  * Measured over 88,866 lines of Tatoeba and zh.wikipedia, 181 教 decode as a
50
- * word of their own and every one of them read `jiào`. This moves 158 to
85
+ * word of their own and every one of them read `jiào`. This moves 162 to
51
86
  * `jiāo` and is wrong on three: 统一教创始人, 方法教深思 and 做到了教政分离,
52
87
  * where a nominal compound takes an object's shape, the last of them because
53
88
  * 做到了 is a word and so the 了 in front is not a particle to look at. Of the
54
- * 21 it leaves, 8 are right — 诸教中, 教外别传, 董教总, 风教, 教青局 twice, a
55
- * 教室 reached through a bad split, and a 教 used as a bare noun — and 13 are
89
+ * 17 it leaves, 8 are right — 诸教中, 教外别传, 董教总, 风教, 教青局 twice, a
90
+ * 教室 reached through a bad split, and a 教 used as a bare noun — and 9 are
56
91
  * misses, where jieba tags the object something this does not name.
92
+ *
93
+ * {@link GOVERNING} is four of that 162 and was added later: 能教教我,
94
+ * 要教一節課, 也會教像拉丁語, 這在學校是不教的. 有 is pointedly outside it,
95
+ * since 有教无类 is `yǒujiào wúlèi`.
57
96
  */
58
97
  export const TEACHING_JIAO = {
59
98
  name: "teaching-jiao",
@@ -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;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,OAAoB,EAAE,EAAU;IAC3D,IAAI,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACvE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CACL,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5C,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CACjE,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAa;IACrC,IAAI,EAAE,eAAe;IACrB,UAAU,EAAE,CAAC,OAAoB,EAAE,EAAE;QACnC,MAAM,EAAE,IAAI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AAC;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,28 @@
1
+ /**
2
+ * The two sweeps a decode makes over a whole lattice.
3
+ *
4
+ * Separate from `decode.ts` because the run-level entry points there build a
5
+ * lattice from a run and cut it back down again, where these two take a lattice
6
+ * as given and say nothing about where it came from.
7
+ */
8
+ import { type Lattice } from "./lattice.js";
9
+ import { type ReadingProjection, type ReadingUnit } from "./locking.js";
10
+ /**
11
+ * Decode the run's readings, scoring only where the readings are still open.
12
+ *
13
+ * The asymmetry ALGORITHM.md calls for. A stretch between two cut points whose
14
+ * positions all locked reads the same way on every path, so its readings are
15
+ * read off the locks and no shortest path is run over it at all. Only the
16
+ * stretches with a genuine choice in them are decoded.
17
+ */
18
+ export declare function decodeReadings(lattice: Lattice, projection: ReadingProjection): readonly ReadingUnit[];
19
+ /**
20
+ * Where a decode would put the word boundaries, as character positions.
21
+ *
22
+ * Run over the whole lattice rather than the open stretches, because spacing
23
+ * stays ambiguous where readings do not: 研究生命起源 reads identically whether
24
+ * it splits 研究生/命 or 研究/生命, so every position in it locks, and the
25
+ * spacing question is still open.
26
+ */
27
+ export declare function decodeSpacing(lattice: Lattice): readonly number[];
28
+ //# sourceMappingURL=lattice-decode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lattice-decode.d.ts","sourceRoot":"","sources":["../../src/decode/lattice-decode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAGjB,MAAM,cAAc,CAAC;AAGtB;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,iBAAiB,GAC5B,SAAS,WAAW,EAAE,CAmBxB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAIjE"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The two sweeps a decode makes over a whole lattice.
3
+ *
4
+ * Separate from `decode.ts` because the run-level entry points there build a
5
+ * lattice from a run and cut it back down again, where these two take a lattice
6
+ * as given and say nothing about where it came from.
7
+ */
8
+ import { cutPoints } from "./lattice.js";
9
+ import { isSettled, settledUnits, unitsOf, } from "./locking.js";
10
+ import { readingCost, shortestPath, spacingCost } from "./viterbi.js";
11
+ /**
12
+ * Decode the run's readings, scoring only where the readings are still open.
13
+ *
14
+ * The asymmetry ALGORITHM.md calls for. A stretch between two cut points whose
15
+ * positions all locked reads the same way on every path, so its readings are
16
+ * read off the locks and no shortest path is run over it at all. Only the
17
+ * stretches with a genuine choice in them are decoded.
18
+ */
19
+ export function decodeReadings(lattice, projection) {
20
+ const cuts = cutPoints(lattice);
21
+ const units = [];
22
+ for (const [index, from] of cuts.entries()) {
23
+ const to = cuts[index + 1];
24
+ if (to === undefined) {
25
+ break;
26
+ }
27
+ if (isSettled(projection, from, to)) {
28
+ units.push(...settledUnits(projection, from, to));
29
+ continue;
30
+ }
31
+ for (const edge of shortestPath(lattice, from, to, readingCost)) {
32
+ units.push(...unitsOf(edge));
33
+ }
34
+ }
35
+ return units;
36
+ }
37
+ /**
38
+ * Where a decode would put the word boundaries, as character positions.
39
+ *
40
+ * Run over the whole lattice rather than the open stretches, because spacing
41
+ * stays ambiguous where readings do not: 研究生命起源 reads identically whether
42
+ * it splits 研究生/命 or 研究/生命, so every position in it locks, and the
43
+ * spacing question is still open.
44
+ */
45
+ export function decodeSpacing(lattice) {
46
+ return shortestPath(lattice, 0, lattice.characters.length, spacingCost).map((edge) => edge.from);
47
+ }
48
+ //# sourceMappingURL=lattice-decode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lattice-decode.js","sourceRoot":"","sources":["../../src/decode/lattice-decode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAgB,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,SAAS,EAGT,YAAY,EACZ,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtE;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB,EAChB,UAA6B;IAE7B,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,MAAM,KAAK,GAAkB,EAAE,CAAC;IAEhC,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3C,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC3B,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACrB,MAAM;QACR,CAAC;QACD,IAAI,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YAClD,SAAS;QACX,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,EAAE,CAAC;YAChE,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,GAAG,CACzE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CACpB,CAAC;AACJ,CAAC"}
@@ -9,11 +9,27 @@ import { type Lattice } from "./lattice.js";
9
9
  import type { EdgeRule } from "./rules.js";
10
10
  import { type ResolvedHints } from "./hints.js";
11
11
  /**
12
- * A lattice to decode over, and where in it the run itself starts.
12
+ * The 汉字 either side of a run that the decode should see and not report.
13
+ *
14
+ * What a run would have been written with had the digits around it been spelled
15
+ * out. Both sides are the same kind of claim about the same text, so they travel
16
+ * together even where the exported signatures keep them apart.
17
+ */
18
+ export interface DecodeContext {
19
+ /** 汉字 standing in front of the run. */
20
+ readonly before: string;
21
+ /** 汉字 standing after it. */
22
+ readonly after: string;
23
+ }
24
+ /**
25
+ * A lattice to decode over, and where in it the run itself lies.
13
26
  */
14
27
  export interface RunLattice {
15
28
  readonly lattice: Lattice;
29
+ /** Where the run starts, past whatever context stands in front of it. */
16
30
  readonly at: number;
31
+ /** Where the run ends, before whatever context stands after it. */
32
+ readonly to: number;
17
33
  }
18
34
  /**
19
35
  * Whether any reading in the lattice would hold the two sides of a join
@@ -27,11 +43,11 @@ export interface RunLattice {
27
43
  */
28
44
  export declare function isJoinedAt(lattice: Lattice, at: number): boolean;
29
45
  /**
30
- * The lattice a run decodes over, with whatever context stands in front of it.
46
+ * The lattice a run decodes over, with whatever context stands around it.
31
47
  *
32
- * The context is dropped where a reading would hold it to the run, leaving the
33
- * run decoded on its own, which is what it would have been before there was any
34
- * context to give.
48
+ * Each side is dropped where a reading would hold it to the run, and only that
49
+ * side: a run whose trailing context is joined still gets the leading one, which
50
+ * is what it would have had before there was any context to give.
35
51
  */
36
- export declare function runLattice(dictionary: Dictionary, run: string, rules: readonly EdgeRule[], before: string, hints: ResolvedHints | undefined): RunLattice;
52
+ export declare function runLattice(dictionary: Dictionary, run: string, rules: readonly EdgeRule[], context: DecodeContext, hints: ResolvedHints | undefined): RunLattice;
37
53
  //# sourceMappingURL=lattice-slice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lattice-slice.d.ts","sourceRoot":"","sources":["../../src/decode/lattice-slice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAG5D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAOhE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,GAAG,SAAS,GAC/B,UAAU,CAoBZ"}
1
+ {"version":3,"file":"lattice-slice.d.ts","sourceRoot":"","sources":["../../src/decode/lattice-slice.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAG5D;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAOhE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,aAAa,GAAG,SAAS,GAC/B,UAAU,CA2BZ"}
@@ -18,26 +18,32 @@ export function isJoinedAt(lattice, at) {
18
18
  edge.reading.length !== edge.to - edge.from);
19
19
  }
20
20
  /**
21
- * The lattice a run decodes over, with whatever context stands in front of it.
21
+ * The lattice a run decodes over, with whatever context stands around it.
22
22
  *
23
- * The context is dropped where a reading would hold it to the run, leaving the
24
- * run decoded on its own, which is what it would have been before there was any
25
- * context to give.
23
+ * Each side is dropped where a reading would hold it to the run, and only that
24
+ * side: a run whose trailing context is joined still gets the leading one, which
25
+ * is what it would have had before there was any context to give.
26
26
  */
27
- export function runLattice(dictionary, run, rules, before, hints) {
28
- const alone = () => ({
29
- lattice: ruledLattice(dictionary, run, rules, hints),
30
- at: 0,
31
- });
32
- if (before === "") {
33
- return alone();
27
+ export function runLattice(dictionary, run, rules, context, hints) {
28
+ const length = toCharacters(run).length;
29
+ const build = (before, after) => {
30
+ const at = toCharacters(before).length;
31
+ // The context is decoded with the run, so every hint position moves along
32
+ // with it. Shifting a copy keeps the caller's positions relative to the run
33
+ // they were given for.
34
+ return {
35
+ lattice: ruledLattice(dictionary, before + run + after, rules, hints === undefined ? undefined : shiftHints(hints, at)),
36
+ at,
37
+ to: at + length,
38
+ };
39
+ };
40
+ const { before, after } = context;
41
+ const held = build(before, after);
42
+ const isLeadJoined = before !== "" && isJoinedAt(held.lattice, held.at);
43
+ const isTailJoined = after !== "" && isJoinedAt(held.lattice, held.to);
44
+ if (!isLeadJoined && !isTailJoined) {
45
+ return held;
34
46
  }
35
- const held = toCharacters(before).length;
36
- // The context is decoded with the run, so every hint position moves along
37
- // with it. Shifting a copy keeps the caller's positions relative to the run
38
- // they were given for.
39
- const lattice = ruledLattice(dictionary, before + run, rules, hints === undefined ? undefined : shiftHints(hints, held));
40
- const at = held;
41
- return isJoinedAt(lattice, at) ? alone() : { lattice, at };
47
+ return build(isLeadJoined ? "" : before, isTailJoined ? "" : after);
42
48
  }
43
49
  //# sourceMappingURL=lattice-slice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lattice-slice.js","sourceRoot":"","sources":["../../src/decode/lattice-slice.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAgB,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAsB,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB,EAAE,EAAU;IACrD,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,CAC3B,CAAC,IAAI,EAAE,EAAE,CACP,I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,CAAC,EAAE,CAAC,CAAC;IACxE,MAAM,YAAY,GAAG,KAAK,KAAK,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACvE,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC"}
@@ -63,15 +63,34 @@ export declare const ALTERNATE_PENALTY = 1;
63
63
  * outright that those two characters together read `dì qì`. A stored reading is
64
64
  * evidence about the characters; a character's default reading is only a prior.
65
65
  *
66
- * So the reading decode charges per *edge* heavily enough that dictionary
67
- * evidence outranks frequency: at 16 an attested word always beats splitting it
68
- * into characters, however common those characters are, since the worst word
69
- * costs `15 + 16` and the best two-character split costs `0 + 16` twice. Word
70
- * frequency survives as the tiebreak between paths covering the same span with
71
- * the same number of words. That ordering — fewest words first, frequency
72
- * second — is the one ALGORITHM.md already gives its data-free fallback tier.
66
+ * So the reading decode charges per *edge*, and the charge is what a word is
67
+ * worth against the frequencies around it. The whole frequency scale is 15
68
+ * buckets wide, so a charge of 15 already makes the rarest possible word beat
69
+ * the two commonest possible characters. This was 16 for most of the project's
70
+ * life, and with `WORD_CHARGE` on top of it the real price of a word boundary
71
+ * was 20.62 — five buckets past the point where frequency can say anything at
72
+ * all. Every 那是 in the language read `nà shi` on the strength of one
73
+ * colloquial CC-CEDICT entry no corpus has ever counted, and 都会, 过得, 得了
74
+ * and 的哥 went the same way.
75
+ *
76
+ * At 6 the price is 10.62 and the arithmetic decides something. A word loses
77
+ * its span to a two-character split when the two characters are more than
78
+ * 25.62 buckets better than it, which needs a word nothing attests standing
79
+ * against two characters near the top of the scale. An attested word survives
80
+ * whatever is beside it, so 地气 is still `dì qì`.
81
+ *
82
+ * Measured over the 88,866 lines of Tatoeba and zh.wikipedia the stage-4 rules
83
+ * were sized against, moving 16 to 6 changes 822 of 139,682 Han runs. The
84
+ * changes are 那是 (303), 都 read `dū` (141), 得 read `dé` after a verb (98),
85
+ * 为 read `wéi` where it means *for* (36), 一个 (27), and a tail of 了, 只, 中,
86
+ * 说 and 的. Against them stand 21 老是, 11 等地 and 10 倒是, where the word
87
+ * really was one word. On CPP's 20,139 hand-labelled polyphones it is 91.48%
88
+ * either way, and the gold corpus does not move.
89
+ *
90
+ * Word frequency survives as the tiebreak between paths covering the same span
91
+ * with the same number of words.
73
92
  */
74
- export declare const READING_CHARGE = 16;
93
+ export declare const READING_CHARGE = 6;
75
94
  /**
76
95
  * What an edge covering a character no dictionary entry knows costs.
77
96
  *
@@ -1 +1 @@
1
- {"version":3,"file":"lattice-types.d.ts","sourceRoot":"","sources":["../../src/decode/lattice-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;IACtC,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,UA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;AACH,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,KAAK,CAAC"}
@@ -25,15 +25,34 @@ export const ALTERNATE_PENALTY = 1;
25
25
  * outright that those two characters together read `dì qì`. A stored reading is
26
26
  * evidence about the characters; a character's default reading is only a prior.
27
27
  *
28
- * So the reading decode charges per *edge* heavily enough that dictionary
29
- * evidence outranks frequency: at 16 an attested word always beats splitting it
30
- * into characters, however common those characters are, since the worst word
31
- * costs `15 + 16` and the best two-character split costs `0 + 16` twice. Word
32
- * frequency survives as the tiebreak between paths covering the same span with
33
- * the same number of words. That ordering — fewest words first, frequency
34
- * second — is the one ALGORITHM.md already gives its data-free fallback tier.
28
+ * So the reading decode charges per *edge*, and the charge is what a word is
29
+ * worth against the frequencies around it. The whole frequency scale is 15
30
+ * buckets wide, so a charge of 15 already makes the rarest possible word beat
31
+ * the two commonest possible characters. This was 16 for most of the project's
32
+ * life, and with `WORD_CHARGE` on top of it the real price of a word boundary
33
+ * was 20.62 — five buckets past the point where frequency can say anything at
34
+ * all. Every 那是 in the language read `nà shi` on the strength of one
35
+ * colloquial CC-CEDICT entry no corpus has ever counted, and 都会, 过得, 得了
36
+ * and 的哥 went the same way.
37
+ *
38
+ * At 6 the price is 10.62 and the arithmetic decides something. A word loses
39
+ * its span to a two-character split when the two characters are more than
40
+ * 25.62 buckets better than it, which needs a word nothing attests standing
41
+ * against two characters near the top of the scale. An attested word survives
42
+ * whatever is beside it, so 地气 is still `dì qì`.
43
+ *
44
+ * Measured over the 88,866 lines of Tatoeba and zh.wikipedia the stage-4 rules
45
+ * were sized against, moving 16 to 6 changes 822 of 139,682 Han runs. The
46
+ * changes are 那是 (303), 都 read `dū` (141), 得 read `dé` after a verb (98),
47
+ * 为 read `wéi` where it means *for* (36), 一个 (27), and a tail of 了, 只, 中,
48
+ * 说 and 的. Against them stand 21 老是, 11 等地 and 10 倒是, where the word
49
+ * really was one word. On CPP's 20,139 hand-labelled polyphones it is 91.48%
50
+ * either way, and the gold corpus does not move.
51
+ *
52
+ * Word frequency survives as the tiebreak between paths covering the same span
53
+ * with the same number of words.
35
54
  */
36
- export const READING_CHARGE = 16;
55
+ export const READING_CHARGE = 6;
37
56
  /**
38
57
  * What an edge covering a character no dictionary entry knows costs.
39
58
  *
@@ -1 +1 @@
1
- {"version":3,"file":"lattice-types.js","sourceRoot":"","sources":["../../src/decode/lattice-types.ts"],"names":[],"mappings":"AAyCA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"lattice-types.js","sourceRoot":"","sources":["../../src/decode/lattice-types.ts"],"names":[],"mappings":"AAyCA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC"}
@@ -30,14 +30,6 @@ export interface RunContext {
30
30
  * supply, and it is what a 一 ending the number assimilates to.
31
31
  */
32
32
  export declare function surrounding(runs: readonly TextRun[], decoded: readonly (readonly ScoredWord[])[], at: number): RunContext;
33
- /**
34
- * The 汉字 a number in front of a Han run stands for, for that run's decode.
35
- *
36
- * Only the last segment of the run before, because only that one touches the
37
- * Han: the D of 3D银行 comes between them, and a decode of 银行 that saw 三
38
- * beside it would be reading a text nobody wrote.
39
- */
40
- export declare function numeralBefore(segments: readonly NumeralSegment[]): string;
41
33
  /**
42
34
  * Write a stretch that was never Han, reading the numbers in it.
43
35
  *
@@ -1 +1 @@
1
- {"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/decode/numbers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,OAAO,EACb,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;KACzC,CAAC;IACF,8DAA8D;IAC9D,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,SAAS,OAAO,EAAE,EACxB,OAAO,EAAE,SAAS,CAAC,SAAS,UAAU,EAAE,CAAC,EAAE,EAC3C,EAAE,EAAE,MAAM,GACT,UAAU,CAQZ;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAEzE;AAED;;;;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AAE,UAAU,EACnB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CAAA;CAAE,GACtD,SAAS,cAAc,EAAE,CA6B3B"}
@@ -25,16 +25,6 @@ export function surrounding(runs, decoded, at) {
25
25
  isAfterHan: runs[at - 1]?.isHan === true,
26
26
  };
27
27
  }
28
- /**
29
- * The 汉字 a number in front of a Han run stands for, for that run's decode.
30
- *
31
- * Only the last segment of the run before, because only that one touches the
32
- * Han: the D of 3D银行 comes between them, and a decode of 银行 that saw 三
33
- * beside it would be reading a text nobody wrote.
34
- */
35
- export function numeralBefore(segments) {
36
- return segments.at(-1)?.hanzi ?? "";
37
- }
38
28
  /**
39
29
  * Write a stretch that was never Han, reading the numbers in it.
40
30
  *
@@ -1 +1 @@
1
- {"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src/decode/numbers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACrE;;;;;;GAMG;AACH,OAAO,EAAuB,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAgB,MAAM,WAAW,CAAC;AAGhE,OAAO,EAEL,UAAU,EACV,WAAW,GAEZ,MAAM,aAAa,CAAC;AAcrB;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,IAAwB,EACxB,OAA2C,EAC3C,EAAU;IAEV,OAAO;QACL,KAAK,EAAE;YACL,SAAS,EAAE,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS;YACpD,QAAQ,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;SAChD;QACD,UAAU,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI;KACzC,C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