@kensio/pinyinjs 1.7.4 → 1.7.6

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 (732) hide show
  1. package/README.md +128 -123
  2. package/data/full.entries +2595 -2595
  3. package/data/manifest.json +5 -5
  4. package/data/script.map +66 -3
  5. package/dist/accuracy/score-case.d.ts +23 -0
  6. package/dist/accuracy/score-case.d.ts.map +1 -0
  7. package/dist/accuracy/score-case.js +63 -0
  8. package/dist/accuracy/score-case.js.map +1 -0
  9. package/dist/accuracy/score.d.ts +1 -8
  10. package/dist/accuracy/score.d.ts.map +1 -1
  11. package/dist/accuracy/score.js +1 -55
  12. package/dist/accuracy/score.js.map +1 -1
  13. package/dist/cli/arguments.d.ts +4 -290
  14. package/dist/cli/arguments.d.ts.map +1 -1
  15. package/dist/cli/arguments.js +5 -357
  16. package/dist/cli/arguments.js.map +1 -1
  17. package/dist/cli/check-command.d.ts +9 -0
  18. package/dist/cli/check-command.d.ts.map +1 -0
  19. package/dist/cli/check-command.js +95 -0
  20. package/dist/cli/check-command.js.map +1 -0
  21. package/dist/cli/cli-input.d.ts +49 -0
  22. package/dist/cli/cli-input.d.ts.map +1 -0
  23. package/dist/cli/cli-input.js +31 -0
  24. package/dist/cli/cli-input.js.map +1 -0
  25. package/dist/cli/command.d.ts +97 -0
  26. package/dist/cli/command.d.ts.map +1 -0
  27. package/dist/cli/command.js +40 -0
  28. package/dist/cli/command.js.map +1 -0
  29. package/dist/cli/commands.d.ts +7 -110
  30. package/dist/cli/commands.d.ts.map +1 -1
  31. package/dist/cli/commands.js +14 -991
  32. package/dist/cli/commands.js.map +1 -1
  33. package/dist/cli/convert-command.d.ts +6 -0
  34. package/dist/cli/convert-command.d.ts.map +1 -0
  35. package/dist/cli/convert-command.js +52 -0
  36. package/dist/cli/convert-command.js.map +1 -0
  37. package/dist/cli/environment.d.ts +1 -1
  38. package/dist/cli/environment.d.ts.map +1 -1
  39. package/dist/cli/explain-command.d.ts +6 -0
  40. package/dist/cli/explain-command.d.ts.map +1 -0
  41. package/dist/cli/explain-command.js +40 -0
  42. package/dist/cli/explain-command.js.map +1 -0
  43. package/dist/cli/explain-syllable.d.ts +10 -0
  44. package/dist/cli/explain-syllable.d.ts.map +1 -0
  45. package/dist/cli/explain-syllable.js +70 -0
  46. package/dist/cli/explain-syllable.js.map +1 -0
  47. package/dist/cli/flag-help.d.ts +18 -0
  48. package/dist/cli/flag-help.d.ts.map +1 -0
  49. package/dist/cli/flag-help.js +78 -0
  50. package/dist/cli/flag-help.js.map +1 -0
  51. package/dist/cli/flag-lists.d.ts +49 -0
  52. package/dist/cli/flag-lists.d.ts.map +1 -0
  53. package/dist/cli/flag-lists.js +58 -0
  54. package/dist/cli/flag-lists.js.map +1 -0
  55. package/dist/cli/flag-values.d.ts +44 -0
  56. package/dist/cli/flag-values.d.ts.map +1 -0
  57. package/dist/cli/flag-values.js +56 -0
  58. package/dist/cli/flag-values.js.map +1 -0
  59. package/dist/cli/flags.d.ts +193 -0
  60. package/dist/cli/flags.d.ts.map +1 -0
  61. package/dist/cli/flags.js +133 -0
  62. package/dist/cli/flags.js.map +1 -0
  63. package/dist/cli/format-options.d.ts +29 -0
  64. package/dist/cli/format-options.d.ts.map +1 -0
  65. package/dist/cli/format-options.js +72 -0
  66. package/dist/cli/format-options.js.map +1 -0
  67. package/dist/cli/global-help.d.ts +23 -0
  68. package/dist/cli/global-help.d.ts.map +1 -0
  69. package/dist/cli/global-help.js +40 -0
  70. package/dist/cli/global-help.js.map +1 -0
  71. package/dist/cli/help.d.ts +1 -1
  72. package/dist/cli/help.d.ts.map +1 -1
  73. package/dist/cli/help.js +5 -99
  74. package/dist/cli/help.js.map +1 -1
  75. package/dist/cli/html-commands.d.ts +13 -0
  76. package/dist/cli/html-commands.d.ts.map +1 -0
  77. package/dist/cli/html-commands.js +49 -0
  78. package/dist/cli/html-commands.js.map +1 -0
  79. package/dist/cli/info-command.d.ts +7 -0
  80. package/dist/cli/info-command.d.ts.map +1 -0
  81. package/dist/cli/info-command.js +39 -0
  82. package/dist/cli/info-command.js.map +1 -0
  83. package/dist/cli/lookup-commands.d.ts +10 -0
  84. package/dist/cli/lookup-commands.d.ts.map +1 -0
  85. package/dist/cli/lookup-commands.js +101 -0
  86. package/dist/cli/lookup-commands.js.map +1 -0
  87. package/dist/cli/match-command.d.ts +11 -0
  88. package/dist/cli/match-command.d.ts.map +1 -0
  89. package/dist/cli/match-command.js +76 -0
  90. package/dist/cli/match-command.js.map +1 -0
  91. package/dist/cli/number-command.d.ts +12 -0
  92. package/dist/cli/number-command.d.ts.map +1 -0
  93. package/dist/cli/number-command.js +89 -0
  94. package/dist/cli/number-command.js.map +1 -0
  95. package/dist/cli/options.d.ts +30 -0
  96. package/dist/cli/options.d.ts.map +1 -0
  97. package/dist/cli/options.js +54 -0
  98. package/dist/cli/options.js.map +1 -0
  99. package/dist/cli/run-command.d.ts +24 -0
  100. package/dist/cli/run-command.d.ts.map +1 -0
  101. package/dist/cli/run-command.js +40 -0
  102. package/dist/cli/run-command.js.map +1 -0
  103. package/dist/cli/run.d.ts +4 -42
  104. package/dist/cli/run.d.ts.map +1 -1
  105. package/dist/cli/run.js +6 -61
  106. package/dist/cli/run.js.map +1 -1
  107. package/dist/cli/script-command.d.ts +10 -0
  108. package/dist/cli/script-command.d.ts.map +1 -0
  109. package/dist/cli/script-command.js +58 -0
  110. package/dist/cli/script-command.js.map +1 -0
  111. package/dist/cli/segment-command.d.ts +11 -0
  112. package/dist/cli/segment-command.d.ts.map +1 -0
  113. package/dist/cli/segment-command.js +53 -0
  114. package/dist/cli/segment-command.js.map +1 -0
  115. package/dist/cli/slug-command.d.ts +10 -0
  116. package/dist/cli/slug-command.d.ts.map +1 -0
  117. package/dist/cli/slug-command.js +28 -0
  118. package/dist/cli/slug-command.js.map +1 -0
  119. package/dist/cli/syllable-command.d.ts +14 -0
  120. package/dist/cli/syllable-command.d.ts.map +1 -0
  121. package/dist/cli/syllable-command.js +82 -0
  122. package/dist/cli/syllable-command.js.map +1 -0
  123. package/dist/cli/system-table.d.ts +12 -0
  124. package/dist/cli/system-table.d.ts.map +1 -0
  125. package/dist/cli/system-table.js +48 -0
  126. package/dist/cli/system-table.js.map +1 -0
  127. package/dist/cli/systems.d.ts +57 -0
  128. package/dist/cli/systems.d.ts.map +1 -0
  129. package/dist/cli/systems.js +27 -0
  130. package/dist/cli/systems.js.map +1 -0
  131. package/dist/cli/transcribe-command.d.ts +18 -0
  132. package/dist/cli/transcribe-command.d.ts.map +1 -0
  133. package/dist/cli/transcribe-command.js +86 -0
  134. package/dist/cli/transcribe-command.js.map +1 -0
  135. package/dist/cli/transcribe-reading.d.ts +15 -0
  136. package/dist/cli/transcribe-reading.d.ts.map +1 -0
  137. package/dist/cli/transcribe-reading.js +90 -0
  138. package/dist/cli/transcribe-reading.js.map +1 -0
  139. package/dist/cli/transcribe-rows.d.ts +26 -0
  140. package/dist/cli/transcribe-rows.d.ts.map +1 -0
  141. package/dist/cli/transcribe-rows.js +30 -0
  142. package/dist/cli/transcribe-rows.js.map +1 -0
  143. package/dist/cli/usage-error.d.ts +9 -0
  144. package/dist/cli/usage-error.d.ts.map +1 -0
  145. package/dist/cli/usage-error.js +9 -0
  146. package/dist/cli/usage-error.js.map +1 -0
  147. package/dist/decode/alternatives.d.ts +16 -0
  148. package/dist/decode/alternatives.d.ts.map +1 -0
  149. package/dist/decode/alternatives.js +31 -0
  150. package/dist/decode/alternatives.js.map +1 -0
  151. package/dist/decode/chang-context.d.ts +27 -0
  152. package/dist/decode/chang-context.d.ts.map +1 -0
  153. package/dist/decode/chang-context.js +66 -0
  154. package/dist/decode/chang-context.js.map +1 -0
  155. package/dist/decode/chang-rule.d.ts +37 -0
  156. package/dist/decode/chang-rule.d.ts.map +1 -0
  157. package/dist/decode/chang-rule.js +169 -0
  158. package/dist/decode/chang-rule.js.map +1 -0
  159. package/dist/decode/confidence.d.ts +11 -3
  160. package/dist/decode/confidence.d.ts.map +1 -1
  161. package/dist/decode/confidence.js +14 -121
  162. package/dist/decode/confidence.js.map +1 -1
  163. package/dist/decode/convert-options.d.ts +116 -0
  164. package/dist/decode/convert-options.d.ts.map +1 -0
  165. package/dist/decode/convert-options.js +2 -0
  166. package/dist/decode/convert-options.js.map +1 -0
  167. package/dist/decode/convert-pipeline.d.ts +18 -0
  168. package/dist/decode/convert-pipeline.d.ts.map +1 -0
  169. package/dist/decode/convert-pipeline.js +67 -0
  170. package/dist/decode/convert-pipeline.js.map +1 -0
  171. package/dist/decode/convert.d.ts +9 -118
  172. package/dist/decode/convert.d.ts.map +1 -1
  173. package/dist/decode/convert.js +5 -453
  174. package/dist/decode/convert.js.map +1 -1
  175. package/dist/decode/de-rule.d.ts +54 -0
  176. package/dist/decode/de-rule.d.ts.map +1 -0
  177. package/dist/decode/de-rule.js +113 -0
  178. package/dist/decode/de-rule.js.map +1 -0
  179. package/dist/decode/decode.d.ts +2 -15
  180. package/dist/decode/decode.d.ts.map +1 -1
  181. package/dist/decode/decode.js +2 -121
  182. package/dist/decode/decode.js.map +1 -1
  183. package/dist/decode/decoders.d.ts +32 -0
  184. package/dist/decode/decoders.d.ts.map +1 -0
  185. package/dist/decode/decoders.js +29 -0
  186. package/dist/decode/decoders.js.map +1 -0
  187. package/dist/decode/edge-context.d.ts +38 -0
  188. package/dist/decode/edge-context.d.ts.map +1 -0
  189. package/dist/decode/edge-context.js +57 -0
  190. package/dist/decode/edge-context.js.map +1 -0
  191. package/dist/decode/hint-lattice.d.ts +45 -0
  192. package/dist/decode/hint-lattice.d.ts.map +1 -0
  193. package/dist/decode/hint-lattice.js +154 -0
  194. package/dist/decode/hint-lattice.js.map +1 -0
  195. package/dist/decode/hints.d.ts +2 -45
  196. package/dist/decode/hints.d.ts.map +1 -1
  197. package/dist/decode/hints.js +1 -139
  198. package/dist/decode/hints.js.map +1 -1
  199. package/dist/decode/jiao-rule.d.ts +64 -0
  200. package/dist/decode/jiao-rule.d.ts.map +1 -0
  201. package/dist/decode/jiao-rule.js +115 -0
  202. package/dist/decode/jiao-rule.js.map +1 -0
  203. package/dist/decode/lattice-costs.d.ts +55 -0
  204. package/dist/decode/lattice-costs.d.ts.map +1 -0
  205. package/dist/decode/lattice-costs.js +90 -0
  206. package/dist/decode/lattice-costs.js.map +1 -0
  207. package/dist/decode/lattice-edges.d.ts +29 -0
  208. package/dist/decode/lattice-edges.d.ts.map +1 -0
  209. package/dist/decode/lattice-edges.js +78 -0
  210. package/dist/decode/lattice-edges.js.map +1 -0
  211. package/dist/decode/lattice-slice.d.ts +37 -0
  212. package/dist/decode/lattice-slice.d.ts.map +1 -0
  213. package/dist/decode/lattice-slice.js +43 -0
  214. package/dist/decode/lattice-slice.js.map +1 -0
  215. package/dist/decode/lattice-types.d.ts +101 -0
  216. package/dist/decode/lattice-types.d.ts.map +1 -0
  217. package/dist/decode/lattice-types.js +63 -0
  218. package/dist/decode/lattice-types.js.map +1 -0
  219. package/dist/decode/lattice.d.ts +2 -59
  220. package/dist/decode/lattice.d.ts.map +1 -1
  221. package/dist/decode/lattice.js +2 -118
  222. package/dist/decode/lattice.js.map +1 -1
  223. package/dist/decode/number-pieces.d.ts +62 -0
  224. package/dist/decode/number-pieces.d.ts.map +1 -0
  225. package/dist/decode/number-pieces.js +106 -0
  226. package/dist/decode/number-pieces.js.map +1 -0
  227. package/dist/decode/numbers.d.ts +53 -0
  228. package/dist/decode/numbers.d.ts.map +1 -0
  229. package/dist/decode/numbers.js +69 -0
  230. package/dist/decode/numbers.js.map +1 -0
  231. package/dist/decode/pieces.d.ts +78 -0
  232. package/dist/decode/pieces.d.ts.map +1 -0
  233. package/dist/decode/pieces.js +136 -0
  234. package/dist/decode/pieces.js.map +1 -0
  235. package/dist/decode/polyphone-rules.d.ts +11 -0
  236. package/dist/decode/polyphone-rules.d.ts.map +1 -0
  237. package/dist/decode/polyphone-rules.js +11 -0
  238. package/dist/decode/polyphone-rules.js.map +1 -0
  239. package/dist/decode/reading-rules.d.ts +3 -126
  240. package/dist/decode/reading-rules.d.ts.map +1 -1
  241. package/dist/decode/reading-rules.js +8 -434
  242. package/dist/decode/reading-rules.js.map +1 -1
  243. package/dist/decode/rules.d.ts +1 -17
  244. package/dist/decode/rules.d.ts.map +1 -1
  245. package/dist/decode/rules.js +1 -43
  246. package/dist/decode/rules.js.map +1 -1
  247. package/dist/decode/run-lattice.d.ts +52 -0
  248. package/dist/decode/run-lattice.d.ts.map +1 -0
  249. package/dist/decode/run-lattice.js +91 -0
  250. package/dist/decode/run-lattice.js.map +1 -0
  251. package/dist/decode/run-words.d.ts +17 -0
  252. package/dist/decode/run-words.d.ts.map +1 -0
  253. package/dist/decode/run-words.js +29 -0
  254. package/dist/decode/run-words.js.map +1 -0
  255. package/dist/decode/sandhi-input.d.ts +30 -0
  256. package/dist/decode/sandhi-input.d.ts.map +1 -0
  257. package/dist/decode/sandhi-input.js +35 -0
  258. package/dist/decode/sandhi-input.js.map +1 -0
  259. package/dist/decode/sandhi-tones.d.ts +97 -0
  260. package/dist/decode/sandhi-tones.d.ts.map +1 -0
  261. package/dist/decode/sandhi-tones.js +139 -0
  262. package/dist/decode/sandhi-tones.js.map +1 -0
  263. package/dist/decode/sandhi.d.ts +10 -7
  264. package/dist/decode/sandhi.d.ts.map +1 -1
  265. package/dist/decode/sandhi.js +11 -88
  266. package/dist/decode/sandhi.js.map +1 -1
  267. package/dist/decode/script-types.d.ts +76 -0
  268. package/dist/decode/script-types.d.ts.map +1 -0
  269. package/dist/decode/script-types.js +35 -0
  270. package/dist/decode/script-types.js.map +1 -0
  271. package/dist/decode/script-words.d.ts +32 -0
  272. package/dist/decode/script-words.d.ts.map +1 -0
  273. package/dist/decode/script-words.js +77 -0
  274. package/dist/decode/script-words.js.map +1 -0
  275. package/dist/decode/script.d.ts +3 -73
  276. package/dist/decode/script.d.ts.map +1 -1
  277. package/dist/decode/script.js +3 -109
  278. package/dist/decode/script.js.map +1 -1
  279. package/dist/decode/tan-rule.d.ts +68 -0
  280. package/dist/decode/tan-rule.d.ts.map +1 -0
  281. package/dist/decode/tan-rule.js +131 -0
  282. package/dist/decode/tan-rule.js.map +1 -0
  283. package/dist/decode/write-run.d.ts +21 -0
  284. package/dist/decode/write-run.d.ts.map +1 -0
  285. package/dist/decode/write-run.js +42 -0
  286. package/dist/decode/write-run.js.map +1 -0
  287. package/dist/dictionary/artifact-claims.d.ts +25 -0
  288. package/dist/dictionary/artifact-claims.d.ts.map +1 -0
  289. package/dist/dictionary/artifact-claims.js +47 -0
  290. package/dist/dictionary/artifact-claims.js.map +1 -0
  291. package/dist/dictionary/artifact-format.d.ts +86 -0
  292. package/dist/dictionary/artifact-format.d.ts.map +1 -0
  293. package/dist/dictionary/artifact-format.js +91 -0
  294. package/dist/dictionary/artifact-format.js.map +1 -0
  295. package/dist/dictionary/artifact-read.d.ts +34 -0
  296. package/dist/dictionary/artifact-read.d.ts.map +1 -0
  297. package/dist/dictionary/artifact-read.js +114 -0
  298. package/dist/dictionary/artifact-read.js.map +1 -0
  299. package/dist/dictionary/artifact.d.ts +4 -63
  300. package/dist/dictionary/artifact.d.ts.map +1 -1
  301. package/dist/dictionary/artifact.js +12 -229
  302. package/dist/dictionary/artifact.js.map +1 -1
  303. package/dist/dictionary/assertions.d.ts +5 -57
  304. package/dist/dictionary/assertions.d.ts.map +1 -1
  305. package/dist/dictionary/assertions.js +4 -317
  306. package/dist/dictionary/assertions.js.map +1 -1
  307. package/dist/dictionary/build-assertions.d.ts +12 -0
  308. package/dist/dictionary/build-assertions.d.ts.map +1 -0
  309. package/dist/dictionary/build-assertions.js +13 -0
  310. package/dist/dictionary/build-assertions.js.map +1 -0
  311. package/dist/dictionary/built-dictionary.d.ts +46 -0
  312. package/dist/dictionary/built-dictionary.d.ts.map +1 -0
  313. package/dist/dictionary/built-dictionary.js +97 -0
  314. package/dist/dictionary/built-dictionary.js.map +1 -0
  315. package/dist/dictionary/cedict-senses.d.ts +87 -0
  316. package/dist/dictionary/cedict-senses.d.ts.map +1 -0
  317. package/dist/dictionary/cedict-senses.js +126 -0
  318. package/dist/dictionary/cedict-senses.js.map +1 -0
  319. package/dist/dictionary/character-defaults.d.ts +26 -0
  320. package/dist/dictionary/character-defaults.d.ts.map +1 -0
  321. package/dist/dictionary/character-defaults.js +67 -0
  322. package/dist/dictionary/character-defaults.js.map +1 -0
  323. package/dist/dictionary/character-readings.d.ts +10 -0
  324. package/dist/dictionary/character-readings.d.ts.map +1 -0
  325. package/dist/dictionary/character-readings.js +25 -0
  326. package/dist/dictionary/character-readings.js.map +1 -0
  327. package/dist/dictionary/constituent-repair.d.ts +36 -0
  328. package/dist/dictionary/constituent-repair.d.ts.map +1 -0
  329. package/dist/dictionary/constituent-repair.js +117 -0
  330. package/dist/dictionary/constituent-repair.js.map +1 -0
  331. package/dist/dictionary/dictionary-entry.d.ts +37 -0
  332. package/dist/dictionary/dictionary-entry.d.ts.map +1 -0
  333. package/dist/dictionary/dictionary-entry.js +41 -0
  334. package/dist/dictionary/dictionary-entry.js.map +1 -0
  335. package/dist/dictionary/dictionary-readings.d.ts +56 -0
  336. package/dist/dictionary/dictionary-readings.d.ts.map +1 -0
  337. package/dist/dictionary/dictionary-readings.js +93 -0
  338. package/dist/dictionary/dictionary-readings.js.map +1 -0
  339. package/dist/dictionary/dictionary.d.ts +6 -60
  340. package/dist/dictionary/dictionary.d.ts.map +1 -1
  341. package/dist/dictionary/dictionary.js +9 -169
  342. package/dist/dictionary/dictionary.js.map +1 -1
  343. package/dist/dictionary/entry-invariants.d.ts +3 -0
  344. package/dist/dictionary/entry-invariants.d.ts.map +1 -0
  345. package/dist/dictionary/entry-invariants.js +67 -0
  346. package/dist/dictionary/entry-invariants.js.map +1 -0
  347. package/dist/dictionary/entry-lines.d.ts +35 -0
  348. package/dist/dictionary/entry-lines.d.ts.map +1 -0
  349. package/dist/dictionary/entry-lines.js +70 -0
  350. package/dist/dictionary/entry-lines.js.map +1 -0
  351. package/dist/dictionary/erhua-repair.d.ts +26 -0
  352. package/dist/dictionary/erhua-repair.d.ts.map +1 -0
  353. package/dist/dictionary/erhua-repair.js +49 -0
  354. package/dist/dictionary/erhua-repair.js.map +1 -0
  355. package/dist/dictionary/frequency-tones.d.ts +74 -0
  356. package/dist/dictionary/frequency-tones.d.ts.map +1 -0
  357. package/dist/dictionary/frequency-tones.js +128 -0
  358. package/dist/dictionary/frequency-tones.js.map +1 -0
  359. package/dist/dictionary/inventory-invariants.d.ts +3 -0
  360. package/dist/dictionary/inventory-invariants.d.ts.map +1 -0
  361. package/dist/dictionary/inventory-invariants.js +54 -0
  362. package/dist/dictionary/inventory-invariants.js.map +1 -0
  363. package/dist/dictionary/locale-candidates.d.ts +40 -0
  364. package/dist/dictionary/locale-candidates.d.ts.map +1 -0
  365. package/dist/dictionary/locale-candidates.js +77 -0
  366. package/dist/dictionary/locale-candidates.js.map +1 -0
  367. package/dist/dictionary/locale-segments.d.ts +47 -0
  368. package/dist/dictionary/locale-segments.d.ts.map +1 -0
  369. package/dist/dictionary/locale-segments.js +141 -0
  370. package/dist/dictionary/locale-segments.js.map +1 -0
  371. package/dist/dictionary/locale.d.ts +1 -21
  372. package/dist/dictionary/locale.d.ts.map +1 -1
  373. package/dist/dictionary/locale.js +9 -198
  374. package/dist/dictionary/locale.js.map +1 -1
  375. package/dist/dictionary/merge-types.d.ts +127 -0
  376. package/dist/dictionary/merge-types.d.ts.map +1 -0
  377. package/dist/dictionary/merge-types.js +35 -0
  378. package/dist/dictionary/merge-types.js.map +1 -0
  379. package/dist/dictionary/merge-walk.d.ts +27 -0
  380. package/dist/dictionary/merge-walk.d.ts.map +1 -0
  381. package/dist/dictionary/merge-walk.js +49 -0
  382. package/dist/dictionary/merge-walk.js.map +1 -0
  383. package/dist/dictionary/merge-word.d.ts +7 -0
  384. package/dist/dictionary/merge-word.d.ts.map +1 -0
  385. package/dist/dictionary/merge-word.js +91 -0
  386. package/dist/dictionary/merge-word.js.map +1 -0
  387. package/dist/dictionary/merge.d.ts +5 -62
  388. package/dist/dictionary/merge.d.ts.map +1 -1
  389. package/dist/dictionary/merge.js +32 -725
  390. package/dist/dictionary/merge.js.map +1 -1
  391. package/dist/dictionary/proper-noun.d.ts +28 -0
  392. package/dist/dictionary/proper-noun.d.ts.map +1 -0
  393. package/dist/dictionary/proper-noun.js +43 -0
  394. package/dist/dictionary/proper-noun.js.map +1 -0
  395. package/dist/dictionary/reading-agreement.d.ts +71 -0
  396. package/dist/dictionary/reading-agreement.d.ts.map +1 -0
  397. package/dist/dictionary/reading-agreement.js +156 -0
  398. package/dist/dictionary/reading-agreement.js.map +1 -0
  399. package/dist/dictionary/script-conversion.d.ts +28 -0
  400. package/dist/dictionary/script-conversion.d.ts.map +1 -0
  401. package/dist/dictionary/script-conversion.js +58 -0
  402. package/dist/dictionary/script-conversion.js.map +1 -0
  403. package/dist/dictionary/script-pairings.d.ts +74 -0
  404. package/dist/dictionary/script-pairings.d.ts.map +1 -0
  405. package/dist/dictionary/script-pairings.js +120 -0
  406. package/dist/dictionary/script-pairings.js.map +1 -0
  407. package/dist/dictionary/script-tables.d.ts.map +1 -1
  408. package/dist/dictionary/script-tables.js +2 -165
  409. package/dist/dictionary/script-tables.js.map +1 -1
  410. package/dist/dictionary/taiwan-reading.d.ts +8 -0
  411. package/dist/dictionary/taiwan-reading.d.ts.map +1 -0
  412. package/dist/dictionary/taiwan-reading.js +38 -0
  413. package/dist/dictionary/taiwan-reading.js.map +1 -0
  414. package/dist/dictionary/tone-invariants.d.ts +3 -0
  415. package/dist/dictionary/tone-invariants.d.ts.map +1 -0
  416. package/dist/dictionary/tone-invariants.js +64 -0
  417. package/dist/dictionary/tone-invariants.js.map +1 -0
  418. package/dist/dictionary/traditional-form.d.ts +21 -0
  419. package/dist/dictionary/traditional-form.d.ts.map +1 -0
  420. package/dist/dictionary/traditional-form.js +59 -0
  421. package/dist/dictionary/traditional-form.js.map +1 -0
  422. package/dist/dictionary/traditional-ranking.d.ts +22 -0
  423. package/dist/dictionary/traditional-ranking.d.ts.map +1 -0
  424. package/dist/dictionary/traditional-ranking.js +74 -0
  425. package/dist/dictionary/traditional-ranking.js.map +1 -0
  426. package/dist/dictionary/traditional-table.d.ts +51 -0
  427. package/dist/dictionary/traditional-table.d.ts.map +1 -0
  428. package/dist/dictionary/traditional-table.js +98 -0
  429. package/dist/dictionary/traditional-table.js.map +1 -0
  430. package/dist/dictionary/traditional.d.ts +3 -56
  431. package/dist/dictionary/traditional.d.ts.map +1 -1
  432. package/dist/dictionary/traditional.js +3 -186
  433. package/dist/dictionary/traditional.js.map +1 -1
  434. package/dist/dictionary/variant-counts.d.ts +39 -0
  435. package/dist/dictionary/variant-counts.d.ts.map +1 -0
  436. package/dist/dictionary/variant-counts.js +38 -0
  437. package/dist/dictionary/variant-counts.js.map +1 -0
  438. package/dist/dictionary/word-reading.d.ts +26 -0
  439. package/dist/dictionary/word-reading.d.ts.map +1 -0
  440. package/dist/dictionary/word-reading.js +76 -0
  441. package/dist/dictionary/word-reading.js.map +1 -0
  442. package/dist/dictionary/word-readings.d.ts +15 -0
  443. package/dist/dictionary/word-readings.d.ts.map +1 -0
  444. package/dist/dictionary/word-readings.js +41 -0
  445. package/dist/dictionary/word-readings.js.map +1 -0
  446. package/dist/format/annotate.d.ts +90 -0
  447. package/dist/format/annotate.d.ts.map +1 -0
  448. package/dist/format/annotate.js +168 -0
  449. package/dist/format/annotate.js.map +1 -0
  450. package/dist/format/html.d.ts +15 -46
  451. package/dist/format/html.d.ts.map +1 -1
  452. package/dist/format/html.js +3 -162
  453. package/dist/format/html.js.map +1 -1
  454. package/dist/format/slug-hash.d.ts +51 -0
  455. package/dist/format/slug-hash.d.ts.map +1 -0
  456. package/dist/format/slug-hash.js +74 -0
  457. package/dist/format/slug-hash.js.map +1 -0
  458. package/dist/format/slug-options.d.ts +98 -0
  459. package/dist/format/slug-options.d.ts.map +1 -0
  460. package/dist/format/slug-options.js +2 -0
  461. package/dist/format/slug-options.js.map +1 -0
  462. package/dist/format/slug-words.d.ts +27 -0
  463. package/dist/format/slug-words.d.ts.map +1 -0
  464. package/dist/format/slug-words.js +0 -0
  465. package/dist/format/slug-words.js.map +1 -0
  466. package/dist/format/slug.d.ts +3 -128
  467. package/dist/format/slug.d.ts.map +1 -1
  468. package/dist/format/slug.js +0 -0
  469. package/dist/format/slug.js.map +1 -1
  470. package/dist/grade/check-readings.d.ts +41 -0
  471. package/dist/grade/check-readings.d.ts.map +1 -0
  472. package/dist/grade/check-readings.js +36 -0
  473. package/dist/grade/check-readings.js.map +1 -0
  474. package/dist/grade/check.d.ts +4 -4
  475. package/dist/grade/check.d.ts.map +1 -1
  476. package/dist/grade/check.js +5 -270
  477. package/dist/grade/check.js.map +1 -1
  478. package/dist/grade/pair-syllables.d.ts +48 -0
  479. package/dist/grade/pair-syllables.d.ts.map +1 -0
  480. package/dist/grade/pair-syllables.js +71 -0
  481. package/dist/grade/pair-syllables.js.map +1 -0
  482. package/dist/grade/reading-syllables.d.ts +62 -0
  483. package/dist/grade/reading-syllables.d.ts.map +1 -0
  484. package/dist/grade/reading-syllables.js +58 -0
  485. package/dist/grade/reading-syllables.js.map +1 -0
  486. package/dist/grade/reading-tolerance.d.ts +72 -0
  487. package/dist/grade/reading-tolerance.d.ts.map +1 -0
  488. package/dist/grade/reading-tolerance.js +107 -0
  489. package/dist/grade/reading-tolerance.js.map +1 -0
  490. package/dist/grade/typed-reading.d.ts +28 -0
  491. package/dist/grade/typed-reading.d.ts.map +1 -0
  492. package/dist/grade/typed-reading.js +36 -0
  493. package/dist/grade/typed-reading.js.map +1 -0
  494. package/dist/index.d.ts +1 -1
  495. package/dist/index.d.ts.map +1 -1
  496. package/dist/index.js +1 -1
  497. package/dist/index.js.map +1 -1
  498. package/dist/numerals/numeral-parse.d.ts +32 -0
  499. package/dist/numerals/numeral-parse.d.ts.map +1 -0
  500. package/dist/numerals/numeral-parse.js +44 -0
  501. package/dist/numerals/numeral-parse.js.map +1 -0
  502. package/dist/numerals/numeral-shapes.d.ts +89 -0
  503. package/dist/numerals/numeral-shapes.d.ts.map +1 -0
  504. package/dist/numerals/numeral-shapes.js +99 -0
  505. package/dist/numerals/numeral-shapes.js.map +1 -0
  506. package/dist/numerals/numerals.d.ts.map +1 -1
  507. package/dist/numerals/numerals.js +2 -36
  508. package/dist/numerals/numerals.js.map +1 -1
  509. package/dist/numerals/read-numeral.d.ts +76 -0
  510. package/dist/numerals/read-numeral.d.ts.map +1 -0
  511. package/dist/numerals/read-numeral.js +88 -0
  512. package/dist/numerals/read-numeral.js.map +1 -0
  513. package/dist/numerals/text.d.ts +3 -37
  514. package/dist/numerals/text.d.ts.map +1 -1
  515. package/dist/numerals/text.js +3 -254
  516. package/dist/numerals/text.js.map +1 -1
  517. package/dist/numerals/time.d.ts +34 -0
  518. package/dist/numerals/time.d.ts.map +1 -0
  519. package/dist/numerals/time.js +93 -0
  520. package/dist/numerals/time.js.map +1 -0
  521. package/dist/orthography/address-grouping.d.ts +34 -0
  522. package/dist/orthography/address-grouping.d.ts.map +1 -0
  523. package/dist/orthography/address-grouping.js +52 -0
  524. package/dist/orthography/address-grouping.js.map +1 -0
  525. package/dist/orthography/grouping.d.ts +3 -87
  526. package/dist/orthography/grouping.d.ts.map +1 -1
  527. package/dist/orthography/grouping.js +4 -270
  528. package/dist/orthography/grouping.js.map +1 -1
  529. package/dist/orthography/place-grouping.d.ts +39 -0
  530. package/dist/orthography/place-grouping.d.ts.map +1 -0
  531. package/dist/orthography/place-grouping.js +83 -0
  532. package/dist/orthography/place-grouping.js.map +1 -0
  533. package/dist/orthography/word-grouping.d.ts +48 -0
  534. package/dist/orthography/word-grouping.d.ts.map +1 -0
  535. package/dist/orthography/word-grouping.js +147 -0
  536. package/dist/orthography/word-grouping.js.map +1 -0
  537. package/dist/script/conversion-format.d.ts +22 -0
  538. package/dist/script/conversion-format.d.ts.map +1 -0
  539. package/dist/script/conversion-format.js +22 -0
  540. package/dist/script/conversion-format.js.map +1 -0
  541. package/dist/script/conversion-read.d.ts +9 -0
  542. package/dist/script/conversion-read.d.ts.map +1 -0
  543. package/dist/script/conversion-read.js +69 -0
  544. package/dist/script/conversion-read.js.map +1 -0
  545. package/dist/script/conversion-write.d.ts +14 -0
  546. package/dist/script/conversion-write.d.ts.map +1 -0
  547. package/dist/script/conversion-write.js +34 -0
  548. package/dist/script/conversion-write.js.map +1 -0
  549. package/dist/script/conversion.d.ts +10 -16
  550. package/dist/script/conversion.d.ts.map +1 -1
  551. package/dist/script/conversion.js +2 -115
  552. package/dist/script/conversion.js.map +1 -1
  553. package/dist/search/candidate-narrowing.d.ts +56 -0
  554. package/dist/search/candidate-narrowing.d.ts.map +1 -0
  555. package/dist/search/candidate-narrowing.js +55 -0
  556. package/dist/search/candidate-narrowing.js.map +1 -0
  557. package/dist/search/candidate-query.d.ts +25 -0
  558. package/dist/search/candidate-query.d.ts.map +1 -0
  559. package/dist/search/candidate-query.js +28 -0
  560. package/dist/search/candidate-query.js.map +1 -0
  561. package/dist/search/candidate-writings.d.ts +24 -0
  562. package/dist/search/candidate-writings.d.ts.map +1 -0
  563. package/dist/search/candidate-writings.js +114 -0
  564. package/dist/search/candidate-writings.js.map +1 -0
  565. package/dist/search/candidates.d.ts +7 -41
  566. package/dist/search/candidates.d.ts.map +1 -1
  567. package/dist/search/candidates.js +10 -164
  568. package/dist/search/candidates.js.map +1 -1
  569. package/dist/search/match-chunks.d.ts +19 -0
  570. package/dist/search/match-chunks.d.ts.map +1 -0
  571. package/dist/search/match-chunks.js +30 -0
  572. package/dist/search/match-chunks.js.map +1 -0
  573. package/dist/search/match-ranking.d.ts +39 -0
  574. package/dist/search/match-ranking.d.ts.map +1 -0
  575. package/dist/search/match-ranking.js +51 -0
  576. package/dist/search/match-ranking.js.map +1 -0
  577. package/dist/search/match-readings.d.ts +43 -0
  578. package/dist/search/match-readings.d.ts.map +1 -0
  579. package/dist/search/match-readings.js +83 -0
  580. package/dist/search/match-readings.js.map +1 -0
  581. package/dist/search/match-scoring.d.ts +146 -0
  582. package/dist/search/match-scoring.d.ts.map +1 -0
  583. package/dist/search/match-scoring.js +114 -0
  584. package/dist/search/match-scoring.js.map +1 -0
  585. package/dist/search/match-search.d.ts +28 -0
  586. package/dist/search/match-search.d.ts.map +1 -0
  587. package/dist/search/match-search.js +128 -0
  588. package/dist/search/match-search.js.map +1 -0
  589. package/dist/search/match.d.ts +5 -36
  590. package/dist/search/match.d.ts.map +1 -1
  591. package/dist/search/match.js +2 -379
  592. package/dist/search/match.js.map +1 -1
  593. package/dist/search/reverse-index-build.d.ts +30 -0
  594. package/dist/search/reverse-index-build.d.ts.map +1 -0
  595. package/dist/search/reverse-index-build.js +72 -0
  596. package/dist/search/reverse-index-build.js.map +1 -0
  597. package/dist/search/reverse-index-format.d.ts +60 -0
  598. package/dist/search/reverse-index-format.d.ts.map +1 -0
  599. package/dist/search/reverse-index-format.js +54 -0
  600. package/dist/search/reverse-index-format.js.map +1 -0
  601. package/dist/search/reverse-index-groups.d.ts +37 -0
  602. package/dist/search/reverse-index-groups.d.ts.map +1 -0
  603. package/dist/search/reverse-index-groups.js +71 -0
  604. package/dist/search/reverse-index-groups.js.map +1 -0
  605. package/dist/search/reverse-index-passes.d.ts +78 -0
  606. package/dist/search/reverse-index-passes.d.ts.map +1 -0
  607. package/dist/search/reverse-index-passes.js +59 -0
  608. package/dist/search/reverse-index-passes.js.map +1 -0
  609. package/dist/search/reverse-index-state.d.ts +36 -0
  610. package/dist/search/reverse-index-state.d.ts.map +1 -0
  611. package/dist/search/reverse-index-state.js +95 -0
  612. package/dist/search/reverse-index-state.js.map +1 -0
  613. package/dist/search/reverse-index.d.ts +8 -67
  614. package/dist/search/reverse-index.d.ts.map +1 -1
  615. package/dist/search/reverse-index.js +4 -255
  616. package/dist/search/reverse-index.js.map +1 -1
  617. package/dist/sources/unihan-readings.d.ts +58 -0
  618. package/dist/sources/unihan-readings.d.ts.map +1 -0
  619. package/dist/sources/unihan-readings.js +95 -0
  620. package/dist/sources/unihan-readings.js.map +1 -0
  621. package/dist/sources/unihan.d.ts +6 -9
  622. package/dist/sources/unihan.d.ts.map +1 -1
  623. package/dist/sources/unihan.js +2 -85
  624. package/dist/sources/unihan.js.map +1 -1
  625. package/dist/syllable/final-tables.d.ts +23 -0
  626. package/dist/syllable/final-tables.d.ts.map +1 -0
  627. package/dist/syllable/final-tables.js +50 -0
  628. package/dist/syllable/final-tables.js.map +1 -0
  629. package/dist/syllable/inventory.d.ts +8 -42
  630. package/dist/syllable/inventory.d.ts.map +1 -1
  631. package/dist/syllable/inventory.js +9 -918
  632. package/dist/syllable/inventory.js.map +1 -1
  633. package/dist/syllable/spellings.d.ts +40 -0
  634. package/dist/syllable/spellings.d.ts.map +1 -0
  635. package/dist/syllable/spellings.js +469 -0
  636. package/dist/syllable/spellings.js.map +1 -0
  637. package/dist/syllable/syllable-parts.d.ts +31 -0
  638. package/dist/syllable/syllable-parts.d.ts.map +1 -0
  639. package/dist/syllable/syllable-parts.js +105 -0
  640. package/dist/syllable/syllable-parts.js.map +1 -0
  641. package/dist/syllable/syllable.d.ts +1 -14
  642. package/dist/syllable/syllable.d.ts.map +1 -1
  643. package/dist/syllable/syllable.js +3 -144
  644. package/dist/syllable/syllable.js.map +1 -1
  645. package/dist/syllable/written-tones.d.ts +6 -0
  646. package/dist/syllable/written-tones.d.ts.map +1 -0
  647. package/dist/syllable/written-tones.js +453 -0
  648. package/dist/syllable/written-tones.js.map +1 -0
  649. package/dist/transcription/bopomofo-parse.d.ts +42 -0
  650. package/dist/transcription/bopomofo-parse.d.ts.map +1 -0
  651. package/dist/transcription/bopomofo-parse.js +92 -0
  652. package/dist/transcription/bopomofo-parse.js.map +1 -0
  653. package/dist/transcription/bopomofo-reverse.d.ts +31 -0
  654. package/dist/transcription/bopomofo-reverse.d.ts.map +1 -0
  655. package/dist/transcription/bopomofo-reverse.js +48 -0
  656. package/dist/transcription/bopomofo-reverse.js.map +1 -0
  657. package/dist/transcription/bopomofo-symbols.d.ts +36 -0
  658. package/dist/transcription/bopomofo-symbols.d.ts.map +1 -0
  659. package/dist/transcription/bopomofo-symbols.js +41 -0
  660. package/dist/transcription/bopomofo-symbols.js.map +1 -0
  661. package/dist/transcription/bopomofo-tables.d.ts +87 -0
  662. package/dist/transcription/bopomofo-tables.d.ts.map +1 -0
  663. package/dist/transcription/bopomofo-tables.js +180 -0
  664. package/dist/transcription/bopomofo-tables.js.map +1 -0
  665. package/dist/transcription/bopomofo.d.ts +14 -32
  666. package/dist/transcription/bopomofo.d.ts.map +1 -1
  667. package/dist/transcription/bopomofo.js +5 -343
  668. package/dist/transcription/bopomofo.js.map +1 -1
  669. package/dist/transcription/gwoyeu-first-second.d.ts +36 -0
  670. package/dist/transcription/gwoyeu-first-second.d.ts.map +1 -0
  671. package/dist/transcription/gwoyeu-first-second.js +75 -0
  672. package/dist/transcription/gwoyeu-first-second.js.map +1 -0
  673. package/dist/transcription/gwoyeu-spelling.d.ts +38 -0
  674. package/dist/transcription/gwoyeu-spelling.d.ts.map +1 -0
  675. package/dist/transcription/gwoyeu-spelling.js +124 -0
  676. package/dist/transcription/gwoyeu-spelling.js.map +1 -0
  677. package/dist/transcription/gwoyeu-tables.d.ts +93 -0
  678. package/dist/transcription/gwoyeu-tables.d.ts.map +1 -0
  679. package/dist/transcription/gwoyeu-tables.js +205 -0
  680. package/dist/transcription/gwoyeu-tables.js.map +1 -0
  681. package/dist/transcription/gwoyeu-tonal-forms.d.ts +49 -0
  682. package/dist/transcription/gwoyeu-tonal-forms.d.ts.map +1 -0
  683. package/dist/transcription/gwoyeu-tonal-forms.js +89 -0
  684. package/dist/transcription/gwoyeu-tonal-forms.js.map +1 -0
  685. package/dist/transcription/gwoyeu-vowels.d.ts +51 -0
  686. package/dist/transcription/gwoyeu-vowels.d.ts.map +1 -0
  687. package/dist/transcription/gwoyeu-vowels.js +58 -0
  688. package/dist/transcription/gwoyeu-vowels.js.map +1 -0
  689. package/dist/transcription/gwoyeu.d.ts +1 -26
  690. package/dist/transcription/gwoyeu.d.ts.map +1 -1
  691. package/dist/transcription/gwoyeu.js +2 -540
  692. package/dist/transcription/gwoyeu.js.map +1 -1
  693. package/dist/transcription/ipa-symbols.d.ts +67 -0
  694. package/dist/transcription/ipa-symbols.d.ts.map +1 -0
  695. package/dist/transcription/ipa-symbols.js +135 -0
  696. package/dist/transcription/ipa-symbols.js.map +1 -0
  697. package/dist/transcription/ipa.d.ts +2 -10
  698. package/dist/transcription/ipa.d.ts.map +1 -1
  699. package/dist/transcription/ipa.js +2 -134
  700. package/dist/transcription/ipa.js.map +1 -1
  701. package/dist/transcription/wade-giles-index.d.ts +35 -0
  702. package/dist/transcription/wade-giles-index.d.ts.map +1 -0
  703. package/dist/transcription/wade-giles-index.js +110 -0
  704. package/dist/transcription/wade-giles-index.js.map +1 -0
  705. package/dist/transcription/wade-giles-parse.d.ts +36 -0
  706. package/dist/transcription/wade-giles-parse.d.ts.map +1 -0
  707. package/dist/transcription/wade-giles-parse.js +84 -0
  708. package/dist/transcription/wade-giles-parse.js.map +1 -0
  709. package/dist/transcription/wade-giles-spelling.d.ts +61 -0
  710. package/dist/transcription/wade-giles-spelling.d.ts.map +1 -0
  711. package/dist/transcription/wade-giles-spelling.js +107 -0
  712. package/dist/transcription/wade-giles-spelling.js.map +1 -0
  713. package/dist/transcription/wade-giles-syllable.d.ts +29 -0
  714. package/dist/transcription/wade-giles-syllable.d.ts.map +1 -0
  715. package/dist/transcription/wade-giles-syllable.js +90 -0
  716. package/dist/transcription/wade-giles-syllable.js.map +1 -0
  717. package/dist/transcription/wade-giles-tables.d.ts +80 -0
  718. package/dist/transcription/wade-giles-tables.d.ts.map +1 -0
  719. package/dist/transcription/wade-giles-tables.js +178 -0
  720. package/dist/transcription/wade-giles-tables.js.map +1 -0
  721. package/dist/transcription/wade-giles.d.ts +9 -60
  722. package/dist/transcription/wade-giles.d.ts.map +1 -1
  723. package/dist/transcription/wade-giles.js +6 -543
  724. package/dist/transcription/wade-giles.js.map +1 -1
  725. package/dist/transcription/yale-tables.d.ts +54 -0
  726. package/dist/transcription/yale-tables.d.ts.map +1 -0
  727. package/dist/transcription/yale-tables.js +125 -0
  728. package/dist/transcription/yale-tables.js.map +1 -0
  729. package/dist/transcription/yale.d.ts.map +1 -1
  730. package/dist/transcription/yale.js +1 -124
  731. package/dist/transcription/yale.js.map +1 -1
  732. package/package.json +2 -2
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Cutting a compound into the constituents a 國語 delta can be composed from.
3
+ *
4
+ * The segmentation the composition runs on: which pieces a word divides into,
5
+ * and what each of them costs, so that the division a reader would make is
6
+ * the one that wins.
7
+ */
8
+ import { toCharacters } from "../script/characters.js";
9
+ import { FrequencyTable } from "./frequency-table.js";
10
+ /**
11
+ * What each word in a segmentation costs on top of its frequency.
12
+ *
13
+ * The same charge, and for the same reason, as `READING_CHARGE` in
14
+ * `src/decode/lattice.ts`: it orders candidate segmentations by fewest words
15
+ * first and frequency second. That ordering is what decides 皮夹克 is 皮 + 夹克
16
+ * rather than 皮夹 + 克, which is the difference between leaving `pí jiákè`
17
+ * alone and mistaking it for the wallet 皮夹 that reads `pí jiá` in 國語.
18
+ *
19
+ * Duplicated rather than imported because the decoder sits above the dictionary
20
+ * and must not be depended on from inside it. The two are kept in step by
21
+ * `src/dictionary/locale.test.ts`, which asserts the segmentations this value
22
+ * produces rather than the value itself.
23
+ */
24
+ const WORD_CHARGE = 16;
25
+ /**
26
+ * Every key an entry answers to, under either script.
27
+ */
28
+ export function keysOf(entry) {
29
+ return [entry.hans, entry.hant, ...(entry.hantVariants ?? [])];
30
+ }
31
+ /**
32
+ * A compound's constituent words, and the readings they carry.
33
+ *
34
+ * Indexed by every key an entry claims, so that a 繁體 headword segments into
35
+ * 繁體 constituents. Headwords are set first and never displaced, which is the
36
+ * same precedence the artifact and the build assertions use: 发 and 髮 both claim
37
+ * 发, and the entry the key names has to win.
38
+ */
39
+ export class ConstituentIndex {
40
+ #byKey;
41
+ #cost;
42
+ /**
43
+ * Index entries by key, quantising their frequencies the way the decoder will.
44
+ */
45
+ constructor(entries) {
46
+ const byKey = new Map();
47
+ for (const entry of entries) {
48
+ byKey.set(entry.hans, entry);
49
+ }
50
+ for (const entry of entries) {
51
+ for (const form of keysOf(entry)) {
52
+ if (!byKey.has(form)) {
53
+ byKey.set(form, entry);
54
+ }
55
+ }
56
+ }
57
+ // Costs come from the same quantised table the artifact ships, so that a
58
+ // segmentation decided here is the one the decoder would have reached.
59
+ const table = FrequencyTable.build(entries.map((entry) => entry.frequency));
60
+ const byEntry = new Map();
61
+ for (const [at, entry] of entries.entries()) {
62
+ byEntry.set(entry, table.costOf(at));
63
+ }
64
+ const cost = new Map();
65
+ for (const [key, entry] of byKey) {
66
+ /* c8 ignore next -- every key was indexed from one of these entries */
67
+ cost.set(key, (byEntry.get(entry) ?? 0) + WORD_CHARGE);
68
+ }
69
+ this.#byKey = byKey;
70
+ this.#cost = cost;
71
+ }
72
+ /**
73
+ * Relax every word starting at one position, improving the costs it reaches.
74
+ *
75
+ * One step of the shortest-path scan, lifted out of its enclosing loop.
76
+ */
77
+ #relaxFrom(word, characters, from, best, previous) {
78
+ /* c8 ignore next -- the caller only relaxes from a position in range */
79
+ const reached = best[from] ?? Infinity;
80
+ let candidate = "";
81
+ for (let to = from; to < characters.length; to++) {
82
+ /* c8 ignore next -- the loop condition keeps the index in range */
83
+ candidate += characters[to] ?? "";
84
+ // The whole word is not a segmentation of itself.
85
+ const entry = candidate === word ? undefined : this.#byKey.get(candidate);
86
+ const total = reached + this.costOf(candidate);
87
+ /* c8 ignore next -- `to + 1` is at most `length`, which `best` holds */
88
+ if (entry !== undefined && total < (best[to + 1] ?? Infinity)) {
89
+ best[to + 1] = total;
90
+ previous[to + 1] = { entry, text: candidate, from, to: to + 1 };
91
+ }
92
+ }
93
+ }
94
+ /**
95
+ * What a key costs a segmentation that uses it.
96
+ */
97
+ costOf(key) {
98
+ /* c8 ignore next -- only asked about keys the index just returned */
99
+ return this.#cost.get(key) ?? WORD_CHARGE;
100
+ }
101
+ /**
102
+ * The likeliest way to cut a word into *other* dictionary words.
103
+ *
104
+ * The whole word is excluded from its own segmentation, which is the point:
105
+ * 垃圾分类 is a dictionary word, so a decoder handed the text would stop there
106
+ * and never ask what it is made of. This asks anyway.
107
+ *
108
+ * Returns undefined when no path of known words covers the word, which is
109
+ * common — most compounds contain a character no shorter word claims.
110
+ */
111
+ segment(word) {
112
+ const characters = toCharacters(word);
113
+ const length = characters.length;
114
+ const best = Array.from({ length: length + 1 }, () => Infinity);
115
+ const previous = Array.from({ length: length + 1 });
116
+ best[0] = 0;
117
+ for (let from = 0; from < length; from++) {
118
+ /* c8 ignore next -- the loop condition keeps the index in range */
119
+ if ((best[from] ?? Infinity) !== Infinity) {
120
+ this.#relaxFrom(word, characters, from, best, previous);
121
+ }
122
+ }
123
+ /* c8 ignore next -- `best` is built one longer than the word */
124
+ if ((best[length] ?? Infinity) === Infinity) {
125
+ return undefined;
126
+ }
127
+ const path = [];
128
+ let at = length;
129
+ while (at > 0) {
130
+ const step = previous[at];
131
+ /* c8 ignore next 3 -- a finite cost at `at` means a step reached it */
132
+ if (step === undefined) {
133
+ return undefined;
134
+ }
135
+ path.unshift(step);
136
+ at = step.from;
137
+ }
138
+ return path;
139
+ }
140
+ }
141
+ //# sourceMappingURL=locale-segments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-segments.js","sourceRoot":"","sources":["../../src/dictionary/locale-segments.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,GAAG,EAAE,CAAC;AAcvB;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAAsB;IAC3C,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC;AACjE,CAA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EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;QACjB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -1,25 +1,5 @@
1
1
  import { type DictionaryEntry } from "./entry.js";
2
- /**
3
- * Compounds whose constituent's 國語 reading must not be carried over.
4
- *
5
- * The composition below only fires where the compound reads its constituent
6
- * exactly as that constituent's own entry does, which rules out most of the ways
7
- * it could be wrong. What it cannot rule out is a homograph: two words spelled
8
- * and read identically in 普通话, of which only one shifts in 國語. 相亲 is
9
- * `xiāngqīn` either way when it means "mutually close" and `xiàngqīn` in Taiwan
10
- * when it means a matchmaking meeting, and nothing in the data distinguishes the
11
- * two senses.
12
- *
13
- * **Keep this small**, for the same reason
14
- * {@link import("./overrides.js").READING_OVERRIDES} is kept small. Three
15
- * exclusions against the 100 compounds the composition settles is the measured
16
- * ratio; a list growing much past that would mean the alignment check has
17
- * stopped carrying its weight and the rule itself needs revisiting.
18
- */
19
- export declare const LOCALE_COMPOSITION_EXCLUSIONS: readonly {
20
- readonly word: string;
21
- readonly reason: string;
22
- }[];
2
+ export { LOCALE_COMPOSITION_EXCLUSIONS } from "./locale-candidates.js";
23
3
  /**
24
4
  * What the composition pass changed.
25
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/dictionary/locale.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,YAAY,CAAC;AAGjE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,EAeA,CAAC;AA6PF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAYD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,iBAAiB,CA8DnB"}
1
+ {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/dictionary/locale.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,YAAY,CAAC;AAIjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AA6CvE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAYD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,iBAAiB,CA8DnB"}
@@ -1,172 +1,15 @@
1
- import { isSingleCharacter, toCharacters } from "../script/characters.js";
2
- import { isSameReading } from "./entry.js";
3
- import { FrequencyTable } from "./frequency-table.js";
4
1
  /**
5
- * Compounds whose constituent's 國語 reading must not be carried over.
6
- *
7
- * The composition below only fires where the compound reads its constituent
8
- * exactly as that constituent's own entry does, which rules out most of the ways
9
- * it could be wrong. What it cannot rule out is a homograph: two words spelled
10
- * and read identically in 普通话, of which only one shifts in 國語. 相亲 is
11
- * `xiāngqīn` either way when it means "mutually close" and `xiàngqīn` in Taiwan
12
- * when it means a matchmaking meeting, and nothing in the data distinguishes the
13
- * two senses.
2
+ * Giving a compound the 國語 reading its constituents already carry.
14
3
  *
15
- * **Keep this small**, for the same reason
16
- * {@link import("./overrides.js").READING_OVERRIDES} is kept small. Three
17
- * exclusions against the 100 compounds the composition settles is the measured
18
- * ratio; a list growing much past that would mean the alignment check has
19
- * stopped carrying its weight and the rule itself needs revisiting.
20
- */
21
- export const LOCALE_COMPOSITION_EXCLUSIONS = [
22
- {
23
- word: "相亲相爱",
24
- reason: "相亲 here is 相 + 亲 in the reciprocal sense, `xiāngqīn`, not the matchmaking word that reads `xiàngqīn` in 國語.",
25
- },
26
- {
27
- word: "腹背相亲",
28
- reason: "The same reciprocal 相亲, so the same reading in both locales.",
29
- },
30
- {
31
- word: "洋为中用",
32
- reason: "中 is 中国 and 用 is its own verb: 洋为中用 is not built on the word 中用, which is what reads `zhòngyòng` in 國語.",
33
- },
34
- ];
35
- /**
36
- * The exclusions as a set, for the composition to consult.
4
+ * Which compounds may be asked at all is `locale-candidates.ts`; what is here
5
+ * is what a compound inherits once it has been asked, and the rounds of the
6
+ * pass that let an inheritance itself be inherited.
37
7
  */
38
- const EXCLUDED = new Set(LOCALE_COMPOSITION_EXCLUSIONS.map((exclusion) => exclusion.word));
39
- /**
40
- * What each word in a segmentation costs on top of its frequency.
41
- *
42
- * The same charge, and for the same reason, as `READING_CHARGE` in
43
- * `src/decode/lattice.ts`: it orders candidate segmentations by fewest words
44
- * first and frequency second. That ordering is what decides 皮夹克 is 皮 + 夹克
45
- * rather than 皮夹 + 克, which is the difference between leaving `pí jiákè`
46
- * alone and mistaking it for the wallet 皮夹 that reads `pí jiá` in 國語.
47
- *
48
- * Duplicated rather than imported because the decoder sits above the dictionary
49
- * and must not be depended on from inside it. The two are kept in step by
50
- * `src/dictionary/locale.test.ts`, which asserts the segmentations this value
51
- * produces rather than the value itself.
52
- */
53
- const WORD_CHARGE = 16;
54
- /**
55
- * Every key an entry answers to, under either script.
56
- */
57
- function keysOf(entry) {
58
- return [entry.hans, entry.hant, ...(entry.hantVariants ?? [])];
59
- }
60
- /**
61
- * A compound's constituent words, and the readings they carry.
62
- *
63
- * Indexed by every key an entry claims, so that a 繁體 headword segments into
64
- * 繁體 constituents. Headwords are set first and never displaced, which is the
65
- * same precedence the artifact and the build assertions use: 发 and 髮 both claim
66
- * 发, and the entry the key names has to win.
67
- */
68
- class ConstituentIndex {
69
- #byKey;
70
- #cost;
71
- /**
72
- * Index entries by key, quantising their frequencies the way the decoder will.
73
- */
74
- constructor(entries) {
75
- const byKey = new Map();
76
- for (const entry of entries) {
77
- byKey.set(entry.hans, entry);
78
- }
79
- for (const entry of entries) {
80
- for (const form of keysOf(entry)) {
81
- if (!byKey.has(form)) {
82
- byKey.set(form, entry);
83
- }
84
- }
85
- }
86
- // Costs come from the same quantised table the artifact ships, so that a
87
- // segmentation decided here is the one the decoder would have reached.
88
- const table = FrequencyTable.build(entries.map((entry) => entry.frequency));
89
- const byEntry = new Map();
90
- for (const [at, entry] of entries.entries()) {
91
- byEntry.set(entry, table.costOf(at));
92
- }
93
- const cost = new Map();
94
- for (const [key, entry] of byKey) {
95
- /* c8 ignore next -- every key was indexed from one of these entries */
96
- cost.set(key, (byEntry.get(entry) ?? 0) + WORD_CHARGE);
97
- }
98
- this.#byKey = byKey;
99
- this.#cost = cost;
100
- }
101
- /**
102
- * Relax every word starting at one position, improving the costs it reaches.
103
- *
104
- * One step of the shortest-path scan, lifted out of its enclosing loop.
105
- */
106
- #relaxFrom(word, characters, from, best, previous) {
107
- /* c8 ignore next -- the caller only relaxes from a position in range */
108
- const reached = best[from] ?? Infinity;
109
- let candidate = "";
110
- for (let to = from; to < characters.length; to++) {
111
- /* c8 ignore next -- the loop condition keeps the index in range */
112
- candidate += characters[to] ?? "";
113
- // The whole word is not a segmentation of itself.
114
- const entry = candidate === word ? undefined : this.#byKey.get(candidate);
115
- const total = reached + this.costOf(candidate);
116
- /* c8 ignore next -- `to + 1` is at most `length`, which `best` holds */
117
- if (entry !== undefined && total < (best[to + 1] ?? Infinity)) {
118
- best[to + 1] = total;
119
- previous[to + 1] = { entry, text: candidate, from, to: to + 1 };
120
- }
121
- }
122
- }
123
- /**
124
- * What a key costs a segmentation that uses it.
125
- */
126
- costOf(key) {
127
- /* c8 ignore next -- only asked about keys the index just returned */
128
- return this.#cost.get(key) ?? WORD_CHARGE;
129
- }
130
- /**
131
- * The likeliest way to cut a word into *other* dictionary words.
132
- *
133
- * The whole word is excluded from its own segmentation, which is the point:
134
- * 垃圾分类 is a dictionary word, so a decoder handed the text would stop there
135
- * and never ask what it is made of. This asks anyway.
136
- *
137
- * Returns undefined when no path of known words covers the word, which is
138
- * common — most compounds contain a character no shorter word claims.
139
- */
140
- segment(word) {
141
- const characters = toCharacters(word);
142
- const length = characters.length;
143
- const best = Array.from({ length: length + 1 }, () => Infinity);
144
- const previous = Array.from({ length: length + 1 });
145
- best[0] = 0;
146
- for (let from = 0; from < length; from++) {
147
- /* c8 ignore next -- the loop condition keeps the index in range */
148
- if ((best[from] ?? Infinity) !== Infinity) {
149
- this.#relaxFrom(word, characters, from, best, previous);
150
- }
151
- }
152
- /* c8 ignore next -- `best` is built one longer than the word */
153
- if ((best[length] ?? Infinity) === Infinity) {
154
- return undefined;
155
- }
156
- const path = [];
157
- let at = length;
158
- while (at > 0) {
159
- const step = previous[at];
160
- /* c8 ignore next 3 -- a finite cost at `at` means a step reached it */
161
- if (step === undefined) {
162
- return undefined;
163
- }
164
- path.unshift(step);
165
- at = step.from;
166
- }
167
- return path;
168
- }
169
- }
8
+ import { isSingleCharacter } from "../script/characters.js";
9
+ import { isSameReading } from "./entry.js";
10
+ import { hasMarkedConstituent, isComposable } from "./locale-candidates.js";
11
+ import { ConstituentIndex, keysOf } from "./locale-segments.js";
12
+ export { LOCALE_COMPOSITION_EXCLUSIONS } from "./locale-candidates.js";
170
13
  /**
171
14
  * The 國語 reading a compound inherits from its constituents, or undefined.
172
15
  *
@@ -204,38 +47,6 @@ function composedReading(entry, path, settled) {
204
47
  }
205
48
  return isContributed ? composed : undefined;
206
49
  }
207
- /**
208
- * Whether a compound can be asked what it is made of at all.
209
- *
210
- * A reading of one syllable per character is what lets a character span be cut
211
- * out of the compound's reading and replaced. 儿化 folds two characters into one
212
- * syllable and punctuation reads as none, so neither lines up and both are left
213
- * alone.
214
- */
215
- function isComposable(entry) {
216
- const characters = toCharacters(entry.hans);
217
- return (characters.length > 2 &&
218
- entry.readings.cn.length === characters.length &&
219
- !EXCLUDED.has(entry.hans) &&
220
- !EXCLUDED.has(entry.hant));
221
- }
222
- /**
223
- * Whether any delta-carrying word appears inside this one.
224
- *
225
- * A cheap filter ahead of the segmentation: only a few hundred words carry a
226
- * delta, against 461,555 entries, and enumerating one word's substrings costs
227
- * far less than segmenting it.
228
- */
229
- function hasMarkedConstituent(word, marked) {
230
- const characters = toCharacters(word);
231
- return characters.some((_, from) => {
232
- let candidate = "";
233
- return characters.slice(from).some((character) => {
234
- candidate += character;
235
- return candidate !== word && marked.has(candidate);
236
- });
237
- });
238
- }
239
50
  /**
240
51
  * How many times the pass may feed its own output back in.
241
52
  *
@@ -1 +1 @@
1
- {"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/dictionary/locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAwB,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAGpC;IACJ;QACE,IAAI,EAAE,MAAM;QACZ,MAAM,EACJ,6GAA6G;KAChH;IACD;QACE,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,8DAA8D;KACvE;IACD;QACE,IAAI,EAAE,MAAM;QACZ,MAAM,EACJ,yGAAyG;KAC5G;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAC3C,6BAA6B,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CACjE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,GAAG,EAAE,CAAC;AAcvB;;GAEG;AACH,SAAS,MAAM,CAAC,KAAsB;IACpC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,C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AK,CAAC;QACf,CAAC;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,SAAS,IAAI,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QACvE,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;YAClB,MAAM;QACR,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,OAAO,OAAO,KAAK,SAAS;YAC1B,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * What the merge takes in and what it hands back.
3
+ *
4
+ * Their own module so that a step of the merge can name them without
5
+ * importing the merge itself.
6
+ */
7
+ import type { CedictEntry } from "../sources/cedict.js";
8
+ import type { JiebaEntry } from "../sources/jieba.js";
9
+ import type { UnihanReadings, UnihanVariants } from "../sources/unihan.js";
10
+ import type { Syllable } from "../syllable/syllable.js";
11
+ import type { DictionaryEntry } from "./entry.js";
12
+ import type { TraditionalTable } from "./traditional-table.js";
13
+ /**
14
+ * The parsed sources the merge combines.
15
+ */
16
+ export interface MergeSources {
17
+ readonly unihanReadings: ReadonlyMap<string, UnihanReadings>;
18
+ readonly unihanVariants: UnihanVariants;
19
+ readonly phrase: ReadonlyMap<string, readonly string[]>;
20
+ readonly cedict: readonly CedictEntry[];
21
+ readonly jieba: ReadonlyMap<string, JiebaEntry>;
22
+ }
23
+ /**
24
+ * Counts describing what the merge did, for the build to report and check.
25
+ */
26
+ export interface MergeStats {
27
+ readonly characters: number;
28
+ readonly phraseWords: number;
29
+ readonly cedictWords: number;
30
+ /** Words whose reading CC-CEDICT corrected to a neutral tone. */
31
+ readonly neutralToneCorrections: number;
32
+ /**
33
+ * Characters whose default was a 轻声 the frequency field only counted inside
34
+ * words — see {@link import("./frequency-tones.js").demoteReducedNeutrals}.
35
+ */
36
+ readonly reducedNeutrals: number;
37
+ /** Words whose trailing 儿 was folded into the syllable before it. */
38
+ readonly erhuaRepairs: number;
39
+ /** Words whose 繁體 form was derived rather than taken from CC-CEDICT. */
40
+ readonly derivedTraditional: number;
41
+ /** Entries with a 繁體 form differing from their 简体 one. */
42
+ readonly scriptPairs: number;
43
+ /** Entries a source writes more than one 繁體 spelling of. */
44
+ readonly variantSpellings: number;
45
+ /**
46
+ * Phrase entries read as a corroborated word inside them reads them — see
47
+ * {@link import("./constituent-repair.js").repairConstituentReadings}.
48
+ */
49
+ readonly repairedConstituents: number;
50
+ /** Entries carrying a zh-TW reading delta a source stated. */
51
+ readonly taiwanReadings: number;
52
+ /** Compounds given a zh-TW delta composed from their constituents. */
53
+ readonly composedTaiwanReadings: number;
54
+ /**
55
+ * Words jieba tagged a proper noun that CC-CEDICT's lowercase pinyin vetoed.
56
+ */
57
+ readonly properNounVetoes: number;
58
+ /** Entries whose parts CC-CEDICT's capitalisation divides. */
59
+ readonly nameBoundaries: number;
60
+ /** Words dropped because no source gave a usable reading. */
61
+ readonly rejected: number;
62
+ }
63
+ /**
64
+ * What the merge produced.
65
+ */
66
+ export interface MergeResult {
67
+ /** Entries, ordered by their 简体 form. */
68
+ readonly entries: readonly DictionaryEntry[];
69
+ /** Words no source could be read, with the reading that failed. */
70
+ readonly rejected: ReadonlyMap<string, readonly string[]>;
71
+ readonly stats: MergeStats;
72
+ }
73
+ /**
74
+ * What the sources between them say about one word, indexed once for all of
75
+ * them.
76
+ *
77
+ * The per-word view of {@link MergeSources}: the same data, turned inside out
78
+ * so that merging a word is a handful of map reads rather than a scan.
79
+ */
80
+ export interface WordSources {
81
+ readonly cedictByWord: ReadonlyMap<string, readonly CedictEntry[]>;
82
+ readonly cedictByHant: ReadonlyMap<string, readonly CedictEntry[]>;
83
+ readonly phrase: ReadonlyMap<string, readonly string[]>;
84
+ readonly jieba: ReadonlyMap<string, JiebaEntry>;
85
+ readonly unihanReadings: ReadonlyMap<string, UnihanReadings>;
86
+ readonly traditional: TraditionalTable;
87
+ readonly defaults: ReadonlyMap<string, readonly Syllable[]>;
88
+ }
89
+ /**
90
+ * What one word contributed to the build's counts.
91
+ *
92
+ * The per-word view of {@link MergeStats}, minus the counts no single word can
93
+ * move: `reducedNeutrals`, `repairedConstituents` and `composedTaiwanReadings`
94
+ * are settled by passes over the whole dictionary, and `rejected` is counted by
95
+ * the caller.
96
+ */
97
+ export interface WordTally {
98
+ readonly neutralToneCorrections: number;
99
+ readonly erhuaRepairs: number;
100
+ readonly derivedTraditional: number;
101
+ readonly scriptPairs: number;
102
+ readonly variantSpellings: number;
103
+ readonly taiwanReadings: number;
104
+ readonly properNounVetoes: number;
105
+ readonly nameBoundaries: number;
106
+ readonly characters: number;
107
+ readonly phraseWords: number;
108
+ readonly cedictWords: number;
109
+ }
110
+ /**
111
+ * A word that contributed nothing, because no source could read it.
112
+ */
113
+ export declare const NO_TALLY: WordTally;
114
+ /**
115
+ * One word's entry, or the reading that failed.
116
+ */
117
+ export interface MergedWord {
118
+ readonly entry: DictionaryEntry | undefined;
119
+ /** The reading no source could make sense of, where that is what happened. */
120
+ readonly rejected: readonly string[] | undefined;
121
+ readonly tally: WordTally;
122
+ }
123
+ /**
124
+ * Add one word's tally to the running total.
125
+ */
126
+ export declare function addTally(total: WordTally, tally: WordTally): WordTally;
127
+ //# sourceMappingURL=merge-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-types.d.ts","sourceRoot":"","sources":["../../src/dictionary/merge-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7D,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IACxD,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,Q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C3B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,CAetE"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * A word that contributed nothing, because no source could read it.
3
+ */
4
+ export const NO_TALLY = {
5
+ neutralToneCorrections: 0,
6
+ erhuaRepairs: 0,
7
+ derivedTraditional: 0,
8
+ scriptPairs: 0,
9
+ variantSpellings: 0,
10
+ taiwanReadings: 0,
11
+ properNounVetoes: 0,
12
+ nameBoundaries: 0,
13
+ characters: 0,
14
+ phraseWords: 0,
15
+ cedictWords: 0,
16
+ };
17
+ /**
18
+ * Add one word's tally to the running total.
19
+ */
20
+ export function addTally(total, tally) {
21
+ return {
22
+ neutralToneCorrections: total.neutralToneCorrections + tally.neutralToneCorrections,
23
+ erhuaRepairs: total.erhuaRepairs + tally.erhuaRepairs,
24
+ derivedTraditional: total.derivedTraditional + tally.derivedTraditional,
25
+ scriptPairs: total.scriptPairs + tally.scriptPairs,
26
+ variantSpellings: total.variantSpellings + tally.variantSpellings,
27
+ taiwanReadings: total.taiwanReadings + tally.taiwanReadings,
28
+ properNounVetoes: total.properNounVetoes + tally.properNounVetoes,
29
+ nameBoundaries: total.nameBoundaries + tally.nameBoundaries,
30
+ characters: total.characters + tally.characters,
31
+ phraseWords: total.phraseWords + tally.phraseWords,
32
+ cedictWords: total.cedictWords + tally.cedictWords,
33
+ };
34
+ }
35
+ //# sourceMappingURL=merge-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-types.js","sourceRoot":"","sources":["../../src/dictionary/merge-types.ts"],"names":[],"mappings":"AAmHA;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAc;IACjC,sBAAsB,EAAE,CAAC;IACzB,YAAY,EAAE,CAAC;IACf,kBAAkB,EAAE,CAAC;IACrB,WAAW,EAAE,CAAC;IACd,gBAAgB,EAAE,CAAC;IACnB,cAAc,EAAE,CAAC;IACjB,gBAAgB,EAAE,CAAC;IACnB,cAAc,EAAE,CAAC;IACjB,UAAU,EAAE,CAAC;IACb,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,CAAC;CACf,CAAC;AAYF;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAgB,EAAE,KAAgB;IACzD,OAAO;QACL,sBAAsB,EACpB,KAAK,CAAC,sBAAsB,GAAG,KAAK,CAAC,sBAAsB;QAC7D,YAAY,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY;QACrD,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB;QACvE,WAAW,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW;QAClD,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB;QACjE,cAAc,EAAE,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc;QAC3D,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB;QACjE,cAAc,EAAE,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc;QAC3D,UAAU,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU;QAC/C,WAAW,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW;QAClD,WAAW,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW;KACnD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { CedictEntry } from "../sources/cedict.js";
2
+ import type { DictionaryEntry } from "./entry.js";
3
+ import { type WordSources, type WordTally } from "./merge-types.js";
4
+ /**
5
+ * Every spelling the merge will try to give an entry.
6
+ *
7
+ * The characters Unihan knows, the phrase corpus's headwords and CC-CEDICT's,
8
+ * less the phrase headwords that are really 繁體 spellings of another word —
9
+ * see {@link isSpeltTraditionally}. jieba is absent on purpose: it carries
10
+ * frequencies and tags rather than readings, so a word only it has would arrive
11
+ * with nothing to read it by.
12
+ */
13
+ export declare function wordList(phrase: ReadonlyMap<string, readonly string[]>, defaults: ReadonlyMap<string, unknown>, cedictByWord: ReadonlyMap<string, readonly CedictEntry[]>, cedictByHant: ReadonlyMap<string, readonly CedictEntry[]>): readonly string[];
14
+ /**
15
+ * What the walk produced: the entries, what it turned away, and the counts.
16
+ */
17
+ export interface MergedWords {
18
+ readonly entries: readonly DictionaryEntry[];
19
+ /** Spellings no source gave a usable reading, and what it gave instead. */
20
+ readonly rejected: ReadonlyMap<string, readonly string[]>;
21
+ readonly counts: WordTally;
22
+ }
23
+ /**
24
+ * Settle every word in the list.
25
+ */
26
+ export declare function mergeWords(words: readonly string[], sources: WordSources): MergedWords;
27
+ //# sourceMappingURL=merge-walk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-walk.d.ts","sourceRoot":"","sources":["../../src/dictionary/merge-walk.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EAC9C,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,EACzD,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,GACxD,SAAS,MAAM,EAAE,CASnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC1D,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,WAAW,GACnB,WAAW,CAmBb"}