@kensio/pinyinjs 1.7.4 → 1.7.5

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 (695) hide show
  1. package/dist/accuracy/score-case.d.ts +23 -0
  2. package/dist/accuracy/score-case.d.ts.map +1 -0
  3. package/dist/accuracy/score-case.js +63 -0
  4. package/dist/accuracy/score-case.js.map +1 -0
  5. package/dist/accuracy/score.d.ts +1 -8
  6. package/dist/accuracy/score.d.ts.map +1 -1
  7. package/dist/accuracy/score.js +1 -55
  8. package/dist/accuracy/score.js.map +1 -1
  9. package/dist/cli/arguments.d.ts +4 -290
  10. package/dist/cli/arguments.d.ts.map +1 -1
  11. package/dist/cli/arguments.js +5 -357
  12. package/dist/cli/arguments.js.map +1 -1
  13. package/dist/cli/check-command.d.ts +9 -0
  14. package/dist/cli/check-command.d.ts.map +1 -0
  15. package/dist/cli/check-command.js +95 -0
  16. package/dist/cli/check-command.js.map +1 -0
  17. package/dist/cli/cli-input.d.ts +49 -0
  18. package/dist/cli/cli-input.d.ts.map +1 -0
  19. package/dist/cli/cli-input.js +31 -0
  20. package/dist/cli/cli-input.js.map +1 -0
  21. package/dist/cli/command.d.ts +97 -0
  22. package/dist/cli/command.d.ts.map +1 -0
  23. package/dist/cli/command.js +40 -0
  24. package/dist/cli/command.js.map +1 -0
  25. package/dist/cli/commands.d.ts +7 -110
  26. package/dist/cli/commands.d.ts.map +1 -1
  27. package/dist/cli/commands.js +14 -991
  28. package/dist/cli/commands.js.map +1 -1
  29. package/dist/cli/convert-command.d.ts +6 -0
  30. package/dist/cli/convert-command.d.ts.map +1 -0
  31. package/dist/cli/convert-command.js +52 -0
  32. package/dist/cli/convert-command.js.map +1 -0
  33. package/dist/cli/environment.d.ts +1 -1
  34. package/dist/cli/environment.d.ts.map +1 -1
  35. package/dist/cli/explain-command.d.ts +6 -0
  36. package/dist/cli/explain-command.d.ts.map +1 -0
  37. package/dist/cli/explain-command.js +40 -0
  38. package/dist/cli/explain-command.js.map +1 -0
  39. package/dist/cli/explain-syllable.d.ts +10 -0
  40. package/dist/cli/explain-syllable.d.ts.map +1 -0
  41. package/dist/cli/explain-syllable.js +70 -0
  42. package/dist/cli/explain-syllable.js.map +1 -0
  43. package/dist/cli/flag-help.d.ts +18 -0
  44. package/dist/cli/flag-help.d.ts.map +1 -0
  45. package/dist/cli/flag-help.js +78 -0
  46. package/dist/cli/flag-help.js.map +1 -0
  47. package/dist/cli/flag-lists.d.ts +49 -0
  48. package/dist/cli/flag-lists.d.ts.map +1 -0
  49. package/dist/cli/flag-lists.js +58 -0
  50. package/dist/cli/flag-lists.js.map +1 -0
  51. package/dist/cli/flag-values.d.ts +44 -0
  52. package/dist/cli/flag-values.d.ts.map +1 -0
  53. package/dist/cli/flag-values.js +56 -0
  54. package/dist/cli/flag-values.js.map +1 -0
  55. package/dist/cli/flags.d.ts +193 -0
  56. package/dist/cli/flags.d.ts.map +1 -0
  57. package/dist/cli/flags.js +133 -0
  58. package/dist/cli/flags.js.map +1 -0
  59. package/dist/cli/format-options.d.ts +29 -0
  60. package/dist/cli/format-options.d.ts.map +1 -0
  61. package/dist/cli/format-options.js +72 -0
  62. package/dist/cli/format-options.js.map +1 -0
  63. package/dist/cli/global-help.d.ts +23 -0
  64. package/dist/cli/global-help.d.ts.map +1 -0
  65. package/dist/cli/global-help.js +40 -0
  66. package/dist/cli/global-help.js.map +1 -0
  67. package/dist/cli/help.d.ts +1 -1
  68. package/dist/cli/help.d.ts.map +1 -1
  69. package/dist/cli/help.js +5 -99
  70. package/dist/cli/help.js.map +1 -1
  71. package/dist/cli/html-commands.d.ts +13 -0
  72. package/dist/cli/html-commands.d.ts.map +1 -0
  73. package/dist/cli/html-commands.js +49 -0
  74. package/dist/cli/html-commands.js.map +1 -0
  75. package/dist/cli/info-command.d.ts +7 -0
  76. package/dist/cli/info-command.d.ts.map +1 -0
  77. package/dist/cli/info-command.js +39 -0
  78. package/dist/cli/info-command.js.map +1 -0
  79. package/dist/cli/lookup-commands.d.ts +10 -0
  80. package/dist/cli/lookup-commands.d.ts.map +1 -0
  81. package/dist/cli/lookup-commands.js +101 -0
  82. package/dist/cli/lookup-commands.js.map +1 -0
  83. package/dist/cli/match-command.d.ts +11 -0
  84. package/dist/cli/match-command.d.ts.map +1 -0
  85. package/dist/cli/match-command.js +76 -0
  86. package/dist/cli/match-command.js.map +1 -0
  87. package/dist/cli/number-command.d.ts +12 -0
  88. package/dist/cli/number-command.d.ts.map +1 -0
  89. package/dist/cli/number-command.js +89 -0
  90. package/dist/cli/number-command.js.map +1 -0
  91. package/dist/cli/options.d.ts +30 -0
  92. package/dist/cli/options.d.ts.map +1 -0
  93. package/dist/cli/options.js +54 -0
  94. package/dist/cli/options.js.map +1 -0
  95. package/dist/cli/run-command.d.ts +24 -0
  96. package/dist/cli/run-command.d.ts.map +1 -0
  97. package/dist/cli/run-command.js +40 -0
  98. package/dist/cli/run-command.js.map +1 -0
  99. package/dist/cli/run.d.ts +4 -42
  100. package/dist/cli/run.d.ts.map +1 -1
  101. package/dist/cli/run.js +6 -61
  102. package/dist/cli/run.js.map +1 -1
  103. package/dist/cli/script-command.d.ts +10 -0
  104. package/dist/cli/script-command.d.ts.map +1 -0
  105. package/dist/cli/script-command.js +58 -0
  106. package/dist/cli/script-command.js.map +1 -0
  107. package/dist/cli/segment-command.d.ts +11 -0
  108. package/dist/cli/segment-command.d.ts.map +1 -0
  109. package/dist/cli/segment-command.js +53 -0
  110. package/dist/cli/segment-command.js.map +1 -0
  111. package/dist/cli/slug-command.d.ts +10 -0
  112. package/dist/cli/slug-command.d.ts.map +1 -0
  113. package/dist/cli/slug-command.js +28 -0
  114. package/dist/cli/slug-command.js.map +1 -0
  115. package/dist/cli/syllable-command.d.ts +14 -0
  116. package/dist/cli/syllable-command.d.ts.map +1 -0
  117. package/dist/cli/syllable-command.js +82 -0
  118. package/dist/cli/syllable-command.js.map +1 -0
  119. package/dist/cli/system-table.d.ts +12 -0
  120. package/dist/cli/system-table.d.ts.map +1 -0
  121. package/dist/cli/system-table.js +48 -0
  122. package/dist/cli/system-table.js.map +1 -0
  123. package/dist/cli/systems.d.ts +57 -0
  124. package/dist/cli/systems.d.ts.map +1 -0
  125. package/dist/cli/systems.js +27 -0
  126. package/dist/cli/systems.js.map +1 -0
  127. package/dist/cli/transcribe-command.d.ts +18 -0
  128. package/dist/cli/transcribe-command.d.ts.map +1 -0
  129. package/dist/cli/transcribe-command.js +86 -0
  130. package/dist/cli/transcribe-command.js.map +1 -0
  131. package/dist/cli/transcribe-reading.d.ts +15 -0
  132. package/dist/cli/transcribe-reading.d.ts.map +1 -0
  133. package/dist/cli/transcribe-reading.js +90 -0
  134. package/dist/cli/transcribe-reading.js.map +1 -0
  135. package/dist/cli/transcribe-rows.d.ts +26 -0
  136. package/dist/cli/transcribe-rows.d.ts.map +1 -0
  137. package/dist/cli/transcribe-rows.js +30 -0
  138. package/dist/cli/transcribe-rows.js.map +1 -0
  139. package/dist/cli/usage-error.d.ts +9 -0
  140. package/dist/cli/usage-error.d.ts.map +1 -0
  141. package/dist/cli/usage-error.js +9 -0
  142. package/dist/cli/usage-error.js.map +1 -0
  143. package/dist/decode/alternatives.d.ts +16 -0
  144. package/dist/decode/alternatives.d.ts.map +1 -0
  145. package/dist/decode/alternatives.js +31 -0
  146. package/dist/decode/alternatives.js.map +1 -0
  147. package/dist/decode/confidence.d.ts.map +1 -1
  148. package/dist/decode/confidence.js +3 -118
  149. package/dist/decode/confidence.js.map +1 -1
  150. package/dist/decode/convert-options.d.ts +116 -0
  151. package/dist/decode/convert-options.d.ts.map +1 -0
  152. package/dist/decode/convert-options.js +2 -0
  153. package/dist/decode/convert-options.js.map +1 -0
  154. package/dist/decode/convert-pipeline.d.ts +18 -0
  155. package/dist/decode/convert-pipeline.d.ts.map +1 -0
  156. package/dist/decode/convert-pipeline.js +66 -0
  157. package/dist/decode/convert-pipeline.js.map +1 -0
  158. package/dist/decode/convert.d.ts +9 -118
  159. package/dist/decode/convert.d.ts.map +1 -1
  160. package/dist/decode/convert.js +5 -453
  161. package/dist/decode/convert.js.map +1 -1
  162. package/dist/decode/decode.d.ts +2 -15
  163. package/dist/decode/decode.d.ts.map +1 -1
  164. package/dist/decode/decode.js +2 -121
  165. package/dist/decode/decode.js.map +1 -1
  166. package/dist/decode/decoders.d.ts +32 -0
  167. package/dist/decode/decoders.d.ts.map +1 -0
  168. package/dist/decode/decoders.js +29 -0
  169. package/dist/decode/decoders.js.map +1 -0
  170. package/dist/decode/edge-context.d.ts +38 -0
  171. package/dist/decode/edge-context.d.ts.map +1 -0
  172. package/dist/decode/edge-context.js +57 -0
  173. package/dist/decode/edge-context.js.map +1 -0
  174. package/dist/decode/hint-lattice.d.ts +45 -0
  175. package/dist/decode/hint-lattice.d.ts.map +1 -0
  176. package/dist/decode/hint-lattice.js +140 -0
  177. package/dist/decode/hint-lattice.js.map +1 -0
  178. package/dist/decode/hints.d.ts +2 -45
  179. package/dist/decode/hints.d.ts.map +1 -1
  180. package/dist/decode/hints.js +1 -139
  181. package/dist/decode/hints.js.map +1 -1
  182. package/dist/decode/jiao-rule.d.ts +58 -0
  183. package/dist/decode/jiao-rule.d.ts.map +1 -0
  184. package/dist/decode/jiao-rule.js +76 -0
  185. package/dist/decode/jiao-rule.js.map +1 -0
  186. package/dist/decode/lattice-costs.d.ts +55 -0
  187. package/dist/decode/lattice-costs.d.ts.map +1 -0
  188. package/dist/decode/lattice-costs.js +90 -0
  189. package/dist/decode/lattice-costs.js.map +1 -0
  190. package/dist/decode/lattice-edges.d.ts +29 -0
  191. package/dist/decode/lattice-edges.d.ts.map +1 -0
  192. package/dist/decode/lattice-edges.js +78 -0
  193. package/dist/decode/lattice-edges.js.map +1 -0
  194. package/dist/decode/lattice-slice.d.ts +37 -0
  195. package/dist/decode/lattice-slice.d.ts.map +1 -0
  196. package/dist/decode/lattice-slice.js +43 -0
  197. package/dist/decode/lattice-slice.js.map +1 -0
  198. package/dist/decode/lattice-types.d.ts +82 -0
  199. package/dist/decode/lattice-types.d.ts.map +1 -0
  200. package/dist/decode/lattice-types.js +44 -0
  201. package/dist/decode/lattice-types.js.map +1 -0
  202. package/dist/decode/lattice.d.ts +2 -59
  203. package/dist/decode/lattice.d.ts.map +1 -1
  204. package/dist/decode/lattice.js +2 -118
  205. package/dist/decode/lattice.js.map +1 -1
  206. package/dist/decode/number-pieces.d.ts +62 -0
  207. package/dist/decode/number-pieces.d.ts.map +1 -0
  208. package/dist/decode/number-pieces.js +106 -0
  209. package/dist/decode/number-pieces.js.map +1 -0
  210. package/dist/decode/numbers.d.ts +53 -0
  211. package/dist/decode/numbers.d.ts.map +1 -0
  212. package/dist/decode/numbers.js +69 -0
  213. package/dist/decode/numbers.js.map +1 -0
  214. package/dist/decode/pieces.d.ts +78 -0
  215. package/dist/decode/pieces.d.ts.map +1 -0
  216. package/dist/decode/pieces.js +136 -0
  217. package/dist/decode/pieces.js.map +1 -0
  218. package/dist/decode/polyphone-rules.d.ts +31 -0
  219. package/dist/decode/polyphone-rules.d.ts.map +1 -0
  220. package/dist/decode/polyphone-rules.js +159 -0
  221. package/dist/decode/polyphone-rules.js.map +1 -0
  222. package/dist/decode/reading-rules.d.ts +2 -97
  223. package/dist/decode/reading-rules.d.ts.map +1 -1
  224. package/dist/decode/reading-rules.js +4 -365
  225. package/dist/decode/reading-rules.js.map +1 -1
  226. package/dist/decode/rules.d.ts +1 -17
  227. package/dist/decode/rules.d.ts.map +1 -1
  228. package/dist/decode/rules.js +1 -43
  229. package/dist/decode/rules.js.map +1 -1
  230. package/dist/decode/run-lattice.d.ts +52 -0
  231. package/dist/decode/run-lattice.d.ts.map +1 -0
  232. package/dist/decode/run-lattice.js +91 -0
  233. package/dist/decode/run-lattice.js.map +1 -0
  234. package/dist/decode/sandhi-tones.d.ts +69 -0
  235. package/dist/decode/sandhi-tones.d.ts.map +1 -0
  236. package/dist/decode/sandhi-tones.js +88 -0
  237. package/dist/decode/sandhi-tones.js.map +1 -0
  238. package/dist/decode/sandhi.d.ts +1 -1
  239. package/dist/decode/sandhi.d.ts.map +1 -1
  240. package/dist/decode/sandhi.js +1 -81
  241. package/dist/decode/sandhi.js.map +1 -1
  242. package/dist/decode/script-types.d.ts +76 -0
  243. package/dist/decode/script-types.d.ts.map +1 -0
  244. package/dist/decode/script-types.js +35 -0
  245. package/dist/decode/script-types.js.map +1 -0
  246. package/dist/decode/script-words.d.ts +32 -0
  247. package/dist/decode/script-words.d.ts.map +1 -0
  248. package/dist/decode/script-words.js +77 -0
  249. package/dist/decode/script-words.js.map +1 -0
  250. package/dist/decode/script.d.ts +3 -73
  251. package/dist/decode/script.d.ts.map +1 -1
  252. package/dist/decode/script.js +3 -109
  253. package/dist/decode/script.js.map +1 -1
  254. package/dist/decode/tan-rule.d.ts +68 -0
  255. package/dist/decode/tan-rule.d.ts.map +1 -0
  256. package/dist/decode/tan-rule.js +131 -0
  257. package/dist/decode/tan-rule.js.map +1 -0
  258. package/dist/decode/write-run.d.ts +28 -0
  259. package/dist/decode/write-run.d.ts.map +1 -0
  260. package/dist/decode/write-run.js +77 -0
  261. package/dist/decode/write-run.js.map +1 -0
  262. package/dist/dictionary/artifact-claims.d.ts +25 -0
  263. package/dist/dictionary/artifact-claims.d.ts.map +1 -0
  264. package/dist/dictionary/artifact-claims.js +47 -0
  265. package/dist/dictionary/artifact-claims.js.map +1 -0
  266. package/dist/dictionary/artifact-format.d.ts +86 -0
  267. package/dist/dictionary/artifact-format.d.ts.map +1 -0
  268. package/dist/dictionary/artifact-format.js +91 -0
  269. package/dist/dictionary/artifact-format.js.map +1 -0
  270. package/dist/dictionary/artifact-read.d.ts +34 -0
  271. package/dist/dictionary/artifact-read.d.ts.map +1 -0
  272. package/dist/dictionary/artifact-read.js +114 -0
  273. package/dist/dictionary/artifact-read.js.map +1 -0
  274. package/dist/dictionary/artifact.d.ts +4 -63
  275. package/dist/dictionary/artifact.d.ts.map +1 -1
  276. package/dist/dictionary/artifact.js +12 -229
  277. package/dist/dictionary/artifact.js.map +1 -1
  278. package/dist/dictionary/assertions.d.ts +5 -57
  279. package/dist/dictionary/assertions.d.ts.map +1 -1
  280. package/dist/dictionary/assertions.js +4 -317
  281. package/dist/dictionary/assertions.js.map +1 -1
  282. package/dist/dictionary/build-assertions.d.ts +12 -0
  283. package/dist/dictionary/build-assertions.d.ts.map +1 -0
  284. package/dist/dictionary/build-assertions.js +13 -0
  285. package/dist/dictionary/build-assertions.js.map +1 -0
  286. package/dist/dictionary/built-dictionary.d.ts +46 -0
  287. package/dist/dictionary/built-dictionary.d.ts.map +1 -0
  288. package/dist/dictionary/built-dictionary.js +97 -0
  289. package/dist/dictionary/built-dictionary.js.map +1 -0
  290. package/dist/dictionary/cedict-senses.d.ts +80 -0
  291. package/dist/dictionary/cedict-senses.d.ts.map +1 -0
  292. package/dist/dictionary/cedict-senses.js +114 -0
  293. package/dist/dictionary/cedict-senses.js.map +1 -0
  294. package/dist/dictionary/character-defaults.d.ts +26 -0
  295. package/dist/dictionary/character-defaults.d.ts.map +1 -0
  296. package/dist/dictionary/character-defaults.js +67 -0
  297. package/dist/dictionary/character-defaults.js.map +1 -0
  298. package/dist/dictionary/character-readings.d.ts +10 -0
  299. package/dist/dictionary/character-readings.d.ts.map +1 -0
  300. package/dist/dictionary/character-readings.js +25 -0
  301. package/dist/dictionary/character-readings.js.map +1 -0
  302. package/dist/dictionary/dictionary-entry.d.ts +37 -0
  303. package/dist/dictionary/dictionary-entry.d.ts.map +1 -0
  304. package/dist/dictionary/dictionary-entry.js +41 -0
  305. package/dist/dictionary/dictionary-entry.js.map +1 -0
  306. package/dist/dictionary/dictionary-readings.d.ts +56 -0
  307. package/dist/dictionary/dictionary-readings.d.ts.map +1 -0
  308. package/dist/dictionary/dictionary-readings.js +93 -0
  309. package/dist/dictionary/dictionary-readings.js.map +1 -0
  310. package/dist/dictionary/dictionary.d.ts +6 -60
  311. package/dist/dictionary/dictionary.d.ts.map +1 -1
  312. package/dist/dictionary/dictionary.js +9 -169
  313. package/dist/dictionary/dictionary.js.map +1 -1
  314. package/dist/dictionary/entry-invariants.d.ts +3 -0
  315. package/dist/dictionary/entry-invariants.d.ts.map +1 -0
  316. package/dist/dictionary/entry-invariants.js +67 -0
  317. package/dist/dictionary/entry-invariants.js.map +1 -0
  318. package/dist/dictionary/entry-lines.d.ts +35 -0
  319. package/dist/dictionary/entry-lines.d.ts.map +1 -0
  320. package/dist/dictionary/entry-lines.js +70 -0
  321. package/dist/dictionary/entry-lines.js.map +1 -0
  322. package/dist/dictionary/erhua-repair.d.ts +26 -0
  323. package/dist/dictionary/erhua-repair.d.ts.map +1 -0
  324. package/dist/dictionary/erhua-repair.js +49 -0
  325. package/dist/dictionary/erhua-repair.js.map +1 -0
  326. package/dist/dictionary/frequency-tones.d.ts +74 -0
  327. package/dist/dictionary/frequency-tones.d.ts.map +1 -0
  328. package/dist/dictionary/frequency-tones.js +128 -0
  329. package/dist/dictionary/frequency-tones.js.map +1 -0
  330. package/dist/dictionary/inventory-invariants.d.ts +3 -0
  331. package/dist/dictionary/inventory-invariants.d.ts.map +1 -0
  332. package/dist/dictionary/inventory-invariants.js +54 -0
  333. package/dist/dictionary/inventory-invariants.js.map +1 -0
  334. package/dist/dictionary/locale-candidates.d.ts +40 -0
  335. package/dist/dictionary/locale-candidates.d.ts.map +1 -0
  336. package/dist/dictionary/locale-candidates.js +77 -0
  337. package/dist/dictionary/locale-candidates.js.map +1 -0
  338. package/dist/dictionary/locale-segments.d.ts +47 -0
  339. package/dist/dictionary/locale-segments.d.ts.map +1 -0
  340. package/dist/dictionary/locale-segments.js +141 -0
  341. package/dist/dictionary/locale-segments.js.map +1 -0
  342. package/dist/dictionary/locale.d.ts +1 -21
  343. package/dist/dictionary/locale.d.ts.map +1 -1
  344. package/dist/dictionary/locale.js +9 -198
  345. package/dist/dictionary/locale.js.map +1 -1
  346. package/dist/dictionary/merge-types.d.ts +121 -0
  347. package/dist/dictionary/merge-types.d.ts.map +1 -0
  348. package/dist/dictionary/merge-types.js +35 -0
  349. package/dist/dictionary/merge-types.js.map +1 -0
  350. package/dist/dictionary/merge-word.d.ts +7 -0
  351. package/dist/dictionary/merge-word.d.ts.map +1 -0
  352. package/dist/dictionary/merge-word.js +91 -0
  353. package/dist/dictionary/merge-word.js.map +1 -0
  354. package/dist/dictionary/merge.d.ts +5 -62
  355. package/dist/dictionary/merge.d.ts.map +1 -1
  356. package/dist/dictionary/merge.js +30 -713
  357. package/dist/dictionary/merge.js.map +1 -1
  358. package/dist/dictionary/proper-noun.d.ts +28 -0
  359. package/dist/dictionary/proper-noun.d.ts.map +1 -0
  360. package/dist/dictionary/proper-noun.js +43 -0
  361. package/dist/dictionary/proper-noun.js.map +1 -0
  362. package/dist/dictionary/reading-agreement.d.ts +71 -0
  363. package/dist/dictionary/reading-agreement.d.ts.map +1 -0
  364. package/dist/dictionary/reading-agreement.js +156 -0
  365. package/dist/dictionary/reading-agreement.js.map +1 -0
  366. package/dist/dictionary/script-conversion.d.ts +28 -0
  367. package/dist/dictionary/script-conversion.d.ts.map +1 -0
  368. package/dist/dictionary/script-conversion.js +58 -0
  369. package/dist/dictionary/script-conversion.js.map +1 -0
  370. package/dist/dictionary/script-pairings.d.ts +74 -0
  371. package/dist/dictionary/script-pairings.d.ts.map +1 -0
  372. package/dist/dictionary/script-pairings.js +120 -0
  373. package/dist/dictionary/script-pairings.js.map +1 -0
  374. package/dist/dictionary/script-tables.d.ts.map +1 -1
  375. package/dist/dictionary/script-tables.js +2 -165
  376. package/dist/dictionary/script-tables.js.map +1 -1
  377. package/dist/dictionary/taiwan-reading.d.ts +8 -0
  378. package/dist/dictionary/taiwan-reading.d.ts.map +1 -0
  379. package/dist/dictionary/taiwan-reading.js +38 -0
  380. package/dist/dictionary/taiwan-reading.js.map +1 -0
  381. package/dist/dictionary/tone-invariants.d.ts +3 -0
  382. package/dist/dictionary/tone-invariants.d.ts.map +1 -0
  383. package/dist/dictionary/tone-invariants.js +64 -0
  384. package/dist/dictionary/tone-invariants.js.map +1 -0
  385. package/dist/dictionary/traditional-form.d.ts +21 -0
  386. package/dist/dictionary/traditional-form.d.ts.map +1 -0
  387. package/dist/dictionary/traditional-form.js +59 -0
  388. package/dist/dictionary/traditional-form.js.map +1 -0
  389. package/dist/dictionary/traditional-ranking.d.ts +22 -0
  390. package/dist/dictionary/traditional-ranking.d.ts.map +1 -0
  391. package/dist/dictionary/traditional-ranking.js +74 -0
  392. package/dist/dictionary/traditional-ranking.js.map +1 -0
  393. package/dist/dictionary/traditional-table.d.ts +51 -0
  394. package/dist/dictionary/traditional-table.d.ts.map +1 -0
  395. package/dist/dictionary/traditional-table.js +98 -0
  396. package/dist/dictionary/traditional-table.js.map +1 -0
  397. package/dist/dictionary/traditional.d.ts +3 -56
  398. package/dist/dictionary/traditional.d.ts.map +1 -1
  399. package/dist/dictionary/traditional.js +3 -186
  400. package/dist/dictionary/traditional.js.map +1 -1
  401. package/dist/dictionary/variant-counts.d.ts +39 -0
  402. package/dist/dictionary/variant-counts.d.ts.map +1 -0
  403. package/dist/dictionary/variant-counts.js +38 -0
  404. package/dist/dictionary/variant-counts.js.map +1 -0
  405. package/dist/dictionary/word-reading.d.ts +26 -0
  406. package/dist/dictionary/word-reading.d.ts.map +1 -0
  407. package/dist/dictionary/word-reading.js +76 -0
  408. package/dist/dictionary/word-reading.js.map +1 -0
  409. package/dist/dictionary/word-readings.d.ts +15 -0
  410. package/dist/dictionary/word-readings.d.ts.map +1 -0
  411. package/dist/dictionary/word-readings.js +38 -0
  412. package/dist/dictionary/word-readings.js.map +1 -0
  413. package/dist/format/annotate.d.ts +90 -0
  414. package/dist/format/annotate.d.ts.map +1 -0
  415. package/dist/format/annotate.js +168 -0
  416. package/dist/format/annotate.js.map +1 -0
  417. package/dist/format/html.d.ts +15 -46
  418. package/dist/format/html.d.ts.map +1 -1
  419. package/dist/format/html.js +3 -162
  420. package/dist/format/html.js.map +1 -1
  421. package/dist/format/slug-hash.d.ts +51 -0
  422. package/dist/format/slug-hash.d.ts.map +1 -0
  423. package/dist/format/slug-hash.js +74 -0
  424. package/dist/format/slug-hash.js.map +1 -0
  425. package/dist/format/slug-options.d.ts +98 -0
  426. package/dist/format/slug-options.d.ts.map +1 -0
  427. package/dist/format/slug-options.js +2 -0
  428. package/dist/format/slug-options.js.map +1 -0
  429. package/dist/format/slug-words.d.ts +27 -0
  430. package/dist/format/slug-words.d.ts.map +1 -0
  431. package/dist/format/slug-words.js +0 -0
  432. package/dist/format/slug-words.js.map +1 -0
  433. package/dist/format/slug.d.ts +3 -128
  434. package/dist/format/slug.d.ts.map +1 -1
  435. package/dist/format/slug.js +0 -0
  436. package/dist/format/slug.js.map +1 -1
  437. package/dist/grade/check-readings.d.ts +41 -0
  438. package/dist/grade/check-readings.d.ts.map +1 -0
  439. package/dist/grade/check-readings.js +36 -0
  440. package/dist/grade/check-readings.js.map +1 -0
  441. package/dist/grade/check.d.ts +4 -4
  442. package/dist/grade/check.d.ts.map +1 -1
  443. package/dist/grade/check.js +5 -270
  444. package/dist/grade/check.js.map +1 -1
  445. package/dist/grade/pair-syllables.d.ts +48 -0
  446. package/dist/grade/pair-syllables.d.ts.map +1 -0
  447. package/dist/grade/pair-syllables.js +71 -0
  448. package/dist/grade/pair-syllables.js.map +1 -0
  449. package/dist/grade/reading-syllables.d.ts +62 -0
  450. package/dist/grade/reading-syllables.d.ts.map +1 -0
  451. package/dist/grade/reading-syllables.js +58 -0
  452. package/dist/grade/reading-syllables.js.map +1 -0
  453. package/dist/grade/reading-tolerance.d.ts +72 -0
  454. package/dist/grade/reading-tolerance.d.ts.map +1 -0
  455. package/dist/grade/reading-tolerance.js +107 -0
  456. package/dist/grade/reading-tolerance.js.map +1 -0
  457. package/dist/grade/typed-reading.d.ts +28 -0
  458. package/dist/grade/typed-reading.d.ts.map +1 -0
  459. package/dist/grade/typed-reading.js +36 -0
  460. package/dist/grade/typed-reading.js.map +1 -0
  461. package/dist/numerals/numeral-parse.d.ts +32 -0
  462. package/dist/numerals/numeral-parse.d.ts.map +1 -0
  463. package/dist/numerals/numeral-parse.js +44 -0
  464. package/dist/numerals/numeral-parse.js.map +1 -0
  465. package/dist/numerals/numeral-shapes.d.ts +89 -0
  466. package/dist/numerals/numeral-shapes.d.ts.map +1 -0
  467. package/dist/numerals/numeral-shapes.js +99 -0
  468. package/dist/numerals/numeral-shapes.js.map +1 -0
  469. package/dist/numerals/numerals.d.ts.map +1 -1
  470. package/dist/numerals/numerals.js +2 -36
  471. package/dist/numerals/numerals.js.map +1 -1
  472. package/dist/numerals/read-numeral.d.ts +76 -0
  473. package/dist/numerals/read-numeral.d.ts.map +1 -0
  474. package/dist/numerals/read-numeral.js +88 -0
  475. package/dist/numerals/read-numeral.js.map +1 -0
  476. package/dist/numerals/text.d.ts +3 -37
  477. package/dist/numerals/text.d.ts.map +1 -1
  478. package/dist/numerals/text.js +3 -254
  479. package/dist/numerals/text.js.map +1 -1
  480. package/dist/numerals/time.d.ts +34 -0
  481. package/dist/numerals/time.d.ts.map +1 -0
  482. package/dist/numerals/time.js +93 -0
  483. package/dist/numerals/time.js.map +1 -0
  484. package/dist/orthography/address-grouping.d.ts +34 -0
  485. package/dist/orthography/address-grouping.d.ts.map +1 -0
  486. package/dist/orthography/address-grouping.js +52 -0
  487. package/dist/orthography/address-grouping.js.map +1 -0
  488. package/dist/orthography/grouping.d.ts +3 -87
  489. package/dist/orthography/grouping.d.ts.map +1 -1
  490. package/dist/orthography/grouping.js +4 -270
  491. package/dist/orthography/grouping.js.map +1 -1
  492. package/dist/orthography/place-grouping.d.ts +39 -0
  493. package/dist/orthography/place-grouping.d.ts.map +1 -0
  494. package/dist/orthography/place-grouping.js +83 -0
  495. package/dist/orthography/place-grouping.js.map +1 -0
  496. package/dist/orthography/word-grouping.d.ts +48 -0
  497. package/dist/orthography/word-grouping.d.ts.map +1 -0
  498. package/dist/orthography/word-grouping.js +147 -0
  499. package/dist/orthography/word-grouping.js.map +1 -0
  500. package/dist/script/conversion-format.d.ts +22 -0
  501. package/dist/script/conversion-format.d.ts.map +1 -0
  502. package/dist/script/conversion-format.js +22 -0
  503. package/dist/script/conversion-format.js.map +1 -0
  504. package/dist/script/conversion-read.d.ts +9 -0
  505. package/dist/script/conversion-read.d.ts.map +1 -0
  506. package/dist/script/conversion-read.js +69 -0
  507. package/dist/script/conversion-read.js.map +1 -0
  508. package/dist/script/conversion-write.d.ts +14 -0
  509. package/dist/script/conversion-write.d.ts.map +1 -0
  510. package/dist/script/conversion-write.js +34 -0
  511. package/dist/script/conversion-write.js.map +1 -0
  512. package/dist/script/conversion.d.ts +10 -16
  513. package/dist/script/conversion.d.ts.map +1 -1
  514. package/dist/script/conversion.js +2 -115
  515. package/dist/script/conversion.js.map +1 -1
  516. package/dist/search/candidate-narrowing.d.ts +56 -0
  517. package/dist/search/candidate-narrowing.d.ts.map +1 -0
  518. package/dist/search/candidate-narrowing.js +55 -0
  519. package/dist/search/candidate-narrowing.js.map +1 -0
  520. package/dist/search/candidate-query.d.ts +25 -0
  521. package/dist/search/candidate-query.d.ts.map +1 -0
  522. package/dist/search/candidate-query.js +28 -0
  523. package/dist/search/candidate-query.js.map +1 -0
  524. package/dist/search/candidate-writings.d.ts +24 -0
  525. package/dist/search/candidate-writings.d.ts.map +1 -0
  526. package/dist/search/candidate-writings.js +114 -0
  527. package/dist/search/candidate-writings.js.map +1 -0
  528. package/dist/search/candidates.d.ts +7 -41
  529. package/dist/search/candidates.d.ts.map +1 -1
  530. package/dist/search/candidates.js +10 -164
  531. package/dist/search/candidates.js.map +1 -1
  532. package/dist/search/match-chunks.d.ts +19 -0
  533. package/dist/search/match-chunks.d.ts.map +1 -0
  534. package/dist/search/match-chunks.js +30 -0
  535. package/dist/search/match-chunks.js.map +1 -0
  536. package/dist/search/match-ranking.d.ts +39 -0
  537. package/dist/search/match-ranking.d.ts.map +1 -0
  538. package/dist/search/match-ranking.js +51 -0
  539. package/dist/search/match-ranking.js.map +1 -0
  540. package/dist/search/match-readings.d.ts +43 -0
  541. package/dist/search/match-readings.d.ts.map +1 -0
  542. package/dist/search/match-readings.js +83 -0
  543. package/dist/search/match-readings.js.map +1 -0
  544. package/dist/search/match-scoring.d.ts +146 -0
  545. package/dist/search/match-scoring.d.ts.map +1 -0
  546. package/dist/search/match-scoring.js +114 -0
  547. package/dist/search/match-scoring.js.map +1 -0
  548. package/dist/search/match-search.d.ts +28 -0
  549. package/dist/search/match-search.d.ts.map +1 -0
  550. package/dist/search/match-search.js +128 -0
  551. package/dist/search/match-search.js.map +1 -0
  552. package/dist/search/match.d.ts +5 -36
  553. package/dist/search/match.d.ts.map +1 -1
  554. package/dist/search/match.js +2 -379
  555. package/dist/search/match.js.map +1 -1
  556. package/dist/search/reverse-index-build.d.ts +30 -0
  557. package/dist/search/reverse-index-build.d.ts.map +1 -0
  558. package/dist/search/reverse-index-build.js +72 -0
  559. package/dist/search/reverse-index-build.js.map +1 -0
  560. package/dist/search/reverse-index-format.d.ts +60 -0
  561. package/dist/search/reverse-index-format.d.ts.map +1 -0
  562. package/dist/search/reverse-index-format.js +54 -0
  563. package/dist/search/reverse-index-format.js.map +1 -0
  564. package/dist/search/reverse-index-groups.d.ts +37 -0
  565. package/dist/search/reverse-index-groups.d.ts.map +1 -0
  566. package/dist/search/reverse-index-groups.js +71 -0
  567. package/dist/search/reverse-index-groups.js.map +1 -0
  568. package/dist/search/reverse-index-passes.d.ts +78 -0
  569. package/dist/search/reverse-index-passes.d.ts.map +1 -0
  570. package/dist/search/reverse-index-passes.js +59 -0
  571. package/dist/search/reverse-index-passes.js.map +1 -0
  572. package/dist/search/reverse-index-state.d.ts +36 -0
  573. package/dist/search/reverse-index-state.d.ts.map +1 -0
  574. package/dist/search/reverse-index-state.js +95 -0
  575. package/dist/search/reverse-index-state.js.map +1 -0
  576. package/dist/search/reverse-index.d.ts +8 -67
  577. package/dist/search/reverse-index.d.ts.map +1 -1
  578. package/dist/search/reverse-index.js +4 -255
  579. package/dist/search/reverse-index.js.map +1 -1
  580. package/dist/sources/unihan-readings.d.ts +58 -0
  581. package/dist/sources/unihan-readings.d.ts.map +1 -0
  582. package/dist/sources/unihan-readings.js +95 -0
  583. package/dist/sources/unihan-readings.js.map +1 -0
  584. package/dist/sources/unihan.d.ts +6 -9
  585. package/dist/sources/unihan.d.ts.map +1 -1
  586. package/dist/sources/unihan.js +2 -85
  587. package/dist/sources/unihan.js.map +1 -1
  588. package/dist/syllable/final-tables.d.ts +23 -0
  589. package/dist/syllable/final-tables.d.ts.map +1 -0
  590. package/dist/syllable/final-tables.js +50 -0
  591. package/dist/syllable/final-tables.js.map +1 -0
  592. package/dist/syllable/inventory.d.ts +8 -42
  593. package/dist/syllable/inventory.d.ts.map +1 -1
  594. package/dist/syllable/inventory.js +9 -918
  595. package/dist/syllable/inventory.js.map +1 -1
  596. package/dist/syllable/spellings.d.ts +40 -0
  597. package/dist/syllable/spellings.d.ts.map +1 -0
  598. package/dist/syllable/spellings.js +469 -0
  599. package/dist/syllable/spellings.js.map +1 -0
  600. package/dist/syllable/syllable-parts.d.ts +31 -0
  601. package/dist/syllable/syllable-parts.d.ts.map +1 -0
  602. package/dist/syllable/syllable-parts.js +105 -0
  603. package/dist/syllable/syllable-parts.js.map +1 -0
  604. package/dist/syllable/syllable.d.ts +1 -14
  605. package/dist/syllable/syllable.d.ts.map +1 -1
  606. package/dist/syllable/syllable.js +3 -144
  607. package/dist/syllable/syllable.js.map +1 -1
  608. package/dist/syllable/written-tones.d.ts +6 -0
  609. package/dist/syllable/written-tones.d.ts.map +1 -0
  610. package/dist/syllable/written-tones.js +453 -0
  611. package/dist/syllable/written-tones.js.map +1 -0
  612. package/dist/transcription/bopomofo-parse.d.ts +42 -0
  613. package/dist/transcription/bopomofo-parse.d.ts.map +1 -0
  614. package/dist/transcription/bopomofo-parse.js +92 -0
  615. package/dist/transcription/bopomofo-parse.js.map +1 -0
  616. package/dist/transcription/bopomofo-reverse.d.ts +31 -0
  617. package/dist/transcription/bopomofo-reverse.d.ts.map +1 -0
  618. package/dist/transcription/bopomofo-reverse.js +48 -0
  619. package/dist/transcription/bopomofo-reverse.js.map +1 -0
  620. package/dist/transcription/bopomofo-symbols.d.ts +36 -0
  621. package/dist/transcription/bopomofo-symbols.d.ts.map +1 -0
  622. package/dist/transcription/bopomofo-symbols.js +41 -0
  623. package/dist/transcription/bopomofo-symbols.js.map +1 -0
  624. package/dist/transcription/bopomofo-tables.d.ts +87 -0
  625. package/dist/transcription/bopomofo-tables.d.ts.map +1 -0
  626. package/dist/transcription/bopomofo-tables.js +180 -0
  627. package/dist/transcription/bopomofo-tables.js.map +1 -0
  628. package/dist/transcription/bopomofo.d.ts +14 -32
  629. package/dist/transcription/bopomofo.d.ts.map +1 -1
  630. package/dist/transcription/bopomofo.js +5 -343
  631. package/dist/transcription/bopomofo.js.map +1 -1
  632. package/dist/transcription/gwoyeu-first-second.d.ts +36 -0
  633. package/dist/transcription/gwoyeu-first-second.d.ts.map +1 -0
  634. package/dist/transcription/gwoyeu-first-second.js +75 -0
  635. package/dist/transcription/gwoyeu-first-second.js.map +1 -0
  636. package/dist/transcription/gwoyeu-spelling.d.ts +38 -0
  637. package/dist/transcription/gwoyeu-spelling.d.ts.map +1 -0
  638. package/dist/transcription/gwoyeu-spelling.js +124 -0
  639. package/dist/transcription/gwoyeu-spelling.js.map +1 -0
  640. package/dist/transcription/gwoyeu-tables.d.ts +93 -0
  641. package/dist/transcription/gwoyeu-tables.d.ts.map +1 -0
  642. package/dist/transcription/gwoyeu-tables.js +205 -0
  643. package/dist/transcription/gwoyeu-tables.js.map +1 -0
  644. package/dist/transcription/gwoyeu-tonal-forms.d.ts +49 -0
  645. package/dist/transcription/gwoyeu-tonal-forms.d.ts.map +1 -0
  646. package/dist/transcription/gwoyeu-tonal-forms.js +89 -0
  647. package/dist/transcription/gwoyeu-tonal-forms.js.map +1 -0
  648. package/dist/transcription/gwoyeu-vowels.d.ts +51 -0
  649. package/dist/transcription/gwoyeu-vowels.d.ts.map +1 -0
  650. package/dist/transcription/gwoyeu-vowels.js +58 -0
  651. package/dist/transcription/gwoyeu-vowels.js.map +1 -0
  652. package/dist/transcription/gwoyeu.d.ts +1 -26
  653. package/dist/transcription/gwoyeu.d.ts.map +1 -1
  654. package/dist/transcription/gwoyeu.js +2 -540
  655. package/dist/transcription/gwoyeu.js.map +1 -1
  656. package/dist/transcription/ipa-symbols.d.ts +67 -0
  657. package/dist/transcription/ipa-symbols.d.ts.map +1 -0
  658. package/dist/transcription/ipa-symbols.js +135 -0
  659. package/dist/transcription/ipa-symbols.js.map +1 -0
  660. package/dist/transcription/ipa.d.ts +2 -10
  661. package/dist/transcription/ipa.d.ts.map +1 -1
  662. package/dist/transcription/ipa.js +2 -134
  663. package/dist/transcription/ipa.js.map +1 -1
  664. package/dist/transcription/wade-giles-index.d.ts +35 -0
  665. package/dist/transcription/wade-giles-index.d.ts.map +1 -0
  666. package/dist/transcription/wade-giles-index.js +110 -0
  667. package/dist/transcription/wade-giles-index.js.map +1 -0
  668. package/dist/transcription/wade-giles-parse.d.ts +36 -0
  669. package/dist/transcription/wade-giles-parse.d.ts.map +1 -0
  670. package/dist/transcription/wade-giles-parse.js +84 -0
  671. package/dist/transcription/wade-giles-parse.js.map +1 -0
  672. package/dist/transcription/wade-giles-spelling.d.ts +61 -0
  673. package/dist/transcription/wade-giles-spelling.d.ts.map +1 -0
  674. package/dist/transcription/wade-giles-spelling.js +107 -0
  675. package/dist/transcription/wade-giles-spelling.js.map +1 -0
  676. package/dist/transcription/wade-giles-syllable.d.ts +29 -0
  677. package/dist/transcription/wade-giles-syllable.d.ts.map +1 -0
  678. package/dist/transcription/wade-giles-syllable.js +90 -0
  679. package/dist/transcription/wade-giles-syllable.js.map +1 -0
  680. package/dist/transcription/wade-giles-tables.d.ts +80 -0
  681. package/dist/transcription/wade-giles-tables.d.ts.map +1 -0
  682. package/dist/transcription/wade-giles-tables.js +178 -0
  683. package/dist/transcription/wade-giles-tables.js.map +1 -0
  684. package/dist/transcription/wade-giles.d.ts +9 -60
  685. package/dist/transcription/wade-giles.d.ts.map +1 -1
  686. package/dist/transcription/wade-giles.js +6 -543
  687. package/dist/transcription/wade-giles.js.map +1 -1
  688. package/dist/transcription/yale-tables.d.ts +54 -0
  689. package/dist/transcription/yale-tables.d.ts.map +1 -0
  690. package/dist/transcription/yale-tables.js +125 -0
  691. package/dist/transcription/yale-tables.js.map +1 -0
  692. package/dist/transcription/yale.d.ts.map +1 -1
  693. package/dist/transcription/yale.js +1 -124
  694. package/dist/transcription/yale.js.map +1 -1
  695. package/package.json +1 -1
@@ -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,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,gBAAgB;IACX,MAAM,CAAuC;IAC7C,KAAK,CAA8B;IAE5C;;OAEG;IACH,YAAY,OAAmC;QAC7C,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;QACjD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAA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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,121 @@
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
+ /** Entries carrying a zh-TW reading delta a source stated. */
46
+ readonly taiwanReadings: number;
47
+ /** Compounds given a zh-TW delta composed from their constituents. */
48
+ readonly composedTaiwanReadings: number;
49
+ /**
50
+ * Words jieba tagged a proper noun that CC-CEDICT's lowercase pinyin vetoed.
51
+ */
52
+ readonly properNounVetoes: number;
53
+ /** Entries whose parts CC-CEDICT's capitalisation divides. */
54
+ readonly nameBoundaries: number;
55
+ /** Words dropped because no source gave a usable reading. */
56
+ readonly rejected: number;
57
+ }
58
+ /**
59
+ * What the merge produced.
60
+ */
61
+ export interface MergeResult {
62
+ /** Entries, ordered by their 简体 form. */
63
+ readonly entries: readonly DictionaryEntry[];
64
+ /** Words no source could be read, with the reading that failed. */
65
+ readonly rejected: ReadonlyMap<string, readonly string[]>;
66
+ readonly stats: MergeStats;
67
+ }
68
+ /**
69
+ * What the sources between them say about one word, indexed once for all of
70
+ * them.
71
+ *
72
+ * The per-word view of {@link MergeSources}: the same data, turned inside out
73
+ * so that merging a word is a handful of map reads rather than a scan.
74
+ */
75
+ export interface WordSources {
76
+ readonly cedictByWord: ReadonlyMap<string, readonly CedictEntry[]>;
77
+ readonly cedictByHant: ReadonlyMap<string, readonly CedictEntry[]>;
78
+ readonly phrase: ReadonlyMap<string, readonly string[]>;
79
+ readonly jieba: ReadonlyMap<string, JiebaEntry>;
80
+ readonly unihanReadings: ReadonlyMap<string, UnihanReadings>;
81
+ readonly traditional: TraditionalTable;
82
+ readonly defaults: ReadonlyMap<string, readonly Syllable[]>;
83
+ }
84
+ /**
85
+ * What one word contributed to the build's counts.
86
+ *
87
+ * The per-word view of {@link MergeStats}, minus the counts no single word can
88
+ * move: `reducedNeutrals` and `composedTaiwanReadings` are settled by passes
89
+ * over the whole dictionary, and `rejected` is counted by the caller.
90
+ */
91
+ export interface WordTally {
92
+ readonly neutralToneCorrections: number;
93
+ readonly erhuaRepairs: number;
94
+ readonly derivedTraditional: number;
95
+ readonly scriptPairs: number;
96
+ readonly variantSpellings: number;
97
+ readonly taiwanReadings: number;
98
+ readonly properNounVetoes: number;
99
+ readonly nameBoundaries: number;
100
+ readonly characters: number;
101
+ readonly phraseWords: number;
102
+ readonly cedictWords: number;
103
+ }
104
+ /**
105
+ * A word that contributed nothing, because no source could read it.
106
+ */
107
+ export declare const NO_TALLY: WordTally;
108
+ /**
109
+ * One word's entry, or the reading that failed.
110
+ */
111
+ export interface MergedWord {
112
+ readonly entry: DictionaryEntry | undefined;
113
+ /** The reading no source could make sense of, where that is what happened. */
114
+ readonly rejected: readonly string[] | undefined;
115
+ readonly tally: WordTally;
116
+ }
117
+ /**
118
+ * Add one word's tally to the running total.
119
+ */
120
+ export declare function addTally(total: WordTally, tally: WordTally): WordTally;
121
+ //# 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,O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,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,SAYtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;IAC5C,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;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":"AA6GA;;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,7 @@
1
+ import { type MergedWord, type WordSources } from "./merge-types.js";
2
+ export type { MergedWord, WordSources, WordTally } from "./merge-types.js";
3
+ /**
4
+ * Merge one word.
5
+ */
6
+ export declare function mergeWord(word: string, sources: WordSources): MergedWord;
7
+ //# sourceMappingURL=merge-word.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-word.d.ts","sourceRoot":"","sources":["../../src/dictionary/merge-word.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,UAAU,EAAY,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/E,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE3E;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,UAAU,CA8GxE"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Everything the merge decides about one word.
3
+ *
4
+ * The phases run in the order MERGE.md sets out and each depends on the one
5
+ * before, so they stay in one function rather than becoming a pipeline of
6
+ * small ones. What has changed is that the counts come back as a tally
7
+ * instead of being written into eleven variables the caller owns.
8
+ */
9
+ import { isSingleCharacter } from "../script/characters.js";
10
+ import { isSameReading } from "./entry.js";
11
+ import { readAlignedReading } from "./reading.js";
12
+ import { cedictReadingsOf } from "./cedict-senses.js";
13
+ import { traditionalFormOf } from "./traditional-form.js";
14
+ import { taiwanReadingOf } from "./taiwan-reading.js";
15
+ import { properNounOf } from "./proper-noun.js";
16
+ import { settleReading } from "./word-reading.js";
17
+ import { NO_TALLY } from "./merge-types.js";
18
+ /**
19
+ * Merge one word.
20
+ */
21
+ export function mergeWord(word, sources) {
22
+ const { cedictByWord, cedictByHant, phrase, jieba, unihanReadings, traditional, defaults, } = sources;
23
+ const cedictEntries = cedictByWord.get(word) ?? [];
24
+ const cedictReadings = cedictReadingsOf(word, cedictEntries);
25
+ // Every reading CC-CEDICT gives this spelling, under either script.
26
+ const senseReadings = [
27
+ ...cedictReadings,
28
+ ...cedictReadingsOf(word, cedictByHant.get(word) ?? []),
29
+ ];
30
+ const phraseReading = phrase.get(word);
31
+ const phraseAligned = phraseReading === undefined
32
+ ? undefined
33
+ : readAlignedReading(word, phraseReading);
34
+ const settled = settleReading(word, defaults, cedictEntries, cedictReadings, phraseAligned);
35
+ if (settled.reading === undefined) {
36
+ return {
37
+ entry: undefined,
38
+ rejected: phraseReading ?? cedictEntries[0]?.readings ?? [],
39
+ tally: NO_TALLY,
40
+ };
41
+ }
42
+ const reading = settled.reading;
43
+ const aligned = settled.aligned;
44
+ // ── 繁體: taken from CC-CEDICT, derived where it is silent ─
45
+ const { senses, hant, hantVariants, isDerived } = traditionalFormOf(word, cedictEntries, reading, aligned, traditional);
46
+ // ── zh-TW delta ───────────────────────────────────────────
47
+ const taiwan = taiwanReadingOf(word, senses, senseReadings, reading, unihanReadings.get(word));
48
+ // ── Frequency, part of speech and the proper noun bit ─────
49
+ const jiebaEntry = jieba.get(word);
50
+ const { isProperNoun, boundaries, isVetoed } = properNounOf(word, jiebaEntry, cedictEntries, senses, reading);
51
+ // ── Polyphone priors, for single characters only ──────────
52
+ const isCharacter = isSingleCharacter(word);
53
+ const characterReadings = defaults.get(word) ?? [];
54
+ const alternates = isCharacter
55
+ ? characterReadings
56
+ .filter((syllable) => !isSameReading([syllable], reading))
57
+ .map((syllable) => [syllable])
58
+ : [];
59
+ const entry = {
60
+ hans: word,
61
+ hant,
62
+ ...(hantVariants.length > 0 && { hantVariants }),
63
+ readings: { cn: reading, ...(taiwan !== undefined && { tw: taiwan }) },
64
+ frequency: jiebaEntry?.frequency ?? 0,
65
+ partOfSpeech: jiebaEntry?.partOfSpeech ?? "",
66
+ isProperNoun,
67
+ ...(boundaries.length > 0 && { nameBoundaries: boundaries }),
68
+ ...(alternates.length > 0 && { alternates }),
69
+ };
70
+ // Read off the decisions above rather than counted as they were made: every
71
+ // one of these is a fact about the finished entry, so a running total would
72
+ // only be a second place for it to be recorded.
73
+ return {
74
+ entry,
75
+ rejected: undefined,
76
+ tally: {
77
+ neutralToneCorrections: settled.neutralToneCorrections,
78
+ erhuaRepairs: settled.erhuaRepairs,
79
+ derivedTraditional: isDerived ? 1 : 0,
80
+ scriptPairs: hant === word ? 0 : 1,
81
+ variantSpellings: hantVariants.length > 0 ? 1 : 0,
82
+ taiwanReadings: taiwan === undefined ? 0 : 1,
83
+ properNounVetoes: isVetoed ? 1 : 0,
84
+ nameBoundaries: boundaries.length > 0 ? 1 : 0,
85
+ characters: isCharacter ? 1 : 0,
86
+ phraseWords: phraseReading === undefined ? 0 : 1,
87
+ cedictWords: cedictEntries.length > 0 ? 1 : 0,
88
+ },
89
+ };
90
+ }
91
+ //# sourceMappingURL=merge-word.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-word.js","sourceRoot":"","sources":["../../src/dictionary/merge-word.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAwB,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAA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C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,WAAW,EAAE,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C;KACF,CAAC;AACJ,CAAC"}
@@ -1,70 +1,13 @@
1
- import { type CedictEntry } from "../sources/cedict.js";
2
- import { type JiebaEntry } from "../sources/jieba.js";
3
- import { type UnihanReadings, type UnihanVariants } from "../sources/unihan.js";
4
- import { type DictionaryEntry } from "./entry.js";
5
- /**
6
- * The parsed sources the merge combines.
7
- */
8
- export interface MergeSources {
9
- readonly unihanReadings: ReadonlyMap<string, UnihanReadings>;
10
- readonly unihanVariants: UnihanVariants;
11
- readonly phrase: ReadonlyMap<string, readonly string[]>;
12
- readonly cedict: readonly CedictEntry[];
13
- readonly jieba: ReadonlyMap<string, JiebaEntry>;
14
- }
15
- /**
16
- * Counts describing what the merge did, for the build to report and check.
17
- */
18
- export interface MergeStats {
19
- readonly characters: number;
20
- readonly phraseWords: number;
21
- readonly cedictWords: number;
22
- /** Words whose reading CC-CEDICT corrected to a neutral tone. */
23
- readonly neutralToneCorrections: number;
24
- /**
25
- * Characters whose default was a 轻声 the frequency field only counted inside
26
- * words — see {@link demoteReducedNeutrals}.
27
- */
28
- readonly reducedNeutrals: number;
29
- /** Words whose trailing 儿 was folded into the syllable before it. */
30
- readonly erhuaRepairs: number;
31
- /** Words whose 繁體 form was derived rather than taken from CC-CEDICT. */
32
- readonly derivedTraditional: number;
33
- /** Entries with a 繁體 form differing from their 简体 one. */
34
- readonly scriptPairs: number;
35
- /** Entries a source writes more than one 繁體 spelling of. */
36
- readonly variantSpellings: number;
37
- /** Entries carrying a zh-TW reading delta a source stated. */
38
- readonly taiwanReadings: number;
39
- /** Compounds given a zh-TW delta composed from their constituents. */
40
- readonly composedTaiwanReadings: number;
41
- /**
42
- * Words jieba tagged a proper noun that CC-CEDICT's lowercase pinyin vetoed.
43
- */
44
- readonly properNounVetoes: number;
45
- /** Entries whose parts CC-CEDICT's capitalisation divides. */
46
- readonly nameBoundaries: number;
47
- /** Words dropped because no source gave a usable reading. */
48
- readonly rejected: number;
49
- }
50
- /**
51
- * What the merge produced.
52
- */
53
- export interface MergeResult {
54
- /** Entries, ordered by their 简体 form. */
55
- readonly entries: readonly DictionaryEntry[];
56
- /** Words no source could be read, with the reading that failed. */
57
- readonly rejected: ReadonlyMap<string, readonly string[]>;
58
- readonly stats: MergeStats;
59
- }
1
+ import { type MergeResult, type MergeSources } from "./merge-types.js";
2
+ export type { MergeResult, MergeSources, MergeStats } from "./merge-types.js";
60
3
  /**
61
4
  * Build the merged dictionary from the four parsed sources.
62
5
  *
63
6
  * The order of operations is the one MERGE.md sets out, and it is not
64
7
  * arbitrary — each step depends on the one before. Spelling, tones, sandhi and
65
- * validation happen in {@link readAlignedReading} as each source is read; this
66
- * function then repairs 儿化, derives 繁體 forms, resolves the disagreements
67
- * between sources, and finally applies the override table.
8
+ * validation happen in {@link import("./reading.js").readAlignedReading} as each source is read;
9
+ * {@link mergeWord} then settles one word at a time, and this walks the words
10
+ * and gathers what each of them came to.
68
11
  */
69
12
  export declare function mergeSources(sources: MergeSources): MergeResult;
70
13
  //# sourceMappingURL=merge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/dictionary/merge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,YAAY,CAAC;AAgBjE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7D,QAAQ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