@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
@@ -0,0 +1,76 @@
1
+ import { isSingleCharacter } from "../script/characters.js";
2
+ import { isSameReading } from "./entry.js";
3
+ import { readAlignedReading } from "./reading.js";
4
+ import { repairErhua } from "./erhua-repair.js";
5
+ import { NEUTRAL_SENSE_LOOKUP } from "./neutral-senses.js";
6
+ import { OVERRIDE_READINGS } from "./overrides.js";
7
+ import { nearestReading, preferNeutralTones, reducesToNeutral, } from "./reading-agreement.js";
8
+ /**
9
+ * Settle it.
10
+ */
11
+ export function settleReading(word, defaults, cedictEntries, cedictReadings, phraseAligned) {
12
+ let neutralToneCorrections = 0;
13
+ let erhuaRepairs = 0;
14
+ // ── The reading: phrase corpus leads, CC-CEDICT corrects ──
15
+ let aligned = phraseAligned;
16
+ let reading = aligned
17
+ ?.map((read) => read.syllable)
18
+ .filter((syllable) => syllable !== undefined);
19
+ if (reading === undefined) {
20
+ // No phrase entry. Single characters fall back to Unihan, which is the
21
+ // better source for them anyway; everything else falls back to
22
+ // CC-CEDICT.
23
+ const characterDefault = defaults.get(word);
24
+ if (isSingleCharacter(word) && characterDefault !== undefined) {
25
+ reading = characterDefault.slice(0, 1);
26
+ aligned = [{ characters: word, syllable: reading[0] }];
27
+ }
28
+ else if (cedictReadings[0] !== undefined) {
29
+ reading = cedictReadings[0];
30
+ aligned = readAlignedReading(word, cedictEntries[0]?.readings ?? []);
31
+ }
32
+ }
33
+ if (reading === undefined || reading.length === 0) {
34
+ return {
35
+ reading: undefined,
36
+ aligned: undefined,
37
+ neutralToneCorrections: 0,
38
+ erhuaRepairs: 0,
39
+ };
40
+ }
41
+ // ── 儿化, before anything compares two readings ────────────
42
+ const repaired = repairErhua(word, reading, aligned, cedictEntries, cedictReadings);
43
+ reading = repaired.reading;
44
+ aligned = repaired.aligned;
45
+ if (repaired.isRepaired) {
46
+ erhuaRepairs++;
47
+ }
48
+ // ── Disagreements: CC-CEDICT wins on neutral tones ────────
49
+ // Which sense to correct against is normally the nearest one. For a word on
50
+ // the 轻声 list it is the nearest sense that *reduces* a syllable, because
51
+ // there the nearest sense is the full-tone homograph the corpus happens to
52
+ // have written and the everyday word is the other one — see
53
+ // {@link NEUTRAL_SENSE_WORDS}.
54
+ const chosen = reading;
55
+ const nearest = phraseAligned === undefined
56
+ ? undefined
57
+ : ((NEUTRAL_SENSE_LOOKUP.has(word)
58
+ ? nearestReading(chosen, cedictReadings.filter((candidate) => reducesToNeutral(chosen, candidate)))
59
+ : undefined) ?? nearestReading(chosen, cedictReadings));
60
+ // A sense of a different length describes a different pronunciation, so
61
+ // there is no syllable-for-syllable correction to make against it.
62
+ if (nearest !== undefined) {
63
+ const corrected = preferNeutralTones(reading, nearest);
64
+ if (!isSameReading(corrected, reading)) {
65
+ neutralToneCorrections++;
66
+ reading = corrected;
67
+ }
68
+ }
69
+ // ── The override table has the last word ──────────────────
70
+ const override = OVERRIDE_READINGS.get(word);
71
+ if (override !== undefined) {
72
+ reading = override;
73
+ }
74
+ return { reading, aligned, neutralToneCorrections, erhuaRepairs };
75
+ }
76
+ //# sourceMappingURL=word-reading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"word-reading.js","sourceRoot":"","sources":["../../src/dictionary/word-reading.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,M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AO,CAAC,EAAE,CAAC;YACvC,sBAAsB,EAAE,CAAC;YACzB,OAAO,GAAG,SAAS,CAAC;QACtB,CAAC;IACH,CAAC;IAED,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,GAAG,QAAQ,CAAC;IACrB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,CAAC;AACpE,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The words whose reading a build must reproduce.
3
+ *
4
+ * Each stands for a class of upstream defect a source refresh could
5
+ * reintroduce — a 儿化 repair, a sandhi normalisation, a polyphone the corpus
6
+ * would otherwise flatten — so a failure means the merge stopped doing
7
+ * something it used to, not that one word is wrong.
8
+ */
9
+ import type { BuildAssertion } from "./built-dictionary.js";
10
+ /**
11
+ * Assert one word reads a particular way.
12
+ */
13
+ export declare function reads(word: string, expected: string, why: string): BuildAssertion;
14
+ export declare const WORD_READINGS: readonly BuildAssertion[];
15
+ //# sourceMappingURL=word-readings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"word-readings.d.ts","sourceRoot":"","sources":["../../src/dictionary/word-readings.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,uBAAuB,CAAC;AAE7E;;GAEG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,cAAc,CAahB;AAED,eAAO,MAAM,aAAa,EAAE,SAAS,cAAc,EAmBlD,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Assert one word reads a particular way.
3
+ */
4
+ export function reads(word, expected, why) {
5
+ return {
6
+ description: `${word} → ${expected} (${why})`,
7
+ check: (dictionary) => {
8
+ const actual = dictionary.reading(word);
9
+ if (actual === undefined) {
10
+ return `${word} is missing from the dictionary`;
11
+ }
12
+ return actual === expected
13
+ ? undefined
14
+ : `${word} reads ${actual}, expected ${expected}`;
15
+ },
16
+ };
17
+ }
18
+ export const WORD_READINGS = [
19
+ reads("玩儿", "wánr", "儿化 repaired from CC-CEDICT's r5"),
20
+ reads("女儿", "nǚ ér", "儿 keeps its own syllable here"),
21
+ reads("这儿", "zhèr", "儿化 despite upstream writing a tone on the er"),
22
+ reads("儿子", "ér zi", "儿化 exception list consulted"),
23
+ reads("一丁不识", "yī dīng bù shí", "一 sandhi normalised out"),
24
+ reads("一不小心", "yī bù xiǎo xīn", "一 and 不 sandhi normalised out"),
25
+ reads("大夫", "dài fu", "override applied over both sources"),
26
+ reads("东西", "dōng xi", "the thing, not the compass directions"),
27
+ reads("东西方", "dōng xī fāng", "and the directions where that is the word"),
28
+ reads("告诉", "gào su", "the everyday verb, not filing a complaint"),
29
+ reads("银行", "yín háng", "polyphone survives"),
30
+ reads("行长", "háng zhǎng", "polyphone survives"),
31
+ reads("头发", "tóu fa", "CC-CEDICT wins on the neutral tone"),
32
+ reads("还是", "hái shi", "CC-CEDICT wins on the neutral tone"),
33
+ reads("頭髮", "tóu fa", "繁體 derived using the reading, and keyed directly"),
34
+ reads("重複", "chóng fù", "one of two 繁體 spellings, both keyed"),
35
+ reads("重覆", "chóng fù", "the other, on the same entry"),
36
+ reads("下麵", "xià miàn", "both spellings of a word CC-CEDICT writes twice"),
37
+ ];
38
+ //# sourceMappingURL=word-readings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"word-readings.js","sourceRoot":"","sources":["../../src/dictionary/word-readings.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,UAAU,KAAK,CACnB,IAAY,EACZ,QAAgB,EAChB,GAAW;IAEX,OAAO;QACL,WAAW,EAAE,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG,GAAG;QAC7C,KAAK,EAAE,CAAC,U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,CAAC;IACzE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,qCAAqC,CAAC;IAC9D,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,8BAA8B,CAAC;IACvD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,iDAAiD,CAAC;CAC3E,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Writing a conversion as ruby annotation.
3
+ *
4
+ * The pinyin sits above the characters rather than beside them, so the pieces
5
+ * are regrouped against the text they annotate.
6
+ */
7
+ import { type HtmlOptions } from "./html.js";
8
+ import { type ConvertedPiece } from "../decode/convert.js";
9
+ import type { Dictionary } from "../dictionary/dictionary.js";
10
+ /**
11
+ * What the characters being annotated declare themselves to be.
12
+ *
13
+ * The mirror of {@link languageTag}: inside an annotation the base is hanzi and
14
+ * only the reading is pinyin, so on an English page the two need different tags
15
+ * and neither can be left to inherit.
16
+ *
17
+ * **`zh`, with no script subtag, and that is deliberate.** `Hans` or `Hant`
18
+ * would be better for font selection, and neither can be known here. The
19
+ * conversion's locale does not settle it — script and locale are separate axes,
20
+ * and a mainland edition of a classical text is 繁體 read as `zh-CN` — and
21
+ * detecting it from the characters needs the script tables, which load
22
+ * separately from the dictionary precisely so that converting does not pay for
23
+ * them. A tag that is merely unspecific is worth more than one that is wrong,
24
+ * so a caller who knows the script should wrap the output and say so there.
25
+ */
26
+ export declare const BASE_TAG = "zh";
27
+ /**
28
+ * One base and everything read off it.
29
+ */
30
+ export interface Annotation {
31
+ /** The characters, or undefined for text that reads as nothing. */
32
+ readonly source: string | undefined;
33
+ readonly pieces: readonly ConvertedPiece[];
34
+ }
35
+ /**
36
+ * Gather pieces into the bases they are readings of.
37
+ *
38
+ * A piece naming characters opens a group and every piece after it that names
39
+ * none reads on into the same one, which is how 玩儿 keeps `wánr` over both
40
+ * characters and 95% keeps `bǎifēnzhījiǔshíwǔ` over all three. Pieces writing
41
+ * no reading at all — the spaces between words, and runs that were never Han —
42
+ * are their own groups, with nothing to annotate.
43
+ */
44
+ export declare function annotationsOf(pieces: readonly ConvertedPiece[]): Annotation[];
45
+ /**
46
+ * Mark up a converted text as hanzi with its reading above, syllable by
47
+ * syllable.
48
+ *
49
+ * The output every other mode cannot give: `convert` and {@link toHtml} write
50
+ * the pinyin *instead of* the hanzi, and a learner's text, a subtitle and a
51
+ * dictionary entry all want both at once. The markup is `<ruby>`, which every
52
+ * current browser lays out natively and which degrades to parentheses through
53
+ * `<rp>` where it is not supported.
54
+ *
55
+ * ```html
56
+ * <ruby lang="zh">银<rp>(</rp><rt><span …>yín</span></rt><rp>)</rp></ruby>
57
+ * ```
58
+ *
59
+ * Each `<rt>` holds whatever {@link toHtml} would have written for those
60
+ * syllables, so tone classes and uncertainty marking work inside an annotation
61
+ * exactly as they do outside one.
62
+ *
63
+ * **A base is not always one character.** 玩儿 is two characters and the one
64
+ * syllable `wánr`, and a read number reverses on the way — 95% is
65
+ * `bǎifēnzhījiǔshíwǔ` — so both are annotated whole. Splitting them per
66
+ * character is what everything that emits ruby from a pinyin library gets
67
+ * wrong, and it is why {@link ConvertedPiece.source} exists.
68
+ */
69
+ export declare function toAnnotatedHtml(pieces: readonly ConvertedPiece[], options?: HtmlOptions): string;
70
+ /**
71
+ * Convert hanzi to pinyin as HTML, hanzi and reading together.
72
+ *
73
+ * {@link toAnnotatedHtml} applied to a fresh conversion; see it for what the
74
+ * markup is and why a base is not always one character.
75
+ */
76
+ export declare function convertToAnnotatedHtml(dictionary: Dictionary, text: string, options?: HtmlOptions): string;
77
+ /**
78
+ * Convert hanzi to pinyin as HTML, one element per syllable.
79
+ *
80
+ * What per-syllable confidence is for, and the reason ALGORITHM.md asks for it:
81
+ * a reading the decode was guessing at can be *shown* to be a guess, which for
82
+ * a learner is a feature rather than a diagnostic. No styling is imposed — the
83
+ * classes are hooks, and the page decides whether a fourth tone is red and an
84
+ * uncertain reading is dotted underneath.
85
+ *
86
+ * Nothing is wrapped around the whole conversion, and anything that is not Han
87
+ * passes through escaped rather than marked up.
88
+ */
89
+ export declare function convertToHtml(dictionary: Dictionary, text: string, options?: HtmlOptions): string;
90
+ //# sourceMappingURL=annotate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotate.d.ts","sourceRoot":"","sources":["../../src/format/annotate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAU,KAAK,WAAW,EAAsB,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,OAAO,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;CAC5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,UAAU,EAAE,CAc7E;AA2ED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,cAAc,EAAE,EACjC,OAAO,GAAE,WAAgB,GACxB,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,GACxB,MAAM,CAER;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,GACxB,MAAM,CAER"}
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Writing a conversion as ruby annotation.
3
+ *
4
+ * The pinyin sits above the characters rather than beside them, so the pieces
5
+ * are regrouped against the text they annotate.
6
+ */
7
+ import { escape, toHtml, writePiece } from "./html.js";
8
+ import { convertPieces } from "../decode/convert.js";
9
+ /**
10
+ * What the characters being annotated declare themselves to be.
11
+ *
12
+ * The mirror of {@link languageTag}: inside an annotation the base is hanzi and
13
+ * only the reading is pinyin, so on an English page the two need different tags
14
+ * and neither can be left to inherit.
15
+ *
16
+ * **`zh`, with no script subtag, and that is deliberate.** `Hans` or `Hant`
17
+ * would be better for font selection, and neither can be known here. The
18
+ * conversion's locale does not settle it — script and locale are separate axes,
19
+ * and a mainland edition of a classical text is 繁體 read as `zh-CN` — and
20
+ * detecting it from the characters needs the script tables, which load
21
+ * separately from the dictionary precisely so that converting does not pay for
22
+ * them. A tag that is merely unspecific is worth more than one that is wrong,
23
+ * so a caller who knows the script should wrap the output and say so there.
24
+ */
25
+ export const BASE_TAG = "zh";
26
+ /**
27
+ * Gather pieces into the bases they are readings of.
28
+ *
29
+ * A piece naming characters opens a group and every piece after it that names
30
+ * none reads on into the same one, which is how 玩儿 keeps `wánr` over both
31
+ * characters and 95% keeps `bǎifēnzhījiǔshíwǔ` over all three. Pieces writing
32
+ * no reading at all — the spaces between words, and runs that were never Han —
33
+ * are their own groups, with nothing to annotate.
34
+ */
35
+ export function annotationsOf(pieces) {
36
+ const groups = [];
37
+ for (const [at, piece] of pieces.entries()) {
38
+ const open = groups.at(-1);
39
+ if (open?.source !== undefined && continues(piece, pieces[at + 1])) {
40
+ groups[groups.length - 1] = {
41
+ source: open.source,
42
+ pieces: [...open.pieces, piece],
43
+ };
44
+ continue;
45
+ }
46
+ groups.push({ source: piece.source, pieces: [piece] });
47
+ }
48
+ return groups;
49
+ }
50
+ /**
51
+ * Whether a piece belongs to the annotation the group before it opened.
52
+ *
53
+ * Three kinds do:
54
+ *
55
+ * - A **syllable naming no characters** is reading on into the ones already
56
+ * named, which is 儿化 and every syllable of a read number after the first.
57
+ * - A **separator that is not a space** is a mark *inside* one orthographic
58
+ * word rather than a gap between two — the hyphen of `gāngān-jìngjìng`, the
59
+ * only one GB/T 16159 writes — so it belongs beside the syllables it divides.
60
+ * - A **space with more of the same reading after it**. 1988 is read
61
+ * `yī jiǔ bā bā`, four syllables over one base, and the spaces between them
62
+ * are inside that reading rather than between two of them.
63
+ *
64
+ * That last one is why this needs the piece after it. A space is written the
65
+ * same way whether it separates two words or two syllables of one number, and
66
+ * what tells them apart is whether what follows is still reading the same
67
+ * characters. Told apart wrongly, the reading escapes its own annotation:
68
+ * 1988年 came out as `1988` over `yī` with `jiǔ bā bā` loose beside it.
69
+ *
70
+ * A space between two words is the case that does not continue, and dropping it
71
+ * is the point: the hanzi it annotates has no space in it, and each base is
72
+ * already its own group on the page.
73
+ */
74
+ function continues(piece, next) {
75
+ if (piece.syllable !== undefined) {
76
+ return piece.source === undefined;
77
+ }
78
+ if (piece.source !== undefined) {
79
+ return false;
80
+ }
81
+ return (piece.text.trim() !== "" ||
82
+ (next?.syllable !== undefined && next.source === undefined));
83
+ }
84
+ /**
85
+ * Mark up one base and its reading.
86
+ */
87
+ function writeAnnotation(annotation, options) {
88
+ const { lang = true } = options;
89
+ const { source, pieces } = annotation;
90
+ if (pieces.every((piece) => piece.syllable === undefined)) {
91
+ // Nothing is read here. Either it is source text that simply has no
92
+ // reading — punctuation, a Latin word — and is written as the author wrote
93
+ // it, or it is pinyin orthography with no source behind it at all: the
94
+ // space between two words, and the hyphen in `gāngān-jìngjìng`. Writing
95
+ // those into the hanzi would annotate 干干净净 as 干干-净净.
96
+ return source === undefined ? "" : escape(source);
97
+ }
98
+ if (source === undefined) {
99
+ // A reading whose piece never named what it reads. Nothing a conversion
100
+ // builds looks like this — every group is opened by a piece carrying its
101
+ // characters — but {@link toAnnotatedHtml} takes pieces from the caller,
102
+ // and there is no base to hang an annotation on, so it is written as the
103
+ // plain markup it would have got from {@link toHtml}.
104
+ return pieces.map((piece) => writePiece(piece, options)).join("");
105
+ }
106
+ const reading = pieces.map((piece) => writePiece(piece, options)).join("");
107
+ // The tag goes on the <ruby> rather than around the base, and the syllables
108
+ // inside the <rt> override it with their own. `<rb>` would be the obvious
109
+ // place for it and is not an element any more: the WHATWG parser drops it,
110
+ // leaving the base as bare text, so writing one would mean emitting markup
111
+ // that no browser keeps.
112
+ const opening = lang ? `<ruby lang="${BASE_TAG}">` : "<ruby>";
113
+ return `${opening}${escape(source)}<rp>(</rp><rt>${reading}</rt><rp>)</rp></ruby>`;
114
+ }
115
+ /**
116
+ * Mark up a converted text as hanzi with its reading above, syllable by
117
+ * syllable.
118
+ *
119
+ * The output every other mode cannot give: `convert` and {@link toHtml} write
120
+ * the pinyin *instead of* the hanzi, and a learner's text, a subtitle and a
121
+ * dictionary entry all want both at once. The markup is `<ruby>`, which every
122
+ * current browser lays out natively and which degrades to parentheses through
123
+ * `<rp>` where it is not supported.
124
+ *
125
+ * ```html
126
+ * <ruby lang="zh">银<rp>(</rp><rt><span …>yín</span></rt><rp>)</rp></ruby>
127
+ * ```
128
+ *
129
+ * Each `<rt>` holds whatever {@link toHtml} would have written for those
130
+ * syllables, so tone classes and uncertainty marking work inside an annotation
131
+ * exactly as they do outside one.
132
+ *
133
+ * **A base is not always one character.** 玩儿 is two characters and the one
134
+ * syllable `wánr`, and a read number reverses on the way — 95% is
135
+ * `bǎifēnzhījiǔshíwǔ` — so both are annotated whole. Splitting them per
136
+ * character is what everything that emits ruby from a pinyin library gets
137
+ * wrong, and it is why {@link ConvertedPiece.source} exists.
138
+ */
139
+ export function toAnnotatedHtml(pieces, options = {}) {
140
+ return annotationsOf(pieces)
141
+ .map((annotation) => writeAnnotation(annotation, options))
142
+ .join("");
143
+ }
144
+ /**
145
+ * Convert hanzi to pinyin as HTML, hanzi and reading together.
146
+ *
147
+ * {@link toAnnotatedHtml} applied to a fresh conversion; see it for what the
148
+ * markup is and why a base is not always one character.
149
+ */
150
+ export function convertToAnnotatedHtml(dictionary, text, options = {}) {
151
+ return toAnnotatedHtml(convertPieces(dictionary, text, options), options);
152
+ }
153
+ /**
154
+ * Convert hanzi to pinyin as HTML, one element per syllable.
155
+ *
156
+ * What per-syllable confidence is for, and the reason ALGORITHM.md asks for it:
157
+ * a reading the decode was guessing at can be *shown* to be a guess, which for
158
+ * a learner is a feature rather than a diagnostic. No styling is imposed — the
159
+ * classes are hooks, and the page decides whether a fourth tone is red and an
160
+ * uncertain reading is dotted underneath.
161
+ *
162
+ * Nothing is wrapped around the whole conversion, and anything that is not Han
163
+ * passes through escaped rather than marked up.
164
+ */
165
+ export function convertToHtml(dictionary, text, options = {}) {
166
+ return toHtml(convertPieces(dictionary, text, options), options);
167
+ }
168
+ //# sourceMappingURL=annotate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotate.js","sourceRoot":"","sources":["../../src/format/annotate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAoB,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAuB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAW7B;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,MAAiC;IAC7D,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,IAAI,EAAE,MAAM,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACnE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG;gBAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;aACh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I,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC"}
@@ -1,5 +1,5 @@
1
- import { type ConvertedPiece, type ConvertOptions } from "../decode/convert.js";
2
- import type { Dictionary } from "../dictionary/dictionary.js";
1
+ export { convertToAnnotatedHtml, convertToHtml, toAnnotatedHtml, } from "./annotate.js";
2
+ import type { ConvertedPiece, ConvertOptions } from "../decode/convert.js";
3
3
  /**
4
4
  * How a conversion is marked up.
5
5
  */
@@ -29,55 +29,24 @@ export interface HtmlOptions extends ConvertOptions {
29
29
  readonly lang?: boolean;
30
30
  }
31
31
  /**
32
- * Mark up a converted text, one element per syllable.
33
- *
34
- * Takes the pieces {@link convertPieces} produces, so that a caller can convert
35
- * once and render more than one way.
36
- */
37
- export declare function toHtml(pieces: readonly ConvertedPiece[], options?: HtmlOptions): string;
38
- /**
39
- * Mark up a converted text as hanzi with its reading above, syllable by
40
- * syllable.
41
- *
42
- * The output every other mode cannot give: `convert` and {@link toHtml} write
43
- * the pinyin *instead of* the hanzi, and a learner's text, a subtitle and a
44
- * dictionary entry all want both at once. The markup is `<ruby>`, which every
45
- * current browser lays out natively and which degrades to parentheses through
46
- * `<rp>` where it is not supported.
32
+ * Escape text for markup.
47
33
  *
48
- * ```html
49
- * <ruby lang="zh">银<rp>(</rp><rt><span …>yín</span></rt><rp>)</rp></ruby>
50
- * ```
51
- *
52
- * Each `<rt>` holds whatever {@link toHtml} would have written for those
53
- * syllables, so tone classes and uncertainty marking work inside an annotation
54
- * exactly as they do outside one.
55
- *
56
- * **A base is not always one character.** 玩儿 is two characters and the one
57
- * syllable `wánr`, and a read number reverses on the way — 95% is
58
- * `bǎifēnzhījiǔshíwǔ` — so both are annotated whole. Splitting them per
59
- * character is what everything that emits ruby from a pinyin library gets
60
- * wrong, and it is why {@link ConvertedPiece.source} exists.
34
+ * Applied to everything, including the source's own text: a conversion passes
35
+ * anything that is not Han through untouched, so `<script>` in the input
36
+ * reaches the output as written. The apostrophe is deliberately not escaped:
37
+ * every attribute here is double-quoted, and the 隔音符号 of `Xī'ān` is a
38
+ * letter of the orthography that a reader should see as one.
61
39
  */
62
- export declare function toAnnotatedHtml(pieces: readonly ConvertedPiece[], options?: HtmlOptions): string;
40
+ export declare function escape(text: string): string;
63
41
  /**
64
- * Convert hanzi to pinyin as HTML, hanzi and reading together.
65
- *
66
- * {@link toAnnotatedHtml} applied to a fresh conversion; see it for what the
67
- * markup is and why a base is not always one character.
42
+ * Mark up one piece of a conversion.
68
43
  */
69
- export declare function convertToAnnotatedHtml(dictionary: Dictionary, text: string, options?: HtmlOptions): string;
44
+ export declare function writePiece(piece: ConvertedPiece, options: HtmlOptions): string;
70
45
  /**
71
- * Convert hanzi to pinyin as HTML, one element per syllable.
72
- *
73
- * What per-syllable confidence is for, and the reason ALGORITHM.md asks for it:
74
- * a reading the decode was guessing at can be *shown* to be a guess, which for
75
- * a learner is a feature rather than a diagnostic. No styling is imposed — the
76
- * classes are hooks, and the page decides whether a fourth tone is red and an
77
- * uncertain reading is dotted underneath.
46
+ * Mark up a converted text, one element per syllable.
78
47
  *
79
- * Nothing is wrapped around the whole conversion, and anything that is not Han
80
- * passes through escaped rather than marked up.
48
+ * Takes the pieces {@link convertPieces} produces, so that a caller can convert
49
+ * once and render more than one way.
81
50
  */
82
- export declare function convertToHtml(dictionary: Dictionary, text: string, options?: HtmlOptions): string;
51
+ export declare function toHtml(pieces: readonly ConvertedPiece[], options?: HtmlOptions): string;
83
52
  //# sourceMappingURL=html.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/format/html.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI9D;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD;;;;;OAKG;IACH,QAAQ,CAAC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