@kensio/pinyinjs 1.7.4 → 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (732) hide show
  1. package/README.md +128 -123
  2. package/data/full.entries +2595 -2595
  3. package/data/manifest.json +5 -5
  4. package/data/script.map +66 -3
  5. package/dist/accuracy/score-case.d.ts +23 -0
  6. package/dist/accuracy/score-case.d.ts.map +1 -0
  7. package/dist/accuracy/score-case.js +63 -0
  8. package/dist/accuracy/score-case.js.map +1 -0
  9. package/dist/accuracy/score.d.ts +1 -8
  10. package/dist/accuracy/score.d.ts.map +1 -1
  11. package/dist/accuracy/score.js +1 -55
  12. package/dist/accuracy/score.js.map +1 -1
  13. package/dist/cli/arguments.d.ts +4 -290
  14. package/dist/cli/arguments.d.ts.map +1 -1
  15. package/dist/cli/arguments.js +5 -357
  16. package/dist/cli/arguments.js.map +1 -1
  17. package/dist/cli/check-command.d.ts +9 -0
  18. package/dist/cli/check-command.d.ts.map +1 -0
  19. package/dist/cli/check-command.js +95 -0
  20. package/dist/cli/check-command.js.map +1 -0
  21. package/dist/cli/cli-input.d.ts +49 -0
  22. package/dist/cli/cli-input.d.ts.map +1 -0
  23. package/dist/cli/cli-input.js +31 -0
  24. package/dist/cli/cli-input.js.map +1 -0
  25. package/dist/cli/command.d.ts +97 -0
  26. package/dist/cli/command.d.ts.map +1 -0
  27. package/dist/cli/command.js +40 -0
  28. package/dist/cli/command.js.map +1 -0
  29. package/dist/cli/commands.d.ts +7 -110
  30. package/dist/cli/commands.d.ts.map +1 -1
  31. package/dist/cli/commands.js +14 -991
  32. package/dist/cli/commands.js.map +1 -1
  33. package/dist/cli/convert-command.d.ts +6 -0
  34. package/dist/cli/convert-command.d.ts.map +1 -0
  35. package/dist/cli/convert-command.js +52 -0
  36. package/dist/cli/convert-command.js.map +1 -0
  37. package/dist/cli/environment.d.ts +1 -1
  38. package/dist/cli/environment.d.ts.map +1 -1
  39. package/dist/cli/explain-command.d.ts +6 -0
  40. package/dist/cli/explain-command.d.ts.map +1 -0
  41. package/dist/cli/explain-command.js +40 -0
  42. package/dist/cli/explain-command.js.map +1 -0
  43. package/dist/cli/explain-syllable.d.ts +10 -0
  44. package/dist/cli/explain-syllable.d.ts.map +1 -0
  45. package/dist/cli/explain-syllable.js +70 -0
  46. package/dist/cli/explain-syllable.js.map +1 -0
  47. package/dist/cli/flag-help.d.ts +18 -0
  48. package/dist/cli/flag-help.d.ts.map +1 -0
  49. package/dist/cli/flag-help.js +78 -0
  50. package/dist/cli/flag-help.js.map +1 -0
  51. package/dist/cli/flag-lists.d.ts +49 -0
  52. package/dist/cli/flag-lists.d.ts.map +1 -0
  53. package/dist/cli/flag-lists.js +58 -0
  54. package/dist/cli/flag-lists.js.map +1 -0
  55. package/dist/cli/flag-values.d.ts +44 -0
  56. package/dist/cli/flag-values.d.ts.map +1 -0
  57. package/dist/cli/flag-values.js +56 -0
  58. package/dist/cli/flag-values.js.map +1 -0
  59. package/dist/cli/flags.d.ts +193 -0
  60. package/dist/cli/flags.d.ts.map +1 -0
  61. package/dist/cli/flags.js +133 -0
  62. package/dist/cli/flags.js.map +1 -0
  63. package/dist/cli/format-options.d.ts +29 -0
  64. package/dist/cli/format-options.d.ts.map +1 -0
  65. package/dist/cli/format-options.js +72 -0
  66. package/dist/cli/format-options.js.map +1 -0
  67. package/dist/cli/global-help.d.ts +23 -0
  68. package/dist/cli/global-help.d.ts.map +1 -0
  69. package/dist/cli/global-help.js +40 -0
  70. package/dist/cli/global-help.js.map +1 -0
  71. package/dist/cli/help.d.ts +1 -1
  72. package/dist/cli/help.d.ts.map +1 -1
  73. package/dist/cli/help.js +5 -99
  74. package/dist/cli/help.js.map +1 -1
  75. package/dist/cli/html-commands.d.ts +13 -0
  76. package/dist/cli/html-commands.d.ts.map +1 -0
  77. package/dist/cli/html-commands.js +49 -0
  78. package/dist/cli/html-commands.js.map +1 -0
  79. package/dist/cli/info-command.d.ts +7 -0
  80. package/dist/cli/info-command.d.ts.map +1 -0
  81. package/dist/cli/info-command.js +39 -0
  82. package/dist/cli/info-command.js.map +1 -0
  83. package/dist/cli/lookup-commands.d.ts +10 -0
  84. package/dist/cli/lookup-commands.d.ts.map +1 -0
  85. package/dist/cli/lookup-commands.js +101 -0
  86. package/dist/cli/lookup-commands.js.map +1 -0
  87. package/dist/cli/match-command.d.ts +11 -0
  88. package/dist/cli/match-command.d.ts.map +1 -0
  89. package/dist/cli/match-command.js +76 -0
  90. package/dist/cli/match-command.js.map +1 -0
  91. package/dist/cli/number-command.d.ts +12 -0
  92. package/dist/cli/number-command.d.ts.map +1 -0
  93. package/dist/cli/number-command.js +89 -0
  94. package/dist/cli/number-command.js.map +1 -0
  95. package/dist/cli/options.d.ts +30 -0
  96. package/dist/cli/options.d.ts.map +1 -0
  97. package/dist/cli/options.js +54 -0
  98. package/dist/cli/options.js.map +1 -0
  99. package/dist/cli/run-command.d.ts +24 -0
  100. package/dist/cli/run-command.d.ts.map +1 -0
  101. package/dist/cli/run-command.js +40 -0
  102. package/dist/cli/run-command.js.map +1 -0
  103. package/dist/cli/run.d.ts +4 -42
  104. package/dist/cli/run.d.ts.map +1 -1
  105. package/dist/cli/run.js +6 -61
  106. package/dist/cli/run.js.map +1 -1
  107. package/dist/cli/script-command.d.ts +10 -0
  108. package/dist/cli/script-command.d.ts.map +1 -0
  109. package/dist/cli/script-command.js +58 -0
  110. package/dist/cli/script-command.js.map +1 -0
  111. package/dist/cli/segment-command.d.ts +11 -0
  112. package/dist/cli/segment-command.d.ts.map +1 -0
  113. package/dist/cli/segment-command.js +53 -0
  114. package/dist/cli/segment-command.js.map +1 -0
  115. package/dist/cli/slug-command.d.ts +10 -0
  116. package/dist/cli/slug-command.d.ts.map +1 -0
  117. package/dist/cli/slug-command.js +28 -0
  118. package/dist/cli/slug-command.js.map +1 -0
  119. package/dist/cli/syllable-command.d.ts +14 -0
  120. package/dist/cli/syllable-command.d.ts.map +1 -0
  121. package/dist/cli/syllable-command.js +82 -0
  122. package/dist/cli/syllable-command.js.map +1 -0
  123. package/dist/cli/system-table.d.ts +12 -0
  124. package/dist/cli/system-table.d.ts.map +1 -0
  125. package/dist/cli/system-table.js +48 -0
  126. package/dist/cli/system-table.js.map +1 -0
  127. package/dist/cli/systems.d.ts +57 -0
  128. package/dist/cli/systems.d.ts.map +1 -0
  129. package/dist/cli/systems.js +27 -0
  130. package/dist/cli/systems.js.map +1 -0
  131. package/dist/cli/transcribe-command.d.ts +18 -0
  132. package/dist/cli/transcribe-command.d.ts.map +1 -0
  133. package/dist/cli/transcribe-command.js +86 -0
  134. package/dist/cli/transcribe-command.js.map +1 -0
  135. package/dist/cli/transcribe-reading.d.ts +15 -0
  136. package/dist/cli/transcribe-reading.d.ts.map +1 -0
  137. package/dist/cli/transcribe-reading.js +90 -0
  138. package/dist/cli/transcribe-reading.js.map +1 -0
  139. package/dist/cli/transcribe-rows.d.ts +26 -0
  140. package/dist/cli/transcribe-rows.d.ts.map +1 -0
  141. package/dist/cli/transcribe-rows.js +30 -0
  142. package/dist/cli/transcribe-rows.js.map +1 -0
  143. package/dist/cli/usage-error.d.ts +9 -0
  144. package/dist/cli/usage-error.d.ts.map +1 -0
  145. package/dist/cli/usage-error.js +9 -0
  146. package/dist/cli/usage-error.js.map +1 -0
  147. package/dist/decode/alternatives.d.ts +16 -0
  148. package/dist/decode/alternatives.d.ts.map +1 -0
  149. package/dist/decode/alternatives.js +31 -0
  150. package/dist/decode/alternatives.js.map +1 -0
  151. package/dist/decode/chang-context.d.ts +27 -0
  152. package/dist/decode/chang-context.d.ts.map +1 -0
  153. package/dist/decode/chang-context.js +66 -0
  154. package/dist/decode/chang-context.js.map +1 -0
  155. package/dist/decode/chang-rule.d.ts +37 -0
  156. package/dist/decode/chang-rule.d.ts.map +1 -0
  157. package/dist/decode/chang-rule.js +169 -0
  158. package/dist/decode/chang-rule.js.map +1 -0
  159. package/dist/decode/confidence.d.ts +11 -3
  160. package/dist/decode/confidence.d.ts.map +1 -1
  161. package/dist/decode/confidence.js +14 -121
  162. package/dist/decode/confidence.js.map +1 -1
  163. package/dist/decode/convert-options.d.ts +116 -0
  164. package/dist/decode/convert-options.d.ts.map +1 -0
  165. package/dist/decode/convert-options.js +2 -0
  166. package/dist/decode/convert-options.js.map +1 -0
  167. package/dist/decode/convert-pipeline.d.ts +18 -0
  168. package/dist/decode/convert-pipeline.d.ts.map +1 -0
  169. package/dist/decode/convert-pipeline.js +67 -0
  170. package/dist/decode/convert-pipeline.js.map +1 -0
  171. package/dist/decode/convert.d.ts +9 -118
  172. package/dist/decode/convert.d.ts.map +1 -1
  173. package/dist/decode/convert.js +5 -453
  174. package/dist/decode/convert.js.map +1 -1
  175. package/dist/decode/de-rule.d.ts +54 -0
  176. package/dist/decode/de-rule.d.ts.map +1 -0
  177. package/dist/decode/de-rule.js +113 -0
  178. package/dist/decode/de-rule.js.map +1 -0
  179. package/dist/decode/decode.d.ts +2 -15
  180. package/dist/decode/decode.d.ts.map +1 -1
  181. package/dist/decode/decode.js +2 -121
  182. package/dist/decode/decode.js.map +1 -1
  183. package/dist/decode/decoders.d.ts +32 -0
  184. package/dist/decode/decoders.d.ts.map +1 -0
  185. package/dist/decode/decoders.js +29 -0
  186. package/dist/decode/decoders.js.map +1 -0
  187. package/dist/decode/edge-context.d.ts +38 -0
  188. package/dist/decode/edge-context.d.ts.map +1 -0
  189. package/dist/decode/edge-context.js +57 -0
  190. package/dist/decode/edge-context.js.map +1 -0
  191. package/dist/decode/hint-lattice.d.ts +45 -0
  192. package/dist/decode/hint-lattice.d.ts.map +1 -0
  193. package/dist/decode/hint-lattice.js +154 -0
  194. package/dist/decode/hint-lattice.js.map +1 -0
  195. package/dist/decode/hints.d.ts +2 -45
  196. package/dist/decode/hints.d.ts.map +1 -1
  197. package/dist/decode/hints.js +1 -139
  198. package/dist/decode/hints.js.map +1 -1
  199. package/dist/decode/jiao-rule.d.ts +64 -0
  200. package/dist/decode/jiao-rule.d.ts.map +1 -0
  201. package/dist/decode/jiao-rule.js +115 -0
  202. package/dist/decode/jiao-rule.js.map +1 -0
  203. package/dist/decode/lattice-costs.d.ts +55 -0
  204. package/dist/decode/lattice-costs.d.ts.map +1 -0
  205. package/dist/decode/lattice-costs.js +90 -0
  206. package/dist/decode/lattice-costs.js.map +1 -0
  207. package/dist/decode/lattice-edges.d.ts +29 -0
  208. package/dist/decode/lattice-edges.d.ts.map +1 -0
  209. package/dist/decode/lattice-edges.js +78 -0
  210. package/dist/decode/lattice-edges.js.map +1 -0
  211. package/dist/decode/lattice-slice.d.ts +37 -0
  212. package/dist/decode/lattice-slice.d.ts.map +1 -0
  213. package/dist/decode/lattice-slice.js +43 -0
  214. package/dist/decode/lattice-slice.js.map +1 -0
  215. package/dist/decode/lattice-types.d.ts +101 -0
  216. package/dist/decode/lattice-types.d.ts.map +1 -0
  217. package/dist/decode/lattice-types.js +63 -0
  218. package/dist/decode/lattice-types.js.map +1 -0
  219. package/dist/decode/lattice.d.ts +2 -59
  220. package/dist/decode/lattice.d.ts.map +1 -1
  221. package/dist/decode/lattice.js +2 -118
  222. package/dist/decode/lattice.js.map +1 -1
  223. package/dist/decode/number-pieces.d.ts +62 -0
  224. package/dist/decode/number-pieces.d.ts.map +1 -0
  225. package/dist/decode/number-pieces.js +106 -0
  226. package/dist/decode/number-pieces.js.map +1 -0
  227. package/dist/decode/numbers.d.ts +53 -0
  228. package/dist/decode/numbers.d.ts.map +1 -0
  229. package/dist/decode/numbers.js +69 -0
  230. package/dist/decode/numbers.js.map +1 -0
  231. package/dist/decode/pieces.d.ts +78 -0
  232. package/dist/decode/pieces.d.ts.map +1 -0
  233. package/dist/decode/pieces.js +136 -0
  234. package/dist/decode/pieces.js.map +1 -0
  235. package/dist/decode/polyphone-rules.d.ts +11 -0
  236. package/dist/decode/polyphone-rules.d.ts.map +1 -0
  237. package/dist/decode/polyphone-rules.js +11 -0
  238. package/dist/decode/polyphone-rules.js.map +1 -0
  239. package/dist/decode/reading-rules.d.ts +3 -126
  240. package/dist/decode/reading-rules.d.ts.map +1 -1
  241. package/dist/decode/reading-rules.js +8 -434
  242. package/dist/decode/reading-rules.js.map +1 -1
  243. package/dist/decode/rules.d.ts +1 -17
  244. package/dist/decode/rules.d.ts.map +1 -1
  245. package/dist/decode/rules.js +1 -43
  246. package/dist/decode/rules.js.map +1 -1
  247. package/dist/decode/run-lattice.d.ts +52 -0
  248. package/dist/decode/run-lattice.d.ts.map +1 -0
  249. package/dist/decode/run-lattice.js +91 -0
  250. package/dist/decode/run-lattice.js.map +1 -0
  251. package/dist/decode/run-words.d.ts +17 -0
  252. package/dist/decode/run-words.d.ts.map +1 -0
  253. package/dist/decode/run-words.js +29 -0
  254. package/dist/decode/run-words.js.map +1 -0
  255. package/dist/decode/sandhi-input.d.ts +30 -0
  256. package/dist/decode/sandhi-input.d.ts.map +1 -0
  257. package/dist/decode/sandhi-input.js +35 -0
  258. package/dist/decode/sandhi-input.js.map +1 -0
  259. package/dist/decode/sandhi-tones.d.ts +97 -0
  260. package/dist/decode/sandhi-tones.d.ts.map +1 -0
  261. package/dist/decode/sandhi-tones.js +139 -0
  262. package/dist/decode/sandhi-tones.js.map +1 -0
  263. package/dist/decode/sandhi.d.ts +10 -7
  264. package/dist/decode/sandhi.d.ts.map +1 -1
  265. package/dist/decode/sandhi.js +11 -88
  266. package/dist/decode/sandhi.js.map +1 -1
  267. package/dist/decode/script-types.d.ts +76 -0
  268. package/dist/decode/script-types.d.ts.map +1 -0
  269. package/dist/decode/script-types.js +35 -0
  270. package/dist/decode/script-types.js.map +1 -0
  271. package/dist/decode/script-words.d.ts +32 -0
  272. package/dist/decode/script-words.d.ts.map +1 -0
  273. package/dist/decode/script-words.js +77 -0
  274. package/dist/decode/script-words.js.map +1 -0
  275. package/dist/decode/script.d.ts +3 -73
  276. package/dist/decode/script.d.ts.map +1 -1
  277. package/dist/decode/script.js +3 -109
  278. package/dist/decode/script.js.map +1 -1
  279. package/dist/decode/tan-rule.d.ts +68 -0
  280. package/dist/decode/tan-rule.d.ts.map +1 -0
  281. package/dist/decode/tan-rule.js +131 -0
  282. package/dist/decode/tan-rule.js.map +1 -0
  283. package/dist/decode/write-run.d.ts +21 -0
  284. package/dist/decode/write-run.d.ts.map +1 -0
  285. package/dist/decode/write-run.js +42 -0
  286. package/dist/decode/write-run.js.map +1 -0
  287. package/dist/dictionary/artifact-claims.d.ts +25 -0
  288. package/dist/dictionary/artifact-claims.d.ts.map +1 -0
  289. package/dist/dictionary/artifact-claims.js +47 -0
  290. package/dist/dictionary/artifact-claims.js.map +1 -0
  291. package/dist/dictionary/artifact-format.d.ts +86 -0
  292. package/dist/dictionary/artifact-format.d.ts.map +1 -0
  293. package/dist/dictionary/artifact-format.js +91 -0
  294. package/dist/dictionary/artifact-format.js.map +1 -0
  295. package/dist/dictionary/artifact-read.d.ts +34 -0
  296. package/dist/dictionary/artifact-read.d.ts.map +1 -0
  297. package/dist/dictionary/artifact-read.js +114 -0
  298. package/dist/dictionary/artifact-read.js.map +1 -0
  299. package/dist/dictionary/artifact.d.ts +4 -63
  300. package/dist/dictionary/artifact.d.ts.map +1 -1
  301. package/dist/dictionary/artifact.js +12 -229
  302. package/dist/dictionary/artifact.js.map +1 -1
  303. package/dist/dictionary/assertions.d.ts +5 -57
  304. package/dist/dictionary/assertions.d.ts.map +1 -1
  305. package/dist/dictionary/assertions.js +4 -317
  306. package/dist/dictionary/assertions.js.map +1 -1
  307. package/dist/dictionary/build-assertions.d.ts +12 -0
  308. package/dist/dictionary/build-assertions.d.ts.map +1 -0
  309. package/dist/dictionary/build-assertions.js +13 -0
  310. package/dist/dictionary/build-assertions.js.map +1 -0
  311. package/dist/dictionary/built-dictionary.d.ts +46 -0
  312. package/dist/dictionary/built-dictionary.d.ts.map +1 -0
  313. package/dist/dictionary/built-dictionary.js +97 -0
  314. package/dist/dictionary/built-dictionary.js.map +1 -0
  315. package/dist/dictionary/cedict-senses.d.ts +87 -0
  316. package/dist/dictionary/cedict-senses.d.ts.map +1 -0
  317. package/dist/dictionary/cedict-senses.js +126 -0
  318. package/dist/dictionary/cedict-senses.js.map +1 -0
  319. package/dist/dictionary/character-defaults.d.ts +26 -0
  320. package/dist/dictionary/character-defaults.d.ts.map +1 -0
  321. package/dist/dictionary/character-defaults.js +67 -0
  322. package/dist/dictionary/character-defaults.js.map +1 -0
  323. package/dist/dictionary/character-readings.d.ts +10 -0
  324. package/dist/dictionary/character-readings.d.ts.map +1 -0
  325. package/dist/dictionary/character-readings.js +25 -0
  326. package/dist/dictionary/character-readings.js.map +1 -0
  327. package/dist/dictionary/constituent-repair.d.ts +36 -0
  328. package/dist/dictionary/constituent-repair.d.ts.map +1 -0
  329. package/dist/dictionary/constituent-repair.js +117 -0
  330. package/dist/dictionary/constituent-repair.js.map +1 -0
  331. package/dist/dictionary/dictionary-entry.d.ts +37 -0
  332. package/dist/dictionary/dictionary-entry.d.ts.map +1 -0
  333. package/dist/dictionary/dictionary-entry.js +41 -0
  334. package/dist/dictionary/dictionary-entry.js.map +1 -0
  335. package/dist/dictionary/dictionary-readings.d.ts +56 -0
  336. package/dist/dictionary/dictionary-readings.d.ts.map +1 -0
  337. package/dist/dictionary/dictionary-readings.js +93 -0
  338. package/dist/dictionary/dictionary-readings.js.map +1 -0
  339. package/dist/dictionary/dictionary.d.ts +6 -60
  340. package/dist/dictionary/dictionary.d.ts.map +1 -1
  341. package/dist/dictionary/dictionary.js +9 -169
  342. package/dist/dictionary/dictionary.js.map +1 -1
  343. package/dist/dictionary/entry-invariants.d.ts +3 -0
  344. package/dist/dictionary/entry-invariants.d.ts.map +1 -0
  345. package/dist/dictionary/entry-invariants.js +67 -0
  346. package/dist/dictionary/entry-invariants.js.map +1 -0
  347. package/dist/dictionary/entry-lines.d.ts +35 -0
  348. package/dist/dictionary/entry-lines.d.ts.map +1 -0
  349. package/dist/dictionary/entry-lines.js +70 -0
  350. package/dist/dictionary/entry-lines.js.map +1 -0
  351. package/dist/dictionary/erhua-repair.d.ts +26 -0
  352. package/dist/dictionary/erhua-repair.d.ts.map +1 -0
  353. package/dist/dictionary/erhua-repair.js +49 -0
  354. package/dist/dictionary/erhua-repair.js.map +1 -0
  355. package/dist/dictionary/frequency-tones.d.ts +74 -0
  356. package/dist/dictionary/frequency-tones.d.ts.map +1 -0
  357. package/dist/dictionary/frequency-tones.js +128 -0
  358. package/dist/dictionary/frequency-tones.js.map +1 -0
  359. package/dist/dictionary/inventory-invariants.d.ts +3 -0
  360. package/dist/dictionary/inventory-invariants.d.ts.map +1 -0
  361. package/dist/dictionary/inventory-invariants.js +54 -0
  362. package/dist/dictionary/inventory-invariants.js.map +1 -0
  363. package/dist/dictionary/locale-candidates.d.ts +40 -0
  364. package/dist/dictionary/locale-candidates.d.ts.map +1 -0
  365. package/dist/dictionary/locale-candidates.js +77 -0
  366. package/dist/dictionary/locale-candidates.js.map +1 -0
  367. package/dist/dictionary/locale-segments.d.ts +47 -0
  368. package/dist/dictionary/locale-segments.d.ts.map +1 -0
  369. package/dist/dictionary/locale-segments.js +141 -0
  370. package/dist/dictionary/locale-segments.js.map +1 -0
  371. package/dist/dictionary/locale.d.ts +1 -21
  372. package/dist/dictionary/locale.d.ts.map +1 -1
  373. package/dist/dictionary/locale.js +9 -198
  374. package/dist/dictionary/locale.js.map +1 -1
  375. package/dist/dictionary/merge-types.d.ts +127 -0
  376. package/dist/dictionary/merge-types.d.ts.map +1 -0
  377. package/dist/dictionary/merge-types.js +35 -0
  378. package/dist/dictionary/merge-types.js.map +1 -0
  379. package/dist/dictionary/merge-walk.d.ts +27 -0
  380. package/dist/dictionary/merge-walk.d.ts.map +1 -0
  381. package/dist/dictionary/merge-walk.js +49 -0
  382. package/dist/dictionary/merge-walk.js.map +1 -0
  383. package/dist/dictionary/merge-word.d.ts +7 -0
  384. package/dist/dictionary/merge-word.d.ts.map +1 -0
  385. package/dist/dictionary/merge-word.js +91 -0
  386. package/dist/dictionary/merge-word.js.map +1 -0
  387. package/dist/dictionary/merge.d.ts +5 -62
  388. package/dist/dictionary/merge.d.ts.map +1 -1
  389. package/dist/dictionary/merge.js +32 -725
  390. package/dist/dictionary/merge.js.map +1 -1
  391. package/dist/dictionary/proper-noun.d.ts +28 -0
  392. package/dist/dictionary/proper-noun.d.ts.map +1 -0
  393. package/dist/dictionary/proper-noun.js +43 -0
  394. package/dist/dictionary/proper-noun.js.map +1 -0
  395. package/dist/dictionary/reading-agreement.d.ts +71 -0
  396. package/dist/dictionary/reading-agreement.d.ts.map +1 -0
  397. package/dist/dictionary/reading-agreement.js +156 -0
  398. package/dist/dictionary/reading-agreement.js.map +1 -0
  399. package/dist/dictionary/script-conversion.d.ts +28 -0
  400. package/dist/dictionary/script-conversion.d.ts.map +1 -0
  401. package/dist/dictionary/script-conversion.js +58 -0
  402. package/dist/dictionary/script-conversion.js.map +1 -0
  403. package/dist/dictionary/script-pairings.d.ts +74 -0
  404. package/dist/dictionary/script-pairings.d.ts.map +1 -0
  405. package/dist/dictionary/script-pairings.js +120 -0
  406. package/dist/dictionary/script-pairings.js.map +1 -0
  407. package/dist/dictionary/script-tables.d.ts.map +1 -1
  408. package/dist/dictionary/script-tables.js +2 -165
  409. package/dist/dictionary/script-tables.js.map +1 -1
  410. package/dist/dictionary/taiwan-reading.d.ts +8 -0
  411. package/dist/dictionary/taiwan-reading.d.ts.map +1 -0
  412. package/dist/dictionary/taiwan-reading.js +38 -0
  413. package/dist/dictionary/taiwan-reading.js.map +1 -0
  414. package/dist/dictionary/tone-invariants.d.ts +3 -0
  415. package/dist/dictionary/tone-invariants.d.ts.map +1 -0
  416. package/dist/dictionary/tone-invariants.js +64 -0
  417. package/dist/dictionary/tone-invariants.js.map +1 -0
  418. package/dist/dictionary/traditional-form.d.ts +21 -0
  419. package/dist/dictionary/traditional-form.d.ts.map +1 -0
  420. package/dist/dictionary/traditional-form.js +59 -0
  421. package/dist/dictionary/traditional-form.js.map +1 -0
  422. package/dist/dictionary/traditional-ranking.d.ts +22 -0
  423. package/dist/dictionary/traditional-ranking.d.ts.map +1 -0
  424. package/dist/dictionary/traditional-ranking.js +74 -0
  425. package/dist/dictionary/traditional-ranking.js.map +1 -0
  426. package/dist/dictionary/traditional-table.d.ts +51 -0
  427. package/dist/dictionary/traditional-table.d.ts.map +1 -0
  428. package/dist/dictionary/traditional-table.js +98 -0
  429. package/dist/dictionary/traditional-table.js.map +1 -0
  430. package/dist/dictionary/traditional.d.ts +3 -56
  431. package/dist/dictionary/traditional.d.ts.map +1 -1
  432. package/dist/dictionary/traditional.js +3 -186
  433. package/dist/dictionary/traditional.js.map +1 -1
  434. package/dist/dictionary/variant-counts.d.ts +39 -0
  435. package/dist/dictionary/variant-counts.d.ts.map +1 -0
  436. package/dist/dictionary/variant-counts.js +38 -0
  437. package/dist/dictionary/variant-counts.js.map +1 -0
  438. package/dist/dictionary/word-reading.d.ts +26 -0
  439. package/dist/dictionary/word-reading.d.ts.map +1 -0
  440. package/dist/dictionary/word-reading.js +76 -0
  441. package/dist/dictionary/word-reading.js.map +1 -0
  442. package/dist/dictionary/word-readings.d.ts +15 -0
  443. package/dist/dictionary/word-readings.d.ts.map +1 -0
  444. package/dist/dictionary/word-readings.js +41 -0
  445. package/dist/dictionary/word-readings.js.map +1 -0
  446. package/dist/format/annotate.d.ts +90 -0
  447. package/dist/format/annotate.d.ts.map +1 -0
  448. package/dist/format/annotate.js +168 -0
  449. package/dist/format/annotate.js.map +1 -0
  450. package/dist/format/html.d.ts +15 -46
  451. package/dist/format/html.d.ts.map +1 -1
  452. package/dist/format/html.js +3 -162
  453. package/dist/format/html.js.map +1 -1
  454. package/dist/format/slug-hash.d.ts +51 -0
  455. package/dist/format/slug-hash.d.ts.map +1 -0
  456. package/dist/format/slug-hash.js +74 -0
  457. package/dist/format/slug-hash.js.map +1 -0
  458. package/dist/format/slug-options.d.ts +98 -0
  459. package/dist/format/slug-options.d.ts.map +1 -0
  460. package/dist/format/slug-options.js +2 -0
  461. package/dist/format/slug-options.js.map +1 -0
  462. package/dist/format/slug-words.d.ts +27 -0
  463. package/dist/format/slug-words.d.ts.map +1 -0
  464. package/dist/format/slug-words.js +0 -0
  465. package/dist/format/slug-words.js.map +1 -0
  466. package/dist/format/slug.d.ts +3 -128
  467. package/dist/format/slug.d.ts.map +1 -1
  468. package/dist/format/slug.js +0 -0
  469. package/dist/format/slug.js.map +1 -1
  470. package/dist/grade/check-readings.d.ts +41 -0
  471. package/dist/grade/check-readings.d.ts.map +1 -0
  472. package/dist/grade/check-readings.js +36 -0
  473. package/dist/grade/check-readings.js.map +1 -0
  474. package/dist/grade/check.d.ts +4 -4
  475. package/dist/grade/check.d.ts.map +1 -1
  476. package/dist/grade/check.js +5 -270
  477. package/dist/grade/check.js.map +1 -1
  478. package/dist/grade/pair-syllables.d.ts +48 -0
  479. package/dist/grade/pair-syllables.d.ts.map +1 -0
  480. package/dist/grade/pair-syllables.js +71 -0
  481. package/dist/grade/pair-syllables.js.map +1 -0
  482. package/dist/grade/reading-syllables.d.ts +62 -0
  483. package/dist/grade/reading-syllables.d.ts.map +1 -0
  484. package/dist/grade/reading-syllables.js +58 -0
  485. package/dist/grade/reading-syllables.js.map +1 -0
  486. package/dist/grade/reading-tolerance.d.ts +72 -0
  487. package/dist/grade/reading-tolerance.d.ts.map +1 -0
  488. package/dist/grade/reading-tolerance.js +107 -0
  489. package/dist/grade/reading-tolerance.js.map +1 -0
  490. package/dist/grade/typed-reading.d.ts +28 -0
  491. package/dist/grade/typed-reading.d.ts.map +1 -0
  492. package/dist/grade/typed-reading.js +36 -0
  493. package/dist/grade/typed-reading.js.map +1 -0
  494. package/dist/index.d.ts +1 -1
  495. package/dist/index.d.ts.map +1 -1
  496. package/dist/index.js +1 -1
  497. package/dist/index.js.map +1 -1
  498. package/dist/numerals/numeral-parse.d.ts +32 -0
  499. package/dist/numerals/numeral-parse.d.ts.map +1 -0
  500. package/dist/numerals/numeral-parse.js +44 -0
  501. package/dist/numerals/numeral-parse.js.map +1 -0
  502. package/dist/numerals/numeral-shapes.d.ts +89 -0
  503. package/dist/numerals/numeral-shapes.d.ts.map +1 -0
  504. package/dist/numerals/numeral-shapes.js +99 -0
  505. package/dist/numerals/numeral-shapes.js.map +1 -0
  506. package/dist/numerals/numerals.d.ts.map +1 -1
  507. package/dist/numerals/numerals.js +2 -36
  508. package/dist/numerals/numerals.js.map +1 -1
  509. package/dist/numerals/read-numeral.d.ts +76 -0
  510. package/dist/numerals/read-numeral.d.ts.map +1 -0
  511. package/dist/numerals/read-numeral.js +88 -0
  512. package/dist/numerals/read-numeral.js.map +1 -0
  513. package/dist/numerals/text.d.ts +3 -37
  514. package/dist/numerals/text.d.ts.map +1 -1
  515. package/dist/numerals/text.js +3 -254
  516. package/dist/numerals/text.js.map +1 -1
  517. package/dist/numerals/time.d.ts +34 -0
  518. package/dist/numerals/time.d.ts.map +1 -0
  519. package/dist/numerals/time.js +93 -0
  520. package/dist/numerals/time.js.map +1 -0
  521. package/dist/orthography/address-grouping.d.ts +34 -0
  522. package/dist/orthography/address-grouping.d.ts.map +1 -0
  523. package/dist/orthography/address-grouping.js +52 -0
  524. package/dist/orthography/address-grouping.js.map +1 -0
  525. package/dist/orthography/grouping.d.ts +3 -87
  526. package/dist/orthography/grouping.d.ts.map +1 -1
  527. package/dist/orthography/grouping.js +4 -270
  528. package/dist/orthography/grouping.js.map +1 -1
  529. package/dist/orthography/place-grouping.d.ts +39 -0
  530. package/dist/orthography/place-grouping.d.ts.map +1 -0
  531. package/dist/orthography/place-grouping.js +83 -0
  532. package/dist/orthography/place-grouping.js.map +1 -0
  533. package/dist/orthography/word-grouping.d.ts +48 -0
  534. package/dist/orthography/word-grouping.d.ts.map +1 -0
  535. package/dist/orthography/word-grouping.js +147 -0
  536. package/dist/orthography/word-grouping.js.map +1 -0
  537. package/dist/script/conversion-format.d.ts +22 -0
  538. package/dist/script/conversion-format.d.ts.map +1 -0
  539. package/dist/script/conversion-format.js +22 -0
  540. package/dist/script/conversion-format.js.map +1 -0
  541. package/dist/script/conversion-read.d.ts +9 -0
  542. package/dist/script/conversion-read.d.ts.map +1 -0
  543. package/dist/script/conversion-read.js +69 -0
  544. package/dist/script/conversion-read.js.map +1 -0
  545. package/dist/script/conversion-write.d.ts +14 -0
  546. package/dist/script/conversion-write.d.ts.map +1 -0
  547. package/dist/script/conversion-write.js +34 -0
  548. package/dist/script/conversion-write.js.map +1 -0
  549. package/dist/script/conversion.d.ts +10 -16
  550. package/dist/script/conversion.d.ts.map +1 -1
  551. package/dist/script/conversion.js +2 -115
  552. package/dist/script/conversion.js.map +1 -1
  553. package/dist/search/candidate-narrowing.d.ts +56 -0
  554. package/dist/search/candidate-narrowing.d.ts.map +1 -0
  555. package/dist/search/candidate-narrowing.js +55 -0
  556. package/dist/search/candidate-narrowing.js.map +1 -0
  557. package/dist/search/candidate-query.d.ts +25 -0
  558. package/dist/search/candidate-query.d.ts.map +1 -0
  559. package/dist/search/candidate-query.js +28 -0
  560. package/dist/search/candidate-query.js.map +1 -0
  561. package/dist/search/candidate-writings.d.ts +24 -0
  562. package/dist/search/candidate-writings.d.ts.map +1 -0
  563. package/dist/search/candidate-writings.js +114 -0
  564. package/dist/search/candidate-writings.js.map +1 -0
  565. package/dist/search/candidates.d.ts +7 -41
  566. package/dist/search/candidates.d.ts.map +1 -1
  567. package/dist/search/candidates.js +10 -164
  568. package/dist/search/candidates.js.map +1 -1
  569. package/dist/search/match-chunks.d.ts +19 -0
  570. package/dist/search/match-chunks.d.ts.map +1 -0
  571. package/dist/search/match-chunks.js +30 -0
  572. package/dist/search/match-chunks.js.map +1 -0
  573. package/dist/search/match-ranking.d.ts +39 -0
  574. package/dist/search/match-ranking.d.ts.map +1 -0
  575. package/dist/search/match-ranking.js +51 -0
  576. package/dist/search/match-ranking.js.map +1 -0
  577. package/dist/search/match-readings.d.ts +43 -0
  578. package/dist/search/match-readings.d.ts.map +1 -0
  579. package/dist/search/match-readings.js +83 -0
  580. package/dist/search/match-readings.js.map +1 -0
  581. package/dist/search/match-scoring.d.ts +146 -0
  582. package/dist/search/match-scoring.d.ts.map +1 -0
  583. package/dist/search/match-scoring.js +114 -0
  584. package/dist/search/match-scoring.js.map +1 -0
  585. package/dist/search/match-search.d.ts +28 -0
  586. package/dist/search/match-search.d.ts.map +1 -0
  587. package/dist/search/match-search.js +128 -0
  588. package/dist/search/match-search.js.map +1 -0
  589. package/dist/search/match.d.ts +5 -36
  590. package/dist/search/match.d.ts.map +1 -1
  591. package/dist/search/match.js +2 -379
  592. package/dist/search/match.js.map +1 -1
  593. package/dist/search/reverse-index-build.d.ts +30 -0
  594. package/dist/search/reverse-index-build.d.ts.map +1 -0
  595. package/dist/search/reverse-index-build.js +72 -0
  596. package/dist/search/reverse-index-build.js.map +1 -0
  597. package/dist/search/reverse-index-format.d.ts +60 -0
  598. package/dist/search/reverse-index-format.d.ts.map +1 -0
  599. package/dist/search/reverse-index-format.js +54 -0
  600. package/dist/search/reverse-index-format.js.map +1 -0
  601. package/dist/search/reverse-index-groups.d.ts +37 -0
  602. package/dist/search/reverse-index-groups.d.ts.map +1 -0
  603. package/dist/search/reverse-index-groups.js +71 -0
  604. package/dist/search/reverse-index-groups.js.map +1 -0
  605. package/dist/search/reverse-index-passes.d.ts +78 -0
  606. package/dist/search/reverse-index-passes.d.ts.map +1 -0
  607. package/dist/search/reverse-index-passes.js +59 -0
  608. package/dist/search/reverse-index-passes.js.map +1 -0
  609. package/dist/search/reverse-index-state.d.ts +36 -0
  610. package/dist/search/reverse-index-state.d.ts.map +1 -0
  611. package/dist/search/reverse-index-state.js +95 -0
  612. package/dist/search/reverse-index-state.js.map +1 -0
  613. package/dist/search/reverse-index.d.ts +8 -67
  614. package/dist/search/reverse-index.d.ts.map +1 -1
  615. package/dist/search/reverse-index.js +4 -255
  616. package/dist/search/reverse-index.js.map +1 -1
  617. package/dist/sources/unihan-readings.d.ts +58 -0
  618. package/dist/sources/unihan-readings.d.ts.map +1 -0
  619. package/dist/sources/unihan-readings.js +95 -0
  620. package/dist/sources/unihan-readings.js.map +1 -0
  621. package/dist/sources/unihan.d.ts +6 -9
  622. package/dist/sources/unihan.d.ts.map +1 -1
  623. package/dist/sources/unihan.js +2 -85
  624. package/dist/sources/unihan.js.map +1 -1
  625. package/dist/syllable/final-tables.d.ts +23 -0
  626. package/dist/syllable/final-tables.d.ts.map +1 -0
  627. package/dist/syllable/final-tables.js +50 -0
  628. package/dist/syllable/final-tables.js.map +1 -0
  629. package/dist/syllable/inventory.d.ts +8 -42
  630. package/dist/syllable/inventory.d.ts.map +1 -1
  631. package/dist/syllable/inventory.js +9 -918
  632. package/dist/syllable/inventory.js.map +1 -1
  633. package/dist/syllable/spellings.d.ts +40 -0
  634. package/dist/syllable/spellings.d.ts.map +1 -0
  635. package/dist/syllable/spellings.js +469 -0
  636. package/dist/syllable/spellings.js.map +1 -0
  637. package/dist/syllable/syllable-parts.d.ts +31 -0
  638. package/dist/syllable/syllable-parts.d.ts.map +1 -0
  639. package/dist/syllable/syllable-parts.js +105 -0
  640. package/dist/syllable/syllable-parts.js.map +1 -0
  641. package/dist/syllable/syllable.d.ts +1 -14
  642. package/dist/syllable/syllable.d.ts.map +1 -1
  643. package/dist/syllable/syllable.js +3 -144
  644. package/dist/syllable/syllable.js.map +1 -1
  645. package/dist/syllable/written-tones.d.ts +6 -0
  646. package/dist/syllable/written-tones.d.ts.map +1 -0
  647. package/dist/syllable/written-tones.js +453 -0
  648. package/dist/syllable/written-tones.js.map +1 -0
  649. package/dist/transcription/bopomofo-parse.d.ts +42 -0
  650. package/dist/transcription/bopomofo-parse.d.ts.map +1 -0
  651. package/dist/transcription/bopomofo-parse.js +92 -0
  652. package/dist/transcription/bopomofo-parse.js.map +1 -0
  653. package/dist/transcription/bopomofo-reverse.d.ts +31 -0
  654. package/dist/transcription/bopomofo-reverse.d.ts.map +1 -0
  655. package/dist/transcription/bopomofo-reverse.js +48 -0
  656. package/dist/transcription/bopomofo-reverse.js.map +1 -0
  657. package/dist/transcription/bopomofo-symbols.d.ts +36 -0
  658. package/dist/transcription/bopomofo-symbols.d.ts.map +1 -0
  659. package/dist/transcription/bopomofo-symbols.js +41 -0
  660. package/dist/transcription/bopomofo-symbols.js.map +1 -0
  661. package/dist/transcription/bopomofo-tables.d.ts +87 -0
  662. package/dist/transcription/bopomofo-tables.d.ts.map +1 -0
  663. package/dist/transcription/bopomofo-tables.js +180 -0
  664. package/dist/transcription/bopomofo-tables.js.map +1 -0
  665. package/dist/transcription/bopomofo.d.ts +14 -32
  666. package/dist/transcription/bopomofo.d.ts.map +1 -1
  667. package/dist/transcription/bopomofo.js +5 -343
  668. package/dist/transcription/bopomofo.js.map +1 -1
  669. package/dist/transcription/gwoyeu-first-second.d.ts +36 -0
  670. package/dist/transcription/gwoyeu-first-second.d.ts.map +1 -0
  671. package/dist/transcription/gwoyeu-first-second.js +75 -0
  672. package/dist/transcription/gwoyeu-first-second.js.map +1 -0
  673. package/dist/transcription/gwoyeu-spelling.d.ts +38 -0
  674. package/dist/transcription/gwoyeu-spelling.d.ts.map +1 -0
  675. package/dist/transcription/gwoyeu-spelling.js +124 -0
  676. package/dist/transcription/gwoyeu-spelling.js.map +1 -0
  677. package/dist/transcription/gwoyeu-tables.d.ts +93 -0
  678. package/dist/transcription/gwoyeu-tables.d.ts.map +1 -0
  679. package/dist/transcription/gwoyeu-tables.js +205 -0
  680. package/dist/transcription/gwoyeu-tables.js.map +1 -0
  681. package/dist/transcription/gwoyeu-tonal-forms.d.ts +49 -0
  682. package/dist/transcription/gwoyeu-tonal-forms.d.ts.map +1 -0
  683. package/dist/transcription/gwoyeu-tonal-forms.js +89 -0
  684. package/dist/transcription/gwoyeu-tonal-forms.js.map +1 -0
  685. package/dist/transcription/gwoyeu-vowels.d.ts +51 -0
  686. package/dist/transcription/gwoyeu-vowels.d.ts.map +1 -0
  687. package/dist/transcription/gwoyeu-vowels.js +58 -0
  688. package/dist/transcription/gwoyeu-vowels.js.map +1 -0
  689. package/dist/transcription/gwoyeu.d.ts +1 -26
  690. package/dist/transcription/gwoyeu.d.ts.map +1 -1
  691. package/dist/transcription/gwoyeu.js +2 -540
  692. package/dist/transcription/gwoyeu.js.map +1 -1
  693. package/dist/transcription/ipa-symbols.d.ts +67 -0
  694. package/dist/transcription/ipa-symbols.d.ts.map +1 -0
  695. package/dist/transcription/ipa-symbols.js +135 -0
  696. package/dist/transcription/ipa-symbols.js.map +1 -0
  697. package/dist/transcription/ipa.d.ts +2 -10
  698. package/dist/transcription/ipa.d.ts.map +1 -1
  699. package/dist/transcription/ipa.js +2 -134
  700. package/dist/transcription/ipa.js.map +1 -1
  701. package/dist/transcription/wade-giles-index.d.ts +35 -0
  702. package/dist/transcription/wade-giles-index.d.ts.map +1 -0
  703. package/dist/transcription/wade-giles-index.js +110 -0
  704. package/dist/transcription/wade-giles-index.js.map +1 -0
  705. package/dist/transcription/wade-giles-parse.d.ts +36 -0
  706. package/dist/transcription/wade-giles-parse.d.ts.map +1 -0
  707. package/dist/transcription/wade-giles-parse.js +84 -0
  708. package/dist/transcription/wade-giles-parse.js.map +1 -0
  709. package/dist/transcription/wade-giles-spelling.d.ts +61 -0
  710. package/dist/transcription/wade-giles-spelling.d.ts.map +1 -0
  711. package/dist/transcription/wade-giles-spelling.js +107 -0
  712. package/dist/transcription/wade-giles-spelling.js.map +1 -0
  713. package/dist/transcription/wade-giles-syllable.d.ts +29 -0
  714. package/dist/transcription/wade-giles-syllable.d.ts.map +1 -0
  715. package/dist/transcription/wade-giles-syllable.js +90 -0
  716. package/dist/transcription/wade-giles-syllable.js.map +1 -0
  717. package/dist/transcription/wade-giles-tables.d.ts +80 -0
  718. package/dist/transcription/wade-giles-tables.d.ts.map +1 -0
  719. package/dist/transcription/wade-giles-tables.js +178 -0
  720. package/dist/transcription/wade-giles-tables.js.map +1 -0
  721. package/dist/transcription/wade-giles.d.ts +9 -60
  722. package/dist/transcription/wade-giles.d.ts.map +1 -1
  723. package/dist/transcription/wade-giles.js +6 -543
  724. package/dist/transcription/wade-giles.js.map +1 -1
  725. package/dist/transcription/yale-tables.d.ts +54 -0
  726. package/dist/transcription/yale-tables.d.ts.map +1 -0
  727. package/dist/transcription/yale-tables.js +125 -0
  728. package/dist/transcription/yale-tables.js.map +1 -0
  729. package/dist/transcription/yale.d.ts.map +1 -1
  730. package/dist/transcription/yale.js +1 -124
  731. package/dist/transcription/yale.js.map +1 -1
  732. package/package.json +2 -2
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The layout the fill and rank passes are written against.
3
+ */
4
+ export interface GroupLayout {
5
+ /** The reading keys, sorted by code unit, which is `KeyIndex` order. */
6
+ readonly keys: readonly string[];
7
+ /** Where each group begins, with one past the end on the tail. */
8
+ readonly starts: Uint32Array;
9
+ /** Which group a reading key is, for the fill pass. */
10
+ readonly slots: Map<string, number>;
11
+ /** The largest group, which is how big the ranking scratch must be. */
12
+ readonly widest: number;
13
+ /** Where the fill pass has got to within each group. */
14
+ readonly cursors: Uint32Array;
15
+ /** The postings themselves, empty until the fill pass runs. */
16
+ readonly postings: Uint32Array;
17
+ }
18
+ /**
19
+ * Sort the reading keys and lay out where each group's postings go.
20
+ *
21
+ * Sorted as pairs rather than by key and looked up again, and by code unit
22
+ * rather than by locale, which is the order `KeyIndex` searches in.
23
+ */
24
+ export declare function layOutGroups(counts: ReadonlyMap<string, number>): GroupLayout;
25
+ /**
26
+ * Sort one group likeliest-first, which is a counting sort on the bucket.
27
+ *
28
+ * Buckets run 0 to 15, so there is nothing to compare: tally the group, turn
29
+ * the tally into offsets, and deal the postings out. Stable, so two words in
30
+ * the same bucket keep the dictionary's own order and the result does not
31
+ * depend on how the fill pass happened to lay the postings down.
32
+ *
33
+ * The scratch and tally arrays are the caller's, so that ranking 723,147
34
+ * postings allocates twice rather than twice per group.
35
+ */
36
+ export declare function rankGroup(postings: Uint32Array, from: number, to: number, scratch: Uint32Array, tally: Uint32Array, rankOf: (position: number) => number): void;
37
+ //# sourceMappingURL=reverse-index-groups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-index-groups.d.ts","sourceRoot":"","sources":["../../src/search/reverse-index-groups.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;CAChC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,WAAW,CAwB7E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GACnC,IAAI,CAoBN"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Where each reading's postings go, and what order they go in.
3
+ *
4
+ * The two parts of the build that are about a group rather than about a pass:
5
+ * laying the groups out once the counts are in, and sorting one of them
6
+ * likeliest-first. Both are ordinary functions over arrays, and neither knows
7
+ * anything about the state machine that calls them.
8
+ */
9
+ import { readAt } from "./reverse-index-passes.js";
10
+ /**
11
+ * Sort the reading keys and lay out where each group's postings go.
12
+ *
13
+ * Sorted as pairs rather than by key and looked up again, and by code unit
14
+ * rather than by locale, which is the order `KeyIndex` searches in.
15
+ */
16
+ export function layOutGroups(counts) {
17
+ const ordered = [...counts].toSorted(([left], [right]) => left < right ? -1 : Number(left > right));
18
+ const keys = ordered.map(([key]) => key);
19
+ const starts = new Uint32Array(keys.length + 1);
20
+ const slots = new Map();
21
+ let running = 0;
22
+ let widest = 0;
23
+ for (const [group, [key, held]] of ordered.entries()) {
24
+ slots.set(key, group);
25
+ starts[group] = running;
26
+ running += held;
27
+ widest = Math.max(widest, held);
28
+ }
29
+ starts[keys.length] = running;
30
+ return {
31
+ keys,
32
+ starts,
33
+ slots,
34
+ widest,
35
+ cursors: starts.slice(0, keys.length),
36
+ postings: new Uint32Array(running),
37
+ };
38
+ }
39
+ /**
40
+ * Sort one group likeliest-first, which is a counting sort on the bucket.
41
+ *
42
+ * Buckets run 0 to 15, so there is nothing to compare: tally the group, turn
43
+ * the tally into offsets, and deal the postings out. Stable, so two words in
44
+ * the same bucket keep the dictionary's own order and the result does not
45
+ * depend on how the fill pass happened to lay the postings down.
46
+ *
47
+ * The scratch and tally arrays are the caller's, so that ranking 723,147
48
+ * postings allocates twice rather than twice per group.
49
+ */
50
+ export function rankGroup(postings, from, to, scratch, tally, rankOf) {
51
+ tally.fill(0);
52
+ for (let cursor = from; cursor < to; cursor++) {
53
+ const position = readAt(postings, cursor);
54
+ scratch[cursor - from] = position;
55
+ const bucket = rankOf(position);
56
+ tally[bucket] = readAt(tally, bucket) + 1;
57
+ }
58
+ let running = from;
59
+ for (let bucket = 0; bucket < tally.length; bucket++) {
60
+ const held = readAt(tally, bucket);
61
+ tally[bucket] = running;
62
+ running += held;
63
+ }
64
+ for (let cursor = 0; cursor < to - from; cursor++) {
65
+ const position = readAt(scratch, cursor);
66
+ const bucket = rankOf(position);
67
+ postings[readAt(tally, bucket)] = position;
68
+ tally[bucket] = readAt(tally, bucket) + 1;
69
+ }
70
+ }
71
+ //# sourceMappingURL=reverse-index-groups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-index-groups.js","sourceRoot":"","sources":["../../src/search/reverse-index-groups.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM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AAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The passes a reverse index build runs, and how far along it is.
3
+ *
4
+ * A leaf both the build and the index import, rather than either importing the
5
+ * other: what the stepper is, what it is doing and how far along it is, plus
6
+ * the empty posting list and the checked read that both sides use.
7
+ */
8
+ import type { ReverseIndex } from "./reverse-index.js";
9
+ /**
10
+ * A reverse index being built, a slice at a time.
11
+ *
12
+ * The full tier costs about 510 ms to derive, which is thirty-odd frames, so the
13
+ * build is a state machine a caller can drive from `requestIdleCallback` rather
14
+ * than a function that takes the thread. `core` is 4 ms and `standard` is 62 ms,
15
+ * and both can simply be built with {@link ReverseIndex.of}.
16
+ *
17
+ * ```ts
18
+ * const build = ReverseIndex.building(dictionary);
19
+ * const tick = (): void => {
20
+ * const index = build.step();
21
+ * if (index === undefined) {
22
+ * requestIdleCallback(tick);
23
+ * }
24
+ * };
25
+ * requestIdleCallback(tick);
26
+ * ```
27
+ */
28
+ export interface ReverseIndexBuild {
29
+ /**
30
+ * How much of the build is done, from 0 to 1.
31
+ */
32
+ readonly progress: number;
33
+ /**
34
+ * Do some more of the work, returning the index once there is none left.
35
+ *
36
+ * `positions` bounds a step to that many dictionary positions, or that many
37
+ * reading groups while the last pass is ranking them. It is a bound rather
38
+ * than a promise: the pass that sorts the reading keys cannot be divided, and
39
+ * is one step of its own.
40
+ */
41
+ readonly step: (positions?: number) => ReverseIndex | undefined;
42
+ }
43
+ /**
44
+ * Which pass a build is on.
45
+ */
46
+ export type Pass = "counting" | "ordering" | "filling" | "ranking" | "done";
47
+ /**
48
+ * What share of the build each pass is worth, for
49
+ * {@link import("./reverse-index.js").ReverseIndexBuild.progress}.
50
+ */
51
+ export declare const SHARE: {
52
+ counting: number;
53
+ filling: number;
54
+ ranking: number;
55
+ };
56
+ /**
57
+ * The empty posting list, shared rather than allocated per miss.
58
+ */
59
+ export declare const NONE: Uint32Array<ArrayBuffer>;
60
+ /**
61
+ * Read a `Uint32Array` at an index that is in range by construction.
62
+ *
63
+ * `noUncheckedIndexedAccess` types every read as possibly undefined, and every
64
+ * one below is bounded by the layout of the array it indexes — a group start, a
65
+ * cursor inside a group, a bucket between 0 and 15. Gathered here rather than
66
+ * written as a fallback at each of them, since a fallback that cannot happen
67
+ * reads as a case somebody considered.
68
+ */
69
+ export declare function readAt(values: Uint32Array, at: number): number;
70
+ /**
71
+ * How much of the build is done, from 0 to 1.
72
+ *
73
+ * The counting and filling passes are measured in dictionary positions and the
74
+ * ranking pass in reading groups, so the two counts are both taken and each
75
+ * pass reports against the one it is walking.
76
+ */
77
+ export declare function progressOf(pass: Pass, at: number, positions: number, groups: number): number;
78
+ //# sourceMappingURL=reverse-index-passes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-index-passes.d.ts","sourceRoot":"","sources":["../../src/search/reverse-index-passes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,YAAY,GAAG,SAAS,CAAC;CACjE;AAED;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,KAAK;IAAK,QAAQ;IAAQ,OAAO;IAAQ,OAAO;CAAO,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,IAAI,0BAAqB,CAAC;AAEvC;;;;;;;;GAQG;AAEH,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,MAAM,CAuBR"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The passes a reverse index build runs, and how far along it is.
3
+ *
4
+ * A leaf both the build and the index import, rather than either importing the
5
+ * other: what the stepper is, what it is doing and how far along it is, plus
6
+ * the empty posting list and the checked read that both sides use.
7
+ */
8
+ /**
9
+ * What share of the build each pass is worth, for
10
+ * {@link import("./reverse-index.js").ReverseIndexBuild.progress}.
11
+ */
12
+ export const SHARE = { counting: 0.45, filling: 0.45, ranking: 0.1 };
13
+ /**
14
+ * The empty posting list, shared rather than allocated per miss.
15
+ */
16
+ export const NONE = new Uint32Array(0);
17
+ /**
18
+ * Read a `Uint32Array` at an index that is in range by construction.
19
+ *
20
+ * `noUncheckedIndexedAccess` types every read as possibly undefined, and every
21
+ * one below is bounded by the layout of the array it indexes — a group start, a
22
+ * cursor inside a group, a bucket between 0 and 15. Gathered here rather than
23
+ * written as a fallback at each of them, since a fallback that cannot happen
24
+ * reads as a case somebody considered.
25
+ */
26
+ /* c8 ignore next 3 -- the fallback is unreachable; see above */
27
+ export function readAt(values, at) {
28
+ return values[at] ?? 0;
29
+ }
30
+ /**
31
+ * How much of the build is done, from 0 to 1.
32
+ *
33
+ * The counting and filling passes are measured in dictionary positions and the
34
+ * ranking pass in reading groups, so the two counts are both taken and each
35
+ * pass reports against the one it is walking.
36
+ */
37
+ export function progressOf(pass, at, positions, groups) {
38
+ const size = Math.max(1, positions);
39
+ switch (pass) {
40
+ case "counting": {
41
+ return (SHARE.counting * at) / size;
42
+ }
43
+ case "ordering": {
44
+ return SHARE.counting;
45
+ }
46
+ case "filling": {
47
+ return SHARE.counting + (SHARE.filling * at) / size;
48
+ }
49
+ case "ranking": {
50
+ return (SHARE.counting +
51
+ SHARE.filling +
52
+ (SHARE.ranking * at) / Math.max(1, groups));
53
+ }
54
+ case "done": {
55
+ return 1;
56
+ }
57
+ }
58
+ }
59
+ //# sourceMappingURL=reverse-index-passes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-index-passes.js","sourceRoot":"","sources":["../../src/search/reverse-index-passes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA4CH;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAEvC;;;;;;;;GAQG;AACH,gEAAgE;AAChE,MAAM,UAAU,MAAM,CAAC,MAAmB,EAAE,EAAU;IACpD,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,IAAU,EACV,EAAU,EACV,SAAiB,EACjB,MAAc;IAEd,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACpC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;QACtC,CAAC;QACD,KAAK,UAAU,EAAE,CAAC;YAChB,OAAO,KAAK,CAAC,QAAQ,CAAC;QACxB,CAAC;QACD,KAAK,SAAS,EAAE,CAAC;YACf,OAAO,KAAK,CAAC,QAAQ,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;QACtD,CAAC;QACD,KAAK,SAAS,EAAE,CAAC;YACf,OAAO,CACL,KAAK,CAAC,QAAQ;gBACd,KAAK,CAAC,OAAO;gBACb,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAC3C,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,EAAE,CAAC;YACZ,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type GroupLayout } from "./reverse-index-groups.js";
2
+ import { type Pass } from "./reverse-index-passes.js";
3
+ /**
4
+ * Everything the passes share.
5
+ */
6
+ export interface BuildState {
7
+ pass: Pass;
8
+ /** A dictionary position while counting and filling, a group while ranking. */
9
+ at: number;
10
+ /** How many words each reading has; dropped once the groups are laid out. */
11
+ counts: Map<string, number>;
12
+ /** Where the postings go, which the ordering pass settles. */
13
+ layout: GroupLayout;
14
+ }
15
+ /**
16
+ * A build that has done nothing yet.
17
+ */
18
+ export declare function startState(): BuildState;
19
+ /**
20
+ * Count how many words each reading has, so the postings can be one array.
21
+ */
22
+ export declare function countPass(state: BuildState, size: number, keyAt: (position: number) => string, positions: number): void;
23
+ /**
24
+ * Lay the groups out, which is one step of its own because a sort cannot be
25
+ * resumed part way through.
26
+ */
27
+ export declare function orderPass(state: BuildState): void;
28
+ /**
29
+ * Place each position in its reading's group, recomputing the reading.
30
+ */
31
+ export declare function fillPass(state: BuildState, size: number, keyAt: (position: number) => string, positions: number): void;
32
+ /**
33
+ * Sort some groups likeliest-first, and say whether that was the last of them.
34
+ */
35
+ export declare function rankPass(state: BuildState, groups: number, rankOf: (position: number) => number): boolean;
36
+ //# sourceMappingURL=reverse-index-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-index-state.d.ts","sourceRoot":"","sources":["../../src/search/reverse-index-state.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAQ,KAAK,IAAI,EAAU,MAAM,2BAA2B,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,+EAA+E;IAC/E,EAAE,EAAE,MAAM,CAAC;IACX,6EAA6E;IAC7E,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,8DAA8D;IAC9D,MAAM,EAAE,WAAW,CAAC;CACrB;AAYD;;GAEG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAEvC;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,EACnC,SAAS,EAAE,MAAM,GAChB,IAAI,CAWN;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAKjD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,EACnC,SAAS,EAAE,MAAM,GAChB,IAAI,CAoBN;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GACnC,OAAO,CAoBT"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * The build as a state machine: what it holds, and what each pass does to it.
3
+ *
4
+ * Held as one record rather than as a closure's variables so that the four
5
+ * transitions can be written as functions and read in order. Two of the fields
6
+ * are dropped part way through — what is live during counting is not what is
7
+ * live during ranking — which is the reason the build streams at all: keeping
8
+ * all 723,147 readings costs 39 MB retained and peaks at 65 MB, where
9
+ * recomputing them in the fill pass peaks at 25 MB for a 2 MB result.
10
+ */
11
+ import { FREQUENCY_BUCKETS } from "../dictionary/frequency-table.js";
12
+ import { layOutGroups, rankGroup, } from "./reverse-index-groups.js";
13
+ import { NONE, readAt } from "./reverse-index-passes.js";
14
+ /** A layout with nothing in it, before the ordering pass has run. */
15
+ const NO_LAYOUT = {
16
+ keys: [],
17
+ starts: new Uint32Array(1),
18
+ slots: new Map(),
19
+ widest: 0,
20
+ cursors: new Uint32Array(0),
21
+ postings: NONE,
22
+ };
23
+ /**
24
+ * A build that has done nothing yet.
25
+ */
26
+ export function startState() {
27
+ return { pass: "counting", at: 0, counts: new Map(), layout: NO_LAYOUT };
28
+ }
29
+ /**
30
+ * Count how many words each reading has, so the postings can be one array.
31
+ */
32
+ export function countPass(state, size, keyAt, positions) {
33
+ const end = Math.min(size, state.at + positions);
34
+ for (; state.at < end; state.at++) {
35
+ const key = keyAt(state.at);
36
+ if (key !== "") {
37
+ state.counts.set(key, (state.counts.get(key) ?? 0) + 1);
38
+ }
39
+ }
40
+ if (state.at >= size) {
41
+ state.pass = "ordering";
42
+ }
43
+ }
44
+ /**
45
+ * Lay the groups out, which is one step of its own because a sort cannot be
46
+ * resumed part way through.
47
+ */
48
+ export function orderPass(state) {
49
+ state.layout = layOutGroups(state.counts);
50
+ state.counts = new Map();
51
+ state.at = 0;
52
+ state.pass = "filling";
53
+ }
54
+ /**
55
+ * Place each position in its reading's group, recomputing the reading.
56
+ */
57
+ export function fillPass(state, size, keyAt, positions) {
58
+ const end = Math.min(size, state.at + positions);
59
+ for (; state.at < end; state.at++) {
60
+ const key = keyAt(state.at);
61
+ const group = key === "" ? undefined : state.layout.slots.get(key);
62
+ if (group === undefined) {
63
+ continue;
64
+ }
65
+ const cursor = readAt(state.layout.cursors, group);
66
+ state.layout.postings[cursor] = state.at;
67
+ state.layout.cursors[group] = cursor + 1;
68
+ }
69
+ if (state.at >= size) {
70
+ // The slots and the cursors are the fill pass's own, and the ranking pass
71
+ // is about to walk arrays as big as the dictionary. Dropped rather than
72
+ // carried, which on the full tier is 42 MB the build never holds.
73
+ state.layout = { ...state.layout, slots: new Map(), cursors: NONE };
74
+ state.at = 0;
75
+ state.pass = "ranking";
76
+ }
77
+ }
78
+ /**
79
+ * Sort some groups likeliest-first, and say whether that was the last of them.
80
+ */
81
+ export function rankPass(state, groups, rankOf) {
82
+ const { keys, starts, postings, widest } = state.layout;
83
+ const scratch = new Uint32Array(widest);
84
+ const tally = new Uint32Array(FREQUENCY_BUCKETS);
85
+ const end = Math.min(keys.length, state.at + groups);
86
+ for (; state.at < end; state.at++) {
87
+ rankGroup(postings, readAt(starts, state.at), readAt(starts, state.at + 1), scratch, tally, rankOf);
88
+ }
89
+ if (state.at < keys.length) {
90
+ return false;
91
+ }
92
+ state.pass = "done";
93
+ return true;
94
+ }
95
+ //# sourceMappingURL=reverse-index-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-index-state.js","sourceRoot":"","sources":["../../src/search/reverse-index-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAEL,YAAY,EACZ,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAa,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAepE,qEAAqE;AACrE,MAAM,SAAS,GAAgB;IAC7B,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,IAAI,WAAW,CAAC,CAAC,CAAC;IAC1B,KAAK,EAAE,IAAI,GAAG,EAAE;IAChB,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,IAAI,WAAW,CAAC,CAAC,CAAC;IAC3B,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,KAAiB,EACjB,IAAY,EACZ,KAAmC,EACnC,SAAiB;IAEjB,MAAM,GAAG,GAAG,IAAI,CAAC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E,EAAE,EAAE,CAAC;QAClC,SAAS,CACP,QAAQ,EACR,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,EACxB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,EAC5B,OAAO,EACP,KAAK,EACL,MAAM,CACP,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC;IACpB,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,73 +1,14 @@
1
- import type { Dictionary } from "../dictionary/dictionary.js";
2
- /**
3
- * Fold a stored reading into the key a typist's spelling reaches it by.
4
- *
5
- * `yin2 hang2` becomes `yinhang` and `lü4 se4` becomes `luse`. Three things go:
6
- * the spaces, because nobody types them; the tone digits, because a typist
7
- * mostly does not write tones and a toned query is answered by filtering a
8
- * toneless list rather than by a second index; and the umlaut, because `lu` and
9
- * `lv` both have to reach 绿 and the only spelling both of them fold to is `lu`.
10
- *
11
- * The 儿化 r **stays**, so 玩儿 is keyed `wanr` and not `wan`. It is a letter a
12
- * typist writes, and the query side reaches the key from both directions by
13
- * searching `wan` and `wanr` alike — see `candidates`.
14
- *
15
- * Nothing here parses a syllable, which is what keeps a pass over every key in
16
- * the dictionary affordable.
17
- */
18
- export declare function readingKey(reading: string): string;
19
- /**
20
- * A reverse index in the form it can be handed between threads.
21
- *
22
- * Three pieces, the same shape the forward index has: the reading keys as one
23
- * sorted newline-joined blob, the dictionary positions grouped under them, and
24
- * where each group begins. The two arrays are transferable and the blob is a
25
- * string, so a worker can build this and post it back with no copy of the
26
- * postings — which is the point, since the full tier's build is over half a
27
- * second and does not belong on the main thread.
28
- */
29
- export interface ReverseIndexData {
30
- /** Sorted reading keys, newline-joined: a {@link KeyIndex} blob. */
31
- readonly keys: string;
32
- /** Dictionary positions, grouped by reading key, likeliest first. */
33
- readonly postings: Uint32Array;
34
- /** Where each key's postings begin, with one past the end on the tail. */
35
- readonly starts: Uint32Array;
36
- }
37
1
  /**
38
- * A reverse index being built, a slice at a time.
39
- *
40
- * The full tier costs about 510 ms to derive, which is thirty-odd frames, so the
41
- * build is a state machine a caller can drive from `requestIdleCallback` rather
42
- * than a function that takes the thread. `core` is 4 ms and `standard` is 62 ms,
43
- * and both can simply be built with {@link ReverseIndex.of}.
2
+ * The reverse index itself: reading key → the words read that way.
44
3
  *
45
- * ```ts
46
- * const build = ReverseIndex.building(dictionary);
47
- * const tick = (): void => {
48
- * const index = build.step();
49
- * if (index === undefined) {
50
- * requestIdleCallback(tick);
51
- * }
52
- * };
53
- * requestIdleCallback(tick);
54
- * ```
4
+ * How it is derived is `reverse-index-build.ts`, and the vocabulary the two
5
+ * share sits below both in `reverse-index-passes.ts`.
55
6
  */
56
- export interface ReverseIndexBuild {
57
- /**
58
- * How much of the build is done, from 0 to 1.
59
- */
60
- readonly progress: number;
61
- /**
62
- * Do some more of the work, returning the index once there is none left.
63
- *
64
- * `positions` bounds a step to that many dictionary positions, or that many
65
- * reading groups while the last pass is ranking them. It is a bound rather
66
- * than a promise: the pass that sorts the reading keys cannot be divided, and
67
- * is one step of its own.
68
- */
69
- readonly step: (positions?: number) => ReverseIndex | undefined;
70
- }
7
+ import type { Dictionary } from "../dictionary/dictionary.js";
8
+ import type { ReverseIndexData } from "./reverse-index-format.js";
9
+ import { type ReverseIndexBuild } from "./reverse-index-passes.js";
10
+ export type { ReverseIndexBuild } from "./reverse-index-passes.js";
11
+ export { readingKey, type ReverseIndexData } from "./reverse-index-format.js";
71
12
  /**
72
13
  * Which readings each word in the dictionary can be reached by.
73
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"reverse-index.d.ts","sourceRoot":"","sources":["../../src/search/reverse-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AA6B9D;;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