harumt 0.1.0 → 0.1.1

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 (762) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.en.md +24 -21
  3. package/README.md +66 -73
  4. package/data/config/lookup_tables.toml +9 -4
  5. package/dist/analyzer/config.js +1 -3
  6. package/dist/analyzer/connect.d.ts +1 -1
  7. package/dist/analyzer/connect.js +2 -1
  8. package/dist/analyzer/dictionary-provider.d.ts +2 -0
  9. package/dist/analyzer/dictionary-provider.js +3 -0
  10. package/dist/analyzer/haru-dictionary-provider.js +17 -6
  11. package/dist/analyzer/node-dictionary-provider.d.ts +19 -8
  12. package/dist/analyzer/node-dictionary-provider.js +109 -48
  13. package/dist/analyzer/node-helpers.js +12 -18
  14. package/dist/analyzer/page-cached-source.d.ts +59 -0
  15. package/dist/analyzer/page-cached-source.js +157 -0
  16. package/dist/analyzer-lexicon.js +6 -1
  17. package/dist/default-provider.d.ts +1 -1
  18. package/dist/default-provider.js +14 -6
  19. package/dist/dictionary/derivation.d.ts +0 -1
  20. package/dist/dictionary/morpheme.js +13 -7
  21. package/dist/dictionary/pattern.js +1 -1
  22. package/dist/dictionary/sense-normalization.js +3 -3
  23. package/dist/generator/aux-map.d.ts +1 -0
  24. package/dist/generator/aux-map.js +1 -1
  25. package/dist/generator/conjugator.d.ts +0 -1
  26. package/dist/generator/conjugator.js +0 -3
  27. package/dist/generator/numerals.d.ts +0 -1
  28. package/dist/generator/numerals.js +0 -3
  29. package/dist/pipeline/assembler/affix-helpers.d.ts +14 -0
  30. package/dist/pipeline/assembler/affix-helpers.js +154 -0
  31. package/dist/pipeline/assembler/content-override.d.ts +3 -0
  32. package/dist/pipeline/assembler/content-override.js +79 -0
  33. package/dist/pipeline/assembler/copula-focus-plan.d.ts +10 -0
  34. package/dist/pipeline/assembler/copula-focus-plan.js +32 -0
  35. package/dist/pipeline/assembler/copula-helpers.d.ts +31 -0
  36. package/dist/pipeline/assembler/copula-helpers.js +192 -0
  37. package/dist/pipeline/assembler/lexical-layout-hypothesis.d.ts +59 -0
  38. package/dist/pipeline/assembler/lexical-layout-hypothesis.js +357 -0
  39. package/dist/pipeline/assembler/light-verb-projection.d.ts +21 -0
  40. package/dist/pipeline/assembler/light-verb-projection.js +43 -0
  41. package/dist/pipeline/assembler/nande-reason.d.ts +4 -0
  42. package/dist/pipeline/assembler/nande-reason.js +162 -0
  43. package/dist/pipeline/assembler/particle-helpers.d.ts +10 -0
  44. package/dist/pipeline/assembler/particle-helpers.js +57 -0
  45. package/dist/pipeline/assembler/quantity-spans.d.ts +24 -0
  46. package/dist/pipeline/assembler/quantity-spans.js +58 -0
  47. package/dist/pipeline/assembler/question-plan.d.ts +5 -0
  48. package/dist/pipeline/assembler/question-plan.js +121 -0
  49. package/dist/pipeline/assembler/quote-helpers.d.ts +11 -0
  50. package/dist/pipeline/assembler/quote-helpers.js +67 -0
  51. package/dist/pipeline/assembler.d.ts +47 -31
  52. package/dist/pipeline/assembler.js +1219 -3234
  53. package/dist/pipeline/assembly-content-span.d.ts +59 -0
  54. package/dist/pipeline/assembly-content-span.js +149 -0
  55. package/dist/pipeline/attributive.d.ts +2 -2
  56. package/dist/pipeline/attributive.js +2 -5
  57. package/dist/pipeline/candidate-runtime.d.ts +2 -30
  58. package/dist/pipeline/candidate-runtime.js +4 -125
  59. package/dist/pipeline/clause-layout/adverbial-predicate.d.ts +22 -0
  60. package/dist/pipeline/clause-layout/adverbial-predicate.js +180 -0
  61. package/dist/pipeline/clause-layout/attributive-boundaries.d.ts +12 -0
  62. package/dist/pipeline/clause-layout/attributive-boundaries.js +325 -0
  63. package/dist/pipeline/clause-layout/boundary-detection.d.ts +100 -0
  64. package/dist/pipeline/clause-layout/boundary-detection.js +729 -0
  65. package/dist/pipeline/clause-layout/boundary-event-common.d.ts +8 -0
  66. package/dist/pipeline/clause-layout/boundary-event-common.js +50 -0
  67. package/dist/pipeline/clause-layout/boundary-settlement.d.ts +40 -0
  68. package/dist/pipeline/clause-layout/boundary-settlement.js +534 -0
  69. package/dist/pipeline/clause-layout/chuushi-closure.js +1 -2
  70. package/dist/pipeline/clause-layout/connective-boundaries.d.ts +34 -0
  71. package/dist/pipeline/clause-layout/connective-boundaries.js +1049 -0
  72. package/dist/pipeline/clause-layout/final-layout.d.ts +155 -0
  73. package/dist/pipeline/clause-layout/final-layout.js +544 -0
  74. package/dist/pipeline/clause-layout/index.d.ts +5 -597
  75. package/dist/pipeline/clause-layout/index.js +69 -6576
  76. package/dist/pipeline/clause-layout/juncture-verdict.d.ts +1 -3
  77. package/dist/pipeline/clause-layout/layout-types.d.ts +142 -0
  78. package/dist/pipeline/clause-layout/layout-types.js +16 -0
  79. package/dist/pipeline/clause-layout/lexical-adverbial-affiliation.d.ts +1 -1
  80. package/dist/pipeline/clause-layout/navigation.d.ts +48 -0
  81. package/dist/pipeline/clause-layout/navigation.js +264 -0
  82. package/dist/pipeline/clause-layout/nominal-anchor-evidence.d.ts +57 -0
  83. package/dist/pipeline/clause-layout/nominal-anchor-evidence.js +180 -0
  84. package/dist/pipeline/clause-layout/nominal-anchors.d.ts +9 -0
  85. package/dist/pipeline/clause-layout/nominal-anchors.js +318 -0
  86. package/dist/pipeline/clause-layout/nominal-binding.d.ts +1 -1
  87. package/dist/pipeline/clause-layout/nominal-binding.js +1 -1
  88. package/dist/pipeline/clause-layout/nominal-frame-reach.d.ts +7 -0
  89. package/dist/pipeline/clause-layout/nominal-frame-reach.js +77 -0
  90. package/dist/pipeline/clause-layout/particle-phrase-copula.d.ts +1 -1
  91. package/dist/pipeline/clause-layout/phrase-enumeration.d.ts +1 -1
  92. package/dist/pipeline/clause-layout/phrase-enumeration.js +2 -1
  93. package/dist/pipeline/clause-layout/predicate-ownership.d.ts +22 -0
  94. package/dist/pipeline/clause-layout/predicate-ownership.js +323 -0
  95. package/dist/pipeline/clause-layout/predicate-parallel.d.ts +2 -1
  96. package/dist/pipeline/clause-layout/predicate-parallel.js +16 -1
  97. package/dist/pipeline/clause-layout/predicate-shape.d.ts +49 -0
  98. package/dist/pipeline/clause-layout/predicate-shape.js +369 -0
  99. package/dist/pipeline/clause-layout/predicate-token-shape.d.ts +15 -0
  100. package/dist/pipeline/clause-layout/predicate-token-shape.js +142 -0
  101. package/dist/pipeline/clause-layout/prenominal-head-reach.d.ts +29 -0
  102. package/dist/pipeline/clause-layout/prenominal-head-reach.js +349 -0
  103. package/dist/pipeline/clause-layout/proto-layout.d.ts +144 -0
  104. package/dist/pipeline/clause-layout/proto-layout.js +327 -0
  105. package/dist/pipeline/clause-layout/proto-state.d.ts +2 -1
  106. package/dist/pipeline/clause-layout/punctuated-copula.d.ts +1 -1
  107. package/dist/pipeline/clause-layout/punctuation.d.ts +8 -0
  108. package/dist/pipeline/clause-layout/punctuation.js +33 -0
  109. package/dist/pipeline/clause-layout/quote-classification.d.ts +48 -0
  110. package/dist/pipeline/clause-layout/quote-classification.js +430 -0
  111. package/dist/pipeline/clause-layout/quote-delimiters.d.ts +2 -0
  112. package/dist/pipeline/clause-layout/quote-delimiters.js +16 -0
  113. package/dist/pipeline/clause-layout/renyou-verb-reading.d.ts +1 -1
  114. package/dist/pipeline/clause-layout/speech-act.js +1 -1
  115. package/dist/pipeline/clause-layout/token-evidence.d.ts +11 -0
  116. package/dist/pipeline/clause-layout/token-evidence.js +41 -0
  117. package/dist/pipeline/clause-layout/trivia.d.ts +5 -0
  118. package/dist/pipeline/clause-layout/trivia.js +18 -1
  119. package/dist/pipeline/clause-layout/utterance-boundaries.d.ts +41 -0
  120. package/dist/pipeline/clause-layout/utterance-boundaries.js +627 -0
  121. package/dist/pipeline/clause-layout/vocative.d.ts +5 -0
  122. package/dist/pipeline/clause-layout/vocative.js +91 -0
  123. package/dist/pipeline/clause-layout/whitespace-attributive-reading.d.ts +1 -1
  124. package/dist/pipeline/clause-layout/whitespace-attributive-reading.js +4 -1
  125. package/dist/pipeline/commitment/adverbial-adjunct-routing.d.ts +3 -0
  126. package/dist/pipeline/commitment/adverbial-adjunct-routing.js +109 -0
  127. package/dist/pipeline/commitment/benefactive-span-hydration.d.ts +5 -0
  128. package/dist/pipeline/commitment/benefactive-span-hydration.js +49 -0
  129. package/dist/pipeline/commitment/candidate-projection.d.ts +29 -0
  130. package/dist/pipeline/commitment/candidate-projection.js +512 -0
  131. package/dist/pipeline/commitment/connective-refinement.d.ts +8 -0
  132. package/dist/pipeline/commitment/connective-refinement.js +152 -0
  133. package/dist/pipeline/commitment/deferred-reanalysis.d.ts +1 -1
  134. package/dist/pipeline/commitment/final-sense-sync.d.ts +8 -0
  135. package/dist/pipeline/commitment/final-sense-sync.js +264 -0
  136. package/dist/pipeline/commitment/head-owner-candidate-selection.d.ts +15 -0
  137. package/dist/pipeline/commitment/head-owner-candidate-selection.js +158 -0
  138. package/dist/pipeline/commitment/particle-roles.d.ts +1 -1
  139. package/dist/pipeline/commitment/particle-roles.js +546 -398
  140. package/dist/pipeline/commitment/passive-class.d.ts +1 -1
  141. package/dist/pipeline/commitment/passive-class.js +2 -3
  142. package/dist/pipeline/commitment/quantity-span-commitment.d.ts +4 -0
  143. package/dist/pipeline/commitment/quantity-span-commitment.js +37 -0
  144. package/dist/pipeline/commitment/quote-refinement.d.ts +6 -0
  145. package/dist/pipeline/commitment/quote-refinement.js +130 -0
  146. package/dist/pipeline/commitment/role-case-shadow.d.ts +0 -4
  147. package/dist/pipeline/commitment/role-case-shadow.js +0 -3
  148. package/dist/pipeline/commitment/semantic-frame.d.ts +1 -1
  149. package/dist/pipeline/commitment/semantic-frame.js +2 -3
  150. package/dist/pipeline/commitment/span-evidence.d.ts +2 -3
  151. package/dist/pipeline/commitment/span-evidence.js +7 -18
  152. package/dist/pipeline/commitment/stem-candidate-selection.d.ts +24 -0
  153. package/dist/pipeline/commitment/stem-candidate-selection.js +663 -0
  154. package/dist/pipeline/commitment/te-connective-resolution.d.ts +1 -1
  155. package/dist/pipeline/commitment/te-connective-resolution.js +0 -1
  156. package/dist/pipeline/commitment/types.d.ts +1 -1
  157. package/dist/pipeline/commitment/types.js +1 -1
  158. package/dist/pipeline/commitment/voice-reading-resolution.d.ts +1 -1
  159. package/dist/pipeline/commitment/voice-reading-resolution.js +117 -34
  160. package/dist/pipeline/compounds/compound-tail-tokens.d.ts +12 -0
  161. package/dist/pipeline/compounds/compound-tail-tokens.js +37 -0
  162. package/dist/pipeline/compounds/compound-translation-candidates.d.ts +49 -0
  163. package/dist/pipeline/compounds/compound-translation-candidates.js +154 -0
  164. package/dist/pipeline/compounds/compound-verbs.js +4 -9
  165. package/dist/pipeline/compounds/index.d.ts +24 -29
  166. package/dist/pipeline/compounds/index.js +361 -383
  167. package/dist/pipeline/content-resolver/postaux-pattern-rendering.d.ts +0 -2
  168. package/dist/pipeline/content-resolver/postaux-pattern-rendering.js +1 -5
  169. package/dist/pipeline/content-resolver/types.d.ts +0 -4
  170. package/dist/pipeline/content-resolver.js +641 -492
  171. package/dist/pipeline/context.d.ts +2 -1
  172. package/dist/pipeline/context.js +4 -3
  173. package/dist/pipeline/core.d.ts +8 -95
  174. package/dist/pipeline/core.js +1339 -7183
  175. package/dist/pipeline/deferred-commitment.d.ts +2 -17
  176. package/dist/pipeline/deferred-commitment.js +406 -2353
  177. package/dist/pipeline/demo-discourse.d.ts +1 -1
  178. package/dist/pipeline/fallback/index.d.ts +0 -1
  179. package/dist/pipeline/fallback/index.js +3 -7
  180. package/dist/pipeline/fallback/orphan-unit-absorption.d.ts +4 -0
  181. package/dist/pipeline/fallback/orphan-unit-absorption.js +57 -0
  182. package/dist/pipeline/fallback/unsupported-raw.d.ts +0 -2
  183. package/dist/pipeline/fallback/unsupported-raw.js +0 -10
  184. package/dist/pipeline/head-tail/boundary/clause-start.js +1 -10
  185. package/dist/pipeline/head-tail/boundary/ka-ownership.d.ts +3 -2
  186. package/dist/pipeline/head-tail/boundary/ka-ownership.js +16 -9
  187. package/dist/pipeline/head-tail/boundary/marker.js +1 -1
  188. package/dist/pipeline/head-tail/boundary/punctuation.d.ts +0 -1
  189. package/dist/pipeline/head-tail/boundary/punctuation.js +1 -6
  190. package/dist/pipeline/head-tail/boundary/quote-marker.js +1 -1
  191. package/dist/pipeline/head-tail/candidate/collect.d.ts +3 -3
  192. package/dist/pipeline/head-tail/candidate/context.d.ts +1 -1
  193. package/dist/pipeline/head-tail/candidate/context.js +1 -1
  194. package/dist/pipeline/head-tail/candidate/evidence.d.ts +0 -2
  195. package/dist/pipeline/head-tail/candidate/evidence.js +0 -22
  196. package/dist/pipeline/head-tail/candidate/owner-payload.d.ts +1 -1
  197. package/dist/pipeline/head-tail/candidate/semantic-classifiers.d.ts +2 -1
  198. package/dist/pipeline/head-tail/data/honorific-formulaic-arm-table.d.ts +0 -1
  199. package/dist/pipeline/head-tail/data/honorific-formulaic-arm-table.js +0 -3
  200. package/dist/pipeline/head-tail/data/quoted-reporting-sets.d.ts +2 -0
  201. package/dist/pipeline/head-tail/data/quoted-reporting-sets.js +4 -0
  202. package/dist/pipeline/head-tail/grammar.d.ts +0 -1
  203. package/dist/pipeline/head-tail/head/adapters/nominal/commit.js +3 -2
  204. package/dist/pipeline/head-tail/head/adapters/nominal/grammar.d.ts +2 -1
  205. package/dist/pipeline/head-tail/head/adapters/nominal/integration.d.ts +2 -2
  206. package/dist/pipeline/head-tail/head/adapters/nominal/integration.js +6 -6
  207. package/dist/pipeline/head-tail/head/adapters/nominal/owner-arbitration.d.ts +1 -1
  208. package/dist/pipeline/head-tail/head/adapters/nominal/parser.d.ts +1 -2
  209. package/dist/pipeline/head-tail/head/adapters/nominal/parser.js +20 -24
  210. package/dist/pipeline/head-tail/head/adapters/nominal/plan-lifecycle.d.ts +1 -1
  211. package/dist/pipeline/head-tail/head/adapters/nominal/renyou-nominal-head.js +2 -2
  212. package/dist/pipeline/head-tail/integration/content-head-dispatch.d.ts +5 -6
  213. package/dist/pipeline/head-tail/integration/content-head-dispatch.js +2 -5
  214. package/dist/pipeline/head-tail/integration/copula-focus-adjunct.js +1 -1
  215. package/dist/pipeline/head-tail/integration/copula-host-chain.js +1 -1
  216. package/dist/pipeline/head-tail/integration/honorific-formulaic-host.d.ts +25 -0
  217. package/dist/pipeline/head-tail/integration/honorific-formulaic-host.js +142 -0
  218. package/dist/pipeline/head-tail/integration/nominal-assembly.d.ts +2 -2
  219. package/dist/pipeline/head-tail/integration/nominal-assembly.js +1 -1
  220. package/dist/pipeline/head-tail/integration/particle-phrase-copula.d.ts +1 -1
  221. package/dist/pipeline/head-tail/integration/semantic-carrier-predicate.js +3 -20
  222. package/dist/pipeline/head-tail/integration/tail-assembly.d.ts +2 -3
  223. package/dist/pipeline/head-tail/integration/tail-assembly.js +20 -145
  224. package/dist/pipeline/head-tail/lifecycle/commit-context.d.ts +1 -1
  225. package/dist/pipeline/head-tail/lifecycle/head-tail-render-plan.d.ts +1 -1
  226. package/dist/pipeline/head-tail/lifecycle/hooks.d.ts +2 -3
  227. package/dist/pipeline/head-tail/lifecycle/hooks.js +0 -9
  228. package/dist/pipeline/head-tail/lifecycle/plan-context.d.ts +1 -1
  229. package/dist/pipeline/head-tail/lifecycle/plan-context.js +1 -1
  230. package/dist/pipeline/head-tail/lifecycle/registry.d.ts +3 -4
  231. package/dist/pipeline/head-tail/lifecycle/registry.js +1 -4
  232. package/dist/pipeline/head-tail/lifecycle/render.js +2 -2
  233. package/dist/pipeline/head-tail/line-memo.d.ts +1 -1
  234. package/dist/pipeline/head-tail/line-memo.js +25 -6
  235. package/dist/pipeline/head-tail/tail/chain.d.ts +3 -3
  236. package/dist/pipeline/head-tail/tail/families/tokoro-semantics.d.ts +0 -1
  237. package/dist/pipeline/head-tail/tail/families/tokoro-semantics.js +2 -1
  238. package/dist/pipeline/head-tail/tail/families/youda-semantics.js +1 -4
  239. package/dist/pipeline/head-tail/tail/postverb-events.d.ts +0 -180
  240. package/dist/pipeline/head-tail/tail/postverb-events.js +2 -2249
  241. package/dist/pipeline/head-tail/tail/postverb-tail-classifier.js +3 -4
  242. package/dist/pipeline/head-tail/tail/predicate-root/aspect-semantics.d.ts +10 -8
  243. package/dist/pipeline/head-tail/tail/predicate-root/aspect-semantics.js +2 -55
  244. package/dist/pipeline/head-tail/tail/predicate-root/benefactive-hydration.d.ts +1 -1
  245. package/dist/pipeline/head-tail/tail/predicate-root/benefactive-hydration.js +1 -18
  246. package/dist/pipeline/head-tail/tail/predicate-root/boundary-semantics.js +4 -2
  247. package/dist/pipeline/head-tail/tail/predicate-root/classifiers/causative-aux.d.ts +4 -0
  248. package/dist/pipeline/head-tail/tail/predicate-root/classifiers/causative-aux.js +11 -0
  249. package/dist/pipeline/head-tail/tail/predicate-root/classifiers/copula-concessive.d.ts +1 -1
  250. package/dist/pipeline/head-tail/tail/predicate-root/classifiers/copula-concessive.js +14 -3
  251. package/dist/pipeline/head-tail/tail/predicate-root/classifiers/tokens.d.ts +0 -2
  252. package/dist/pipeline/head-tail/tail/predicate-root/classifiers/tokens.js +3 -12
  253. package/dist/pipeline/head-tail/tail/predicate-root/commit.d.ts +2 -1
  254. package/dist/pipeline/head-tail/tail/predicate-root/commit.js +1 -1
  255. package/dist/pipeline/head-tail/tail/predicate-root/commitment-bridge.d.ts +1 -1
  256. package/dist/pipeline/head-tail/tail/predicate-root/connective-ops.d.ts +9 -0
  257. package/dist/pipeline/head-tail/tail/predicate-root/connective-ops.js +69 -0
  258. package/dist/pipeline/head-tail/tail/predicate-root/connective-render.d.ts +7 -0
  259. package/dist/pipeline/head-tail/tail/predicate-root/connective-render.js +52 -0
  260. package/dist/pipeline/head-tail/tail/predicate-root/connective-surface-lookup.d.ts +11 -0
  261. package/dist/pipeline/head-tail/tail/predicate-root/connective-surface-lookup.js +114 -0
  262. package/dist/pipeline/head-tail/tail/predicate-root/derivational-host-base.js +1 -1
  263. package/dist/pipeline/head-tail/tail/predicate-root/grammar.d.ts +2 -14
  264. package/dist/pipeline/head-tail/tail/predicate-root/grammar.js +19 -128
  265. package/dist/pipeline/head-tail/tail/predicate-root/head-contract-table.d.ts +2 -1
  266. package/dist/pipeline/head-tail/tail/predicate-root/head-contract-table.js +1 -1
  267. package/dist/pipeline/head-tail/tail/predicate-root/head-hydration.js +2 -17
  268. package/dist/pipeline/head-tail/tail/predicate-root/inspect.d.ts +2 -8
  269. package/dist/pipeline/head-tail/tail/predicate-root/inspect.js +12 -16
  270. package/dist/pipeline/head-tail/tail/predicate-root/integration/attributive-boundary.d.ts +35 -0
  271. package/dist/pipeline/head-tail/tail/predicate-root/integration/attributive-boundary.js +1079 -0
  272. package/dist/pipeline/head-tail/tail/predicate-root/integration/clause-boundaries.d.ts +69 -0
  273. package/dist/pipeline/head-tail/tail/predicate-root/integration/clause-boundaries.js +2972 -0
  274. package/dist/pipeline/head-tail/tail/predicate-root/integration/contracts.d.ts +118 -0
  275. package/dist/pipeline/head-tail/tail/predicate-root/integration/end-boundary-inference.d.ts +22 -0
  276. package/dist/pipeline/head-tail/tail/predicate-root/integration/end-boundary-inference.js +698 -0
  277. package/dist/pipeline/head-tail/tail/predicate-root/integration/head-admission.d.ts +39 -0
  278. package/dist/pipeline/head-tail/tail/predicate-root/integration/head-admission.js +689 -0
  279. package/dist/pipeline/head-tail/tail/predicate-root/integration/head-profiles.d.ts +13 -0
  280. package/dist/pipeline/head-tail/tail/predicate-root/integration/head-profiles.js +138 -0
  281. package/dist/pipeline/head-tail/tail/predicate-root/integration/parse-clause.d.ts +60 -0
  282. package/dist/pipeline/head-tail/tail/predicate-root/integration/parse-clause.js +2013 -0
  283. package/dist/pipeline/head-tail/tail/predicate-root/integration/predicate-evidence.d.ts +15 -0
  284. package/dist/pipeline/head-tail/tail/predicate-root/integration/predicate-evidence.js +109 -0
  285. package/dist/pipeline/head-tail/tail/predicate-root/integration/predicate-start-evidence.d.ts +48 -0
  286. package/dist/pipeline/head-tail/tail/predicate-root/integration/predicate-start-evidence.js +608 -0
  287. package/dist/pipeline/head-tail/tail/predicate-root/integration/readiness.d.ts +1 -1
  288. package/dist/pipeline/head-tail/tail/predicate-root/integration/readiness.js +3 -2
  289. package/dist/pipeline/head-tail/tail/predicate-root/integration/stem-candidates.d.ts +177 -0
  290. package/dist/pipeline/head-tail/tail/predicate-root/integration/stem-candidates.js +1885 -0
  291. package/dist/pipeline/head-tail/tail/predicate-root/integration/tail-arbitration.d.ts +13 -0
  292. package/dist/pipeline/head-tail/tail/predicate-root/integration/tail-arbitration.js +283 -0
  293. package/dist/pipeline/head-tail/tail/predicate-root/integration/tail-chunk-scan-end.d.ts +8 -0
  294. package/dist/pipeline/head-tail/tail/predicate-root/integration/tail-chunk-scan-end.js +389 -0
  295. package/dist/pipeline/head-tail/tail/predicate-root/integration/zero-head.js +3 -2
  296. package/dist/pipeline/head-tail/tail/predicate-root/integration.d.ts +9 -166
  297. package/dist/pipeline/head-tail/tail/predicate-root/integration.js +254 -10644
  298. package/dist/pipeline/head-tail/tail/predicate-root/matchers/connective-tail.d.ts +51 -0
  299. package/dist/pipeline/head-tail/tail/predicate-root/matchers/connective-tail.js +808 -0
  300. package/dist/pipeline/head-tail/tail/predicate-root/matchers/connective.d.ts +1 -1
  301. package/dist/pipeline/head-tail/tail/predicate-root/matchers/connective.js +5 -3
  302. package/dist/pipeline/head-tail/tail/predicate-root/matchers/copula-tail.d.ts +22 -0
  303. package/dist/pipeline/head-tail/tail/predicate-root/matchers/copula-tail.js +156 -0
  304. package/dist/pipeline/head-tail/tail/predicate-root/matchers/copula.d.ts +8 -2
  305. package/dist/pipeline/head-tail/tail/predicate-root/matchers/copula.js +177 -51
  306. package/dist/pipeline/head-tail/tail/predicate-root/matchers/lexical-idioms.d.ts +37 -0
  307. package/dist/pipeline/head-tail/tail/predicate-root/matchers/lexical-idioms.js +959 -0
  308. package/dist/pipeline/head-tail/tail/predicate-root/matchers/likeness-modal.d.ts +15 -0
  309. package/dist/pipeline/head-tail/tail/predicate-root/matchers/likeness-modal.js +327 -0
  310. package/dist/pipeline/head-tail/tail/predicate-root/matchers/modal-tail.d.ts +44 -0
  311. package/dist/pipeline/head-tail/tail/predicate-root/matchers/modal-tail.js +998 -0
  312. package/dist/pipeline/head-tail/tail/predicate-root/matchers/obligation-tail.d.ts +20 -0
  313. package/dist/pipeline/head-tail/tail/predicate-root/matchers/obligation-tail.js +424 -0
  314. package/dist/pipeline/head-tail/tail/predicate-root/matchers/obligation.d.ts +1 -1
  315. package/dist/pipeline/head-tail/tail/predicate-root/matchers/obligation.js +1 -1
  316. package/dist/pipeline/head-tail/tail/predicate-root/matchers/postverb-operator.d.ts +25 -0
  317. package/dist/pipeline/head-tail/tail/predicate-root/matchers/postverb-operator.js +722 -0
  318. package/dist/pipeline/head-tail/tail/predicate-root/matchers/predicate-projection-connective.js +143 -9
  319. package/dist/pipeline/head-tail/tail/predicate-root/matchers/predicate-quote.d.ts +44 -0
  320. package/dist/pipeline/head-tail/tail/predicate-root/matchers/predicate-quote.js +856 -0
  321. package/dist/pipeline/head-tail/tail/predicate-root/matchers/projection-tail.d.ts +45 -0
  322. package/dist/pipeline/head-tail/tail/predicate-root/matchers/projection-tail.js +573 -0
  323. package/dist/pipeline/head-tail/tail/predicate-root/matchers/quantity-extent.d.ts +2 -1
  324. package/dist/pipeline/head-tail/tail/predicate-root/matchers/quantity-extent.js +1 -1
  325. package/dist/pipeline/head-tail/tail/predicate-root/matchers/te-aspect.d.ts +23 -0
  326. package/dist/pipeline/head-tail/tail/predicate-root/matchers/te-aspect.js +598 -0
  327. package/dist/pipeline/head-tail/tail/predicate-root/matchers/te-host.d.ts +11 -0
  328. package/dist/pipeline/head-tail/tail/predicate-root/matchers/te-host.js +52 -0
  329. package/dist/pipeline/head-tail/tail/predicate-root/matchers/terminal-sfp.d.ts +24 -0
  330. package/dist/pipeline/head-tail/tail/predicate-root/matchers/terminal-sfp.js +873 -0
  331. package/dist/pipeline/head-tail/tail/predicate-root/mid-chain-connective-license.js +2 -1
  332. package/dist/pipeline/head-tail/tail/predicate-root/nominal-host-phrase.d.ts +0 -1
  333. package/dist/pipeline/head-tail/tail/predicate-root/nominal-host-phrase.js +0 -3
  334. package/dist/pipeline/head-tail/tail/predicate-root/op-builders.d.ts +5 -1
  335. package/dist/pipeline/head-tail/tail/predicate-root/op-builders.js +21 -0
  336. package/dist/pipeline/head-tail/tail/predicate-root/operator-head.d.ts +1 -3
  337. package/dist/pipeline/head-tail/tail/predicate-root/operator-head.js +0 -16
  338. package/dist/pipeline/head-tail/tail/predicate-root/parse-boundary-hint.d.ts +1 -1
  339. package/dist/pipeline/head-tail/tail/predicate-root/parse-closure.d.ts +15 -0
  340. package/dist/pipeline/head-tail/tail/predicate-root/parse-closure.js +158 -0
  341. package/dist/pipeline/head-tail/tail/predicate-root/parse-coordinates.d.ts +10 -0
  342. package/dist/pipeline/head-tail/tail/predicate-root/parse-coordinates.js +29 -0
  343. package/dist/pipeline/head-tail/tail/predicate-root/parse-stem.d.ts +14 -0
  344. package/dist/pipeline/head-tail/tail/predicate-root/parse-stem.js +150 -0
  345. package/dist/pipeline/head-tail/tail/predicate-root/parse-tail.d.ts +40 -0
  346. package/dist/pipeline/head-tail/tail/predicate-root/parse-tail.js +1625 -0
  347. package/dist/pipeline/head-tail/tail/predicate-root/parser.d.ts +26 -137
  348. package/dist/pipeline/head-tail/tail/predicate-root/parser.js +153 -9225
  349. package/dist/pipeline/head-tail/tail/predicate-root/plan-lifecycle.d.ts +2 -2
  350. package/dist/pipeline/head-tail/tail/predicate-root/postverb-host-attachment.d.ts +8 -0
  351. package/dist/pipeline/head-tail/tail/predicate-root/postverb-host-attachment.js +105 -0
  352. package/dist/pipeline/head-tail/tail/predicate-root/production-admission-contract.js +261 -215
  353. package/dist/pipeline/head-tail/tail/predicate-root/production-claim-access.d.ts +0 -1
  354. package/dist/pipeline/head-tail/tail/predicate-root/production-claim-access.js +0 -3
  355. package/dist/pipeline/head-tail/tail/predicate-root/production-families/attributive-change.d.ts +3 -0
  356. package/dist/pipeline/head-tail/tail/predicate-root/production-families/attributive-change.js +327 -0
  357. package/dist/pipeline/head-tail/tail/predicate-root/production-families/attributive.d.ts +54 -0
  358. package/dist/pipeline/head-tail/tail/predicate-root/production-families/attributive.js +1212 -0
  359. package/dist/pipeline/head-tail/tail/predicate-root/production-families/chain-patterns.d.ts +191 -0
  360. package/dist/pipeline/head-tail/tail/predicate-root/production-families/chain-patterns.js +127 -0
  361. package/dist/pipeline/head-tail/tail/predicate-root/production-families/clause-chain.d.ts +17 -0
  362. package/dist/pipeline/head-tail/tail/predicate-root/production-families/clause-chain.js +1071 -0
  363. package/dist/pipeline/head-tail/tail/predicate-root/production-families/conditional-carriers.d.ts +4 -0
  364. package/dist/pipeline/head-tail/tail/predicate-root/production-families/conditional-carriers.js +366 -0
  365. package/dist/pipeline/head-tail/tail/predicate-root/production-families/confirmation.d.ts +3 -0
  366. package/dist/pipeline/head-tail/tail/predicate-root/production-families/confirmation.js +289 -0
  367. package/dist/pipeline/head-tail/tail/predicate-root/production-families/copula.d.ts +8 -0
  368. package/dist/pipeline/head-tail/tail/predicate-root/production-families/copula.js +868 -0
  369. package/dist/pipeline/head-tail/tail/predicate-root/production-families/desiderative.d.ts +4 -0
  370. package/dist/pipeline/head-tail/tail/predicate-root/production-families/desiderative.js +414 -0
  371. package/dist/pipeline/head-tail/tail/predicate-root/production-families/exemplification.d.ts +2 -0
  372. package/dist/pipeline/head-tail/tail/predicate-root/production-families/exemplification.js +290 -0
  373. package/dist/pipeline/head-tail/tail/predicate-root/production-families/imperative.d.ts +6 -0
  374. package/dist/pipeline/head-tail/tail/predicate-root/production-families/imperative.js +468 -0
  375. package/dist/pipeline/head-tail/tail/predicate-root/production-families/mid-chain-quote.d.ts +4 -0
  376. package/dist/pipeline/head-tail/tail/predicate-root/production-families/mid-chain-quote.js +558 -0
  377. package/dist/pipeline/head-tail/tail/predicate-root/production-families/nominalization.d.ts +6 -0
  378. package/dist/pipeline/head-tail/tail/predicate-root/production-families/nominalization.js +332 -0
  379. package/dist/pipeline/head-tail/tail/predicate-root/production-families/nominalized-quote.d.ts +3 -0
  380. package/dist/pipeline/head-tail/tail/predicate-root/production-families/nominalized-quote.js +393 -0
  381. package/dist/pipeline/head-tail/tail/predicate-root/production-families/normalization.d.ts +7 -0
  382. package/dist/pipeline/head-tail/tail/predicate-root/production-families/normalization.js +334 -0
  383. package/dist/pipeline/head-tail/tail/predicate-root/production-families/potential.d.ts +3 -0
  384. package/dist/pipeline/head-tail/tail/predicate-root/production-families/potential.js +304 -0
  385. package/dist/pipeline/head-tail/tail/predicate-root/production-families/reason-and-sequence.d.ts +6 -0
  386. package/dist/pipeline/head-tail/tail/predicate-root/production-families/reason-and-sequence.js +687 -0
  387. package/dist/pipeline/head-tail/tail/predicate-root/production-families/request.d.ts +4 -0
  388. package/dist/pipeline/head-tail/tail/predicate-root/production-families/request.js +1013 -0
  389. package/dist/pipeline/head-tail/tail/predicate-root/production-families/shared.d.ts +25 -0
  390. package/dist/pipeline/head-tail/tail/predicate-root/production-families/shared.js +53 -0
  391. package/dist/pipeline/head-tail/tail/predicate-root/production-families/subordination.d.ts +5 -0
  392. package/dist/pipeline/head-tail/tail/predicate-root/production-families/subordination.js +318 -0
  393. package/dist/pipeline/head-tail/tail/predicate-root/production-families/terminal.d.ts +14 -0
  394. package/dist/pipeline/head-tail/tail/predicate-root/production-families/terminal.js +976 -0
  395. package/dist/pipeline/head-tail/tail/predicate-root/production-families/volitional.d.ts +10 -0
  396. package/dist/pipeline/head-tail/tail/predicate-root/production-families/volitional.js +677 -0
  397. package/dist/pipeline/head-tail/tail/predicate-root/production-families.d.ts +1 -8
  398. package/dist/pipeline/head-tail/tail/predicate-root/production-families.js +19 -11025
  399. package/dist/pipeline/head-tail/tail/predicate-root/production-lowering-bindings.js +9 -3
  400. package/dist/pipeline/head-tail/tail/predicate-root/production-registry.d.ts +2 -3
  401. package/dist/pipeline/head-tail/tail/predicate-root/production-registry.js +15 -19
  402. package/dist/pipeline/head-tail/tail/predicate-root/quote-tail-context.d.ts +8 -0
  403. package/dist/pipeline/head-tail/tail/predicate-root/quote-tail-context.js +66 -0
  404. package/dist/pipeline/head-tail/tail/predicate-root/render-derivational-host-projection.d.ts +11 -0
  405. package/dist/pipeline/head-tail/tail/predicate-root/render-derivational-host-projection.js +67 -0
  406. package/dist/pipeline/head-tail/tail/predicate-root/render-root.d.ts +10 -0
  407. package/dist/pipeline/head-tail/tail/predicate-root/render-root.js +203 -0
  408. package/dist/pipeline/head-tail/tail/predicate-root/render-sfp-terminal.d.ts +3 -0
  409. package/dist/pipeline/head-tail/tail/predicate-root/render-sfp-terminal.js +647 -0
  410. package/dist/pipeline/head-tail/tail/predicate-root/render.d.ts +9 -25
  411. package/dist/pipeline/head-tail/tail/predicate-root/render.js +715 -5879
  412. package/dist/pipeline/head-tail/tail/predicate-root/renderers/aspect-bases.d.ts +23 -0
  413. package/dist/pipeline/head-tail/tail/predicate-root/renderers/aspect-bases.js +523 -0
  414. package/dist/pipeline/head-tail/tail/predicate-root/renderers/aspect-benefactive.js +1 -1
  415. package/dist/pipeline/head-tail/tail/predicate-root/renderers/attributive-tail-forms.d.ts +71 -0
  416. package/dist/pipeline/head-tail/tail/predicate-root/renderers/attributive-tail-forms.js +907 -0
  417. package/dist/pipeline/head-tail/tail/predicate-root/renderers/aux-layer-context.d.ts +48 -0
  418. package/dist/pipeline/head-tail/tail/predicate-root/renderers/aux-layer-context.js +1 -0
  419. package/dist/pipeline/head-tail/tail/predicate-root/renderers/base-model.d.ts +3 -1
  420. package/dist/pipeline/head-tail/tail/predicate-root/renderers/base-model.js +35 -1
  421. package/dist/pipeline/head-tail/tail/predicate-root/renderers/base-support.d.ts +8 -1
  422. package/dist/pipeline/head-tail/tail/predicate-root/renderers/base-support.js +90 -0
  423. package/dist/pipeline/head-tail/tail/predicate-root/renderers/command-render.d.ts +1 -13
  424. package/dist/pipeline/head-tail/tail/predicate-root/renderers/command-render.js +3 -10
  425. package/dist/pipeline/head-tail/tail/predicate-root/renderers/command-tail.d.ts +17 -0
  426. package/dist/pipeline/head-tail/tail/predicate-root/renderers/command-tail.js +439 -0
  427. package/dist/pipeline/head-tail/tail/predicate-root/renderers/conjecture-compose.d.ts +34 -0
  428. package/dist/pipeline/head-tail/tail/predicate-root/renderers/conjecture-compose.js +358 -0
  429. package/dist/pipeline/head-tail/tail/predicate-root/renderers/connective-compose.d.ts +2 -120
  430. package/dist/pipeline/head-tail/tail/predicate-root/renderers/connective-compose.js +90 -1670
  431. package/dist/pipeline/head-tail/tail/predicate-root/renderers/connective-ending.d.ts +7 -0
  432. package/dist/pipeline/head-tail/tail/predicate-root/renderers/connective-ending.js +36 -0
  433. package/dist/pipeline/head-tail/tail/predicate-root/renderers/continuative-copula.d.ts +7 -0
  434. package/dist/pipeline/head-tail/tail/predicate-root/renderers/continuative-copula.js +61 -0
  435. package/dist/pipeline/head-tail/tail/predicate-root/renderers/desire-bases.d.ts +9 -0
  436. package/dist/pipeline/head-tail/tail/predicate-root/renderers/desire-bases.js +69 -0
  437. package/dist/pipeline/head-tail/tail/predicate-root/renderers/hostless-conditional-quote.d.ts +12 -2
  438. package/dist/pipeline/head-tail/tail/predicate-root/renderers/hostless-conditional-quote.js +19 -1
  439. package/dist/pipeline/head-tail/tail/predicate-root/renderers/idiom-bases.d.ts +119 -0
  440. package/dist/pipeline/head-tail/tail/predicate-root/renderers/idiom-bases.js +393 -0
  441. package/dist/pipeline/head-tail/tail/predicate-root/renderers/modal-bases.d.ts +77 -0
  442. package/dist/pipeline/head-tail/tail/predicate-root/renderers/modal-bases.js +1243 -0
  443. package/dist/pipeline/head-tail/tail/predicate-root/renderers/non-chain-tail.d.ts +3 -0
  444. package/dist/pipeline/head-tail/tail/predicate-root/renderers/non-chain-tail.js +1045 -0
  445. package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-attributive-forms.d.ts +38 -0
  446. package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-attributive-forms.js +507 -0
  447. package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-conjecture-compose.d.ts +5 -0
  448. package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-conjecture-compose.js +108 -0
  449. package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-tail-forms.d.ts +72 -0
  450. package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-tail-forms.js +1343 -0
  451. package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula.js +9 -3
  452. package/dist/pipeline/head-tail/tail/predicate-root/renderers/op-chain.js +1229 -1107
  453. package/dist/pipeline/head-tail/tail/predicate-root/renderers/operator-chain-tail.d.ts +23 -0
  454. package/dist/pipeline/head-tail/tail/predicate-root/renderers/operator-chain-tail.js +443 -0
  455. package/dist/pipeline/head-tail/tail/predicate-root/renderers/postverb-auxiliary-bases.d.ts +12 -0
  456. package/dist/pipeline/head-tail/tail/predicate-root/renderers/postverb-auxiliary-bases.js +1193 -0
  457. package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-base-projection.d.ts +18 -0
  458. package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-base-projection.js +284 -0
  459. package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-bases.d.ts +3 -271
  460. package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-bases.js +438 -5062
  461. package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-terminal-compose.d.ts +10 -0
  462. package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-terminal-compose.js +167 -0
  463. package/dist/pipeline/head-tail/tail/predicate-root/renderers/purpose-manner-compose.d.ts +9 -0
  464. package/dist/pipeline/head-tail/tail/predicate-root/renderers/purpose-manner-compose.js +92 -0
  465. package/dist/pipeline/head-tail/tail/predicate-root/renderers/quote-complement-compose.d.ts +53 -0
  466. package/dist/pipeline/head-tail/tail/predicate-root/renderers/quote-complement-compose.js +534 -0
  467. package/dist/pipeline/head-tail/tail/predicate-root/renderers/reason-quote-carrier.js +1 -1
  468. package/dist/pipeline/head-tail/tail/predicate-root/renderers/scope-bridge-bases.d.ts +5 -0
  469. package/dist/pipeline/head-tail/tail/predicate-root/renderers/scope-bridge-bases.js +571 -0
  470. package/dist/pipeline/head-tail/tail/predicate-root/renderers/sequence-after-copula.js +1 -1
  471. package/dist/pipeline/head-tail/tail/predicate-root/renderers/sfp-question.d.ts +2 -1
  472. package/dist/pipeline/head-tail/tail/predicate-root/renderers/sfp-question.js +9 -12
  473. package/dist/pipeline/head-tail/tail/predicate-root/renderers/tail-host-trace.d.ts +15 -0
  474. package/dist/pipeline/head-tail/tail/predicate-root/renderers/tail-host-trace.js +134 -0
  475. package/dist/pipeline/head-tail/tail/predicate-root/renderers/voice-benefactive-bases.d.ts +41 -0
  476. package/dist/pipeline/head-tail/tail/predicate-root/renderers/voice-benefactive-bases.js +648 -0
  477. package/dist/pipeline/head-tail/tail/predicate-root/renderers/voice-benefactive-tail.d.ts +12 -0
  478. package/dist/pipeline/head-tail/tail/predicate-root/renderers/voice-benefactive-tail.js +306 -0
  479. package/dist/pipeline/head-tail/tail/predicate-root/span-provenance.d.ts +1 -1
  480. package/dist/pipeline/head-tail/tail/predicate-root/suffix-handoff.d.ts +0 -1
  481. package/dist/pipeline/head-tail/tail/predicate-root/suffix-handoff.js +0 -13
  482. package/dist/pipeline/head-tail/tail/predicate-root/tail-evidence-decision.d.ts +1 -1
  483. package/dist/pipeline/head-tail/tail/predicate-root/tail-evidence-decision.js +5 -45
  484. package/dist/pipeline/head-tail/tail/predicate-root/tame-reason-evidence.d.ts +8 -1
  485. package/dist/pipeline/head-tail/tail/predicate-root/tame-reason-evidence.js +15 -0
  486. package/dist/pipeline/head-tail/tail/predicate-root/trace.d.ts +1 -1
  487. package/dist/pipeline/head-tail/tail/predicate-root/trace.js +2 -1
  488. package/dist/pipeline/head-tail/tail/segments/nominal-frame.d.ts +1 -1
  489. package/dist/pipeline/head-tail/tail/te-tail-continuation-table.js +1 -3
  490. package/dist/pipeline/index.d.ts +0 -4
  491. package/dist/pipeline/lexical-nominal-head-claims.d.ts +1 -1
  492. package/dist/pipeline/lexical-particle-boundary-claims.d.ts +1 -1
  493. package/dist/pipeline/lexical-renyou-head-claims.d.ts +1 -1
  494. package/dist/pipeline/lexical-renyou-head-claims.js +1 -1
  495. package/dist/pipeline/lookup-tables.d.ts +1 -0
  496. package/dist/pipeline/lookup-tables.js +1 -0
  497. package/dist/pipeline/matchers.d.ts +0 -3
  498. package/dist/pipeline/matchers.js +1 -8
  499. package/dist/pipeline/particle-head-dispatch.d.ts +1 -1
  500. package/dist/pipeline/particle-head-dispatch.js +472 -442
  501. package/dist/pipeline/particles/index.d.ts +3 -3
  502. package/dist/pipeline/particles/secondary-particle.d.ts +1 -0
  503. package/dist/pipeline/particles/secondary-particle.js +4 -0
  504. package/dist/pipeline/pattern-runtime.d.ts +0 -61
  505. package/dist/pipeline/pattern-runtime.js +3 -684
  506. package/dist/pipeline/preprocess/analyzer-input-offsets.d.ts +5 -0
  507. package/dist/pipeline/preprocess/analyzer-input-offsets.js +23 -0
  508. package/dist/pipeline/preprocess/auxiliary-variant-retag.d.ts +7 -0
  509. package/dist/pipeline/preprocess/auxiliary-variant-retag.js +178 -0
  510. package/dist/pipeline/preprocess/bungo-nasal-n-retag.d.ts +9 -0
  511. package/dist/pipeline/preprocess/bungo-nasal-n-retag.js +318 -0
  512. package/dist/pipeline/preprocess/cat-meow.d.ts +4 -0
  513. package/dist/pipeline/preprocess/cat-meow.js +46 -0
  514. package/dist/pipeline/preprocess/causative-aux-lemma.d.ts +2 -0
  515. package/dist/pipeline/preprocess/causative-aux-lemma.js +10 -0
  516. package/dist/pipeline/preprocess/collapsed-aspect-aux.d.ts +3 -0
  517. package/dist/pipeline/preprocess/collapsed-aspect-aux.js +217 -0
  518. package/dist/pipeline/preprocess/collapsed-te-oku.d.ts +3 -0
  519. package/dist/pipeline/preprocess/collapsed-te-oku.js +210 -0
  520. package/dist/pipeline/preprocess/collocation-emission.d.ts +14 -0
  521. package/dist/pipeline/preprocess/collocation-emission.js +148 -0
  522. package/dist/pipeline/preprocess/colloquial-vowel-fusion.d.ts +4 -0
  523. package/dist/pipeline/preprocess/colloquial-vowel-fusion.js +164 -0
  524. package/dist/{transform → pipeline/preprocess}/compound-particle-merge.d.ts +2 -2
  525. package/dist/{transform → pipeline/preprocess}/compound-particle-merge.js +5 -5
  526. package/dist/pipeline/preprocess/copula-focus-negative-state-change.d.ts +3 -0
  527. package/dist/pipeline/preprocess/copula-focus-negative-state-change.js +79 -0
  528. package/dist/pipeline/preprocess/copula-renyou-retag.d.ts +3 -0
  529. package/dist/pipeline/preprocess/copula-renyou-retag.js +56 -0
  530. package/dist/pipeline/preprocess/emphasis-sokuon.d.ts +10 -0
  531. package/dist/pipeline/preprocess/emphasis-sokuon.js +182 -0
  532. package/dist/{transform → pipeline/preprocess}/explanatory-mon-sfp-retag.d.ts +1 -1
  533. package/dist/{transform → pipeline/preprocess}/explanatory-mon-sfp-retag.js +2 -2
  534. package/dist/pipeline/preprocess/follower-context.d.ts +7 -0
  535. package/dist/pipeline/preprocess/follower-context.js +33 -0
  536. package/dist/pipeline/preprocess/fused-conditional.d.ts +3 -0
  537. package/dist/pipeline/preprocess/fused-conditional.js +97 -0
  538. package/dist/pipeline/preprocess/imperative-mistag-recovery.d.ts +7 -0
  539. package/dist/pipeline/preprocess/imperative-mistag-recovery.js +135 -0
  540. package/dist/pipeline/preprocess/input-text-normalization.d.ts +3 -0
  541. package/dist/pipeline/preprocess/input-text-normalization.js +39 -0
  542. package/dist/pipeline/preprocess/kansai-dialect.d.ts +9 -0
  543. package/dist/pipeline/preprocess/kansai-dialect.js +501 -0
  544. package/dist/{transform → pipeline/preprocess}/keijouji-copula-de-retag.d.ts +1 -1
  545. package/dist/{transform → pipeline/preprocess}/keijouji-copula-de-retag.js +2 -2
  546. package/dist/{transform → pipeline/preprocess}/ni-complement-matrix-flip.d.ts +1 -1
  547. package/dist/{transform → pipeline/preprocess}/ni-complement-matrix-flip.js +2 -2
  548. package/dist/pipeline/preprocess/past-quotative-tte-resplit.d.ts +3 -0
  549. package/dist/pipeline/preprocess/past-quotative-tte-resplit.js +55 -0
  550. package/dist/pipeline/preprocess/prolonged-orthography.d.ts +5 -0
  551. package/dist/pipeline/preprocess/prolonged-orthography.js +79 -0
  552. package/dist/pipeline/preprocess/prolonged-surface-canonicalization.d.ts +5 -0
  553. package/dist/pipeline/preprocess/prolonged-surface-canonicalization.js +161 -0
  554. package/dist/pipeline/preprocess/punctuation-canonicalization.d.ts +5 -0
  555. package/dist/pipeline/preprocess/punctuation-canonicalization.js +160 -0
  556. package/dist/{transform → pipeline/preprocess}/quotative-manner-noun-flip.d.ts +2 -2
  557. package/dist/{transform → pipeline/preprocess}/quotative-manner-noun-flip.js +10 -10
  558. package/dist/{transform → pipeline/preprocess}/reduplicated-mimetic.d.ts +1 -1
  559. package/dist/{transform → pipeline/preprocess}/reduplicated-mimetic.js +3 -3
  560. package/dist/{transform → pipeline/preprocess}/rentaishi-no-nominalizer-retag.d.ts +1 -1
  561. package/dist/{transform → pipeline/preprocess}/rentaishi-no-nominalizer-retag.js +2 -2
  562. package/dist/pipeline/preprocess/runtime-token-from-analyzer.d.ts +5 -0
  563. package/dist/pipeline/preprocess/runtime-token-from-analyzer.js +77 -0
  564. package/dist/pipeline/preprocess/runtime-token-from-preprocess.d.ts +13 -0
  565. package/dist/pipeline/preprocess/runtime-token-from-preprocess.js +15 -0
  566. package/dist/pipeline/preprocess/standalone-voice-mark.d.ts +9 -0
  567. package/dist/pipeline/preprocess/standalone-voice-mark.js +73 -0
  568. package/dist/pipeline/preprocess/synthetic-token.d.ts +10 -0
  569. package/dist/pipeline/preprocess/synthetic-token.js +26 -0
  570. package/dist/pipeline/preprocess/te-contraction.d.ts +4 -0
  571. package/dist/pipeline/preprocess/te-contraction.js +150 -0
  572. package/dist/pipeline/preprocess/terminal-role-tail.d.ts +5 -0
  573. package/dist/pipeline/preprocess/terminal-role-tail.js +148 -0
  574. package/dist/{transform → pipeline/preprocess}/terminal-sfp-retag-closure.d.ts +2 -2
  575. package/dist/{transform → pipeline/preprocess}/terminal-sfp-retag-closure.js +4 -4
  576. package/dist/pipeline/preprocess/to-iu-contraction.d.ts +2 -0
  577. package/dist/pipeline/preprocess/to-iu-contraction.js +65 -0
  578. package/dist/{transform → pipeline/preprocess}/volitional-resolution-sfp-retag.d.ts +1 -1
  579. package/dist/{transform → pipeline/preprocess}/volitional-resolution-sfp-retag.js +2 -2
  580. package/dist/{transform → pipeline/preprocess}/youon-remerge.d.ts +1 -1
  581. package/dist/{transform → pipeline/preprocess}/youon-remerge.js +3 -3
  582. package/dist/pipeline/projection/narou-ruby-input.d.ts +17 -0
  583. package/dist/pipeline/projection/narou-ruby-input.js +149 -0
  584. package/dist/pipeline/projection/parenthetical-delimiter-annotation.d.ts +6 -0
  585. package/dist/pipeline/projection/parenthetical-delimiter-annotation.js +117 -0
  586. package/dist/pipeline/projection/parenthetical-ruby-absorption.d.ts +6 -0
  587. package/dist/pipeline/projection/parenthetical-ruby-absorption.js +198 -0
  588. package/dist/pipeline/projection/parenthetical-source-boundary.d.ts +12 -0
  589. package/dist/pipeline/projection/parenthetical-source-boundary.js +117 -0
  590. package/dist/pipeline/projection/parenthetical-source-identity.d.ts +14 -0
  591. package/dist/pipeline/projection/parenthetical-source-identity.js +443 -0
  592. package/dist/pipeline/projection/parenthetical-target-insertion.d.ts +22 -0
  593. package/dist/pipeline/projection/parenthetical-target-insertion.js +584 -0
  594. package/dist/pipeline/projection/prepared-translation.d.ts +52 -0
  595. package/dist/pipeline/projection/prepared-translation.js +1 -0
  596. package/dist/pipeline/projection/prepared-tree.d.ts +6 -0
  597. package/dist/pipeline/projection/prepared-tree.js +66 -0
  598. package/dist/pipeline/projection/raw-parenthetical-split.d.ts +15 -0
  599. package/dist/pipeline/projection/raw-parenthetical-split.js +78 -0
  600. package/dist/pipeline/projection/ruby-annotation.d.ts +5 -0
  601. package/dist/pipeline/projection/ruby-annotation.js +161 -0
  602. package/dist/pipeline/projection/text-offset-projection.d.ts +7 -0
  603. package/dist/pipeline/projection/text-offset-projection.js +111 -0
  604. package/dist/pipeline/projection/transparent-pause-island.d.ts +8 -0
  605. package/dist/pipeline/projection/transparent-pause-island.js +188 -0
  606. package/dist/pipeline/pronominal-no-dispatch.js +1 -1
  607. package/dist/pipeline/quote/host-runtime.js +3 -2
  608. package/dist/pipeline/quote/host-taxonomy.d.ts +1 -0
  609. package/dist/pipeline/quote/host-taxonomy.js +2 -2
  610. package/dist/pipeline/quote/question-taking-enumeration.d.ts +1 -1
  611. package/dist/pipeline/quote/question-taking-enumeration.js +0 -4
  612. package/dist/pipeline/reason-source-evidence.d.ts +1 -0
  613. package/dist/pipeline/reason-source-evidence.js +1 -1
  614. package/dist/pipeline/rendering/functional-chain.d.ts +2 -0
  615. package/dist/pipeline/rendering/functional-chain.js +14 -0
  616. package/dist/pipeline/rendering/nominal-head-tail-plan-trace.d.ts +10 -0
  617. package/dist/pipeline/rendering/nominal-head-tail-plan-trace.js +336 -0
  618. package/dist/pipeline/rendering/render-plan-inspect.d.ts +9 -0
  619. package/dist/pipeline/rendering/render-plan-inspect.js +121 -0
  620. package/dist/pipeline/rendering/render-plan-payloads.d.ts +28 -0
  621. package/dist/pipeline/rendering/render-plan-payloads.js +125 -0
  622. package/dist/pipeline/rendering/render-plan-rewrite.d.ts +32 -0
  623. package/dist/pipeline/rendering/render-plan-rewrite.js +540 -0
  624. package/dist/pipeline/rendering/render-plan-segments.d.ts +42 -0
  625. package/dist/pipeline/rendering/render-plan-segments.js +263 -0
  626. package/dist/pipeline/rendering/render-plan.d.ts +4 -57
  627. package/dist/pipeline/rendering/render-plan.js +52 -1433
  628. package/dist/pipeline/rendering/request-normalization.d.ts +0 -1
  629. package/dist/pipeline/rendering/request-normalization.js +0 -3
  630. package/dist/pipeline/rendering/segment-allomorph.d.ts +17 -0
  631. package/dist/pipeline/rendering/segment-allomorph.js +152 -0
  632. package/dist/pipeline/rendering/segment-annotation-keys.d.ts +6 -0
  633. package/dist/pipeline/rendering/segment-annotation-keys.js +137 -0
  634. package/dist/pipeline/rendering/stem-derivation.js +1 -1
  635. package/dist/pipeline/rendering/target-segment-build.d.ts +13 -0
  636. package/dist/pipeline/rendering/target-segment-build.js +167 -0
  637. package/dist/pipeline/rendering/terminal-unit-punctuation.d.ts +16 -0
  638. package/dist/pipeline/rendering/terminal-unit-punctuation.js +96 -0
  639. package/dist/pipeline/rendering/unit-surface.d.ts +9 -0
  640. package/dist/pipeline/rendering/unit-surface.js +35 -0
  641. package/dist/pipeline/resource-cache.d.ts +19 -0
  642. package/dist/pipeline/resource-cache.js +164 -0
  643. package/dist/pipeline/rules/common.d.ts +0 -1
  644. package/dist/pipeline/rules/common.js +0 -1
  645. package/dist/pipeline/rules/entry-aux.d.ts +0 -2
  646. package/dist/pipeline/rules/entry-aux.js +0 -4
  647. package/dist/pipeline/rules/postaux-unsupported.js +1 -5
  648. package/dist/pipeline/rules/pre-entry.d.ts +0 -1
  649. package/dist/pipeline/rules/pre-entry.js +0 -1
  650. package/dist/pipeline/rules/tail-finalization.js +4 -5
  651. package/dist/pipeline/semantics/conditional.d.ts +2 -1
  652. package/dist/pipeline/semantics/conditional.js +3 -2
  653. package/dist/pipeline/semantics/copula-tail-runtime.js +2 -2
  654. package/dist/pipeline/semantics/explanatory-mon-reading.d.ts +1 -1
  655. package/dist/pipeline/semantics/explanatory-mon-reading.js +2 -2
  656. package/dist/pipeline/semantics/extent-phrase.js +1 -1
  657. package/dist/pipeline/semantics/frame.d.ts +3 -3
  658. package/dist/pipeline/semantics/frame.js +4 -4
  659. package/dist/pipeline/semantics/gano-conversion.d.ts +1 -2
  660. package/dist/pipeline/semantics/gano-conversion.js +1 -9
  661. package/dist/pipeline/semantics/grammar-runtime.d.ts +0 -7
  662. package/dist/pipeline/semantics/grammar-runtime.js +0 -92
  663. package/dist/pipeline/semantics/honorific.d.ts +1 -2
  664. package/dist/pipeline/semantics/honorific.js +0 -3
  665. package/dist/pipeline/semantics/mono-modal.d.ts +1 -1
  666. package/dist/pipeline/semantics/numeric.js +1 -3
  667. package/dist/pipeline/semantics/sfp-surface.js +8 -0
  668. package/dist/pipeline/source-candidate-set.d.ts +1 -2
  669. package/dist/pipeline/source-candidate-set.js +0 -3
  670. package/dist/pipeline/source-coordinate.d.ts +20 -0
  671. package/dist/pipeline/source-coordinate.js +42 -0
  672. package/dist/pipeline/structural-relation/clause-connective-relations.d.ts +12 -0
  673. package/dist/pipeline/structural-relation/clause-connective-relations.js +327 -0
  674. package/dist/pipeline/structural-relation/collect.d.ts +1 -12
  675. package/dist/pipeline/structural-relation/collect.js +11 -3105
  676. package/dist/pipeline/structural-relation/connective-relation-match.d.ts +17 -0
  677. package/dist/pipeline/structural-relation/connective-relation-match.js +39 -0
  678. package/dist/pipeline/structural-relation/diagnostics.d.ts +0 -2
  679. package/dist/pipeline/structural-relation/diagnostics.js +0 -7
  680. package/dist/pipeline/structural-relation/ka-parallel-relations.d.ts +3 -0
  681. package/dist/pipeline/structural-relation/ka-parallel-relations.js +695 -0
  682. package/dist/pipeline/structural-relation/nari-relations.d.ts +3 -0
  683. package/dist/pipeline/structural-relation/nari-relations.js +367 -0
  684. package/dist/pipeline/structural-relation/parallel-item-evidence.d.ts +12 -0
  685. package/dist/pipeline/structural-relation/parallel-item-evidence.js +73 -0
  686. package/dist/pipeline/structural-relation/punctuated-attributive-relations.d.ts +2 -0
  687. package/dist/pipeline/structural-relation/punctuated-attributive-relations.js +224 -0
  688. package/dist/pipeline/structural-relation/purpose-relations.d.ts +7 -0
  689. package/dist/pipeline/structural-relation/purpose-relations.js +306 -0
  690. package/dist/pipeline/structural-relation/quote-clause-boundary.d.ts +47 -0
  691. package/dist/pipeline/structural-relation/quote-clause-boundary.js +216 -0
  692. package/dist/pipeline/structural-relation/quote-closed-toka.d.ts +22 -0
  693. package/dist/pipeline/structural-relation/quote-closed-toka.js +158 -0
  694. package/dist/pipeline/structural-relation/quote-content-endings.d.ts +20 -0
  695. package/dist/pipeline/structural-relation/quote-content-endings.js +163 -0
  696. package/dist/pipeline/structural-relation/quote-content-span.d.ts +23 -0
  697. package/dist/pipeline/structural-relation/quote-content-span.js +270 -0
  698. package/dist/pipeline/structural-relation/quote-nominal-and-passive.d.ts +22 -0
  699. package/dist/pipeline/structural-relation/quote-nominal-and-passive.js +724 -0
  700. package/dist/pipeline/structural-relation/quote-payload.d.ts +33 -0
  701. package/dist/pipeline/structural-relation/quote-payload.js +137 -0
  702. package/dist/pipeline/structural-relation/quote-question-content.d.ts +18 -0
  703. package/dist/pipeline/structural-relation/quote-question-content.js +588 -0
  704. package/dist/pipeline/structural-relation/quote-reason-copula.d.ts +18 -0
  705. package/dist/pipeline/structural-relation/quote-reason-copula.js +84 -0
  706. package/dist/pipeline/structural-relation/quote-relation-enrichment.d.ts +4 -0
  707. package/dist/pipeline/structural-relation/quote-relation-enrichment.js +174 -0
  708. package/dist/pipeline/structural-relation/quote-request.d.ts +16 -0
  709. package/dist/pipeline/structural-relation/quote-request.js +249 -0
  710. package/dist/pipeline/structural-relation/quote.d.ts +4 -130
  711. package/dist/pipeline/structural-relation/quote.js +105 -2627
  712. package/dist/pipeline/structural-relation/reason-relations.d.ts +6 -0
  713. package/dist/pipeline/structural-relation/reason-relations.js +328 -0
  714. package/dist/pipeline/structural-relation/relation-coordinates.d.ts +21 -0
  715. package/dist/pipeline/structural-relation/relation-coordinates.js +110 -0
  716. package/dist/pipeline/structural-relation/render-attributive.d.ts +25 -0
  717. package/dist/pipeline/structural-relation/render-attributive.js +195 -0
  718. package/dist/pipeline/structural-relation/render-clause-connective.d.ts +29 -0
  719. package/dist/pipeline/structural-relation/render-clause-connective.js +114 -0
  720. package/dist/pipeline/structural-relation/render-connective-plan.d.ts +28 -0
  721. package/dist/pipeline/structural-relation/render-connective-plan.js +164 -0
  722. package/dist/pipeline/structural-relation/render-parallel.d.ts +60 -0
  723. package/dist/pipeline/structural-relation/render-parallel.js +1088 -0
  724. package/dist/pipeline/structural-relation/render-quote.d.ts +75 -0
  725. package/dist/pipeline/structural-relation/render-quote.js +968 -0
  726. package/dist/pipeline/structural-relation/render-reason-copula.d.ts +24 -0
  727. package/dist/pipeline/structural-relation/render-reason-copula.js +324 -0
  728. package/dist/pipeline/structural-relation/render-source-sequence.d.ts +11 -0
  729. package/dist/pipeline/structural-relation/render-source-sequence.js +154 -0
  730. package/dist/pipeline/structural-relation/render-unit-spans.d.ts +35 -0
  731. package/dist/pipeline/structural-relation/render-unit-spans.js +71 -0
  732. package/dist/pipeline/structural-relation/render.d.ts +2 -25
  733. package/dist/pipeline/structural-relation/render.js +10 -3043
  734. package/dist/pipeline/structural-relation/source-predicate-operator.d.ts +2 -1
  735. package/dist/pipeline/structural-relation/tari-listing-relations.d.ts +5 -0
  736. package/dist/pipeline/structural-relation/tari-listing-relations.js +354 -0
  737. package/dist/pipeline/structural-relation/toka-nominal-listing-relations.d.ts +2 -0
  738. package/dist/pipeline/structural-relation/toka-nominal-listing-relations.js +154 -0
  739. package/dist/pipeline/structural-relation/toka-nominal-listing-run.d.ts +11 -1
  740. package/dist/pipeline/structural-relation/toka-nominal-listing-run.js +16 -4
  741. package/dist/pipeline/structural-relation/types.d.ts +10 -1
  742. package/dist/pipeline/translation/access.d.ts +0 -3
  743. package/dist/pipeline/translation/unit.d.ts +4 -1
  744. package/dist/pipeline/translation/unit.js +29 -9
  745. package/dist/pipeline/translation/warnings.d.ts +9 -0
  746. package/dist/pipeline/translation/warnings.js +251 -0
  747. package/dist/pipeline-factory.js +2 -1
  748. package/dist/scripts/diagnose.js +3 -2
  749. package/dist/types/pos.d.ts +3 -0
  750. package/dist/types/pos.js +8 -0
  751. package/dist/types/reanalysis.d.ts +0 -1
  752. package/dist/types/reanalysis.js +0 -1
  753. package/dist/types/render-plan.d.ts +1 -2
  754. package/dist/utils/char-class.d.ts +2 -0
  755. package/dist/utils/char-class.js +6 -0
  756. package/dist/utils/record.d.ts +1 -0
  757. package/dist/utils/record.js +3 -0
  758. package/dist/webext-provider.d.ts +7 -0
  759. package/dist/webext-provider.js +56 -16
  760. package/package.json +1 -1
  761. package/dist/pipeline/head-tail/audit/types.d.ts +0 -7
  762. /package/dist/pipeline/head-tail/{audit/types.js → tail/predicate-root/integration/contracts.js} +0 -0
@@ -1,50 +1,50 @@
1
- import { rawSourceSurfaceText, rawSourceWarningSpan, UNOWNED_TAIL_FALLBACK_RAW_OP_KIND, unsupportedGrammarRawWarning } from "./fallback/unsupported-raw.js";
2
1
  import { isReanalysisFlipRequest } from "../types/reanalysis.js";
3
2
  import { resolveDeferredReanalysisProposals } from "./commitment/deferred-reanalysis.js";
4
3
  import { extractFeatures as auxExtractFeatures, nounCopula, nounCopulaConnective } from "../generator/aux-map.js";
5
4
  import { asIrregular, conjugate } from "../generator/conjugator.js";
6
5
  import { hasBatchim } from "../generator/hangul.js";
7
6
  import { isUnitSymbolSurface } from "../generator/korean-reading.js";
8
- import { allomorphHostTextFromAnchor, allomorphReadingForRealizedText, segmentIsAllomorphTransparent, segmentIsGeneratedSpacing, trailingNumeralHostKorean } from "./rendering/allomorph-host.js";
7
+ import { allomorphReadingForRealizedText, trailingNumeralHostKorean } from "./rendering/allomorph-host.js";
9
8
  import { applyInitialDueum } from "../generator/hanja.js";
10
- import { ALLOMORPH_MAP, mapParticle, NI_ABSORB_ENDINGS, SKIP_SUBPOS } from "../generator/particle-map.js";
9
+ import { mapParticle, NI_ABSORB_ENDINGS } from "../generator/particle-map.js";
11
10
  import { secondaryParticleCanonical } from "./particles/secondary-particle.js";
12
- import { PARTICLE_PAIRS, selectParticle } from "../generator/particles.js";
11
+ import { selectParticle } from "../generator/particles.js";
13
12
  import {} from "../generator/readings.js";
14
- import { legacySurfaceCompositionPlan, isNominalHeadTailChainRenderPlan, isPredicateHeadTailChainRenderPlan, renderPlanStartsWithShortNegation, spanLocalRenderPlanNode } from "../types/render-plan.js";
13
+ import { legacySurfaceCompositionPlan, isNominalHeadTailChainRenderPlan, isPredicateHeadTailChainRenderPlan, renderPlanStartsWithShortNegation } from "../types/render-plan.js";
15
14
  import { ANNOTATION_KEY_OOV, ANNOTATION_KEY_USER_DICT } from "../types/annotation.js";
16
- import { computeSourceCharSpan, computeSourceSpan, isLongVowelReductionAligned, withRuntimeTokenSourceSpan } from "../types/token.js";
17
- import { applySourceRubyReadingFragments } from "./source-ruby-replay.js";
18
- import { hasRentaikei, isTameReasonHeadContext, resolveNominalAttributiveEvidence } from "./attributive.js";
19
- import { buildClauseLayoutFromProto, buildProtoLayout, prenominalMarkerHeadReachAfterToken } from "./clause-layout/index.js";
15
+ import { hasRentaikei } from "./attributive.js";
16
+ import { buildClauseLayoutFromProto } from "./clause-layout/final-layout.js";
17
+ import { buildProtoLayout } from "./clause-layout/index.js";
18
+ import { prenominalMarkerHeadReachAfterToken } from "./clause-layout/prenominal-head-reach.js";
20
19
  import { collectRenyouVerbReadingProposals, reverifiedRenyouVerbReadings, sameRenyouVerbReadingFacts } from "./clause-layout/renyou-verb-reading.js";
21
20
  import { collectWhitespaceAttributiveReadingProposals, reverifiedWhitespaceAttributiveReadings, sameWhitespaceAttributiveReadingFacts } from "./clause-layout/whitespace-attributive-reading.js";
22
21
  import { ownedSelectedFrameSlotFills } from "./commitment/semantic-frame.js";
23
22
  import { buildStructuralRelationGraph } from "./structural-relation/collect.js";
24
- import { collectBareKaQuestionContentRelations, quoteStructuralRelationAt, quoteStructuralRelationIndex } from "./structural-relation/quote.js";
25
- import { canonicalReformulationMarkerRelationIndex, isKaDouKaMarker, isWhIndefiniteKaMarker, terminalQuestionKaRelationAt } from "./head-tail/boundary/ka-ownership.js";
26
- import { looksEmbeddedQuestionKaNominalizedBoundary } from "./quote/embedded-question.js";
27
- import { applyStructuralRelationRender, defaultStructuralRelationRenderConfig, projectPredicateHeadTailAttributivePlan, relationSourceUnitSequenceParts, structuralRelationRenderTokenSpans } from "./structural-relation/render.js";
28
- import { isAdnominalCopulaToken, isUnrealizableCopulaPoliteAuxiliaryMood } from "./head-tail/tail/predicate-root/classifiers/tokens.js";
29
- import { tryResolveKonosonoUchi, tryResolveMamaDewa, tryFixRenyouVerbNoun, tryFixSentenceFinalDore, tryMergeAdverbialShite, tryRescueSentenceInitialNandes, tryRescueSentenceInitialToiuWakeda, tryRescueSentenceInitialToiuWakede, tryResolveDemonstrativeTame, tryResolveDonnaniConcessive, tryResolveDoushita, tryResolveDoushitemo, tryResolveDoushiyou, tryResolveNiOujiResponse, tryResolveSentenceInitialTokoroDiscourse, niOujiResponsePrevToken } from "./fallback/collocation-rescue.js";
23
+ import { collectBareKaQuestionContentRelations } from "./structural-relation/quote-question-content.js";
24
+ import { quoteStructuralRelationIndex } from "./structural-relation/quote.js";
25
+ import { canonicalReformulationMarkerRelationIndex, isWhIndefiniteKaMarker } from "./head-tail/boundary/ka-ownership.js";
26
+ import { applyStructuralRelationRender, defaultStructuralRelationRenderConfig, structuralRelationRenderTokenSpans } from "./structural-relation/render.js";
27
+ import { projectPredicateHeadTailAttributivePlan } from "./structural-relation/render-attributive.js";
28
+ import { relationSourceUnitSequenceParts } from "./structural-relation/render-source-sequence.js";
29
+ import { isAdnominalCopulaToken } from "./head-tail/tail/predicate-root/classifiers/tokens.js";
30
+ import { tryResolveKonosonoUchi, tryResolveMamaDewa, tryFixRenyouVerbNoun, tryFixSentenceFinalDore, tryMergeAdverbialShite, tryRescueSentenceInitialNandes, tryRescueSentenceInitialToiuWakeda, tryRescueSentenceInitialToiuWakede, tryResolveDemonstrativeTame, tryResolveDonnaniConcessive, tryResolveDoushita, tryResolveDoushitemo, tryResolveDoushiyou, tryResolveNiOujiResponse, tryResolveSentenceInitialTokoroDiscourse } from "./fallback/collocation-rescue.js";
30
31
  import { PipelineCompoundMixin } from "./compounds/index.js";
31
32
  import { contentResultKoreanCache, contentResultKoreanPos } from "./content-types.js";
32
33
  import { PipelineContentResolverMixin } from "./content-resolver.js";
33
- import { lookupConditionMatches, resolveContext, translationFrameAlternativeMatchesWithoutLayout } from "./context.js";
34
+ import { resolveContext, translationFrameAlternativeMatchesWithoutLayout } from "./context.js";
34
35
  import { honorificClusterLookupsFrom, honorificClusterSuffixDecision } from "./honorific-nominal-cluster.js";
35
- import { PREDICATE_POS, resolveCasePreference } from "./deferred-commitment.js";
36
- import { candidateSetCandidates, candidateSetMembers, candidateSetSize, commitmentLaneCandidateSet, createSourceCandidateSet, dropCandidate, isResolvedCandidateSet, stagedCandidate, transformCandidateSet } from "./source-candidate-set.js";
36
+ import { PREDICATE_POS } from "./commitment/types.js";
37
+ import { resolveCasePreference } from "./commitment/particle-roles.js";
38
+ import { candidateSetSize, createSourceCandidateSet, stagedCandidate } from "./source-candidate-set.js";
37
39
  import { resolveHostlessInterjectionAt, tryResolveDemoDiscourseConnective } from "./demo-discourse.js";
38
- import { readExtentPhraseAt } from "./semantics/extent-phrase.js";
39
- import { argumentNounLookupForms } from "./semantics/helpers.js";
40
- import { JP_POS_TO_KR, NONPREDICATE_CONTENT_POS_BITS, PASSTHROUGH_POS_BITS, PLACE_ADMIN_SUFFIX, PipelineFallbackMixin, isLexicalSymbolTokenAt, isNonLexicalSymbolTokenAt, isNonLexicalSymbolToken, splitFallbackKorean, tryNumeralCompound } from "./fallback/index.js";
40
+ import { JP_POS_TO_KR, NONPREDICATE_CONTENT_POS_BITS, PASSTHROUGH_POS_BITS, PLACE_ADMIN_SUFFIX, PipelineFallbackMixin, isNonLexicalSymbolTokenAt, isNonLexicalSymbolToken, splitFallbackKorean, tryNumeralCompound } from "./fallback/index.js";
41
41
  import { buildFunctionalMinimalFallbackUnits as buildFunctionalMinimalFallbackUnitsPorted, buildLeadingFunctionalPrefixUnits as buildLeadingFunctionalPrefixUnitsPorted } from "./fallback/functional.js";
42
42
  import { applyBenefactiveRecipientOrdering } from "./semantics/benefactive-ordering-runtime.js";
43
43
  import { applyKeijoujiDeAdverbSemantics, applyKeijoujiDeIruStateSemantics, applyKeijoujiKanouDeSemantics } from "./semantics/keijouji-de-runtime.js";
44
44
  import { isTerminalYoSfpSurface } from "./semantics/sfp-surface.js";
45
- import { INFLECTABLE_BITS, NOMINAL_BITS, POS0, POS01, POS012, POS0_NAME, POS1, POS4, POS5A, isBareNaAdjSet, isNaAdjectiveDerivationalSuffix, isNaAdjCapableNoun, pos0in, posToString, 記号, 係助詞, 助詞_係助詞, 形状詞, 形状詞_助動詞語幹, 形容詞0, 終止形_一般, 終助詞, 助詞, 助詞_格助詞, 助詞_終助詞, 助動詞, 助動詞_タ, 助動詞_ダ, 助動詞_デス, 助動詞_ナイ, 助動詞_ヌ, 助動詞_マス, 接頭辞, 接尾辞, 接尾辞_形容詞的, 代名詞, 動詞, 非自立可能, 副詞, 副助詞, 補助記号, 名詞, 名詞_数詞, 名詞_普通名詞, 名詞_固有名詞, 名詞_固有名詞_地名, 連体詞, 連用形_, 連用形_一般, 連用形_促音便, 감탄사, 관형사, 대명사, 동사, 명사, 부사, 수사, 접두사, 접미사, 접속사, 조사, 형용사, 기호, 구, isCounterCapableToken, isSymbolCharacterToken, isNumeralToken, } from "../types/pos.js";
45
+ import { NOMINAL_BITS, POS0, POS01, POS012, POS0_NAME, POS1, POS4, POS5A, isNaAdjectiveDerivationalSuffix, isNaAdjCapableNoun, pos0in, posToString, 記号, 係助詞, 助詞_係助詞, 形状詞, 形状詞_助動詞語幹, 形容詞0, 終助詞, 助詞, 助詞_格助詞, 助動詞, 助動詞_ダ, 助動詞_デス, 助動詞_ナイ, 助動詞_ヌ, 接頭辞, 接尾辞, 代名詞, 動詞, 非自立可能, 副詞, 副助詞, 補助記号, 名詞, 名詞_固有名詞_地名, 連体詞, 連用形_, 감탄사, 관형사, 동사, 명사, 부사, 수사, 접두사, 접미사, 접속사, 조사, 형용사, 기호, 구, isCounterCapableToken, isSymbolCharacterToken, isNumeralToken } from "../types/pos.js";
46
46
  export { NEG_MARKERS } from "./semantics/keijouji-de-runtime.js";
47
- import { dearuNounRashiiRenderPlan, isSfpSkipSurface, sfpNodeYieldsToAuthoredQuestion, trailingSfpEffectAfterFirst } from "./semantics/grammar-runtime.js";
47
+ import { dearuNounRashiiRenderPlan } from "./semantics/grammar-runtime.js";
48
48
  import { isContentAdmissionToken } from "./lookup-tables.js";
49
49
  import { collectLexicalParticleBoundaryClaims } from "./lexical-particle-boundary-claims.js";
50
50
  import { collectLexicalRenyouHeadClaims } from "./lexical-renyou-head-claims.js";
@@ -52,16 +52,15 @@ import { collectLexicalNominalHeadClaims } from "./lexical-nominal-head-claims.j
52
52
  import { collectAuxTokens, runtimeTokensFromMatcher } from "./matchers.js";
53
53
  import { matchCopulaNegation } from "./rules/copula.js";
54
54
  import { focusBodyOverNegativeScopeBridgeAt } from "./head-tail/tail/predicate-root/matchers/scope-bridge.js";
55
- import { quantityApproximationMarker, tryMergeNumericAgeNishite, tryMergeNumericShite, tryNumeral } from "./semantics/numeric.js";
55
+ import { quantityApproximationMarker, tryMergeNumericAgeNishite, tryMergeNumericShite } from "./semantics/numeric.js";
56
56
  import { lookupCarrierIdiom } from "./semantics/carrier-idiom.js";
57
- import { selectedCommitmentCandidate, selectedSpanTranslation } from "./commitment/span-evidence.js";
58
57
  import { ParticleCtx, ParticleDecision } from "./particles/index.js";
59
58
  import { isUchiTemporalHeadToken } from "./particles/common.js";
60
59
  import { temporalIntervalVariantHeadedAt } from "./head-tail/tail/predicate-root/temporal-interval-head.js";
61
60
  import { isSahenBoundVerbAfterSahen } from "./predicate-helpers.js";
62
61
  import { collectEllipticRequestFragmentAffiliations, collectInterveningClauseAffiliations, sameLexicalAdverbialAffiliation } from "./clause-layout/lexical-adverbial-affiliation.js";
63
62
  import { activeProtoLayout, useActiveProtoLayout } from "./clause-layout/proto-state.js";
64
- import { convertPunctuationSegments, punctuationOpensWordBoundaryAfter } from "./rendering/punctuation.js";
63
+ import { convertPunctuationSegments } from "./rendering/punctuation.js";
65
64
  import { punctuationSegmentsForTargetSegments, renderTargetSegmentsText } from "./rendering/target-segment-text.js";
66
65
  import { adverbialToCapableKeijoujiHost, tariKeijoujiAdverbialToEvidence } from "./semantics/tari-adverbial-marker.js";
67
66
  import { applyQuoteHostFrameRendering } from "./quote/host-runtime.js";
@@ -71,8 +70,7 @@ import { copulaFocusAdjunctRelationAt } from "./head-tail/integration/copula-foc
71
70
  import { shouldInsertSpaceBetweenSurfaceParts } from "./nominal-phrase-surface.js";
72
71
  import { tryBuildSemanticCarrierPredicateDispatchCursor } from "./head-tail/integration/semantic-carrier-predicate.js";
73
72
  import { tryBuildParticleHeadConsumption } from "./particle-head-dispatch.js";
74
- import { isNanteQuotativeMarker, resolveTteParticleAllomorphKey } from "./semantics/marker-roles.js";
75
- import { caseParticleMarkerRelationForToken, dewaScopeBridgeRelationAt, kaMarkerRelationAt, nominalLinkMarkerRelationAt, predicateNominalizerRelationForToken, pronominalNoMarkerRelationForToken, registeredClauseConnectiveRelationForToken } from "./head-tail/boundary/marker.js";
73
+ import { caseParticleMarkerRelationForToken, nominalLinkMarkerRelationAt, pronominalNoMarkerRelationForToken } from "./head-tail/boundary/marker.js";
76
74
  import { applyHeadedPlanTrailingCopula, tryBuildNominalFrameCopulaChain, withParticleStemProjection } from "./head-tail/integration/nominal-assembly.js";
77
75
  import { tryBuildParticlePhraseCopulaChain } from "./head-tail/integration/particle-phrase-copula.js";
78
76
  import { particlePhraseCopulaHostBinding } from "./clause-layout/particle-phrase-copula.js";
@@ -82,9 +80,9 @@ import { nominalPredicateCommitContext } from "./head-tail/head/adapters/nominal
82
80
  import { applyKotoWoWishComplement } from "./head-tail/head/adapters/nominal/wish-complement-runtime.js";
83
81
  import { applyQuotedKotoTopicContraction } from "./head-tail/head/adapters/nominal/quoted-nominal-runtime.js";
84
82
  import { nominalTailChainAssemblyHint } from "./head-tail/head/adapters/nominal/commit.js";
85
- import { tryParseNominalFrame } from "./head-tail/head/adapters/nominal/parser.js";
86
83
  import { tryBuildNominalFrameMarkerAdapterPlan, nominalTailChainAttachLeft, nominalTailChainKoreanPos } from "./head-tail/head/adapters/nominal/integration.js";
87
- import { realizeRenderPlan, realizeRenderPlanWithTrace, renderPlanContainsAttributiveModifier, replaceLemmaRenderPlan } from "./rendering/render-plan.js";
84
+ import { realizeRenderPlan, realizeRenderPlanWithTrace } from "./rendering/render-plan.js";
85
+ import { renderPlanContainsAttributiveModifier } from "./rendering/render-plan-inspect.js";
88
86
  import { realizeNumeral } from "../generator/numeral-realization.js";
89
87
  import { attachParticleRenderPlan } from "./rendering/particle-plan.js";
90
88
  import { canHostTrailingCopula, canHostTrailingCopulaConnective, isCopulaSupportChainStartAt, isPrefaceConnectiveCopulaHostAt, matchCopulaTailWithOptionalConditional, matchOrphanCopulaConn, matchOrphanNanoconn, trailingCopulaConnectiveTail, trailingCopulaConnectiveTailDetailed, trailingCopulaSfpTail } from "./semantics/copula-tail-runtime.js";
@@ -94,543 +92,52 @@ import { PRONOUN_POSSESSIVE_CONTRACTIONS, PRONOUN_SUBJECT_CONTRACTIONS, tryBuild
94
92
  export { PRONOUN_POSSESSIVE_CONTRACTIONS, PRONOUN_SUBJECT_CONTRACTIONS } from "./pronominal-no-dispatch.js";
95
93
  import { buildTailParserFallbackAssemblyDescriptor, buildTailParserFailureFallbackProvenance, buildContentHeadTailAssemblyBridge, buildEllipticPropositionModalTailDescriptor, buildEllipticPropositionQuoteTailDescriptor, buildFormulaicApologyPredicateDescriptor, buildHonorificFormulaicTailDescriptor, buildHonorificRequestQuoteTailDescriptor, buildTailOwnerCandidatePayloadSource } from "./head-tail/integration/tail-assembly.js";
96
94
  import { hydrateTailChainRootWithHeadMetadata, tailChainPreviousSahenNounAbsorptionStart } from "./head-tail/tail/predicate-root/head-hydration.js";
97
- import { isBareNominalQuoteStart, isContestedZeroTailClaimCoordinate, nounPhraseCopulaPredicateStartKind, tailChainHeadProfile } from "./head-tail/tail/predicate-root/integration.js";
95
+ import { isBareNominalQuoteStart, nounPhraseCopulaPredicateStartKind } from "./head-tail/tail/predicate-root/integration/head-admission.js";
96
+ import { isContestedZeroTailClaimCoordinate, tailChainHeadProfile } from "./head-tail/tail/predicate-root/integration.js";
98
97
  import { copulaStartsPredicateAt } from "./head-tail/tail/predicate-root/integration/readiness.js";
99
- import { auxOpCarriesCommandIllocution, auxOpsInTailNode } from "./head-tail/tail/predicate-root/inspect.js";
100
98
  import { probeProductionDispatch } from "./head-tail/tail/predicate-root/production-registry.js";
101
99
  import { attachRegisteredHeadedAssemblyUnitPlanLifecycle, runRegisteredHeadedContentPlanLifecycle } from "./head-tail/lifecycle/registry.js";
102
100
  import { recordTailChainContentPassTrace, recordTailParserFailureTrace } from "./head-tail/tail/predicate-root/trace.js";
103
101
  import { WH_INDEFINITE_DEMO_HOSTS } from "./head-tail/data/semantic-helper-sets.js";
104
102
  import { getReferentTokenBeforeParticle, isQuotationContext, isQuotedJudgmentPassiveQuotationContext, nextVerbDictForm } from "./semantics/helpers.js";
105
- import { isCopulaAuxToken, resolveCopulaAdj, terminalQuestionTail } from "./semantics/copula-tail-runtime.js";
106
- import { SEPARATION_OPENS_BOUNDARY, nextNonSpaceIndex, previousNonSpaceIndex, separatedAs } from "./clause-layout/trivia.js";
103
+ import { isCopulaAuxToken, terminalQuestionTail } from "./semantics/copula-tail-runtime.js";
104
+ import { nextNonSpaceIndex, previousNonSpaceIndex } from "./clause-layout/trivia.js";
107
105
  import { TokenCursor } from "./token-cursor.js";
108
106
  import { hasTerminalSentenceMark } from "./semantics/terminal-runtime.js";
109
107
  import { TraceCollector, TraceEvent } from "./trace.js";
110
- import { commitWinner, hasTranslationAccess, winner, winnerKorean, winnerKoreanPos } from "./translation/access.js";
108
+ import { hasTranslationAccess, winner, winnerKorean, winnerKoreanPos } from "./translation/access.js";
111
109
  import { metadataAdverbial } from "./translation/metadata.js";
112
- import { allNonWhitespaceTokensCovered, clearGeneratedSurfaceCache, collectAnnotationKeys, collectUncoveredTokenIndices, emitsOutput, findBatchimSource, findUnitCoveringIndex, FunctionalKind, TokenUnitIndex, TranslationUnit, UnitType, phase3InvariantHolds } from "./translation/unit.js";
110
+ import { allNonWhitespaceTokensCovered, clearGeneratedSurfaceCache, collectUncoveredTokenIndices, emitsOutput, findBatchimSource, findUnitCoveringIndex, FunctionalKind, TokenUnitIndex, TranslationUnit, UnitType, phase3InvariantHolds, lastContentUnit, lastOutputUnit, absorbIntoPrecedingUnit } from "./translation/unit.js";
113
111
  import { quoteMarkerRelationAt } from "./head-tail/boundary/quote-marker.js";
114
112
  import { isQuestionParticleKaToken, questionContentPunctuationBridgeRelationAt } from "./head-tail/boundary/marker.js";
115
- import { hasHardTerminalPunctuationClass, hasHardTerminalPunctuationRelation, hasWeakPunctuationRelation, isHardTerminalPunctuationToken, isWeakPunctuationToken, isTrailingPunctuationToken, isTrailingPunctuationSurface, carriesLexicalSurface } from "./head-tail/boundary/punctuation.js";
116
- import { isParentheticalClosingToken, parentheticalSpanEndingAt, OPENING_BRACKET_BY_CLOSING } from "./head-tail/boundary/parenthetical.js";
117
- import { moraStutterRepeatIndex } from "./disfluency/stutter-prefix.js";
118
- import { teDeContinuationRelationAt } from "./head-tail/tail/postverb-tail-classifier.js";
119
- import { createConnectiveOp } from "./head-tail/tail/predicate-root/op-builders.js";
120
- function applyMoraStutterPrefixToGeneratedText(unit, text) {
121
- const stutter = unit.jpHead.stutterPrefix;
122
- if (stutter === undefined || stutter.repeatCount <= 0) {
123
- return text;
124
- }
125
- const index = moraStutterRepeatIndex(text);
126
- if (index === null) {
127
- return text;
128
- }
129
- const char = String.fromCodePoint(text.codePointAt(index));
130
- const prefix = Array.from({ length: stutter.repeatCount }, () => `${char}, `).join("");
131
- return `${text.slice(0, index)}${prefix}${text.slice(index)}`;
132
- }
133
- function isKeijoujiVerbObjectHost(token) {
134
- return token !== undefined && isBareNaAdjSet(token);
135
- }
136
- function isClauseConnectiveEmphasisParticle(cursor) {
137
- const token = cursor.current();
138
- if (token?.surface !== "こそ" || (token.pos & POS0) !== 助詞) {
139
- return false;
140
- }
141
- return registeredClauseConnectiveRelationForToken(cursor.tokens[cursor.pos - 1], cursor.pos - 1, {
142
- acceptedSurfaces: ["から"],
143
- acceptedParticleSubtypes: ["接続助詞", "格助詞"],
144
- consumers: ["assembler"]
145
- }) !== null;
146
- }
147
- export const SUFFIX_NOUN_CHARS = new Set(Array.from("図集論伝記書誌表巻編"));
148
- export function isSuffixNounUnit(unit) {
149
- const surface = unit.jpHead.surface;
150
- const pos = unit.jpHead.pos;
151
- return surface.length === 1 && SUFFIX_NOUN_CHARS.has(surface) && (pos & POS012) === 名詞_普通名詞;
152
- }
153
- export function prevIsNominalUnit(unit) {
154
- const pos = unit?.jpHead.pos ?? 0;
155
- return (pos & POS01) === 名詞_普通名詞 || (pos & POS01) === 名詞_固有名詞;
156
- }
157
- export function resolveTteParticle(cursor, lookups) {
158
- return resolveTteParticleAllomorphKey(cursor, lookups);
159
- }
160
- export function resolveNante(cursor, lookups) {
161
- return isNanteQuotativeMarker(cursor, lookups);
162
- }
113
+ import { hasHardTerminalPunctuationClass, isHardTerminalPunctuationToken, isWeakPunctuationToken } from "./head-tail/boundary/punctuation.js";
114
+ import { allomorphSourceFromTargetSegments, isParticleKey, tracedAllomorphSurface } from "./rendering/segment-allomorph.js";
115
+ import { annotatedSegmentsWithSpacerKeys, applyTransparentPauseBoundaryAnnotationKeys, collectAnnotationKeysForTargetSegment } from "./rendering/segment-annotation-keys.js";
116
+ import { attachSourceInternalBoundaryTargetsToTargetSegments, interUnitSpaceSegment, lastOutputSegmentText, markConsumedWordBoundaryOnLastSegment, preserveOutputTextInTargetSegments, removeTrailingQuestionFromLastSegment, replaceLastUnitSegmentText, targetSegmentForUnit } from "./rendering/target-segment-build.js";
117
+ import { sourceSpanForTokenIndexes } from "./source-coordinate.js";
118
+ import { applyMoraStutterPrefixToGeneratedText, isSuffixNounUnit, prevIsNominalUnit, continuesReduplication, hasUserDictOverride } from "./rendering/unit-surface.js";
119
+ import { isKeijoujiVerbObjectHost, applyTailParserFallbackDescriptorToSpan, closeUnownedTailFallbackSpanToRaw, contentSpanCoversIndex, applySourceCompoundContinuationToContentMap, makeAssemblyContentSpan, contentMapRepairSeed, selectedIntrinsicHonorificMetadata, contentHeadDispatchLimit, committedLookupEntry } from "./assembly-content-span.js";
120
+ import { isClauseConnectiveEmphasisParticle, committedParticleAssignmentAt, isVocativeYo, particleAllomorphKey } from "./assembler/particle-helpers.js";
121
+ import { prefixAttachRightForToken, modifiedHeadNounMatchingSelectedSense, kataVerbHostAttributivePlan, suffixNominalizerAlreadyLexicalizedInPreviousUnit, rewriteFunctionalAdjectivalSuffixHostToNominalized, suffixRenderPlanFromCommittedEntry } from "./assembler/affix-helpers.js";
122
+ import { numeralAttachedSymbolHead, finalizeExtentPostpositionSpan, tryContentNumeral } from "./assembler/quantity-spans.js";
123
+ import { koreanOverrideRenderPlan } from "./assembler/content-override.js";
124
+ import { canCarryCopulaHostPlan, decorationSurfaceParts, isQuoteClosingCopulaHostAt, isNominalizedQuestionCopulaComplementAt, politeCopulaSupportTailIsRealizable, nominalDakeCopulaHostUnit, punctuatedCopulaTailHostUnit, isEllipticConfirmationParticle, isNaniDeConfirmationVeto, matchEllipticConfirmationTerminal, trailingCopulaConnectiveSuffix, nominalDakeTameReasonTail } from "./assembler/copula-helpers.js";
125
+ import { runtimeTokenFromPreprocess } from "./preprocess/runtime-token-from-preprocess.js";
126
+ import { withMergedSourcePosition, withSourcePositionFromConsumed, collocationEmissionPreservesSourceRuby, shouldSkipCollocation } from "./preprocess/collocation-emission.js";
127
+ import { nominalLightVerbObjectLinkAt, rewriteCarrierIdiomRenderPlan } from "./assembler/light-verb-projection.js";
128
+ import { isAssemblerTerminalQuestionKa, applyBareQuestionRenderPlan, applyBareQuestionToRenderPlan } from "./assembler/question-plan.js";
129
+ import { trySplitNandeReasonSpan } from "./assembler/nande-reason.js";
130
+ import { applyCopulaFocusAdjunctRenderPlan } from "./assembler/copula-focus-plan.js";
131
+ import { isSentencePunctuationUnit, moodPunctuationAnchorAt, reconcileTerminalPunctuationUnit, authoredRunClosesWithQuestion, terminalPeriodIsRedundant, isClauseCommaPunctuationUnit } from "./rendering/terminal-unit-punctuation.js";
132
+ import { adoptLexicalLayoutHypothesis, sameLexicalAdverbialAffiliationFacts, lexicalParticleOwnershipHypothesisSlots, lexicalParticleInitialOwnershipChoices, cloneAssemblyContentMap, applyLexicalParticleOwnershipChoice, lexicalParticleConsumedIndicesForChoices, lexicalParticleLayoutSemanticSignature, lexicalParticleChoiceRank, compareLexicalParticleSlotRanks, lexicalParticleChoiceIsRealized } from "./assembler/lexical-layout-hypothesis.js";
133
+ import { harvestFailClosedSpanWarnings } from "./translation/warnings.js";
134
+ import { isQuoteUtteranceClauseEndToken, quoteMarkerFocusRealizationAt, quotedDesireRenderPlan } from "./assembler/quote-helpers.js";
135
+ import { absorbOrphanShuujoshi, absorbOrphanHojokigou } from "./fallback/orphan-unit-absorption.js";
163
136
  const PREFIX_RUN_HOST_POS_BITS = (1 << 名詞) | (1 << 代名詞) | (1 << 動詞) | (1 << 形容詞0) | (1 << 形状詞) | (1 << 連体詞);
164
137
  const PREFIX_RUN_BLOCKED_HOST_POS_BITS = (1 << 補助記号) | (1 << 記号) | (1 << 助詞) | (1 << 助動詞);
165
138
  const PREFIX_RUN_BRIDGE_PARTICLE_POS1 = new Set([係助詞, 副助詞]);
166
139
  const REGISTER_NEUTRAL_BUILD_FORMAL = false;
167
140
  const HOSTLESS_INTERJECTION_LEXEME_POS = ["感動詞", "一般", "*", "*"];
168
- function continuesReduplication(unit, previous, text, tokens) {
169
- if (previous === undefined || tokens === undefined || unit.jpIndices.length === 0 || previous[1] !== text) {
170
- return false;
171
- }
172
- const head = tokens[Math.min(...unit.jpIndices)];
173
- return head?.sourceReduplication === true && previous[0].jpIndices.includes(Math.min(...unit.jpIndices) - 1);
174
- }
175
- function prefixAttachRightForToken(token, tokens, index, defaultAttachRight) {
176
- if (token.dictionaryForm === "約" || token.surface === "約") {
177
- const next = nextNonSpaceIndex(tokens, index + 1, tokens.length);
178
- if (next !== null && ((tokens[next]?.pos ?? 0) & POS01) === 名詞_数詞) {
179
- return false;
180
- }
181
- }
182
- return defaultAttachRight;
183
- }
184
- function targetSegmentKindForUnit(unit) {
185
- if (unit.unitType === UnitType.SYMBOL) {
186
- return "punctuation";
187
- }
188
- if (unit.unitType === UnitType.FUNCTIONAL) {
189
- return unit.functionalKind === FunctionalKind.PARTICLE || unit.allomorphKey !== null || unit.particleRole !== null
190
- ? "particle"
191
- : "connective";
192
- }
193
- if (unit.unitType === UnitType.NUMERAL) {
194
- return "lexeme";
195
- }
196
- if (unit.renderPlan?.kind === "legacySurfaceComposition" || unit.provenance === "fallback" || unit.provenance === "legacy_tail") {
197
- return "fallback";
198
- }
199
- if (unit.renderPlan?.kind === "headTailChain") {
200
- return "modal";
201
- }
202
- return "lexeme";
203
- }
204
- function projectionConfidenceForUnit(unit) {
205
- if (unit.provenance === "legacy_tail" || unit.provenance === "fallback") {
206
- return "fallback";
207
- }
208
- if (unit.renderPlan === null) {
209
- return "semantic";
210
- }
211
- return "owner";
212
- }
213
- function targetSegmentForUnit(unit, text, options = {}) {
214
- const sourceSpan = unit.sourceSpan;
215
- const sourceInternalBoundaryTargets = sourceInternalBoundaryTargetsForUnit(unit);
216
- const symbolIsTransparent = unit.unitType === UnitType.SYMBOL && !isUnitSymbolSurface(text);
217
- const anchorsAllomorph = !symbolIsTransparent && sourceSpan !== null && unit.allomorphKey === null;
218
- return {
219
- text,
220
- sourceSpan,
221
- boundaryBefore: sourceSpan === null ? null : {
222
- beforeOrdinal: sourceSpan.startOrdinal - 1 >= 0 ? sourceSpan.startOrdinal - 1 : null,
223
- afterOrdinal: sourceSpan.startOrdinal
224
- },
225
- boundaryAfter: sourceSpan === null ? null : {
226
- beforeOrdinal: sourceSpan.endOrdinal - 1,
227
- afterOrdinal: sourceSpan.endOrdinal
228
- },
229
- unit,
230
- renderPlanKind: unit.renderPlan?.kind ?? null,
231
- kind: targetSegmentKindForUnit(unit),
232
- attachLeft: unit.attachLeft,
233
- attachRight: unit.attachRight,
234
- transparentForAllomorph: symbolIsTransparent,
235
- ...(symbolIsTransparent
236
- ? { allomorphRole: "transparent" }
237
- : anchorsAllomorph
238
- ? { allomorphRole: "source_anchor" }
239
- : {}),
240
- ...(options.allomorphSourceSpan === undefined ? {} : {
241
- allomorphSourceSpan: options.allomorphSourceSpan
242
- }),
243
- ...(sourceInternalBoundaryTargets.length === 0 ? {} : { sourceInternalBoundaryTargets }),
244
- projectionConfidence: projectionConfidenceForUnit(unit)
245
- };
246
- }
247
- function sourceInternalBoundaryTargetsForUnit(unit) {
248
- const boundaries = unit.jpHead.sourceCompoundProjectionBoundaries ?? [];
249
- if (boundaries.length === 0) {
250
- return [];
251
- }
252
- return boundaries.map((boundary) => ({
253
- sourceBoundary: boundary.sourceBoundary,
254
- ...(boundary.leftTargetText === undefined ? {} : { leftTargetText: boundary.leftTargetText }),
255
- ...(boundary.rightTargetText === undefined ? {} : { rightTargetText: boundary.rightTargetText }),
256
- ...(boundary.leftSplitTargetText === undefined ? {} : { leftSplitTargetText: boundary.leftSplitTargetText }),
257
- ...(boundary.rightSplitTargetText === undefined ? {} : { rightSplitTargetText: boundary.rightSplitTargetText })
258
- }));
259
- }
260
- function attachSourceInternalBoundaryTargetsToTargetSegments(segments, unit) {
261
- const sourceInternalBoundaryTargets = sourceInternalBoundaryTargetsForUnit(unit);
262
- if (sourceInternalBoundaryTargets.length === 0) {
263
- return [...segments];
264
- }
265
- return segments.map((segment) => {
266
- if (segment.unit !== unit) {
267
- return segment;
268
- }
269
- return {
270
- ...segment,
271
- sourceInternalBoundaryTargets
272
- };
273
- });
274
- }
275
- function interUnitSpaceSegment() {
276
- return {
277
- text: " ",
278
- sourceSpan: null,
279
- boundaryBefore: null,
280
- boundaryAfter: null,
281
- unit: null,
282
- renderPlanKind: null,
283
- kind: "punctuation",
284
- attachLeft: false,
285
- attachRight: false,
286
- transparentForAllomorph: true,
287
- allomorphRole: "transparent",
288
- projectionConfidence: "exact"
289
- };
290
- }
291
- function sourceAlignedAllomorphSourceIndexFromTargetSegments(segments, unit) {
292
- const particleSpan = unit.sourceSpan;
293
- if (particleSpan === null) {
294
- return -1;
295
- }
296
- let bestIndex = -1;
297
- let bestEndOrdinal = -1;
298
- for (const [index, segment] of segments.entries()) {
299
- if (segmentIsAllomorphTransparent(segment) || segment.sourceSpan === null) {
300
- continue;
301
- }
302
- if (segment.allomorphRole !== "source_anchor") {
303
- continue;
304
- }
305
- const overlapsParticleStart = segment.sourceSpan.startOrdinal <= particleSpan.startOrdinal &&
306
- segment.sourceSpan.endOrdinal > particleSpan.startOrdinal;
307
- const strictlyBeforeParticle = segment.sourceSpan.endOrdinal <= particleSpan.startOrdinal;
308
- if (!overlapsParticleStart && !strictlyBeforeParticle) {
309
- continue;
310
- }
311
- const rank = overlapsParticleStart
312
- ? 1_000_000_000 + segment.sourceSpan.startOrdinal
313
- : segment.sourceSpan.endOrdinal;
314
- if (rank < bestEndOrdinal) {
315
- continue;
316
- }
317
- bestIndex = index;
318
- bestEndOrdinal = rank;
319
- }
320
- return bestIndex;
321
- }
322
- function restoredIslandAllomorphHost(islandHosts, segments, unit) {
323
- const particleStartOrdinal = unit.sourceSpan?.startOrdinal ?? null;
324
- if (islandHosts.length === 0 || particleStartOrdinal === null) {
325
- return null;
326
- }
327
- const overlapsParticleStart = segments.some((segment) => !segmentIsAllomorphTransparent(segment) &&
328
- segment.sourceSpan !== null &&
329
- segment.sourceSpan.startOrdinal <= particleStartOrdinal &&
330
- segment.sourceSpan.endOrdinal > particleStartOrdinal);
331
- if (overlapsParticleStart) {
332
- return null;
333
- }
334
- let nearest = null;
335
- for (const island of islandHosts) {
336
- if (island.text.length === 0 || island.endOrdinal > particleStartOrdinal) {
337
- continue;
338
- }
339
- if (nearest === null || island.startOrdinal > nearest.startOrdinal) {
340
- nearest = island;
341
- }
342
- }
343
- if (nearest === null) {
344
- return null;
345
- }
346
- const realizedAfterIsland = segments.some((segment) => !segmentIsAllomorphTransparent(segment) &&
347
- segment.sourceSpan !== null &&
348
- segment.sourceSpan.startOrdinal >= nearest.endOrdinal &&
349
- segment.sourceSpan.endOrdinal <= particleStartOrdinal);
350
- if (realizedAfterIsland) {
351
- return null;
352
- }
353
- return islandIsAppendedNotation(segments, lastRealizedFragment(segments)) ? null : nearest;
354
- }
355
- function lastRealizedFragment(segments) {
356
- for (let index = segments.length - 1; index >= 0; index -= 1) {
357
- const segment = segments[index];
358
- if (segment !== undefined && !segmentIsGeneratedSpacing(segment)) {
359
- return segment;
360
- }
361
- }
362
- return undefined;
363
- }
364
- function islandIsAppendedNotation(segments, previous) {
365
- if (previous === undefined) {
366
- return false;
367
- }
368
- if (carriesLexicalSurface(previous.text) || isUnitSymbolSurface(previous.text)) {
369
- return true;
370
- }
371
- const closingChar = previous.text.trimEnd().at(-1);
372
- if (closingChar === undefined ||
373
- !isTrailingPunctuationSurface(closingChar) ||
374
- punctuationOpensWordBoundaryAfter(closingChar)) {
375
- return false;
376
- }
377
- const word = trailingRealizedWord(segments);
378
- const openingChar = OPENING_BRACKET_BY_CLOSING.get(closingChar) ?? closingChar;
379
- if (openingChar !== closingChar) {
380
- return word.includes(openingChar);
381
- }
382
- return [...word].filter((char) => char === closingChar).length % 2 === 0;
383
- }
384
- function trailingRealizedWord(segments) {
385
- let word = "";
386
- for (let index = segments.length - 1; index >= 0; index -= 1) {
387
- const text = segments[index]?.text ?? "";
388
- const spaceAt = text.search(/\s(?![\s\S]*\s)/u);
389
- if (/\s/u.test(text)) {
390
- return text.slice(spaceAt + 1) + word;
391
- }
392
- word = text + word;
393
- }
394
- return word;
395
- }
396
- function allomorphSourceFromTargetSegments(segments, unit, islandHosts = []) {
397
- const island = restoredIslandAllomorphHost(islandHosts, segments, unit);
398
- if (island !== null) {
399
- return {
400
- text: island.text,
401
- sourceSpan: { startOrdinal: island.startOrdinal, endOrdinal: island.endOrdinal }
402
- };
403
- }
404
- const sourceAlignedIndex = sourceAlignedAllomorphSourceIndexFromTargetSegments(segments, unit);
405
- if (sourceAlignedIndex >= 0) {
406
- const sourceAlignedText = allomorphHostTextFromAnchor(segments, sourceAlignedIndex);
407
- if (sourceAlignedText.length > 0) {
408
- return {
409
- text: sourceAlignedText,
410
- sourceSpan: segments[sourceAlignedIndex]?.sourceSpan ?? null
411
- };
412
- }
413
- }
414
- for (let index = segments.length - 1; index >= 0; index -= 1) {
415
- const segment = segments[index];
416
- if (segment === undefined ||
417
- segmentIsAllomorphTransparent(segment)) {
418
- continue;
419
- }
420
- return { text: segment.text, sourceSpan: null };
421
- }
422
- return { text: "", sourceSpan: null };
423
- }
424
- function tracedAllomorphSurface(unit, allomorphSource) {
425
- const key = unit.allomorphKey;
426
- if (key === null) {
427
- return unit.korean;
428
- }
429
- if (!isParticleKey(key)) {
430
- throw new Error(`unknown particle key: ${key}`);
431
- }
432
- return selectParticle(allomorphSource.text, key, { register: unit.register });
433
- }
434
- function lastOutputSegmentIndex(segments) {
435
- for (let index = segments.length - 1; index >= 0; index -= 1) {
436
- const segment = segments[index];
437
- if (segment !== undefined && segment.text.length > 0 && !/^\s+$/u.test(segment.text)) {
438
- return index;
439
- }
440
- }
441
- return -1;
442
- }
443
- function lastOutputSegmentText(segments) {
444
- const index = lastOutputSegmentIndex(segments);
445
- return index < 0 ? "" : segments[index]?.text ?? "";
446
- }
447
- function replaceLastUnitSegmentText(segments, unit, text) {
448
- for (let index = segments.length - 1; index >= 0; index -= 1) {
449
- const segment = segments[index];
450
- if (segment?.unit !== unit) {
451
- continue;
452
- }
453
- segments[index] = { ...segment, text };
454
- return;
455
- }
456
- }
457
- function markConsumedWordBoundaryOnLastSegment(segments) {
458
- const index = lastOutputSegmentIndex(segments);
459
- const segment = index < 0 ? undefined : segments[index];
460
- if (segment === undefined) {
461
- return;
462
- }
463
- segments[index] = { ...segment, consumedWordBoundaryAfter: true };
464
- }
465
- function removeTrailingQuestionFromLastSegment(segments) {
466
- const index = lastOutputSegmentIndex(segments);
467
- const segment = index < 0 ? undefined : segments[index];
468
- if (segment === undefined || !segment.text.endsWith("?")) {
469
- return;
470
- }
471
- segments[index] = { ...segment, text: segment.text.slice(0, -1) };
472
- }
473
- function preserveOutputTextInTargetSegments(segments, expectedText) {
474
- const actualText = segments.map(segment => segment.text).join("");
475
- if (actualText === expectedText) {
476
- return [...segments];
477
- }
478
- if (segments.length === 1) {
479
- const segment = segments[0];
480
- return segment === undefined ? [] : [{ ...segment, text: expectedText }];
481
- }
482
- const first = segments[0];
483
- if (first === undefined) {
484
- return [];
485
- }
486
- return [{
487
- ...first,
488
- text: expectedText,
489
- projectionConfidence: "fallback"
490
- }];
491
- }
492
- function collectAnnotationKeysForTargetSegment(segment, tokens) {
493
- const keys = new Set();
494
- for (const key of segment.annotationKeys ?? []) {
495
- keys.add(key);
496
- }
497
- if (segment.sourceSpan !== null) {
498
- for (const token of tokens) {
499
- const tokenSpan = token.sourceSpan ?? (token.sourceOrdinal === undefined ? null : {
500
- startOrdinal: token.sourceOrdinal,
501
- endOrdinal: token.sourceOrdinal + 1,
502
- });
503
- if (tokenSpan === null ||
504
- tokenSpan.endOrdinal <= segment.sourceSpan.startOrdinal ||
505
- segment.sourceSpan.endOrdinal <= tokenSpan.startOrdinal ||
506
- token.annotationKeys === undefined) {
507
- continue;
508
- }
509
- for (const key of token.annotationKeys) {
510
- keys.add(key);
511
- }
512
- }
513
- }
514
- if (keys.size === 0 && segment.sourceSpan === null && segment.unit !== null) {
515
- for (const key of collectAnnotationKeys(segment.unit, tokens)) {
516
- keys.add(key);
517
- }
518
- }
519
- return Array.from(keys);
520
- }
521
- function applyTransparentPauseBoundaryAnnotationKeys(annotated, segments, tokens) {
522
- for (const token of tokens) {
523
- const keys = token.annotationKeys;
524
- if (keys === undefined || keys.length === 0)
525
- continue;
526
- const span = token.sourceSpan ?? (token.sourceOrdinal === undefined ? null : {
527
- startOrdinal: token.sourceOrdinal,
528
- endOrdinal: token.sourceOrdinal + 1,
529
- });
530
- if (span === null)
531
- continue;
532
- if (targetSegmentAlreadyCarriesTokenPauseKey(annotated, segments, span, keys)) {
533
- continue;
534
- }
535
- if (token.transparentPauseAfter === true) {
536
- const index = targetSegmentIndexBeforeSourceBoundary(segments, span.endOrdinal);
537
- if (index !== null)
538
- addAnnotationKeysToSegment(annotated[index], keys);
539
- }
540
- if (token.transparentPauseBefore === true) {
541
- const index = targetSegmentIndexAfterSourceBoundary(segments, span.startOrdinal);
542
- if (index !== null)
543
- addAnnotationKeysToSegment(annotated[index], keys);
544
- }
545
- }
546
- }
547
- function targetSegmentAlreadyCarriesTokenPauseKey(annotated, segments, tokenSpan, keys) {
548
- for (let index = 0; index < segments.length; index += 1) {
549
- const segment = segments[index];
550
- const span = segment?.sourceSpan ?? null;
551
- if (span === null ||
552
- span.endOrdinal <= tokenSpan.startOrdinal ||
553
- tokenSpan.endOrdinal <= span.startOrdinal) {
554
- continue;
555
- }
556
- const segmentKeys = annotated[index]?.keys;
557
- if (segmentKeys?.some((key) => keys.includes(key)) === true) {
558
- return true;
559
- }
560
- }
561
- return false;
562
- }
563
- function targetSegmentIndexBeforeSourceBoundary(segments, boundaryOrdinal) {
564
- let bestIndex = null;
565
- let bestEnd = Number.NEGATIVE_INFINITY;
566
- for (let index = 0; index < segments.length; index += 1) {
567
- const segment = segments[index];
568
- if (segment === undefined)
569
- continue;
570
- const span = segment.sourceSpan;
571
- if (span === null || /^\s*$/u.test(segment.text))
572
- continue;
573
- if (span.endOrdinal > boundaryOrdinal)
574
- continue;
575
- if (span.endOrdinal > bestEnd) {
576
- bestEnd = span.endOrdinal;
577
- bestIndex = index;
578
- }
579
- }
580
- return bestIndex;
581
- }
582
- function targetSegmentIndexAfterSourceBoundary(segments, boundaryOrdinal) {
583
- let bestIndex = null;
584
- let bestStart = Number.POSITIVE_INFINITY;
585
- for (let index = 0; index < segments.length; index += 1) {
586
- const segment = segments[index];
587
- if (segment === undefined)
588
- continue;
589
- const span = segment.sourceSpan;
590
- if (span === null || /^\s*$/u.test(segment.text))
591
- continue;
592
- if (span.startOrdinal < boundaryOrdinal)
593
- continue;
594
- if (span.startOrdinal < bestStart) {
595
- bestStart = span.startOrdinal;
596
- bestIndex = index;
597
- }
598
- }
599
- return bestIndex;
600
- }
601
- function addAnnotationKeysToSegment(segment, keys) {
602
- if (segment === undefined || keys.length === 0)
603
- return;
604
- const merged = new Set(segment.keys ?? []);
605
- for (const key of keys)
606
- merged.add(key);
607
- const next = Array.from(merged);
608
- if (next.length > 0) {
609
- segment.keys = next;
610
- }
611
- }
612
- function annotatedSegmentsWithSpacerKeys(segments) {
613
- return segments.map((segment, index) => {
614
- if (segment.keys !== undefined || !/^\s+$/u.test(segment.text)) {
615
- return segment;
616
- }
617
- const previousKeys = segments[index - 1]?.keys;
618
- const nextKeys = segments[index + 1]?.keys;
619
- if (previousKeys === undefined || nextKeys === undefined) {
620
- return segment;
621
- }
622
- const shared = previousKeys.filter((key) => nextKeys.includes(key));
623
- return shared.length === 0
624
- ? segment
625
- : { ...segment, keys: [...new Set(shared)] };
626
- });
627
- }
628
- function numeralAttachedSymbolHead(tokens, start) {
629
- const head = tokens[start];
630
- return head !== undefined &&
631
- isLexicalSymbolTokenAt(tokens, start) &&
632
- isUnitSymbolSurface(head.surface);
633
- }
634
141
  export class PipelineAssemblerMixin extends PipelineCompoundMixin {
635
142
  _formal = false;
636
143
  _useCommittedKoreanFallback = false;
@@ -722,17 +229,6 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
722
229
  }
723
230
  return undefined;
724
231
  }
725
- static keijoujiKanouNominalText(unit) {
726
- let source = unit.korean;
727
- const entry = unit.entry;
728
- if (entry !== null && hasTranslationAccess(entry)) {
729
- source = winnerKorean(entry) ?? source;
730
- }
731
- if (source.endsWith("하다")) {
732
- return source.slice(0, -2);
733
- }
734
- return unit.korean;
735
- }
736
232
  static shouldCacheSurface(renderPlan) {
737
233
  return renderPlan === undefined || renderPlan === null;
738
234
  }
@@ -845,27 +341,9 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
845
341
  const referent = getReferentTokenBeforeParticle(tokens, index, this.lookups);
846
342
  return new ParticleCtx(cursor, units, source === undefined ? "" : this.unitSurfaceForAssembly(source), referent === null ? null : runtimeTokensFromMatcher([referent])[0] ?? null, nextVerb, nextPredicate, ownerIndex === undefined ? null : committedParticle, ownerIndex !== undefined, clause);
847
343
  }
848
- static async runParticleRules(ctx, rules) {
849
- for (const rule of rules) {
850
- const decision = await rule(ctx);
851
- if (decision === null) {
852
- continue;
853
- }
854
- if (decision.kind === "emit") {
855
- return decision.consumed;
856
- }
857
- if (decision.kind === "map_fallback") {
858
- return null;
859
- }
860
- }
861
- return null;
862
- }
863
344
  static particleEmit(consumed) {
864
345
  return new ParticleDecision("emit", consumed);
865
346
  }
866
- static particleMapFallback() {
867
- return new ParticleDecision("map_fallback");
868
- }
869
347
  static appendCommittedParticle(units, tokens, index, assignment) {
870
348
  PipelineAssemblerMixin.appendUnit(units, tokens, index, 1, assignment.korean ?? "", {
871
349
  unitType: UnitType.FUNCTIONAL,
@@ -1337,11 +815,12 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
1337
815
  async contentPass(tokens, options = {}) {
1338
816
  const contentMap = new Map(options.seedContentMap ?? []);
1339
817
  const pendingExtentPostpositions = new Map();
1340
- let lastNumeralQuantity = null;
818
+ const state = { lastNumeralQuantity: null };
1341
819
  const numeralContext = {
1342
820
  copulaPredicateStartsAt: (idx) => copulaStartsPredicateAt(tokens, idx, this.lookups)
1343
821
  };
1344
822
  const cursor = new TokenCursor(tokens, Math.max(0, Math.min(options.startIndex ?? 0, tokens.length)), tokens.length);
823
+ const ctx = { tokens, cursor, contentMap, pendingExtentPostpositions, numeralContext, options };
1345
824
  while (cursor.pos < cursor.end) {
1346
825
  const index = cursor.pos;
1347
826
  const token = cursor.current();
@@ -1353,528 +832,682 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
1353
832
  cursor.advance();
1354
833
  continue;
1355
834
  }
1356
- const renderPlan = koreanOverrideRenderPlan(token, 부사);
1357
- if (renderPlan !== null) {
1358
- if (options.trace !== undefined && options.trace !== null) {
1359
- options.trace.record(new TraceEvent(index, "content_pass", "korean_override", true, { surface: token.surface }));
1360
- }
1361
- const span = makeAssemblyContentSpan(index, 1, token.koreanOverride ?? "", 부사, null, UnitType.CONTENT, { renderPlan });
1362
- finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
1363
- contentMap.set(index, span);
1364
- cursor.advance();
835
+ const step = { index, token, yieldedNumeral: undefined };
836
+ if (this.emitKoreanOverrideSpan(ctx, step) === "continue") {
1365
837
  continue;
1366
838
  }
1367
- const splitNandeReason = trySplitNandeReasonSpan(cursor);
1368
- if (splitNandeReason !== undefined) {
1369
- if (options.trace !== undefined && options.trace !== null) {
1370
- options.trace.record(new TraceEvent(index, "content_pass", "split_nande_reason", true, { consumed: splitNandeReason.consumed }));
1371
- }
1372
- contentMap.set(index, splitNandeReason);
839
+ if (this.emitNandeReasonSplitSpan(ctx, step) === "continue") {
1373
840
  continue;
1374
841
  }
1375
- let yieldedNumeral;
1376
- const numeral = cursor.tryParse(c => {
1377
- const result = tryContentNumeral(c, this.numeric, numeralContext);
1378
- if (result === undefined) {
1379
- return undefined;
1380
- }
1381
- const copulaStartKind = nounPhraseCopulaPredicateStartKind(cursor, index, this.numeric, this.lookups, { consumed: result.consumed, plan: result.renderPlan });
1382
- if (copulaStartKind !== "none" &&
1383
- !pendingExtentPostpositions.has(index)) {
1384
- yieldedNumeral = { reason: "copula_host", result, startKind: copulaStartKind };
1385
- return undefined;
1386
- }
1387
- if (isBareNominalQuoteStart(cursor, index, this.numeric, this.lookups)) {
1388
- yieldedNumeral = { reason: "bare_quote", result, startKind: "none" };
1389
- return undefined;
1390
- }
1391
- return result;
1392
- });
1393
- if (numeral !== undefined) {
1394
- if (options.trace !== undefined && options.trace !== null) {
1395
- options.trace.record(new TraceEvent(index, "content_pass", "numeral", true, { consumed: numeral.consumed }));
1396
- }
1397
- const numeralSpan = makeAssemblyContentSpan(index, numeral.consumed, numeral.korean, 수사, null, UnitType.NUMERAL);
1398
- if (numeral.renderPlan !== null) {
1399
- numeralSpan.renderPlan = numeral.renderPlan;
1400
- }
1401
- finalizeExtentPostpositionSpan(cursor, index, numeralSpan, pendingExtentPostpositions, this.numeric);
1402
- contentMap.set(index, numeralSpan);
1403
- lastNumeralQuantity = { endExclusive: index + numeral.consumed, plan: numeral.renderPlan };
842
+ if (this.emitNumeralSpan(ctx, state, step) === "continue") {
1404
843
  continue;
1405
844
  }
1406
- const approximationMarker = this.quantityApproximationSpanAt(cursor, index, lastNumeralQuantity);
1407
- if (approximationMarker !== undefined) {
1408
- if (options.trace !== undefined && options.trace !== null) {
1409
- options.trace.record(new TraceEvent(index, "content_pass", "quantity_approximation_marker", true, { surface: token.surface }));
1410
- }
1411
- contentMap.set(index, approximationMarker);
1412
- cursor.advance();
845
+ if (this.emitQuantityApproximationMarkerSpan(ctx, state, step) === "continue") {
1413
846
  continue;
1414
847
  }
1415
- const ellipticPropositionQuote = await this.tryBuildEllipticPropositionQuoteTailSpan(cursor);
1416
- if (ellipticPropositionQuote !== null) {
1417
- if (options.trace !== undefined && options.trace !== null) {
1418
- options.trace.record(new TraceEvent(index, "content_pass", "elliptic_proposition_quote_tail", true, ellipticPropositionQuote.traceDetail));
1419
- }
1420
- finalizeExtentPostpositionSpan(cursor, index, ellipticPropositionQuote.span, pendingExtentPostpositions, this.numeric);
1421
- contentMap.set(index, ellipticPropositionQuote.span);
848
+ if (await this.emitHeadTailAdapterSpans(ctx, step) === "continue") {
1422
849
  continue;
1423
850
  }
1424
- const ellipticPropositionModal = await this.tryBuildEllipticPropositionModalTailSpan(cursor);
1425
- if (ellipticPropositionModal !== null) {
1426
- if (options.trace !== undefined && options.trace !== null) {
1427
- options.trace.record(new TraceEvent(index, "content_pass", "elliptic_proposition_modal_tail", true, ellipticPropositionModal.traceDetail));
1428
- }
1429
- finalizeExtentPostpositionSpan(cursor, index, ellipticPropositionModal.span, pendingExtentPostpositions, this.numeric);
1430
- contentMap.set(index, ellipticPropositionModal.span);
851
+ if (this.emitDemonstrativeDiscourseConnectiveSpan(ctx, step) === "continue") {
1431
852
  continue;
1432
853
  }
1433
- const honorificRequestQuote = await this.tryBuildHonorificRequestQuoteSpan(cursor);
1434
- if (honorificRequestQuote !== null) {
1435
- if (options.trace !== undefined && options.trace !== null) {
1436
- options.trace.record(new TraceEvent(index, "content_pass", "honorific_request_quote", true, honorificRequestQuote.traceDetail));
1437
- }
1438
- finalizeExtentPostpositionSpan(cursor, index, honorificRequestQuote.span, pendingExtentPostpositions, this.numeric);
1439
- contentMap.set(index, honorificRequestQuote.span);
854
+ if (await this.emitHonorificFormulaicTailSpan(ctx, step) === "continue") {
1440
855
  continue;
1441
856
  }
1442
- const formulaicApologyPredicate = await this.tryBuildFormulaicApologyPredicateSpan(cursor);
1443
- if (formulaicApologyPredicate !== null) {
1444
- if (options.trace !== undefined && options.trace !== null) {
1445
- options.trace.record(new TraceEvent(index, "content_pass", "formulaic_apology_predicate", true, formulaicApologyPredicate.traceDetail));
1446
- }
1447
- finalizeExtentPostpositionSpan(cursor, index, formulaicApologyPredicate.span, pendingExtentPostpositions, this.numeric);
1448
- contentMap.set(index, formulaicApologyPredicate.span);
857
+ if (this.screenContentPassAdmission(ctx, step) === "continue") {
1449
858
  continue;
1450
859
  }
1451
- const hostlessInterjection = await this.tryBuildHostlessInterjectionSpan(cursor);
1452
- if (hostlessInterjection !== null) {
1453
- if (options.trace !== undefined && options.trace !== null) {
1454
- options.trace.record(new TraceEvent(index, "content_pass", "hostless_interjection", true, hostlessInterjection.traceDetail));
1455
- }
1456
- finalizeExtentPostpositionSpan(cursor, index, hostlessInterjection.span, pendingExtentPostpositions, this.numeric);
1457
- contentMap.set(index, hostlessInterjection.span);
860
+ if (this.emitSemanticCarrierPredicateSpan(ctx, step) === "continue") {
1458
861
  continue;
1459
862
  }
1460
- const demoDiscourse = tryResolveDemoDiscourseConnective(cursor, this.lookups);
1461
- if (demoDiscourse !== null) {
1462
- if (options.trace !== undefined && options.trace !== null) {
1463
- options.trace.record(new TraceEvent(index, "content_pass", "demo_discourse_connective", true, { key: demoDiscourse.key, reading: demoDiscourse.reading, consumed: demoDiscourse.consumed }));
1464
- }
1465
- const demoDiscourseSpan = makeAssemblyContentSpan(index, demoDiscourse.consumed, demoDiscourse.korean, demoDiscourse.koreanPos, null, UnitType.CONTENT, {
1466
- discourseConnective: demoDiscourse.reading === "connective",
1467
- renderPlan: {
1468
- kind: "lemma",
1469
- entry: null,
1470
- koreanLemma: demoDiscourse.korean,
1471
- koreanPos: demoDiscourse.koreanPos,
1472
- irregular: null,
1473
- auxTokens: []
1474
- }
1475
- });
1476
- finalizeExtentPostpositionSpan(cursor, index, demoDiscourseSpan, pendingExtentPostpositions, this.numeric);
1477
- contentMap.set(index, demoDiscourseSpan);
863
+ const protoLayout = activeProtoLayout();
864
+ if (this.emitQuoteClauseLikenessMarkerSpan(ctx, step, protoLayout) === "continue") {
1478
865
  continue;
1479
866
  }
1480
- const honorificFormulaicTail = await this.tryBuildHonorificFormulaicTailSpan(cursor);
1481
- if (honorificFormulaicTail !== null) {
1482
- if (options.trace !== undefined && options.trace !== null) {
1483
- options.trace.record(new TraceEvent(index, "content_pass", "honorific_formulaic_tail", true, honorificFormulaicTail.traceDetail));
1484
- }
1485
- finalizeExtentPostpositionSpan(cursor, index, honorificFormulaicTail.span, pendingExtentPostpositions, this.numeric);
1486
- contentMap.set(index, honorificFormulaicTail.span);
867
+ if (await this.emitNominalHostLikenessAdverbialMarkerSpan(ctx, step, protoLayout) === "continue") {
1487
868
  continue;
1488
869
  }
1489
- const pos0 = token.pos & POS0;
1490
- if (isNonLexicalSymbolTokenAt(cursor.tokens, index)) {
1491
- if (options.trace !== undefined && options.trace !== null) {
1492
- options.trace.record(new TraceEvent(index, "content_pass", "non_lexical_symbol", true, { surface: token.surface }));
1493
- }
1494
- cursor.advance();
870
+ if (await this.emitCopulaFocusAdjunctSpan(ctx, step) === "continue") {
1495
871
  continue;
1496
872
  }
1497
- if (!isContentAdmissionToken(token)) {
1498
- cursor.advance();
873
+ const dispatch = await this.dispatchContentPassContentHead(ctx, step, protoLayout);
874
+ const { contentHead, buildHeadTailCandidatePayloadSource } = dispatch;
875
+ if (contentHead?.kind === "nominal") {
876
+ await this.emitContentHeadNominalSpan(ctx, step, contentHead, buildHeadTailCandidatePayloadSource);
1499
877
  continue;
1500
878
  }
1501
- if (index !== options.resolveDeferredCopulaSupportAt &&
1502
- isCopulaSupportChainStartAt(tokens, index - 1) &&
1503
- !contentSpanCoversIndex(contentMap, index - 1)) {
1504
- if (options.trace !== undefined && options.trace !== null) {
1505
- options.trace.record(new TraceEvent(index, "content_pass", "detached_copula_support_deferred", true, { surface: token.surface }));
1506
- }
1507
- cursor.advance();
879
+ const verdict = this.contentHeadTailOwnershipVerdict(ctx, step, contentHead);
880
+ if (contentHead?.kind === "tail" && !verdict.numericYieldClaimMissed && verdict.contestedNominalUseSlot === null) {
881
+ await this.emitContentHeadTailChainSpan(ctx, step, contentHead, buildHeadTailCandidatePayloadSource);
1508
882
  continue;
1509
883
  }
1510
- if (options.trace !== undefined && options.trace !== null) {
1511
- options.trace.record(new TraceEvent(index, "content_pass", "content_pos", true, { pos0: POS0_NAME[pos0] ?? "*" }));
1512
- }
1513
- const semanticCarrierStart = cursor.pos;
1514
- const semanticCarrierPredicate = tryBuildSemanticCarrierPredicateDispatchCursor(cursor, this.lookups);
1515
- if (semanticCarrierPredicate !== null) {
1516
- const semanticCarrierConsumed = cursor.pos - semanticCarrierStart;
1517
- if (options.trace !== undefined && options.trace !== null) {
1518
- options.trace.record(new TraceEvent(index, "content_pass", semanticCarrierPredicate.rule, true, {
1519
- consumed: semanticCarrierConsumed,
1520
- ...semanticCarrierPredicate.traceDetail
1521
- }));
1522
- }
1523
- const span = makeAssemblyContentSpan(index, semanticCarrierConsumed, "", semanticCarrierPredicate.koreanPos, null, UnitType.CONTENT, {
1524
- provenance: "predicate_tail"
1525
- });
1526
- span.renderPlan = semanticCarrierPredicate.renderPlan;
1527
- finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
1528
- contentMap.set(index, span);
884
+ const tailParserFailureReason = this.recordContentHeadDispatchFailure(ctx, step, contentHead, verdict);
885
+ if (this.reclaimYieldedNumeralSpan(ctx, step, tailParserFailureReason) === "continue") {
1529
886
  continue;
1530
887
  }
1531
- const protoLayout = activeProtoLayout();
1532
- const quoteClauseLikenessMarker = this.tryBuildQuoteClauseLikenessMarkerSpan(cursor, protoLayout);
1533
- if (quoteClauseLikenessMarker !== null) {
1534
- if (options.trace !== undefined && options.trace !== null) {
1535
- options.trace.record(new TraceEvent(index, "content_pass", "quote_clause_likeness_marker", true, { consumed: quoteClauseLikenessMarker.consumed }));
1536
- }
1537
- finalizeExtentPostpositionSpan(cursor, index, quoteClauseLikenessMarker, pendingExtentPostpositions, this.numeric);
1538
- contentMap.set(index, quoteClauseLikenessMarker);
1539
- cursor.advance(quoteClauseLikenessMarker.consumed);
888
+ if (await this.emitCompoundDispatchSpan(ctx, step, tailParserFailureReason) === "continue") {
1540
889
  continue;
1541
890
  }
1542
- const nominalHostLikenessAdverbialMarker = await this.tryBuildNominalHostLikenessAdverbialMarkerSpan(cursor, protoLayout);
1543
- if (nominalHostLikenessAdverbialMarker !== null) {
1544
- if (options.trace !== undefined && options.trace !== null) {
1545
- options.trace.record(new TraceEvent(index, "content_pass", "nominal_host_likeness_adverbial_marker", true, { consumed: nominalHostLikenessAdverbialMarker.consumed }));
1546
- }
1547
- finalizeExtentPostpositionSpan(cursor, index, nominalHostLikenessAdverbialMarker, pendingExtentPostpositions, this.numeric);
1548
- contentMap.set(index, nominalHostLikenessAdverbialMarker);
1549
- cursor.advance(nominalHostLikenessAdverbialMarker.consumed);
1550
- continue;
891
+ await this.emitGeneralContentSpan(ctx, step, dispatch, verdict, tailParserFailureReason);
892
+ }
893
+ applySourceCompoundContinuationToContentMap(tokens, contentMap);
894
+ return contentMap;
895
+ }
896
+ emitKoreanOverrideSpan(ctx, step) {
897
+ const { cursor, contentMap, pendingExtentPostpositions, options } = ctx;
898
+ const { index, token } = step;
899
+ const renderPlan = koreanOverrideRenderPlan(token, 부사);
900
+ if (renderPlan !== null) {
901
+ if (options.trace !== undefined && options.trace !== null) {
902
+ options.trace.record(new TraceEvent(index, "content_pass", "korean_override", true, { surface: token.surface }));
1551
903
  }
1552
- const copulaFocusAdjunct = await this.tryBuildCopulaFocusAdjunctSpan(cursor);
1553
- if (copulaFocusAdjunct !== null) {
1554
- if (options.trace !== undefined && options.trace !== null) {
1555
- options.trace.record(new TraceEvent(index, "content_pass", "copula_focus_adjunct", true, { consumed: copulaFocusAdjunct.consumed }));
1556
- }
1557
- finalizeExtentPostpositionSpan(cursor, index, copulaFocusAdjunct, pendingExtentPostpositions, this.numeric);
1558
- contentMap.set(index, copulaFocusAdjunct);
1559
- cursor.advance(copulaFocusAdjunct.consumed);
1560
- continue;
904
+ const span = makeAssemblyContentSpan(index, 1, token.koreanOverride ?? "", 부사, null, UnitType.CONTENT, { renderPlan });
905
+ finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
906
+ contentMap.set(index, span);
907
+ cursor.advance();
908
+ return "continue";
909
+ }
910
+ return "next";
911
+ }
912
+ emitNandeReasonSplitSpan(ctx, step) {
913
+ const { cursor, contentMap, options } = ctx;
914
+ const { index } = step;
915
+ const splitNandeReason = trySplitNandeReasonSpan(cursor);
916
+ if (splitNandeReason !== undefined) {
917
+ if (options.trace !== undefined && options.trace !== null) {
918
+ options.trace.record(new TraceEvent(index, "content_pass", "split_nande_reason", true, { consumed: splitNandeReason.consumed }));
1561
919
  }
1562
- const contentHeadLimit = contentHeadDispatchLimit(tokens, index, protoLayout);
1563
- const buildHeadTailCandidatePayloadSource = (tailCandidateChunk) => buildTailOwnerCandidatePayloadSource({
1564
- tokens,
1565
- cursor,
1566
- index,
1567
- tailChunk: tailCandidateChunk,
1568
- dictionary: this.dictionary,
1569
- lookups: this.lookups,
1570
- numeric: this.numeric,
1571
- resolveHeadMetadata: async (start, end) => contentHeadMetadataFromResult(await this._processContent(cursor.fork(start, end, start), {
1572
- trace: null,
1573
- entryAuxMode: "head_metadata"
1574
- })),
1575
- isKeijoujiVerbObjectHost
1576
- });
1577
- const skipContentHeadForAdverbialNi = await this.shouldUseCandidatePathForLexicalizedAdverbialNi(tokens, index);
1578
- const currentToken = tokens[index];
1579
- const skipContentHeadForLayeredNegativeBridge = currentToken !== undefined &&
1580
- (pos0in(currentToken.pos, NOMINAL_BITS) || isNaAdjCapableNoun(currentToken)) &&
1581
- focusBodyOverNegativeScopeBridgeAt(tokens, index);
1582
- const contentHead = skipContentHeadForAdverbialNi || skipContentHeadForLayeredNegativeBridge
1583
- ? null
1584
- : await tryBuildContentHeadDispatch({
1585
- cursor,
1586
- limit: contentHeadLimit,
1587
- dictionary: this.dictionary,
1588
- previewFormal: REGISTER_NEUTRAL_BUILD_FORMAL,
1589
- lookups: this.lookups,
1590
- numeric: this.numeric,
1591
- ...(yieldedNumeral === undefined
1592
- ? {}
1593
- : {
1594
- numericHostReservation: {
1595
- tokenIdx: index,
1596
- consumed: yieldedNumeral.result.consumed,
1597
- plan: yieldedNumeral.result.renderPlan,
1598
- claimRequired: yieldedNumeral.reason === "copula_host" &&
1599
- yieldedNumeral.startKind === "numeral_span"
1600
- }
1601
- }),
1602
- ...(protoLayout === null ? {} : { layout: protoLayout }),
1603
- synthesizeEntry: async (headToken, synthOptions) => {
1604
- const headPos0 = headToken.pos & POS0;
1605
- const splitFallback = pos0in(headPos0, NONPREDICATE_CONTENT_POS_BITS)
1606
- ? await this._renderSplitFallback(headToken)
1607
- : undefined;
1608
- if (splitFallback !== undefined) {
1609
- const synthEntry = {
1610
- dictionaryForm: headToken.dictionaryForm,
1611
- senses: [{
1612
- korean: splitFallback,
1613
- koreanPos: JP_POS_TO_KR[headPos0] ?? 명사
1614
- }],
1615
- synthetic: true,
1616
- syntheticReason: "split_fallback"
1617
- };
1618
- return synthEntry;
1619
- }
1620
- return this._synthesizeEntry(headToken, { nextToken: synthOptions?.nextToken ?? null });
1621
- },
1622
- resolveNominalHeadMetadata: (start, end) => this._processContent(cursor.fork(start, end, start), {
1623
- trace: null,
1624
- entryAuxMode: "head_metadata"
1625
- }),
1626
- hydrateTailRoot: (root, headResult, predicateTokenIdx) => hydrateTailChainRootWithHeadMetadata(root, headResult, tokens, cursor, predicateTokenIdx, this.dictionary, this.lookups, this.numeric)
1627
- });
1628
- if (contentHead?.kind === "nominal") {
1629
- const payload = contentHeadDispatchNominalAppendPayload(contentHead);
1630
- attachContentHeadSharedHeadTailCandidateToPlan(contentHead, payload.renderPlan);
1631
- const nominalRoot = isNominalHeadTailChainRenderPlan(payload.renderPlan)
1632
- ? payload.renderPlan.realization.root
1633
- : null;
1634
- const absorptionStart = nominalRoot?.kind === "predicateNominalHost"
1635
- ? tailChainPreviousSahenNounAbsorptionStart(nominalRoot.host.root, nominalRoot.host.predicateTokenIdx)
1636
- : null;
1637
- const spanStart = absorptionStart ?? index;
1638
- const span = makeAssemblyContentSpan(spanStart, payload.consumed + index - spanStart, payload.korean, payload.koreanPos, payload.entry, payload.unitType, {
1639
- attachLeft: payload.attachLeft,
1640
- provenance: payload.provenance,
1641
- koreanBase: payload.koreanBase ?? null
1642
- });
1643
- await attachContentHeadOwnerCandidateLifecycle({
1644
- tokens,
1645
- dispatchIndex: index,
1646
- selectedSpanStart: spanStart,
1647
- contentHead,
1648
- span,
1649
- selectedNominalPayload: payload,
1650
- buildTailPayloadSource: buildHeadTailCandidatePayloadSource
1651
- });
1652
- if (options.trace !== undefined && options.trace !== null) {
1653
- options.trace.record(new TraceEvent(index, "content_pass", contentHead.built.profile.traceKind ?? contentHead.built.profile.id, true, {
1654
- consumed: payload.consumed,
1655
- head_profile: contentHead.built.profile.id,
1656
- ...contentHeadDispatchTraceDetail(contentHead)
1657
- }));
1658
- }
1659
- finalizeExtentPostpositionSpan(cursor, spanStart, span, pendingExtentPostpositions, this.numeric);
1660
- contentMap.set(spanStart, span);
1661
- cursor.advance(payload.consumed);
1662
- continue;
920
+ contentMap.set(index, splitNandeReason);
921
+ return "continue";
922
+ }
923
+ return "next";
924
+ }
925
+ emitNumeralSpan(ctx, state, step) {
926
+ const { cursor, contentMap, pendingExtentPostpositions, numeralContext, options } = ctx;
927
+ const { index } = step;
928
+ const numeral = cursor.tryParse(c => {
929
+ const result = tryContentNumeral(c, this.numeric, numeralContext);
930
+ if (result === undefined) {
931
+ return undefined;
1663
932
  }
1664
- const numericYieldClaimMissed = contentHead?.kind === "tail" &&
1665
- yieldedNumeral?.reason === "copula_host" &&
1666
- yieldedNumeral.startKind === "numeral_span" &&
1667
- probeProductionDispatch(contentHead.tailChunk.root, {
1668
- intake: { site: "committed_render", partial: false }
1669
- }).kind !== "registry";
1670
- const contestedNominalUseSlot = contentHead?.kind === "tail"
1671
- ? contentHead.tailChunk.contestedNominalUseSlot ?? null
1672
- : null;
1673
- const contestedClaimCoordinate = contestedNominalUseSlot !== null ||
1674
- isContestedZeroTailClaimCoordinate(tokens, index, this.numeric, this.lookups);
1675
- if (contentHead?.kind === "tail" && !numericYieldClaimMissed && contestedNominalUseSlot === null) {
1676
- const selectedHeadTailCandidate = contentHeadSelectedHeadTailCandidate(contentHead);
1677
- const selectedTailRealization = selectedHeadTailCandidate?.tail.realization;
1678
- const selectedTailPlan = selectedHeadTailCandidate != null && selectedTailRealization?.kind === "predicate_root"
1679
- ? { root: selectedTailRealization.root, sourceSpan: selectedHeadTailCandidate.tail.sourceSpan }
1680
- : null;
1681
- const tailChunk = contentHead.tailChunk;
1682
- const headResult = await this._processContent(cursor.fork(index, tokens.length, index), {
1683
- trace: null,
1684
- entryAuxMode: "head_metadata"
1685
- });
1686
- const headMetadata = contentHeadMetadataFromResult(headResult);
1687
- const tailBridge = await buildContentHeadTailAssemblyBridge({
1688
- tokens,
1689
- cursor,
1690
- index,
1691
- tailChunk,
1692
- selectedTailPlan,
1693
- headResult: headMetadata,
1694
- dictionary: this.dictionary,
1695
- lookups: this.lookups,
1696
- numeric: this.numeric,
1697
- isKeijoujiVerbObjectHost
1698
- });
1699
- if (options.trace !== undefined && options.trace !== null) {
1700
- recordTailChainContentPassTrace({
1701
- trace: options.trace,
1702
- tokens,
1703
- cursor,
1704
- root: tailBridge.root,
1705
- start: index,
1706
- consumed: tailChunk.consumed,
1707
- predicateTokenIdx: tailChunk.predicateTokenIdx,
1708
- blocker: tailBridge.kind === "blocked" ? tailBridge.readinessBlocker : null,
1709
- outgoingBoundary: tailChunk.outgoingBoundary,
1710
- headProfileId: tailChainHeadProfile(tailChunk)?.id ?? null,
1711
- dispatchTraceDetail: contentHeadDispatchTraceDetail(contentHead),
1712
- commitmentCandidateCount: tailBridge.kind === "ready" ? candidateSetSize(tailBridge.descriptor.sourceCandidates) : null,
1713
- ...(tailChunk.candidateObservation === undefined ? {} : { candidateObservation: tailChunk.candidateObservation }),
1714
- lookups: this.lookups
1715
- });
1716
- }
1717
- if (tailBridge.kind === "blocked") {
1718
- const result = await this._processContent(cursor.fork(index, tokens.length, index), {
1719
- trace: options.trace ?? null
1720
- });
1721
- const cacheKorean = PipelineAssemblerMixin.shouldCacheSurface(result.renderPlan);
1722
- const realizedKorean = cacheKorean ? this.surfaceFromRenderPlan(contentResultKoreanCache(result), result.renderPlan) : "";
1723
- const descriptor = buildTailParserFallbackAssemblyDescriptor({
1724
- cursor: cursor.fork(index, cursor.end, index),
1725
- result,
1726
- reason: tailBridge.readinessBlocker,
1727
- mode: "readiness_blocker",
1728
- realizedKorean,
1729
- cacheKorean,
1730
- isKeijoujiVerbObjectHost,
1731
- lookups: this.lookups
1732
- });
1733
- const span = applyTailParserFallbackDescriptorToSpan(descriptor, index, tokens, this.lookups);
1734
- finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
1735
- contentMap.set(index, span);
1736
- cursor.advance(descriptor.consumed);
1737
- continue;
1738
- }
1739
- const spanStart = tailBridge.spanStart;
1740
- const tailDescriptor = tailBridge.descriptor;
1741
- attachContentHeadSharedHeadTailCandidateToPlan(contentHead, tailDescriptor.renderPlan);
1742
- const span = this.makeTailChainSpanFromDescriptor(tokens, spanStart, tailDescriptor);
1743
- await attachContentHeadOwnerCandidateLifecycle({
1744
- tokens,
1745
- dispatchIndex: index,
1746
- selectedSpanStart: spanStart,
1747
- contentHead,
1748
- span,
1749
- selectedTailDescriptor: tailDescriptor,
1750
- buildTailPayloadSource: buildHeadTailCandidatePayloadSource
1751
- });
1752
- finalizeExtentPostpositionSpan(cursor, spanStart, span, pendingExtentPostpositions, this.numeric);
1753
- contentMap.set(spanStart, span);
1754
- cursor.advance(tailChunk.consumed);
1755
- continue;
933
+ const copulaStartKind = nounPhraseCopulaPredicateStartKind(cursor, index, this.numeric, this.lookups, { consumed: result.consumed, plan: result.renderPlan });
934
+ if (copulaStartKind !== "none" &&
935
+ !pendingExtentPostpositions.has(index)) {
936
+ step.yieldedNumeral = { reason: "copula_host", result, startKind: copulaStartKind };
937
+ return undefined;
938
+ }
939
+ if (isBareNominalQuoteStart(cursor, index, this.numeric, this.lookups)) {
940
+ step.yieldedNumeral = { reason: "bare_quote", result, startKind: "none" };
941
+ return undefined;
1756
942
  }
1757
- const tailParserFailureReason = numericYieldClaimMissed
1758
- ? "numeric host yield reclaimed: tail chain did not claim a production family"
1759
- : contestedNominalUseSlot !== null
1760
- ? `contested bare-stem nominal-use claim (${contestedNominalUseSlot}): content lane owns the span until the slot verdict decides`
1761
- : contentHead?.kind === "none"
1762
- ? contentHead.reason
1763
- : "content head dispatch skipped for copula negation owner";
943
+ return result;
944
+ });
945
+ if (numeral !== undefined) {
1764
946
  if (options.trace !== undefined && options.trace !== null) {
1765
- recordTailParserFailureTrace({
1766
- trace: options.trace,
1767
- tokens,
1768
- index,
1769
- reason: tailParserFailureReason,
1770
- ...(contentHead?.kind === "none"
1771
- ? { dispatchTraceDetail: contentHeadDispatchFailureTraceDetail(contentHead) }
1772
- : {})
1773
- });
947
+ options.trace.record(new TraceEvent(index, "content_pass", "numeral", true, { consumed: numeral.consumed }));
1774
948
  }
1775
- if (yieldedNumeral !== undefined &&
1776
- (yieldedNumeral.reason === "bare_quote" || yieldedNumeral.startKind === "numeral_span")) {
1777
- const reclaimed = yieldedNumeral.result;
1778
- if (options.trace !== undefined && options.trace !== null) {
1779
- options.trace.record(new TraceEvent(index, "content_pass", "numeral", true, {
1780
- consumed: reclaimed.consumed,
1781
- yield_reason: yieldedNumeral.reason,
1782
- tail_parser_reason: tailParserFailureReason
1783
- }));
1784
- }
1785
- const reclaimedSpan = makeAssemblyContentSpan(index, reclaimed.consumed, reclaimed.korean, 수사, null, UnitType.NUMERAL);
1786
- if (reclaimed.renderPlan !== null) {
1787
- reclaimedSpan.renderPlan = reclaimed.renderPlan;
1788
- }
1789
- finalizeExtentPostpositionSpan(cursor, index, reclaimedSpan, pendingExtentPostpositions, this.numeric);
1790
- contentMap.set(index, reclaimedSpan);
1791
- cursor.advance(reclaimed.consumed);
1792
- continue;
949
+ const numeralSpan = makeAssemblyContentSpan(index, numeral.consumed, numeral.korean, 수사, null, UnitType.NUMERAL);
950
+ if (numeral.renderPlan !== null) {
951
+ numeralSpan.renderPlan = numeral.renderPlan;
1793
952
  }
1794
- const compound = await this.tryCompoundDispatch(cursor);
1795
- if (compound !== undefined) {
1796
- const [consumed, korean, koreanPos, renderPlan, warnings, candidates] = compound;
1797
- if (options.trace !== undefined && options.trace !== null) {
1798
- options.trace.record(new TraceEvent(index, "content_pass", "compound", true, { consumed, korean_pos: koreanPos, tail_parser_reason: tailParserFailureReason }));
1799
- }
1800
- const shouldCacheKorean = PipelineAssemblerMixin.shouldCacheSurface(renderPlan);
1801
- const cachedKorean = shouldCacheKorean ? this.surfaceFromRenderPlan(korean, renderPlan) : "";
1802
- const provenanceBridge = buildTailParserFailureFallbackProvenance({
1803
- tokens,
1804
- cursor,
1805
- index,
1806
- consumed,
1807
- renderPlan,
1808
- reason: tailParserFailureReason,
1809
- lookups: this.lookups
1810
- });
1811
- const span = makeAssemblyContentSpan(index, consumed, cachedKorean, koreanPos, null, UnitType.CONTENT, {
1812
- attachLeft: isSahenBoundVerbAfterSahen(tokens, index) && !renderPlanStartsWithShortNegation(renderPlan),
1813
- provenance: provenanceBridge.provenance,
1814
- provenanceReason: provenanceBridge.provenanceReason,
1815
- warnings: warnings ?? []
1816
- });
1817
- span.renderPlan = renderPlan ?? null;
1818
- if (candidates !== undefined && candidates.length > 0) {
1819
- span.sourceCandidates = createSourceCandidateSet(candidates.map((candidate) => stagedCandidate(candidate, "unknown")), { sharedConsumed: consumed });
1820
- }
1821
- span.compoundHeadFrameEntry = await this.compoundSemanticHeadEntry(tokens, index, renderPlan ?? null);
1822
- closeUnownedTailFallbackSpanToRaw(span, tokens);
1823
- finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
1824
- contentMap.set(index, span);
1825
- continue;
953
+ finalizeExtentPostpositionSpan(cursor, index, numeralSpan, pendingExtentPostpositions, this.numeric);
954
+ contentMap.set(index, numeralSpan);
955
+ state.lastNumeralQuantity = { endExclusive: index + numeral.consumed, plan: numeral.renderPlan };
956
+ return "continue";
957
+ }
958
+ return "next";
959
+ }
960
+ emitQuantityApproximationMarkerSpan(ctx, state, step) {
961
+ const { cursor, contentMap, options } = ctx;
962
+ const { index, token } = step;
963
+ const approximationMarker = this.quantityApproximationSpanAt(cursor, index, state.lastNumeralQuantity);
964
+ if (approximationMarker !== undefined) {
965
+ if (options.trace !== undefined && options.trace !== null) {
966
+ options.trace.record(new TraceEvent(index, "content_pass", "quantity_approximation_marker", true, { surface: token.surface }));
1826
967
  }
1827
- const result = await this._processContent(cursor.fork(index, tokens.length, index), {
1828
- trace: options.trace ?? null,
1829
- contentMap
1830
- });
1831
- const prenominalModifierSpan = this.tryBuildModifiedHeadPrenominalModifierSpan(tokens, index, result);
1832
- if (prenominalModifierSpan !== null) {
1833
- if (options.trace !== undefined && options.trace !== null) {
1834
- options.trace.record(new TraceEvent(index, "content_pass", "modified_head_prenominal_modifier", true, { consumed: result.consumed, korean_pos: contentResultKoreanPos(result) }));
1835
- }
1836
- finalizeExtentPostpositionSpan(cursor, index, prenominalModifierSpan, pendingExtentPostpositions, this.numeric);
1837
- contentMap.set(index, prenominalModifierSpan);
1838
- cursor.advance(result.consumed);
1839
- continue;
968
+ contentMap.set(index, approximationMarker);
969
+ cursor.advance();
970
+ return "continue";
971
+ }
972
+ return "next";
973
+ }
974
+ async emitHeadTailAdapterSpans(ctx, step) {
975
+ const { cursor, contentMap, pendingExtentPostpositions, options } = ctx;
976
+ const { index } = step;
977
+ const ellipticPropositionQuote = await this.tryBuildEllipticPropositionQuoteTailSpan(cursor);
978
+ if (ellipticPropositionQuote !== null) {
979
+ if (options.trace !== undefined && options.trace !== null) {
980
+ options.trace.record(new TraceEvent(index, "content_pass", "elliptic_proposition_quote_tail", true, ellipticPropositionQuote.traceDetail));
1840
981
  }
1841
- const cacheKorean = PipelineAssemblerMixin.shouldCacheSurface(result.renderPlan);
1842
- const realizedKorean = cacheKorean ? this.surfaceFromRenderPlan(contentResultKoreanCache(result), result.renderPlan) : "";
1843
- const predicateIntake = !numericYieldClaimMissed && contestedNominalUseSlot === null && contentHead?.kind === "none"
1844
- ? contentHead.predicateIntake
1845
- : undefined;
1846
- const descriptor = buildTailParserFallbackAssemblyDescriptor({
1847
- cursor: cursor.fork(index, cursor.end, index),
1848
- result,
1849
- reason: tailParserFailureReason,
1850
- mode: contestedClaimCoordinate ? "contested_claim_yield" : "parse_failure",
1851
- ...(predicateIntake === undefined ? {} : { predicateIntake }),
1852
- realizedKorean,
1853
- cacheKorean,
1854
- isKeijoujiVerbObjectHost,
1855
- lookups: this.lookups
1856
- });
1857
- const span = applyTailParserFallbackDescriptorToSpan(descriptor, index, tokens, this.lookups);
1858
- const intrinsicHonorific = selectedIntrinsicHonorificMetadata(result.sourceCandidates, result.entry);
1859
- if (intrinsicHonorific !== undefined)
1860
- span.intrinsicHonorific = intrinsicHonorific;
1861
- if (contestedNominalUseSlot !== null && contentHead?.kind === "tail") {
1862
- await attachContestedNominalUseOwnerCandidateLifecycle({
1863
- tokens,
1864
- dispatchIndex: index,
1865
- contentHead,
1866
- contestedNominalUseSlot,
1867
- span,
1868
- buildTailPayloadSource: buildHeadTailCandidatePayloadSource
1869
- });
982
+ finalizeExtentPostpositionSpan(cursor, index, ellipticPropositionQuote.span, pendingExtentPostpositions, this.numeric);
983
+ contentMap.set(index, ellipticPropositionQuote.span);
984
+ return "continue";
985
+ }
986
+ const ellipticPropositionModal = await this.tryBuildEllipticPropositionModalTailSpan(cursor);
987
+ if (ellipticPropositionModal !== null) {
988
+ if (options.trace !== undefined && options.trace !== null) {
989
+ options.trace.record(new TraceEvent(index, "content_pass", "elliptic_proposition_modal_tail", true, ellipticPropositionModal.traceDetail));
1870
990
  }
1871
- finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
1872
- contentMap.set(index, span);
1873
- cursor.advance(descriptor.consumed);
991
+ finalizeExtentPostpositionSpan(cursor, index, ellipticPropositionModal.span, pendingExtentPostpositions, this.numeric);
992
+ contentMap.set(index, ellipticPropositionModal.span);
993
+ return "continue";
1874
994
  }
1875
- applySourceCompoundContinuationToContentMap(tokens, contentMap);
1876
- return contentMap;
1877
- }
995
+ const honorificRequestQuote = await this.tryBuildHonorificRequestQuoteSpan(cursor);
996
+ if (honorificRequestQuote !== null) {
997
+ if (options.trace !== undefined && options.trace !== null) {
998
+ options.trace.record(new TraceEvent(index, "content_pass", "honorific_request_quote", true, honorificRequestQuote.traceDetail));
999
+ }
1000
+ finalizeExtentPostpositionSpan(cursor, index, honorificRequestQuote.span, pendingExtentPostpositions, this.numeric);
1001
+ contentMap.set(index, honorificRequestQuote.span);
1002
+ return "continue";
1003
+ }
1004
+ const formulaicApologyPredicate = await this.tryBuildFormulaicApologyPredicateSpan(cursor);
1005
+ if (formulaicApologyPredicate !== null) {
1006
+ if (options.trace !== undefined && options.trace !== null) {
1007
+ options.trace.record(new TraceEvent(index, "content_pass", "formulaic_apology_predicate", true, formulaicApologyPredicate.traceDetail));
1008
+ }
1009
+ finalizeExtentPostpositionSpan(cursor, index, formulaicApologyPredicate.span, pendingExtentPostpositions, this.numeric);
1010
+ contentMap.set(index, formulaicApologyPredicate.span);
1011
+ return "continue";
1012
+ }
1013
+ const hostlessInterjection = await this.tryBuildHostlessInterjectionSpan(cursor);
1014
+ if (hostlessInterjection !== null) {
1015
+ if (options.trace !== undefined && options.trace !== null) {
1016
+ options.trace.record(new TraceEvent(index, "content_pass", "hostless_interjection", true, hostlessInterjection.traceDetail));
1017
+ }
1018
+ finalizeExtentPostpositionSpan(cursor, index, hostlessInterjection.span, pendingExtentPostpositions, this.numeric);
1019
+ contentMap.set(index, hostlessInterjection.span);
1020
+ return "continue";
1021
+ }
1022
+ return "next";
1023
+ }
1024
+ emitDemonstrativeDiscourseConnectiveSpan(ctx, step) {
1025
+ const { cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1026
+ const { index } = step;
1027
+ const demoDiscourse = tryResolveDemoDiscourseConnective(cursor, this.lookups);
1028
+ if (demoDiscourse !== null) {
1029
+ if (options.trace !== undefined && options.trace !== null) {
1030
+ options.trace.record(new TraceEvent(index, "content_pass", "demo_discourse_connective", true, { key: demoDiscourse.key, reading: demoDiscourse.reading, consumed: demoDiscourse.consumed }));
1031
+ }
1032
+ const demoDiscourseSpan = makeAssemblyContentSpan(index, demoDiscourse.consumed, demoDiscourse.korean, demoDiscourse.koreanPos, null, UnitType.CONTENT, {
1033
+ discourseConnective: demoDiscourse.reading === "connective",
1034
+ renderPlan: {
1035
+ kind: "lemma",
1036
+ entry: null,
1037
+ koreanLemma: demoDiscourse.korean,
1038
+ koreanPos: demoDiscourse.koreanPos,
1039
+ irregular: null,
1040
+ auxTokens: []
1041
+ }
1042
+ });
1043
+ finalizeExtentPostpositionSpan(cursor, index, demoDiscourseSpan, pendingExtentPostpositions, this.numeric);
1044
+ contentMap.set(index, demoDiscourseSpan);
1045
+ return "continue";
1046
+ }
1047
+ return "next";
1048
+ }
1049
+ async emitHonorificFormulaicTailSpan(ctx, step) {
1050
+ const { cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1051
+ const { index } = step;
1052
+ const honorificFormulaicTail = await this.tryBuildHonorificFormulaicTailSpan(cursor);
1053
+ if (honorificFormulaicTail !== null) {
1054
+ if (options.trace !== undefined && options.trace !== null) {
1055
+ options.trace.record(new TraceEvent(index, "content_pass", "honorific_formulaic_tail", true, honorificFormulaicTail.traceDetail));
1056
+ }
1057
+ finalizeExtentPostpositionSpan(cursor, index, honorificFormulaicTail.span, pendingExtentPostpositions, this.numeric);
1058
+ contentMap.set(index, honorificFormulaicTail.span);
1059
+ return "continue";
1060
+ }
1061
+ return "next";
1062
+ }
1063
+ screenContentPassAdmission(ctx, step) {
1064
+ const { tokens, cursor, contentMap, options } = ctx;
1065
+ const { index, token } = step;
1066
+ const pos0 = token.pos & POS0;
1067
+ if (isNonLexicalSymbolTokenAt(cursor.tokens, index)) {
1068
+ if (options.trace !== undefined && options.trace !== null) {
1069
+ options.trace.record(new TraceEvent(index, "content_pass", "non_lexical_symbol", true, { surface: token.surface }));
1070
+ }
1071
+ cursor.advance();
1072
+ return "continue";
1073
+ }
1074
+ if (!isContentAdmissionToken(token)) {
1075
+ cursor.advance();
1076
+ return "continue";
1077
+ }
1078
+ if (index !== options.resolveDeferredCopulaSupportAt &&
1079
+ isCopulaSupportChainStartAt(tokens, index - 1) &&
1080
+ !contentSpanCoversIndex(contentMap, index - 1)) {
1081
+ if (options.trace !== undefined && options.trace !== null) {
1082
+ options.trace.record(new TraceEvent(index, "content_pass", "detached_copula_support_deferred", true, { surface: token.surface }));
1083
+ }
1084
+ cursor.advance();
1085
+ return "continue";
1086
+ }
1087
+ if (options.trace !== undefined && options.trace !== null) {
1088
+ options.trace.record(new TraceEvent(index, "content_pass", "content_pos", true, { pos0: POS0_NAME[pos0] ?? "*" }));
1089
+ }
1090
+ return "next";
1091
+ }
1092
+ emitSemanticCarrierPredicateSpan(ctx, step) {
1093
+ const { cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1094
+ const { index } = step;
1095
+ const semanticCarrierStart = cursor.pos;
1096
+ const semanticCarrierPredicate = tryBuildSemanticCarrierPredicateDispatchCursor(cursor, this.lookups);
1097
+ if (semanticCarrierPredicate !== null) {
1098
+ const semanticCarrierConsumed = cursor.pos - semanticCarrierStart;
1099
+ if (options.trace !== undefined && options.trace !== null) {
1100
+ options.trace.record(new TraceEvent(index, "content_pass", semanticCarrierPredicate.rule, true, {
1101
+ consumed: semanticCarrierConsumed,
1102
+ ...semanticCarrierPredicate.traceDetail
1103
+ }));
1104
+ }
1105
+ const span = makeAssemblyContentSpan(index, semanticCarrierConsumed, "", semanticCarrierPredicate.koreanPos, null, UnitType.CONTENT, {
1106
+ provenance: "predicate_tail"
1107
+ });
1108
+ span.renderPlan = semanticCarrierPredicate.renderPlan;
1109
+ finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
1110
+ contentMap.set(index, span);
1111
+ return "continue";
1112
+ }
1113
+ return "next";
1114
+ }
1115
+ emitQuoteClauseLikenessMarkerSpan(ctx, step, protoLayout) {
1116
+ const { cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1117
+ const { index } = step;
1118
+ const quoteClauseLikenessMarker = this.tryBuildQuoteClauseLikenessMarkerSpan(cursor, protoLayout);
1119
+ if (quoteClauseLikenessMarker !== null) {
1120
+ if (options.trace !== undefined && options.trace !== null) {
1121
+ options.trace.record(new TraceEvent(index, "content_pass", "quote_clause_likeness_marker", true, { consumed: quoteClauseLikenessMarker.consumed }));
1122
+ }
1123
+ finalizeExtentPostpositionSpan(cursor, index, quoteClauseLikenessMarker, pendingExtentPostpositions, this.numeric);
1124
+ contentMap.set(index, quoteClauseLikenessMarker);
1125
+ cursor.advance(quoteClauseLikenessMarker.consumed);
1126
+ return "continue";
1127
+ }
1128
+ return "next";
1129
+ }
1130
+ async emitNominalHostLikenessAdverbialMarkerSpan(ctx, step, protoLayout) {
1131
+ const { cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1132
+ const { index } = step;
1133
+ const nominalHostLikenessAdverbialMarker = await this.tryBuildNominalHostLikenessAdverbialMarkerSpan(cursor, protoLayout);
1134
+ if (nominalHostLikenessAdverbialMarker !== null) {
1135
+ if (options.trace !== undefined && options.trace !== null) {
1136
+ options.trace.record(new TraceEvent(index, "content_pass", "nominal_host_likeness_adverbial_marker", true, { consumed: nominalHostLikenessAdverbialMarker.consumed }));
1137
+ }
1138
+ finalizeExtentPostpositionSpan(cursor, index, nominalHostLikenessAdverbialMarker, pendingExtentPostpositions, this.numeric);
1139
+ contentMap.set(index, nominalHostLikenessAdverbialMarker);
1140
+ cursor.advance(nominalHostLikenessAdverbialMarker.consumed);
1141
+ return "continue";
1142
+ }
1143
+ return "next";
1144
+ }
1145
+ async emitCopulaFocusAdjunctSpan(ctx, step) {
1146
+ const { cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1147
+ const { index } = step;
1148
+ const copulaFocusAdjunct = await this.tryBuildCopulaFocusAdjunctSpan(cursor);
1149
+ if (copulaFocusAdjunct !== null) {
1150
+ if (options.trace !== undefined && options.trace !== null) {
1151
+ options.trace.record(new TraceEvent(index, "content_pass", "copula_focus_adjunct", true, { consumed: copulaFocusAdjunct.consumed }));
1152
+ }
1153
+ finalizeExtentPostpositionSpan(cursor, index, copulaFocusAdjunct, pendingExtentPostpositions, this.numeric);
1154
+ contentMap.set(index, copulaFocusAdjunct);
1155
+ cursor.advance(copulaFocusAdjunct.consumed);
1156
+ return "continue";
1157
+ }
1158
+ return "next";
1159
+ }
1160
+ async dispatchContentPassContentHead(ctx, step, protoLayout) {
1161
+ const { tokens, cursor } = ctx;
1162
+ const { index } = step;
1163
+ const contentHeadLimit = contentHeadDispatchLimit(tokens, index, protoLayout);
1164
+ const buildHeadTailCandidatePayloadSource = (tailCandidateChunk) => buildTailOwnerCandidatePayloadSource({
1165
+ tokens,
1166
+ cursor,
1167
+ index,
1168
+ tailChunk: tailCandidateChunk,
1169
+ dictionary: this.dictionary,
1170
+ lookups: this.lookups,
1171
+ numeric: this.numeric,
1172
+ resolveHeadMetadata: async (start, end) => contentHeadMetadataFromResult(await this._processContent(cursor.fork(start, end, start), {
1173
+ trace: null,
1174
+ entryAuxMode: "head_metadata"
1175
+ })),
1176
+ isKeijoujiVerbObjectHost
1177
+ });
1178
+ const skipContentHeadForAdverbialNi = await this.shouldUseCandidatePathForLexicalizedAdverbialNi(tokens, index);
1179
+ const currentToken = tokens[index];
1180
+ const skipContentHeadForLayeredNegativeBridge = currentToken !== undefined &&
1181
+ (pos0in(currentToken.pos, NOMINAL_BITS) || isNaAdjCapableNoun(currentToken)) &&
1182
+ focusBodyOverNegativeScopeBridgeAt(tokens, index);
1183
+ const contentHead = skipContentHeadForAdverbialNi || skipContentHeadForLayeredNegativeBridge
1184
+ ? null
1185
+ : await tryBuildContentHeadDispatch({
1186
+ cursor,
1187
+ limit: contentHeadLimit,
1188
+ dictionary: this.dictionary,
1189
+ previewFormal: REGISTER_NEUTRAL_BUILD_FORMAL,
1190
+ lookups: this.lookups,
1191
+ numeric: this.numeric,
1192
+ ...(step.yieldedNumeral === undefined
1193
+ ? {}
1194
+ : {
1195
+ numericHostReservation: {
1196
+ tokenIdx: index,
1197
+ consumed: step.yieldedNumeral.result.consumed,
1198
+ plan: step.yieldedNumeral.result.renderPlan,
1199
+ claimRequired: step.yieldedNumeral.reason === "copula_host" &&
1200
+ step.yieldedNumeral.startKind === "numeral_span"
1201
+ }
1202
+ }),
1203
+ ...(protoLayout === null ? {} : { layout: protoLayout }),
1204
+ synthesizeEntry: async (headToken, synthOptions) => {
1205
+ const headPos0 = headToken.pos & POS0;
1206
+ const splitFallback = pos0in(headPos0, NONPREDICATE_CONTENT_POS_BITS)
1207
+ ? await this._renderSplitFallback(headToken)
1208
+ : undefined;
1209
+ if (splitFallback !== undefined) {
1210
+ const synthEntry = {
1211
+ dictionaryForm: headToken.dictionaryForm,
1212
+ senses: [{
1213
+ korean: splitFallback,
1214
+ koreanPos: JP_POS_TO_KR[headPos0] ?? 명사
1215
+ }],
1216
+ synthetic: true,
1217
+ syntheticReason: "split_fallback"
1218
+ };
1219
+ return synthEntry;
1220
+ }
1221
+ return this._synthesizeEntry(headToken, { nextToken: synthOptions?.nextToken ?? null });
1222
+ },
1223
+ resolveNominalHeadMetadata: (start, end) => this._processContent(cursor.fork(start, end, start), {
1224
+ trace: null,
1225
+ entryAuxMode: "head_metadata"
1226
+ }),
1227
+ hydrateTailRoot: (root, headResult, predicateTokenIdx) => hydrateTailChainRootWithHeadMetadata(root, headResult, tokens, cursor, predicateTokenIdx, this.dictionary, this.lookups, this.numeric)
1228
+ });
1229
+ return { contentHead, buildHeadTailCandidatePayloadSource };
1230
+ }
1231
+ async emitContentHeadNominalSpan(ctx, step, contentHead, buildHeadTailCandidatePayloadSource) {
1232
+ const { tokens, cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1233
+ const { index } = step;
1234
+ const payload = contentHeadDispatchNominalAppendPayload(contentHead);
1235
+ attachContentHeadSharedHeadTailCandidateToPlan(contentHead, payload.renderPlan);
1236
+ const nominalRoot = isNominalHeadTailChainRenderPlan(payload.renderPlan)
1237
+ ? payload.renderPlan.realization.root
1238
+ : null;
1239
+ const absorptionStart = nominalRoot?.kind === "predicateNominalHost"
1240
+ ? tailChainPreviousSahenNounAbsorptionStart(nominalRoot.host.root, nominalRoot.host.predicateTokenIdx)
1241
+ : null;
1242
+ const spanStart = absorptionStart ?? index;
1243
+ const span = makeAssemblyContentSpan(spanStart, payload.consumed + index - spanStart, payload.korean, payload.koreanPos, payload.entry, payload.unitType, {
1244
+ attachLeft: payload.attachLeft,
1245
+ provenance: payload.provenance,
1246
+ koreanBase: payload.koreanBase ?? null
1247
+ });
1248
+ await attachContentHeadOwnerCandidateLifecycle({
1249
+ tokens,
1250
+ dispatchIndex: index,
1251
+ selectedSpanStart: spanStart,
1252
+ contentHead,
1253
+ span,
1254
+ selectedNominalPayload: payload,
1255
+ buildTailPayloadSource: buildHeadTailCandidatePayloadSource
1256
+ });
1257
+ if (options.trace !== undefined && options.trace !== null) {
1258
+ options.trace.record(new TraceEvent(index, "content_pass", contentHead.built.profile.traceKind ?? contentHead.built.profile.id, true, {
1259
+ consumed: payload.consumed,
1260
+ head_profile: contentHead.built.profile.id,
1261
+ ...contentHeadDispatchTraceDetail(contentHead)
1262
+ }));
1263
+ }
1264
+ finalizeExtentPostpositionSpan(cursor, spanStart, span, pendingExtentPostpositions, this.numeric);
1265
+ contentMap.set(spanStart, span);
1266
+ cursor.advance(payload.consumed);
1267
+ }
1268
+ contentHeadTailOwnershipVerdict(ctx, step, contentHead) {
1269
+ const { tokens } = ctx;
1270
+ const { index } = step;
1271
+ const numericYieldClaimMissed = contentHead?.kind === "tail" &&
1272
+ step.yieldedNumeral?.reason === "copula_host" &&
1273
+ step.yieldedNumeral.startKind === "numeral_span" &&
1274
+ probeProductionDispatch(contentHead.tailChunk.root, {
1275
+ intake: { site: "committed_render", partial: false }
1276
+ }).kind !== "registry";
1277
+ const contestedNominalUseSlot = contentHead?.kind === "tail"
1278
+ ? contentHead.tailChunk.contestedNominalUseSlot ?? null
1279
+ : null;
1280
+ const contestedClaimCoordinate = contestedNominalUseSlot !== null ||
1281
+ isContestedZeroTailClaimCoordinate(tokens, index, this.numeric, this.lookups);
1282
+ return { numericYieldClaimMissed, contestedNominalUseSlot, contestedClaimCoordinate };
1283
+ }
1284
+ async emitContentHeadTailChainSpan(ctx, step, contentHead, buildHeadTailCandidatePayloadSource) {
1285
+ const { tokens, cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1286
+ const { index } = step;
1287
+ const selectedHeadTailCandidate = contentHeadSelectedHeadTailCandidate(contentHead);
1288
+ const selectedTailRealization = selectedHeadTailCandidate?.tail.realization;
1289
+ const selectedTailPlan = selectedHeadTailCandidate != null && selectedTailRealization?.kind === "predicate_root"
1290
+ ? { root: selectedTailRealization.root, sourceSpan: selectedHeadTailCandidate.tail.sourceSpan }
1291
+ : null;
1292
+ const tailChunk = contentHead.tailChunk;
1293
+ const headResult = await this._processContent(cursor.fork(index, tokens.length, index), {
1294
+ trace: null,
1295
+ entryAuxMode: "head_metadata"
1296
+ });
1297
+ const headMetadata = contentHeadMetadataFromResult(headResult);
1298
+ const tailBridge = await buildContentHeadTailAssemblyBridge({
1299
+ tokens,
1300
+ cursor,
1301
+ index,
1302
+ tailChunk,
1303
+ selectedTailPlan,
1304
+ headResult: headMetadata,
1305
+ dictionary: this.dictionary,
1306
+ lookups: this.lookups,
1307
+ numeric: this.numeric,
1308
+ isKeijoujiVerbObjectHost
1309
+ });
1310
+ if (options.trace !== undefined && options.trace !== null) {
1311
+ recordTailChainContentPassTrace({
1312
+ trace: options.trace,
1313
+ tokens,
1314
+ cursor,
1315
+ root: tailBridge.root,
1316
+ start: index,
1317
+ consumed: tailChunk.consumed,
1318
+ predicateTokenIdx: tailChunk.predicateTokenIdx,
1319
+ blocker: tailBridge.kind === "blocked" ? tailBridge.readinessBlocker : null,
1320
+ outgoingBoundary: tailChunk.outgoingBoundary,
1321
+ headProfileId: tailChainHeadProfile(tailChunk)?.id ?? null,
1322
+ dispatchTraceDetail: contentHeadDispatchTraceDetail(contentHead),
1323
+ commitmentCandidateCount: tailBridge.kind === "ready" ? candidateSetSize(tailBridge.descriptor.sourceCandidates) : null,
1324
+ ...(tailChunk.candidateObservation === undefined ? {} : { candidateObservation: tailChunk.candidateObservation }),
1325
+ lookups: this.lookups
1326
+ });
1327
+ }
1328
+ if (tailBridge.kind === "blocked") {
1329
+ await this.emitTailReadinessBlockedFallbackSpan(ctx, step, tailBridge);
1330
+ return;
1331
+ }
1332
+ const spanStart = tailBridge.spanStart;
1333
+ const tailDescriptor = tailBridge.descriptor;
1334
+ attachContentHeadSharedHeadTailCandidateToPlan(contentHead, tailDescriptor.renderPlan);
1335
+ const span = this.makeTailChainSpanFromDescriptor(tokens, spanStart, tailDescriptor);
1336
+ await attachContentHeadOwnerCandidateLifecycle({
1337
+ tokens,
1338
+ dispatchIndex: index,
1339
+ selectedSpanStart: spanStart,
1340
+ contentHead,
1341
+ span,
1342
+ selectedTailDescriptor: tailDescriptor,
1343
+ buildTailPayloadSource: buildHeadTailCandidatePayloadSource
1344
+ });
1345
+ finalizeExtentPostpositionSpan(cursor, spanStart, span, pendingExtentPostpositions, this.numeric);
1346
+ contentMap.set(spanStart, span);
1347
+ cursor.advance(tailChunk.consumed);
1348
+ }
1349
+ async emitTailReadinessBlockedFallbackSpan(ctx, step, tailBridge) {
1350
+ const { tokens, cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1351
+ const { index } = step;
1352
+ const result = await this._processContent(cursor.fork(index, tokens.length, index), {
1353
+ trace: options.trace ?? null
1354
+ });
1355
+ const cacheKorean = PipelineAssemblerMixin.shouldCacheSurface(result.renderPlan);
1356
+ const realizedKorean = cacheKorean ? this.surfaceFromRenderPlan(contentResultKoreanCache(result), result.renderPlan) : "";
1357
+ const descriptor = buildTailParserFallbackAssemblyDescriptor({
1358
+ cursor: cursor.fork(index, cursor.end, index),
1359
+ result,
1360
+ reason: tailBridge.readinessBlocker,
1361
+ mode: "readiness_blocker",
1362
+ realizedKorean,
1363
+ cacheKorean,
1364
+ isKeijoujiVerbObjectHost,
1365
+ lookups: this.lookups
1366
+ });
1367
+ const span = applyTailParserFallbackDescriptorToSpan(descriptor, index, tokens, this.lookups);
1368
+ finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
1369
+ contentMap.set(index, span);
1370
+ cursor.advance(descriptor.consumed);
1371
+ }
1372
+ recordContentHeadDispatchFailure(ctx, step, contentHead, verdict) {
1373
+ const { tokens, options } = ctx;
1374
+ const { index } = step;
1375
+ const { numericYieldClaimMissed, contestedNominalUseSlot } = verdict;
1376
+ const tailParserFailureReason = numericYieldClaimMissed
1377
+ ? "numeric host yield reclaimed: tail chain did not claim a production family"
1378
+ : contestedNominalUseSlot !== null
1379
+ ? `contested bare-stem nominal-use claim (${contestedNominalUseSlot}): content lane owns the span until the slot verdict decides`
1380
+ : contentHead?.kind === "none"
1381
+ ? contentHead.reason
1382
+ : "content head dispatch skipped for copula negation owner";
1383
+ if (options.trace !== undefined && options.trace !== null) {
1384
+ recordTailParserFailureTrace({
1385
+ trace: options.trace,
1386
+ tokens,
1387
+ index,
1388
+ reason: tailParserFailureReason,
1389
+ ...(contentHead?.kind === "none"
1390
+ ? { dispatchTraceDetail: contentHeadDispatchFailureTraceDetail(contentHead) }
1391
+ : {})
1392
+ });
1393
+ }
1394
+ return tailParserFailureReason;
1395
+ }
1396
+ reclaimYieldedNumeralSpan(ctx, step, tailParserFailureReason) {
1397
+ const { cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1398
+ const { index } = step;
1399
+ if (step.yieldedNumeral !== undefined &&
1400
+ (step.yieldedNumeral.reason === "bare_quote" || step.yieldedNumeral.startKind === "numeral_span")) {
1401
+ const reclaimed = step.yieldedNumeral.result;
1402
+ if (options.trace !== undefined && options.trace !== null) {
1403
+ options.trace.record(new TraceEvent(index, "content_pass", "numeral", true, {
1404
+ consumed: reclaimed.consumed,
1405
+ yield_reason: step.yieldedNumeral.reason,
1406
+ tail_parser_reason: tailParserFailureReason
1407
+ }));
1408
+ }
1409
+ const reclaimedSpan = makeAssemblyContentSpan(index, reclaimed.consumed, reclaimed.korean, 수사, null, UnitType.NUMERAL);
1410
+ if (reclaimed.renderPlan !== null) {
1411
+ reclaimedSpan.renderPlan = reclaimed.renderPlan;
1412
+ }
1413
+ finalizeExtentPostpositionSpan(cursor, index, reclaimedSpan, pendingExtentPostpositions, this.numeric);
1414
+ contentMap.set(index, reclaimedSpan);
1415
+ cursor.advance(reclaimed.consumed);
1416
+ return "continue";
1417
+ }
1418
+ return "next";
1419
+ }
1420
+ async emitCompoundDispatchSpan(ctx, step, tailParserFailureReason) {
1421
+ const { tokens, cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1422
+ const { index } = step;
1423
+ const compound = await this.tryCompoundDispatch(cursor);
1424
+ if (compound !== undefined) {
1425
+ const [consumed, korean, koreanPos, renderPlan, warnings, candidates] = compound;
1426
+ if (options.trace !== undefined && options.trace !== null) {
1427
+ options.trace.record(new TraceEvent(index, "content_pass", "compound", true, { consumed, korean_pos: koreanPos, tail_parser_reason: tailParserFailureReason }));
1428
+ }
1429
+ const shouldCacheKorean = PipelineAssemblerMixin.shouldCacheSurface(renderPlan);
1430
+ const cachedKorean = shouldCacheKorean ? this.surfaceFromRenderPlan(korean, renderPlan) : "";
1431
+ const provenanceBridge = buildTailParserFailureFallbackProvenance({
1432
+ tokens,
1433
+ cursor,
1434
+ index,
1435
+ consumed,
1436
+ renderPlan,
1437
+ reason: tailParserFailureReason,
1438
+ lookups: this.lookups
1439
+ });
1440
+ const span = makeAssemblyContentSpan(index, consumed, cachedKorean, koreanPos, null, UnitType.CONTENT, {
1441
+ attachLeft: isSahenBoundVerbAfterSahen(tokens, index) && !renderPlanStartsWithShortNegation(renderPlan),
1442
+ provenance: provenanceBridge.provenance,
1443
+ provenanceReason: provenanceBridge.provenanceReason,
1444
+ warnings: warnings ?? []
1445
+ });
1446
+ span.renderPlan = renderPlan ?? null;
1447
+ if (candidates !== undefined && candidates.length > 0) {
1448
+ span.sourceCandidates = createSourceCandidateSet(candidates.map((candidate) => stagedCandidate(candidate, "unknown")), { sharedConsumed: consumed });
1449
+ }
1450
+ span.compoundHeadFrameEntry = await this.compoundSemanticHeadEntry(tokens, index, renderPlan ?? null);
1451
+ closeUnownedTailFallbackSpanToRaw(span, tokens);
1452
+ finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
1453
+ contentMap.set(index, span);
1454
+ return "continue";
1455
+ }
1456
+ return "next";
1457
+ }
1458
+ async emitGeneralContentSpan(ctx, step, dispatch, verdict, tailParserFailureReason) {
1459
+ const { tokens, cursor, contentMap, pendingExtentPostpositions, options } = ctx;
1460
+ const { index } = step;
1461
+ const { contentHead, buildHeadTailCandidatePayloadSource } = dispatch;
1462
+ const { numericYieldClaimMissed, contestedNominalUseSlot, contestedClaimCoordinate } = verdict;
1463
+ const result = await this._processContent(cursor.fork(index, tokens.length, index), {
1464
+ trace: options.trace ?? null,
1465
+ contentMap
1466
+ });
1467
+ const prenominalModifierSpan = this.tryBuildModifiedHeadPrenominalModifierSpan(tokens, index, result);
1468
+ if (prenominalModifierSpan !== null) {
1469
+ if (options.trace !== undefined && options.trace !== null) {
1470
+ options.trace.record(new TraceEvent(index, "content_pass", "modified_head_prenominal_modifier", true, { consumed: result.consumed, korean_pos: contentResultKoreanPos(result) }));
1471
+ }
1472
+ finalizeExtentPostpositionSpan(cursor, index, prenominalModifierSpan, pendingExtentPostpositions, this.numeric);
1473
+ contentMap.set(index, prenominalModifierSpan);
1474
+ cursor.advance(result.consumed);
1475
+ return;
1476
+ }
1477
+ const cacheKorean = PipelineAssemblerMixin.shouldCacheSurface(result.renderPlan);
1478
+ const realizedKorean = cacheKorean ? this.surfaceFromRenderPlan(contentResultKoreanCache(result), result.renderPlan) : "";
1479
+ const predicateIntake = !numericYieldClaimMissed && contestedNominalUseSlot === null && contentHead?.kind === "none"
1480
+ ? contentHead.predicateIntake
1481
+ : undefined;
1482
+ const descriptor = buildTailParserFallbackAssemblyDescriptor({
1483
+ cursor: cursor.fork(index, cursor.end, index),
1484
+ result,
1485
+ reason: tailParserFailureReason,
1486
+ mode: contestedClaimCoordinate ? "contested_claim_yield" : "parse_failure",
1487
+ ...(predicateIntake === undefined ? {} : { predicateIntake }),
1488
+ realizedKorean,
1489
+ cacheKorean,
1490
+ isKeijoujiVerbObjectHost,
1491
+ lookups: this.lookups
1492
+ });
1493
+ const span = applyTailParserFallbackDescriptorToSpan(descriptor, index, tokens, this.lookups);
1494
+ const intrinsicHonorific = selectedIntrinsicHonorificMetadata(result.sourceCandidates, result.entry);
1495
+ if (intrinsicHonorific !== undefined)
1496
+ span.intrinsicHonorific = intrinsicHonorific;
1497
+ if (contestedNominalUseSlot !== null && contentHead?.kind === "tail") {
1498
+ await attachContestedNominalUseOwnerCandidateLifecycle({
1499
+ tokens,
1500
+ dispatchIndex: index,
1501
+ contentHead,
1502
+ contestedNominalUseSlot,
1503
+ span,
1504
+ buildTailPayloadSource: buildHeadTailCandidatePayloadSource
1505
+ });
1506
+ }
1507
+ finalizeExtentPostpositionSpan(cursor, index, span, pendingExtentPostpositions, this.numeric);
1508
+ contentMap.set(index, span);
1509
+ cursor.advance(descriptor.consumed);
1510
+ }
1878
1511
  descriptorToSpan(tokens, index, result) {
1879
1512
  if (result === null) {
1880
1513
  return null;
@@ -2046,18 +1679,6 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
2046
1679
  }
2047
1680
  return resolveContext(entry, tokens, index, { lookups: this.lookups, numeric: this.numeric });
2048
1681
  }
2049
- async sahenInfo(tokens, start) {
2050
- const isSahen = isSahenBoundVerbAfterSahen(tokens, start);
2051
- if (!isSahen) {
2052
- return [false, null];
2053
- }
2054
- const noun = tokens[start - 1];
2055
- if (noun === undefined) {
2056
- return [true, null];
2057
- }
2058
- const entry = committedLookupEntry(await this.dictionary.lookupTokenRelaxed(noun));
2059
- return [true, entry === null ? null : winnerKorean(entry) ?? null];
2060
- }
2061
1682
  async nominalLightVerbProjectionAt(cursor, nounSpan, contentMap, layout) {
2062
1683
  const link = nominalLightVerbObjectLinkAt(cursor.tokens, cursor.pos, nounSpan.consumed, contentMap, layout);
2063
1684
  if (link === null) {
@@ -2085,54 +1706,21 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
2085
1706
  const repairedContentMap = new Map();
2086
1707
  const carrierOverrides = new Map();
2087
1708
  const cursor = new TokenCursor(tokens, 0, tokens.length);
1709
+ const ctx = {
1710
+ cursor,
1711
+ units,
1712
+ contentMap,
1713
+ repairedContentMap,
1714
+ carrierOverrides,
1715
+ layout,
1716
+ relationRenderSpans,
1717
+ options
1718
+ };
2088
1719
  while (cursor.current() !== undefined) {
2089
1720
  const index = cursor.pos;
2090
1721
  const span = repairedContentMap.get(index) ?? contentMap.get(index);
2091
1722
  if (span !== undefined) {
2092
- const nominalLightVerb = await this.nominalLightVerbProjectionAt(cursor, span, contentMap, layout);
2093
- if (nominalLightVerb !== null) {
2094
- carrierOverrides.set(nominalLightVerb.predicateIndex, nominalLightVerb);
2095
- }
2096
- const surface = cursor.current()?.surface;
2097
- const pos1 = (cursor.current()?.pos ?? 0) & POS1;
2098
- if (surface === "だけでなく" || (surface === "だけ" && (pos1 === 副助詞))) {
2099
- if (await this.matchFocusDakeCopulaTail(cursor, units, options.trace)) {
2100
- continue;
2101
- }
2102
- }
2103
- if ((cursor.current().pos & POS0) === 助動詞 && span.discourseConnective !== true) {
2104
- if (this.tryApplyParticlePhraseCopulaChain(cursor, units, layout, relationRenderSpans)) {
2105
- continue;
2106
- }
2107
- if (this.tryApplyPunctuatedCopulaChain(cursor, units, layout, relationRenderSpans)) {
2108
- continue;
2109
- }
2110
- }
2111
- const carrierOverride = carrierOverrides.get(index);
2112
- const baseRenderPlan = applyCopulaFocusAdjunctRenderPlan(carrierOverride === undefined ? span.renderPlan : carrierOverride.renderPlan, span);
2113
- const renderPlan = applyBareQuestionRenderPlan(baseRenderPlan, cursor.tokens, index + span.consumed, cursor.end);
2114
- const shouldCacheKorean = PipelineAssemblerMixin.shouldCacheSurface(renderPlan);
2115
- const shouldCacheBaseKorean = PipelineAssemblerMixin.shouldCacheBaseSurface(renderPlan);
2116
- const realizedKorean = shouldCacheKorean || shouldCacheBaseKorean
2117
- ? this.surfaceFromRenderPlan(span.korean, renderPlan)
2118
- : "";
2119
- const cachedKorean = shouldCacheKorean ? realizedKorean : "";
2120
- const cachedBaseKorean = shouldCacheBaseKorean ? realizedKorean : span.koreanBase ?? "";
2121
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, span.consumed, cachedKorean, {
2122
- unitType: span.unitType,
2123
- koreanPos: span.koreanPos,
2124
- entry: span.entry,
2125
- renderPlan,
2126
- koreanBase: cachedBaseKorean,
2127
- attachLeft: span.attachLeft,
2128
- particleRole: span.particleRole,
2129
- provenance: span.provenance,
2130
- discourseConnective: span.discourseConnective,
2131
- provenanceReason: carrierOverride === undefined ? span.provenanceReason : "carrier_idiom",
2132
- warnings: span.warnings,
2133
- renderPlanPolicy: span.renderPlanPolicy
2134
- });
2135
- cursor.advance(span.consumed);
1723
+ await this.appendAssemblyContentSpanUnit(ctx, index, span);
2136
1724
  continue;
2137
1725
  }
2138
1726
  const token = cursor.current();
@@ -2146,80 +1734,15 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
2146
1734
  }
2147
1735
  const pos0 = token.pos & POS0;
2148
1736
  if (isNonLexicalSymbolTokenAt(cursor.tokens, index)) {
2149
- if (isHardTerminalPunctuationToken(token) &&
2150
- questionContentPunctuationBridgeRelationAt(cursor.tokens, index, { consumers: ["assembler"] }) !== null) {
2151
- cursor.advance();
2152
- continue;
2153
- }
2154
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, token.surface, {
2155
- unitType: UnitType.SYMBOL,
2156
- koreanPos: 기호,
2157
- attachLeft: true,
2158
- attachRight: true,
2159
- terminalPunctuationRun: layout.terminalPunctuationRunContaining(index) ?? null
2160
- });
2161
- cursor.advance();
1737
+ this.appendNonLexicalSymbolUnit(ctx, index, token);
2162
1738
  continue;
2163
1739
  }
2164
1740
  if (pos0in(pos0, PASSTHROUGH_POS_BITS) && !isSymbolCharacterToken(token)) {
2165
- if (token.surface.length > 0) {
2166
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, token.surface, {
2167
- unitType: UnitType.SYMBOL,
2168
- koreanPos: 기호,
2169
- attachLeft: true,
2170
- attachRight: true
2171
- });
2172
- }
2173
- else {
2174
- absorbIntoPrecedingUnit(units, index);
2175
- }
2176
- cursor.advance();
1741
+ this.appendPassthroughSymbolUnit(ctx, index, token);
2177
1742
  continue;
2178
1743
  }
2179
1744
  if ((token.pos & POS0) === 助詞) {
2180
- if (await this.matchPronominalNoDispatch(cursor, units, options.trace)) {
2181
- continue;
2182
- }
2183
- if (this.tryApplyTrailingCopulaNegation(cursor, units)) {
2184
- continue;
2185
- }
2186
- if (isAssemblerTerminalQuestionKa(cursor.tokens, index)) {
2187
- const nextIndex = nextNonSpaceIndex(cursor.tokens, index + 1) ?? cursor.end;
2188
- if (nextIndex >= cursor.end) {
2189
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, "?", {
2190
- unitType: UnitType.SYMBOL,
2191
- koreanPos: 기호,
2192
- attachLeft: true,
2193
- attachRight: true
2194
- });
2195
- cursor.advance();
2196
- continue;
2197
- }
2198
- if (hasHardTerminalPunctuationClass(cursor.tokens[nextIndex], nextIndex, ["japanese_period"], ["assembler"])) {
2199
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, nextIndex - index + 1, "?", {
2200
- unitType: UnitType.SYMBOL,
2201
- koreanPos: 기호,
2202
- attachLeft: true,
2203
- attachRight: true
2204
- });
2205
- cursor.advance(nextIndex + 1 - cursor.pos);
2206
- continue;
2207
- }
2208
- }
2209
- if (isTerminalYoSfpSurface(token)) {
2210
- if (isVocativeYo(cursor.tokens, index)) {
2211
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, "", {
2212
- unitType: UnitType.FUNCTIONAL,
2213
- koreanPos: 조사,
2214
- attachLeft: true,
2215
- functionalKind: FunctionalKind.CONTEXTUAL,
2216
- allomorphKey: "이여/여"
2217
- });
2218
- }
2219
- else {
2220
- absorbIntoPrecedingUnit(units, index);
2221
- }
2222
- cursor.advance();
1745
+ if (await this.applyAssemblyParticlePrelude(ctx, index, token) === "continue") {
2223
1746
  continue;
2224
1747
  }
2225
1748
  }
@@ -2240,278 +1763,24 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
2240
1763
  }
2241
1764
  }
2242
1765
  if ((token.pos & POS0) === 助動詞) {
2243
- const pronominalNoIndex = nextNonSpaceIndex(cursor.tokens, index + 1, cursor.end);
2244
- const previousToken = cursor.tokens[index - 1];
2245
- if (isAdnominalCopulaToken(token) &&
2246
- previousToken !== undefined &&
2247
- isNaAdjectiveDerivationalSuffix(previousToken) &&
2248
- pronominalNoIndex !== null &&
2249
- pronominalNoMarkerRelationForToken(cursor.tokens[pronominalNoIndex], pronominalNoIndex, {
2250
- requirement: "copula_tail",
2251
- consumers: ["pronominal_no_dispatch"],
2252
- }) !== null) {
2253
- absorbIntoPrecedingUnit(units, index);
2254
- cursor.advance();
2255
- continue;
2256
- }
2257
- if (this.tryApplyEllipticPoliteConfirmation(cursor, units, layout)) {
2258
- continue;
2259
- }
2260
- if (this.tryApplyParticlePhraseCopulaChain(cursor, units, layout, relationRenderSpans)) {
2261
- continue;
2262
- }
2263
- if (this.tryApplyPunctuatedCopulaChain(cursor, units, layout, relationRenderSpans)) {
2264
- continue;
2265
- }
2266
- if (this.tryApplyTrailingCopulaNegation(cursor, units)) {
1766
+ if (this.applyResidualAuxiliaryCopulaOwners(ctx, index, token) === "continue") {
2267
1767
  continue;
2268
1768
  }
2269
1769
  if (await this.matchPronominalNoAuxDeDispatch(cursor, units, options.trace)) {
2270
1770
  continue;
2271
1771
  }
2272
- const previousUnit = lastOutputUnit(units);
2273
- const preceding = this.precedingForAllomorph(units);
2274
- const hasPunctuatedCopulaConnectiveHost = this.hasPunctuatedCopulaConnectiveHost(units);
2275
- let orphanConn;
2276
- if (!(isCopulaAuxToken(token) && (canHostTrailingCopulaConnective(previousUnit, preceding) || hasPunctuatedCopulaConnectiveHost))) {
2277
- orphanConn = matchOrphanCopulaConn(cursor);
2278
- }
2279
- orphanConn ??= matchOrphanNanoconn(cursor);
2280
- if (orphanConn !== undefined) {
2281
- const [korean, orphanConsumed] = orphanConn;
2282
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, orphanConsumed, korean, {
2283
- unitType: UnitType.CONTENT,
2284
- koreanPos: 접속사
2285
- });
2286
- cursor.advance(orphanConsumed);
2287
- continue;
2288
- }
2289
- if (this.matchDearuAux(cursor, units)) {
2290
- continue;
2291
- }
2292
- if (isCopulaAuxToken(token)) {
2293
- const auxProbe1 = cursor.lookahead(index - cursor.pos, c => {
2294
- const auxTokens = collectAuxTokens(c);
2295
- return { auxTokens, afterAux: c.pos };
2296
- });
2297
- const auxTokens = auxProbe1.auxTokens;
2298
- if (auxTokens.length > 0) {
2299
- const connectiveMatch1 = cursor.lookahead(auxProbe1.afterAux - cursor.pos, c => {
2300
- const connective = trailingCopulaConnectiveTail(c, this.lookups);
2301
- return connective === null ? null : { connective, consumed: c.pos - index };
2302
- });
2303
- if (connectiveMatch1 !== null) {
2304
- const puncConsumed = this.tryAppendTrailingPunctuationCopulaConnective(cursor.tokens, index, connectiveMatch1.consumed, units, auxTokens, connectiveMatch1.connective);
2305
- if (puncConsumed !== null) {
2306
- cursor.advance(puncConsumed);
2307
- continue;
2308
- }
2309
- }
2310
- const punctuatedTerminalConsumed = this.tryAppendPunctuatedCopulaTerminalTail(cursor, index, auxProbe1.afterAux, units, auxTokens);
2311
- if (punctuatedTerminalConsumed !== null) {
2312
- cursor.advance(punctuatedTerminalConsumed);
2313
- continue;
2314
- }
2315
- }
2316
- }
2317
- if (isCopulaAuxToken(token) && canHostTrailingCopula(previousUnit, preceding)) {
2318
- const auxProbe2 = cursor.lookahead(index - cursor.pos, c => {
2319
- const auxTokens = collectAuxTokens(c);
2320
- return { auxTokens, afterAux: c.pos };
2321
- });
2322
- const auxTokens = auxProbe2.auxTokens;
2323
- if (auxTokens.length > 0 && canHostTrailingCopulaConnective(previousUnit, preceding)) {
2324
- const connectiveMatch2 = cursor.lookahead(auxProbe2.afterAux - cursor.pos, c => {
2325
- const connective = trailingCopulaConnectiveTail(c, this.lookups);
2326
- return connective === null ? null : { connective, consumed: c.pos - index };
2327
- });
2328
- if (connectiveMatch2 !== null) {
2329
- if (previousUnit !== undefined) {
2330
- applyHeadedPlanTrailingCopula(previousUnit, "", {
2331
- auxTokens,
2332
- baseText: preceding,
2333
- connective: connectiveMatch2.connective
2334
- });
2335
- for (let offset = 0; offset < connectiveMatch2.consumed; offset++) {
2336
- if (!previousUnit.jpIndices.includes(index + offset)) {
2337
- previousUnit.jpIndices.push(index + offset);
2338
- }
2339
- }
2340
- }
2341
- else {
2342
- const features = auxExtractFeatures(auxTokens, { lookups: this.lookups });
2343
- const copula = nounCopulaConnective(preceding, connectiveMatch2.connective, features.past);
2344
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, connectiveMatch2.consumed, copula, {
2345
- unitType: UnitType.CONTENT
2346
- });
2347
- }
2348
- cursor.advance(connectiveMatch2.consumed);
2349
- continue;
2350
- }
2351
- }
2352
- if (auxTokens.length > 0 && cursor.lookahead(auxProbe2.afterAux - cursor.pos, hasTerminalSentenceMark)) {
2353
- const terminalConsumed = auxProbe2.afterAux - index;
2354
- if (previousUnit !== undefined) {
2355
- applyHeadedPlanTrailingCopula(previousUnit, "", { auxTokens, baseText: preceding });
2356
- for (let offset = 0; offset < terminalConsumed; offset++) {
2357
- if (!previousUnit.jpIndices.includes(index + offset)) {
2358
- previousUnit.jpIndices.push(index + offset);
2359
- }
2360
- }
2361
- }
2362
- else {
2363
- const features = auxExtractFeatures(auxTokens, { lookups: this.lookups });
2364
- features.copula = true;
2365
- const copula = nounCopula(preceding, features, this._formal, this.lookups).text;
2366
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, terminalConsumed, copula, {
2367
- unitType: UnitType.CONTENT
2368
- });
2369
- }
2370
- cursor.advance(terminalConsumed);
2371
- continue;
2372
- }
2373
- if (auxTokens.length > 0) {
2374
- const questionMatch = cursor.lookahead(auxProbe2.afterAux - cursor.pos, c => {
2375
- const question = terminalQuestionTail(c);
2376
- return question === null ? null : { question, consumed: c.pos - index };
2377
- });
2378
- if (questionMatch !== null) {
2379
- const question = questionMatch.question;
2380
- if (previousUnit !== undefined) {
2381
- applyHeadedPlanTrailingCopula(previousUnit, "", { auxTokens, baseText: preceding, sfp: "polite_q" });
2382
- for (let offset = 0; offset < questionMatch.consumed; offset++) {
2383
- if (!previousUnit.jpIndices.includes(index + offset)) {
2384
- previousUnit.jpIndices.push(index + offset);
2385
- }
2386
- }
2387
- }
2388
- else {
2389
- const features = auxExtractFeatures(auxTokens, { lookups: this.lookups });
2390
- features.copula = true;
2391
- const copula = nounCopula(preceding, features, this._formal, this.lookups, "polite_q").text;
2392
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, questionMatch.consumed, copula, {
2393
- unitType: UnitType.CONTENT
2394
- });
2395
- }
2396
- if (question.absorbPeriod) {
2397
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index + auxTokens.length, questionMatch.consumed - auxTokens.length, "?", {
2398
- unitType: UnitType.SYMBOL,
2399
- koreanPos: 기호,
2400
- attachLeft: true,
2401
- attachRight: true
2402
- });
2403
- }
2404
- cursor.advance(questionMatch.consumed);
2405
- continue;
2406
- }
2407
- const sfpMatch = cursor.lookahead(auxProbe2.afterAux - cursor.pos, c => {
2408
- const sfp = trailingCopulaSfpTail(c);
2409
- return sfp === null ? null : { sfp, consumed: c.pos - index };
2410
- });
2411
- if (sfpMatch !== null) {
2412
- if (previousUnit !== undefined) {
2413
- applyHeadedPlanTrailingCopula(previousUnit, "", { auxTokens, baseText: preceding, sfp: sfpMatch.sfp });
2414
- for (let offset = 0; offset < sfpMatch.consumed; offset++) {
2415
- if (!previousUnit.jpIndices.includes(index + offset)) {
2416
- previousUnit.jpIndices.push(index + offset);
2417
- }
2418
- }
2419
- }
2420
- else {
2421
- const features = auxExtractFeatures(auxTokens, { lookups: this.lookups });
2422
- features.copula = true;
2423
- const copula = nounCopula(preceding, features, this._formal, this.lookups, sfpMatch.sfp).text;
2424
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, sfpMatch.consumed, copula, {
2425
- unitType: UnitType.CONTENT
2426
- });
2427
- }
2428
- cursor.advance(sfpMatch.consumed);
2429
- continue;
2430
- }
2431
- }
2432
- }
2433
- absorbIntoPrecedingUnit(units, index);
2434
- cursor.advance();
1772
+ this.assembleResidualCopulaTail(ctx, index, token);
2435
1773
  continue;
2436
1774
  }
2437
1775
  if ((token.pos & POS0) === 接頭辞) {
2438
- const entry = committedLookupEntry(await this.dictionary.lookupTokenRelaxed(token));
2439
- const korean = entry === null ? token.surface : winnerKorean(entry) ?? "";
2440
- if (korean.length > 0) {
2441
- const defaultAttachRight = entry !== null ? (winner(entry).attachRight ?? true) : true;
2442
- const attachRight = prefixAttachRightForToken(token, cursor.tokens, index, defaultAttachRight);
2443
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, korean, {
2444
- unitType: UnitType.PREFIX,
2445
- koreanPos: 접두사,
2446
- entry,
2447
- renderPlan: { kind: "fixedText", text: korean, koreanPos: 접두사 },
2448
- attachRight
2449
- });
2450
- }
2451
- cursor.advance();
1776
+ await this.appendAssemblyPrefixUnit(ctx, index, token);
2452
1777
  continue;
2453
1778
  }
2454
1779
  if ((token.pos & POS0) === 接尾辞) {
2455
- const clusterDecision = honorificClusterSuffixDecision(cursor.tokens, index, honorificClusterLookupsFrom(this.lookups));
2456
- if (clusterDecision?.kind === "absorbed") {
2457
- absorbIntoPrecedingUnit(units, index);
2458
- cursor.advance();
2459
- continue;
2460
- }
2461
- if (clusterDecision?.kind === "override") {
2462
- const clusterOverride = clusterDecision.realization;
2463
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, clusterOverride.korean, {
2464
- unitType: UnitType.SUFFIX,
2465
- koreanPos: 접미사,
2466
- attachLeft: clusterOverride.attachLeft,
2467
- renderPlan: {
2468
- kind: "fixedText",
2469
- text: clusterOverride.korean,
2470
- koreanPos: 접미사
2471
- }
2472
- });
2473
- cursor.advance();
2474
- continue;
2475
- }
2476
- let entry = await this.dictionary.lookupTokenRelaxed(token);
2477
- if (entry !== undefined) {
2478
- entry = resolveContext(entry, cursor.tokens, index, { layout, lookups: this.lookups, numeric: this.numeric });
2479
- }
2480
- const committed = committedLookupEntry(entry);
2481
- let korean = committed === null ? token.surface : winnerKorean(committed) ?? "";
2482
- const previousUnit = lastOutputUnit(units);
2483
- let suffixAttachLeft = committed !== null ? (winner(committed).attachLeft ?? true) : true;
2484
- if (token.dictionaryForm === "方"
2485
- && token.reading === "カタ"
2486
- && index > 0
2487
- && previousUnit !== undefined) {
2488
- const hostPlan = kataVerbHostAttributivePlan(previousUnit);
2489
- if (hostPlan !== null) {
2490
- previousUnit.setRenderPlan(hostPlan, { rule: "SUFFIX-KATA-VERB", cacheValue: "" });
2491
- korean = "법";
2492
- suffixAttachLeft = false;
2493
- }
2494
- }
2495
- if (suffixNominalizerAlreadyLexicalizedInPreviousUnit(token, korean, previousUnit)) {
2496
- absorbIntoPrecedingUnit(units, index);
2497
- cursor.advance();
1780
+ if (this.applyHonorificClusterSuffix(ctx, index) === "continue") {
2498
1781
  continue;
2499
1782
  }
2500
- rewriteFunctionalAdjectivalSuffixHostToNominalized(token, previousUnit);
2501
- if (korean.length > 0) {
2502
- const renderPlan = suffixRenderPlanFromCommittedEntry(committed, korean);
2503
- PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, korean, {
2504
- unitType: UnitType.SUFFIX,
2505
- koreanPos: 접미사,
2506
- entry: committed,
2507
- attachLeft: suffixAttachLeft,
2508
- ...(renderPlan === null ? {} : { renderPlan })
2509
- });
2510
- }
2511
- else {
2512
- absorbIntoPrecedingUnit(units, index);
2513
- }
2514
- cursor.advance();
1783
+ await this.appendLexicalSuffixUnit(ctx, index, token);
2515
1784
  continue;
2516
1785
  }
2517
1786
  const repairedConsumed = await this.tryAppendRepairedContentSpan(cursor, units, contentMap, repairedContentMap, layout, options);
@@ -2527,29 +1796,497 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
2527
1796
  this.absorbUncoveredAssemblyTokens(cursor.tokens, units, contentMap, layout);
2528
1797
  return units;
2529
1798
  }
2530
- async tryAppendRepairedContentSpan(cursor, units, contentMap, repairedContentMap, layout, options) {
2531
- const { tokens, pos: index } = cursor;
2532
- const token = tokens[index];
2533
- if (token === undefined || !isContentAdmissionToken(token)) {
2534
- return null;
1799
+ async appendAssemblyContentSpanUnit(ctx, index, span) {
1800
+ const { cursor, units, contentMap, layout, carrierOverrides, relationRenderSpans, options } = ctx;
1801
+ const nominalLightVerb = await this.nominalLightVerbProjectionAt(cursor, span, contentMap, layout);
1802
+ if (nominalLightVerb !== null) {
1803
+ carrierOverrides.set(nominalLightVerb.predicateIndex, nominalLightVerb);
2535
1804
  }
2536
- const seed = contentMapRepairSeed(contentMap, units, index);
2537
- const regenerated = await this.contentPass(tokens, {
2538
- trace: options.trace ?? null,
2539
- startIndex: index,
2540
- seedContentMap: seed,
2541
- resolveDeferredCopulaSupportAt: index
2542
- });
2543
- const regeneratedNew = new Map();
2544
- for (const [start, span] of regenerated) {
2545
- if (start >= index) {
2546
- repairedContentMap.set(start, span);
2547
- if (contentMap.get(start) !== span) {
2548
- regeneratedNew.set(start, span);
2549
- }
1805
+ const surface = cursor.current()?.surface;
1806
+ const pos1 = (cursor.current()?.pos ?? 0) & POS1;
1807
+ if (surface === "だけでなく" || (surface === "だけ" && (pos1 === 副助詞))) {
1808
+ if (await this.matchFocusDakeCopulaTail(cursor, units, options.trace)) {
1809
+ return;
2550
1810
  }
2551
1811
  }
2552
- if (regeneratedNew.size > 0) {
1812
+ if ((cursor.current().pos & POS0) === 助動詞 && span.discourseConnective !== true) {
1813
+ if (this.tryApplyParticlePhraseCopulaChain(cursor, units, layout, relationRenderSpans)) {
1814
+ return;
1815
+ }
1816
+ if (this.tryApplyPunctuatedCopulaChain(cursor, units, layout, relationRenderSpans)) {
1817
+ return;
1818
+ }
1819
+ }
1820
+ const carrierOverride = carrierOverrides.get(index);
1821
+ const baseRenderPlan = applyCopulaFocusAdjunctRenderPlan(carrierOverride === undefined ? span.renderPlan : carrierOverride.renderPlan, span);
1822
+ const renderPlan = applyBareQuestionRenderPlan(baseRenderPlan, cursor.tokens, index + span.consumed, cursor.end);
1823
+ const shouldCacheKorean = PipelineAssemblerMixin.shouldCacheSurface(renderPlan);
1824
+ const shouldCacheBaseKorean = PipelineAssemblerMixin.shouldCacheBaseSurface(renderPlan);
1825
+ const realizedKorean = shouldCacheKorean || shouldCacheBaseKorean
1826
+ ? this.surfaceFromRenderPlan(span.korean, renderPlan)
1827
+ : "";
1828
+ const cachedKorean = shouldCacheKorean ? realizedKorean : "";
1829
+ const cachedBaseKorean = shouldCacheBaseKorean ? realizedKorean : span.koreanBase ?? "";
1830
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, span.consumed, cachedKorean, {
1831
+ unitType: span.unitType,
1832
+ koreanPos: span.koreanPos,
1833
+ entry: span.entry,
1834
+ renderPlan,
1835
+ koreanBase: cachedBaseKorean,
1836
+ attachLeft: span.attachLeft,
1837
+ particleRole: span.particleRole,
1838
+ provenance: span.provenance,
1839
+ discourseConnective: span.discourseConnective,
1840
+ provenanceReason: carrierOverride === undefined ? span.provenanceReason : "carrier_idiom",
1841
+ warnings: span.warnings,
1842
+ renderPlanPolicy: span.renderPlanPolicy
1843
+ });
1844
+ cursor.advance(span.consumed);
1845
+ }
1846
+ appendNonLexicalSymbolUnit(ctx, index, token) {
1847
+ const { cursor, units, layout } = ctx;
1848
+ if (isHardTerminalPunctuationToken(token) &&
1849
+ questionContentPunctuationBridgeRelationAt(cursor.tokens, index, { consumers: ["assembler"] }) !== null) {
1850
+ cursor.advance();
1851
+ return;
1852
+ }
1853
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, token.surface, {
1854
+ unitType: UnitType.SYMBOL,
1855
+ koreanPos: 기호,
1856
+ attachLeft: true,
1857
+ attachRight: true,
1858
+ terminalPunctuationRun: layout.terminalPunctuationRunContaining(index) ?? null
1859
+ });
1860
+ cursor.advance();
1861
+ }
1862
+ appendPassthroughSymbolUnit(ctx, index, token) {
1863
+ const { cursor, units } = ctx;
1864
+ if (token.surface.length > 0) {
1865
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, token.surface, {
1866
+ unitType: UnitType.SYMBOL,
1867
+ koreanPos: 기호,
1868
+ attachLeft: true,
1869
+ attachRight: true
1870
+ });
1871
+ }
1872
+ else {
1873
+ absorbIntoPrecedingUnit(units, index);
1874
+ }
1875
+ cursor.advance();
1876
+ }
1877
+ async applyAssemblyParticlePrelude(ctx, index, token) {
1878
+ const { cursor, units, options } = ctx;
1879
+ if (await this.matchPronominalNoDispatch(cursor, units, options.trace)) {
1880
+ return "continue";
1881
+ }
1882
+ if (this.tryApplyTrailingCopulaNegation(cursor, units)) {
1883
+ return "continue";
1884
+ }
1885
+ if (isAssemblerTerminalQuestionKa(cursor.tokens, index)) {
1886
+ const nextIndex = nextNonSpaceIndex(cursor.tokens, index + 1) ?? cursor.end;
1887
+ if (nextIndex >= cursor.end) {
1888
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, "?", {
1889
+ unitType: UnitType.SYMBOL,
1890
+ koreanPos: 기호,
1891
+ attachLeft: true,
1892
+ attachRight: true
1893
+ });
1894
+ cursor.advance();
1895
+ return "continue";
1896
+ }
1897
+ if (hasHardTerminalPunctuationClass(cursor.tokens[nextIndex], nextIndex, ["japanese_period"], ["assembler"])) {
1898
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, nextIndex - index + 1, "?", {
1899
+ unitType: UnitType.SYMBOL,
1900
+ koreanPos: 기호,
1901
+ attachLeft: true,
1902
+ attachRight: true
1903
+ });
1904
+ cursor.advance(nextIndex + 1 - cursor.pos);
1905
+ return "continue";
1906
+ }
1907
+ }
1908
+ if (isTerminalYoSfpSurface(token)) {
1909
+ if (isVocativeYo(cursor.tokens, index)) {
1910
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, "", {
1911
+ unitType: UnitType.FUNCTIONAL,
1912
+ koreanPos: 조사,
1913
+ attachLeft: true,
1914
+ functionalKind: FunctionalKind.CONTEXTUAL,
1915
+ allomorphKey: "이여/여"
1916
+ });
1917
+ }
1918
+ else {
1919
+ absorbIntoPrecedingUnit(units, index);
1920
+ }
1921
+ cursor.advance();
1922
+ return "continue";
1923
+ }
1924
+ return "next";
1925
+ }
1926
+ applyResidualAuxiliaryCopulaOwners(ctx, index, token) {
1927
+ const { cursor, units, layout, relationRenderSpans } = ctx;
1928
+ if (this.absorbNaAdjectiveSuffixAdnominalCopula(ctx, index, token) === "continue") {
1929
+ return "continue";
1930
+ }
1931
+ if (this.tryApplyEllipticPoliteConfirmation(cursor, units, layout)) {
1932
+ return "continue";
1933
+ }
1934
+ if (this.tryApplyParticlePhraseCopulaChain(cursor, units, layout, relationRenderSpans)) {
1935
+ return "continue";
1936
+ }
1937
+ if (this.tryApplyPunctuatedCopulaChain(cursor, units, layout, relationRenderSpans)) {
1938
+ return "continue";
1939
+ }
1940
+ if (this.tryApplyTrailingCopulaNegation(cursor, units)) {
1941
+ return "continue";
1942
+ }
1943
+ return "next";
1944
+ }
1945
+ assembleResidualCopulaTail(ctx, index, token) {
1946
+ const { cursor, units } = ctx;
1947
+ const previousUnit = lastOutputUnit(units);
1948
+ const preceding = this.precedingForAllomorph(units);
1949
+ const hasPunctuatedCopulaConnectiveHost = this.hasPunctuatedCopulaConnectiveHost(units);
1950
+ if (this.appendOrphanCopulaConnective(ctx, index, token, previousUnit, preceding, hasPunctuatedCopulaConnectiveHost) === "continue") {
1951
+ return;
1952
+ }
1953
+ if (this.matchDearuAux(cursor, units)) {
1954
+ return;
1955
+ }
1956
+ if (this.appendPunctuatedTrailingCopulaTail(ctx, index, token) === "continue") {
1957
+ return;
1958
+ }
1959
+ if (isCopulaAuxToken(token) && canHostTrailingCopula(previousUnit, preceding)) {
1960
+ if (this.foldTrailingCopulaTail(ctx, index, previousUnit, preceding) === "continue") {
1961
+ return;
1962
+ }
1963
+ }
1964
+ absorbIntoPrecedingUnit(units, index);
1965
+ cursor.advance();
1966
+ }
1967
+ absorbNaAdjectiveSuffixAdnominalCopula(ctx, index, token) {
1968
+ const { cursor, units } = ctx;
1969
+ const pronominalNoIndex = nextNonSpaceIndex(cursor.tokens, index + 1, cursor.end);
1970
+ const previousToken = cursor.tokens[index - 1];
1971
+ if (isAdnominalCopulaToken(token) &&
1972
+ previousToken !== undefined &&
1973
+ isNaAdjectiveDerivationalSuffix(previousToken) &&
1974
+ pronominalNoIndex !== null &&
1975
+ pronominalNoMarkerRelationForToken(cursor.tokens[pronominalNoIndex], pronominalNoIndex, {
1976
+ requirement: "copula_tail",
1977
+ consumers: ["pronominal_no_dispatch"],
1978
+ }) !== null) {
1979
+ absorbIntoPrecedingUnit(units, index);
1980
+ cursor.advance();
1981
+ return "continue";
1982
+ }
1983
+ return "next";
1984
+ }
1985
+ appendOrphanCopulaConnective(ctx, index, token, previousUnit, preceding, hasPunctuatedCopulaConnectiveHost) {
1986
+ const { cursor, units } = ctx;
1987
+ let orphanConn;
1988
+ if (!(isCopulaAuxToken(token) && (canHostTrailingCopulaConnective(previousUnit, preceding) || hasPunctuatedCopulaConnectiveHost))) {
1989
+ orphanConn = matchOrphanCopulaConn(cursor);
1990
+ }
1991
+ orphanConn ??= matchOrphanNanoconn(cursor);
1992
+ if (orphanConn !== undefined) {
1993
+ const [korean, orphanConsumed] = orphanConn;
1994
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, orphanConsumed, korean, {
1995
+ unitType: UnitType.CONTENT,
1996
+ koreanPos: 접속사
1997
+ });
1998
+ cursor.advance(orphanConsumed);
1999
+ return "continue";
2000
+ }
2001
+ return "next";
2002
+ }
2003
+ appendPunctuatedTrailingCopulaTail(ctx, index, token) {
2004
+ const { cursor, units } = ctx;
2005
+ if (isCopulaAuxToken(token)) {
2006
+ const auxProbe1 = cursor.lookahead(index - cursor.pos, c => {
2007
+ const auxTokens = collectAuxTokens(c);
2008
+ return { auxTokens, afterAux: c.pos };
2009
+ });
2010
+ const auxTokens = auxProbe1.auxTokens;
2011
+ if (auxTokens.length > 0) {
2012
+ const connectiveMatch1 = cursor.lookahead(auxProbe1.afterAux - cursor.pos, c => {
2013
+ const connective = trailingCopulaConnectiveTail(c, this.lookups);
2014
+ return connective === null ? null : { connective, consumed: c.pos - index };
2015
+ });
2016
+ if (connectiveMatch1 !== null) {
2017
+ const puncConsumed = this.tryAppendTrailingPunctuationCopulaConnective(cursor.tokens, index, connectiveMatch1.consumed, units, auxTokens, connectiveMatch1.connective);
2018
+ if (puncConsumed !== null) {
2019
+ cursor.advance(puncConsumed);
2020
+ return "continue";
2021
+ }
2022
+ }
2023
+ const punctuatedTerminalConsumed = this.tryAppendPunctuatedCopulaTerminalTail(cursor, index, auxProbe1.afterAux, units, auxTokens);
2024
+ if (punctuatedTerminalConsumed !== null) {
2025
+ cursor.advance(punctuatedTerminalConsumed);
2026
+ return "continue";
2027
+ }
2028
+ }
2029
+ }
2030
+ return "next";
2031
+ }
2032
+ foldTrailingCopulaTail(ctx, index, previousUnit, preceding) {
2033
+ const { cursor } = ctx;
2034
+ const auxProbe2 = cursor.lookahead(index - cursor.pos, c => {
2035
+ const auxTokens = collectAuxTokens(c);
2036
+ return { auxTokens, afterAux: c.pos };
2037
+ });
2038
+ const auxTokens = auxProbe2.auxTokens;
2039
+ const fold = { index, previousUnit, preceding, auxProbe2, auxTokens };
2040
+ if (this.foldTrailingCopulaConnective(ctx, fold) === "continue") {
2041
+ return "continue";
2042
+ }
2043
+ if (this.foldTrailingCopulaTerminal(ctx, fold) === "continue") {
2044
+ return "continue";
2045
+ }
2046
+ if (auxTokens.length > 0) {
2047
+ if (this.foldTrailingCopulaQuestion(ctx, fold) === "continue") {
2048
+ return "continue";
2049
+ }
2050
+ if (this.foldTrailingCopulaSfp(ctx, fold) === "continue") {
2051
+ return "continue";
2052
+ }
2053
+ }
2054
+ return "next";
2055
+ }
2056
+ foldTrailingCopulaConnective(ctx, fold) {
2057
+ const { cursor, units } = ctx;
2058
+ const { index, previousUnit, preceding, auxProbe2, auxTokens } = fold;
2059
+ if (auxTokens.length > 0 && canHostTrailingCopulaConnective(previousUnit, preceding)) {
2060
+ const connectiveMatch2 = cursor.lookahead(auxProbe2.afterAux - cursor.pos, c => {
2061
+ const connective = trailingCopulaConnectiveTail(c, this.lookups);
2062
+ return connective === null ? null : { connective, consumed: c.pos - index };
2063
+ });
2064
+ if (connectiveMatch2 !== null) {
2065
+ if (previousUnit !== undefined) {
2066
+ applyHeadedPlanTrailingCopula(previousUnit, "", {
2067
+ auxTokens,
2068
+ baseText: preceding,
2069
+ connective: connectiveMatch2.connective
2070
+ });
2071
+ for (let offset = 0; offset < connectiveMatch2.consumed; offset++) {
2072
+ if (!previousUnit.jpIndices.includes(index + offset)) {
2073
+ previousUnit.jpIndices.push(index + offset);
2074
+ }
2075
+ }
2076
+ }
2077
+ else {
2078
+ const features = auxExtractFeatures(auxTokens, { lookups: this.lookups });
2079
+ const copula = nounCopulaConnective(preceding, connectiveMatch2.connective, features.past);
2080
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, connectiveMatch2.consumed, copula, {
2081
+ unitType: UnitType.CONTENT
2082
+ });
2083
+ }
2084
+ cursor.advance(connectiveMatch2.consumed);
2085
+ return "continue";
2086
+ }
2087
+ }
2088
+ return "next";
2089
+ }
2090
+ foldTrailingCopulaTerminal(ctx, fold) {
2091
+ const { cursor, units } = ctx;
2092
+ const { index, previousUnit, preceding, auxProbe2, auxTokens } = fold;
2093
+ if (auxTokens.length > 0 && cursor.lookahead(auxProbe2.afterAux - cursor.pos, hasTerminalSentenceMark)) {
2094
+ const terminalConsumed = auxProbe2.afterAux - index;
2095
+ if (previousUnit !== undefined) {
2096
+ applyHeadedPlanTrailingCopula(previousUnit, "", { auxTokens, baseText: preceding });
2097
+ for (let offset = 0; offset < terminalConsumed; offset++) {
2098
+ if (!previousUnit.jpIndices.includes(index + offset)) {
2099
+ previousUnit.jpIndices.push(index + offset);
2100
+ }
2101
+ }
2102
+ }
2103
+ else {
2104
+ const features = auxExtractFeatures(auxTokens, { lookups: this.lookups });
2105
+ features.copula = true;
2106
+ const copula = nounCopula(preceding, features, this._formal, this.lookups).text;
2107
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, terminalConsumed, copula, {
2108
+ unitType: UnitType.CONTENT
2109
+ });
2110
+ }
2111
+ cursor.advance(terminalConsumed);
2112
+ return "continue";
2113
+ }
2114
+ return "next";
2115
+ }
2116
+ foldTrailingCopulaQuestion(ctx, fold) {
2117
+ const { cursor, units } = ctx;
2118
+ const { index, previousUnit, preceding, auxProbe2, auxTokens } = fold;
2119
+ const questionMatch = cursor.lookahead(auxProbe2.afterAux - cursor.pos, c => {
2120
+ const question = terminalQuestionTail(c);
2121
+ return question === null ? null : { question, consumed: c.pos - index };
2122
+ });
2123
+ if (questionMatch !== null) {
2124
+ const question = questionMatch.question;
2125
+ if (previousUnit !== undefined) {
2126
+ applyHeadedPlanTrailingCopula(previousUnit, "", { auxTokens, baseText: preceding, sfp: "polite_q" });
2127
+ for (let offset = 0; offset < questionMatch.consumed; offset++) {
2128
+ if (!previousUnit.jpIndices.includes(index + offset)) {
2129
+ previousUnit.jpIndices.push(index + offset);
2130
+ }
2131
+ }
2132
+ }
2133
+ else {
2134
+ const features = auxExtractFeatures(auxTokens, { lookups: this.lookups });
2135
+ features.copula = true;
2136
+ const copula = nounCopula(preceding, features, this._formal, this.lookups, "polite_q").text;
2137
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, questionMatch.consumed, copula, {
2138
+ unitType: UnitType.CONTENT
2139
+ });
2140
+ }
2141
+ if (question.absorbPeriod) {
2142
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index + auxTokens.length, questionMatch.consumed - auxTokens.length, "?", {
2143
+ unitType: UnitType.SYMBOL,
2144
+ koreanPos: 기호,
2145
+ attachLeft: true,
2146
+ attachRight: true
2147
+ });
2148
+ }
2149
+ cursor.advance(questionMatch.consumed);
2150
+ return "continue";
2151
+ }
2152
+ return "next";
2153
+ }
2154
+ foldTrailingCopulaSfp(ctx, fold) {
2155
+ const { cursor, units } = ctx;
2156
+ const { index, previousUnit, preceding, auxProbe2, auxTokens } = fold;
2157
+ const sfpMatch = cursor.lookahead(auxProbe2.afterAux - cursor.pos, c => {
2158
+ const sfp = trailingCopulaSfpTail(c);
2159
+ return sfp === null ? null : { sfp, consumed: c.pos - index };
2160
+ });
2161
+ if (sfpMatch !== null) {
2162
+ if (previousUnit !== undefined) {
2163
+ applyHeadedPlanTrailingCopula(previousUnit, "", { auxTokens, baseText: preceding, sfp: sfpMatch.sfp });
2164
+ for (let offset = 0; offset < sfpMatch.consumed; offset++) {
2165
+ if (!previousUnit.jpIndices.includes(index + offset)) {
2166
+ previousUnit.jpIndices.push(index + offset);
2167
+ }
2168
+ }
2169
+ }
2170
+ else {
2171
+ const features = auxExtractFeatures(auxTokens, { lookups: this.lookups });
2172
+ features.copula = true;
2173
+ const copula = nounCopula(preceding, features, this._formal, this.lookups, sfpMatch.sfp).text;
2174
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, sfpMatch.consumed, copula, {
2175
+ unitType: UnitType.CONTENT
2176
+ });
2177
+ }
2178
+ cursor.advance(sfpMatch.consumed);
2179
+ return "continue";
2180
+ }
2181
+ return "next";
2182
+ }
2183
+ async appendAssemblyPrefixUnit(ctx, index, token) {
2184
+ const { cursor, units } = ctx;
2185
+ const entry = committedLookupEntry(await this.dictionary.lookupTokenRelaxed(token));
2186
+ const korean = entry === null ? token.surface : winnerKorean(entry) ?? "";
2187
+ if (korean.length > 0) {
2188
+ const defaultAttachRight = entry !== null ? (winner(entry).attachRight ?? true) : true;
2189
+ const attachRight = prefixAttachRightForToken(token, cursor.tokens, index, defaultAttachRight);
2190
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, korean, {
2191
+ unitType: UnitType.PREFIX,
2192
+ koreanPos: 접두사,
2193
+ entry,
2194
+ renderPlan: { kind: "fixedText", text: korean, koreanPos: 접두사 },
2195
+ attachRight
2196
+ });
2197
+ }
2198
+ cursor.advance();
2199
+ }
2200
+ applyHonorificClusterSuffix(ctx, index) {
2201
+ const { cursor, units } = ctx;
2202
+ const clusterDecision = honorificClusterSuffixDecision(cursor.tokens, index, honorificClusterLookupsFrom(this.lookups));
2203
+ if (clusterDecision?.kind === "absorbed") {
2204
+ absorbIntoPrecedingUnit(units, index);
2205
+ cursor.advance();
2206
+ return "continue";
2207
+ }
2208
+ if (clusterDecision?.kind === "override") {
2209
+ const clusterOverride = clusterDecision.realization;
2210
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, clusterOverride.korean, {
2211
+ unitType: UnitType.SUFFIX,
2212
+ koreanPos: 접미사,
2213
+ attachLeft: clusterOverride.attachLeft,
2214
+ renderPlan: {
2215
+ kind: "fixedText",
2216
+ text: clusterOverride.korean,
2217
+ koreanPos: 접미사
2218
+ }
2219
+ });
2220
+ cursor.advance();
2221
+ return "continue";
2222
+ }
2223
+ return "next";
2224
+ }
2225
+ async appendLexicalSuffixUnit(ctx, index, token) {
2226
+ const { cursor, units, layout } = ctx;
2227
+ let entry = await this.dictionary.lookupTokenRelaxed(token);
2228
+ if (entry !== undefined) {
2229
+ entry = resolveContext(entry, cursor.tokens, index, { layout, lookups: this.lookups, numeric: this.numeric });
2230
+ }
2231
+ const committed = committedLookupEntry(entry);
2232
+ let korean = committed === null ? token.surface : winnerKorean(committed) ?? "";
2233
+ const previousUnit = lastOutputUnit(units);
2234
+ let suffixAttachLeft = committed !== null ? (winner(committed).attachLeft ?? true) : true;
2235
+ if (token.dictionaryForm === "方"
2236
+ && token.reading === "カタ"
2237
+ && index > 0
2238
+ && previousUnit !== undefined) {
2239
+ const hostPlan = kataVerbHostAttributivePlan(previousUnit);
2240
+ if (hostPlan !== null) {
2241
+ previousUnit.setRenderPlan(hostPlan, { rule: "SUFFIX-KATA-VERB", cacheValue: "" });
2242
+ korean = "법";
2243
+ suffixAttachLeft = false;
2244
+ }
2245
+ }
2246
+ if (suffixNominalizerAlreadyLexicalizedInPreviousUnit(token, korean, previousUnit)) {
2247
+ absorbIntoPrecedingUnit(units, index);
2248
+ cursor.advance();
2249
+ return;
2250
+ }
2251
+ rewriteFunctionalAdjectivalSuffixHostToNominalized(token, previousUnit);
2252
+ if (korean.length > 0) {
2253
+ const renderPlan = suffixRenderPlanFromCommittedEntry(committed, korean);
2254
+ PipelineAssemblerMixin.appendUnit(units, cursor.tokens, index, 1, korean, {
2255
+ unitType: UnitType.SUFFIX,
2256
+ koreanPos: 접미사,
2257
+ entry: committed,
2258
+ attachLeft: suffixAttachLeft,
2259
+ ...(renderPlan === null ? {} : { renderPlan })
2260
+ });
2261
+ }
2262
+ else {
2263
+ absorbIntoPrecedingUnit(units, index);
2264
+ }
2265
+ cursor.advance();
2266
+ }
2267
+ async tryAppendRepairedContentSpan(cursor, units, contentMap, repairedContentMap, layout, options) {
2268
+ const { tokens, pos: index } = cursor;
2269
+ const token = tokens[index];
2270
+ if (token === undefined || !isContentAdmissionToken(token)) {
2271
+ return null;
2272
+ }
2273
+ const seed = contentMapRepairSeed(contentMap, units, index);
2274
+ const regenerated = await this.contentPass(tokens, {
2275
+ trace: options.trace ?? null,
2276
+ startIndex: index,
2277
+ seedContentMap: seed,
2278
+ resolveDeferredCopulaSupportAt: index
2279
+ });
2280
+ const regeneratedNew = new Map();
2281
+ for (const [start, span] of regenerated) {
2282
+ if (start >= index) {
2283
+ repairedContentMap.set(start, span);
2284
+ if (contentMap.get(start) !== span) {
2285
+ regeneratedNew.set(start, span);
2286
+ }
2287
+ }
2288
+ }
2289
+ if (regeneratedNew.size > 0) {
2553
2290
  runRegisteredHeadedContentPlanLifecycle({
2554
2291
  tokens,
2555
2292
  contentMap: regeneratedNew,
@@ -4440,10 +4177,6 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
4440
4177
  generate(units) {
4441
4178
  return this._generate(units);
4442
4179
  }
4443
- async assembleWithUnits(tokens) {
4444
- const { units, warnings } = await this.buildUnitsForAssembly(tokens, { reanalysis: "record_only" });
4445
- return [this._generate(units, { materializeCaches: true, tokens }), units, warnings];
4446
- }
4447
4180
  async buildUnitIrForAssembly(tokens, mode, space = {}) {
4448
4181
  const built = await this.buildUnitsForAssembly(tokens, mode, space);
4449
4182
  if (isReanalysisFlipRequest(built)) {
@@ -5103,15 +4836,9 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
5103
4836
  async _renderSplitFallback(token) {
5104
4837
  return await this.renderSplitFallback(token);
5105
4838
  }
5106
- async _render_split_fallback(token) {
5107
- return await this.renderSplitFallback(token);
5108
- }
5109
4839
  async _synthesizeEntry(token, options = {}) {
5110
4840
  return this.fallbackMixin().synthesizeEntry(token, { nextToken: options.nextToken ?? null });
5111
4841
  }
5112
- async _synthesize_entry(token, options = {}) {
5113
- return this.fallbackMixin().synthesizeEntry(token, { nextToken: options.next_token ?? null });
5114
- }
5115
4842
  async diagnoseRenderPlaceNameFallback(token) {
5116
4843
  return await this.renderPlaceNameFallback(token);
5117
4844
  }
@@ -5189,1396 +4916,29 @@ export class PipelineAssemblerMixin extends PipelineCompoundMixin {
5189
4916
  function toHaruPos(pos) {
5190
4917
  return pos;
5191
4918
  }
5192
- function isParticleKey(value) {
5193
- return value in PARTICLE_PAIRS;
5194
- }
5195
- function koreanOverrideRenderPlan(token, koreanPos) {
5196
- if (token.syntheticReason === "demonstrative_tame_discourse") {
5197
- return {
5198
- kind: "discourseConnective",
5199
- payload: {
5200
- id: "demonstrative_tame_discourse",
5201
- demonstrative: demonstrativeTameKind(token),
5202
- koreanPos
5203
- }
5204
- };
5205
- }
5206
- if (token.syntheticReason === "sentence_initial_toiu_wakeda") {
5207
- return {
5208
- kind: "wakeExplanation",
5209
- payload: {
5210
- prefix: { kind: "fixedText", text: "그런", koreanPos: 관형사 },
5211
- headKind: "register_noun",
5212
- tailKind: "wakeda",
5213
- auxTokens: sentenceInitialToiuWakedaAuxTokens(token),
5214
- connectiveEnding: null
5215
- }
5216
- };
5217
- }
5218
- if (token.koreanOverrideByRegister !== undefined) {
5219
- return {
5220
- kind: "registerText",
5221
- casual: token.koreanOverrideByRegister.casual,
5222
- formal: token.koreanOverrideByRegister.formal,
5223
- koreanPos
5224
- };
5225
- }
5226
- if (token.koreanOverride !== undefined) {
5227
- return {
5228
- kind: "fixedText",
5229
- text: token.koreanOverride,
5230
- koreanPos
5231
- };
5232
- }
5233
- return null;
4919
+ function overlapsStructuralRelationRender(spans, range) {
4920
+ return spans.some((span) => span.start < range.endExclusive && range.start < span.endExclusive);
5234
4921
  }
5235
- function sentenceInitialToiuWakedaAuxTokens(token) {
5236
- if (token.surface.endsWith("でした")) {
5237
- return [
5238
- syntheticCopulaAuxToken("でし", "です", "デシ", 助動詞_デス, 連用形_一般),
5239
- syntheticCopulaAuxToken("た", "た", "タ", 助動詞_タ, 終止形_一般)
5240
- ];
5241
- }
5242
- if (token.surface.endsWith("だった")) {
5243
- return [
5244
- syntheticCopulaAuxToken("だっ", "だ", "ダッ", 助動詞_ダ, 連用形_促音便),
5245
- syntheticCopulaAuxToken("た", "た", "タ", 助動詞_タ, 終止形_一般)
5246
- ];
5247
- }
5248
- if (token.surface.endsWith("です")) {
5249
- return [syntheticCopulaAuxToken("です", "です", "デス", 助動詞_デス, 終止形_一般)];
4922
+ const MAX_LEXICAL_PARTICLE_LAYOUT_HYPOTHESIS_SLOTS = 8;
4923
+ function predicatePrenominalPlan(translation, koreanVerbEndingOverrides) {
4924
+ const ending = predicatePrenominalEnding(translation, koreanVerbEndingOverrides);
4925
+ const cacheValue = PipelineAssemblerMixin.predicatePrenominalText(translation.korean, {
4926
+ koreanPos: translation.koreanPos,
4927
+ irregular: translation.irregular ?? null,
4928
+ ending
4929
+ });
4930
+ if (cacheValue === undefined) {
4931
+ return null;
5250
4932
  }
5251
- return [];
5252
- }
5253
- function syntheticCopulaAuxToken(surface, dictionaryForm, reading, pos4, pos5A) {
5254
4933
  return {
5255
- surface,
5256
- dictionaryForm,
5257
- reading,
5258
- dictionaryFormReading: reading,
5259
- pos: 助動詞 | pos4 | pos5A,
5260
- dictionaryId: 0
5261
- };
5262
- }
5263
- function applyTailParserFallbackDescriptorToSpan(descriptor, index, tokens, lookups) {
5264
- const span = makeAssemblyContentSpan(index, descriptor.consumed, descriptor.korean, descriptor.koreanPos ?? 명사, descriptor.entry, descriptor.unitType, {
5265
- attachLeft: descriptor.attachLeft,
5266
- provenance: descriptor.provenance,
5267
- provenanceReason: descriptor.provenanceReason,
5268
- warnings: descriptor.warnings,
5269
- renderPlanPolicy: descriptor.renderPlanPolicy
5270
- });
5271
- span.renderPlan = descriptor.renderPlan;
5272
- span.voice = descriptor.voice;
5273
- span.rareruReadings = descriptor.rareruReadings;
5274
- span.nareruReadings = descriptor.nareruReadings;
5275
- span.dekiruReadings = descriptor.dekiruReadings;
5276
- span.hasNegative = descriptor.hasNegative;
5277
- span.hasCausative = descriptor.hasCausative;
5278
- span.hasCausativePassive = descriptor.hasCausativePassive;
5279
- span.hasRequestTail = descriptor.hasRequestTail;
5280
- span.hasBenefactiveTail = descriptor.hasBenefactiveTail;
5281
- span.isKeijoujiVerbPredicate = descriptor.isKeijoujiVerbPredicate;
5282
- span.benefactive = descriptor.benefactive;
5283
- span.sourceCandidates = descriptor.sourceCandidates;
5284
- closeUnownedTailFallbackSpanToRaw(span, tokens);
5285
- return span;
5286
- }
5287
- function closeUnownedTailFallbackSpanToRaw(span, tokens) {
5288
- if (span.provenance !== "legacy_tail" && span.provenance !== "fallback")
5289
- return;
5290
- const raw = rawSourceSurfaceText(tokens, span.start, span.consumed);
5291
- span.korean = raw;
5292
- span.koreanBase = null;
5293
- span.renderPlan = null;
5294
- span.sourceCandidates = null;
5295
- span.warnings = [
5296
- ...span.warnings,
5297
- unsupportedGrammarRawWarning(UNOWNED_TAIL_FALLBACK_RAW_OP_KIND, rawSourceWarningSpan(span.start, span.consumed), `unsupported grammar: head-tail did not own this span (provenance=${span.provenance}); ` +
5298
- `the consumed source span was kept raw. surface=${raw}`)
5299
- ];
5300
- }
5301
- function overlapsStructuralRelationRender(spans, range) {
5302
- return spans.some((span) => span.start < range.endExclusive && range.start < span.endExclusive);
5303
- }
5304
- function canCarryCopulaHostPlan(unit) {
5305
- return unit.unitType !== UnitType.SYMBOL && unit.allomorphKey === null;
5306
- }
5307
- function decorationSurfaceParts(tokens, span, decorationUnits) {
5308
- const parts = [];
5309
- for (let idx = span.start; idx < span.endExclusive; idx += 1) {
5310
- const token = tokens[idx];
5311
- if (token === undefined) {
5312
- continue;
5313
- }
5314
- const owner = decorationUnits.find((unit) => unit.jpIndices.includes(idx)) ?? null;
5315
- parts.push({
5316
- kind: "hostText",
5317
- text: token.surface,
5318
- sourceSpan: sourceSpanForTokenIndexes(tokens, [idx]),
5319
- unit: owner,
5320
- decoration: true
5321
- });
5322
- }
5323
- return parts;
5324
- }
5325
- export function sourceSpanForTokenIndexes(tokens, indexes) {
5326
- function* iterTokens() {
5327
- for (const index of indexes) {
5328
- const token = tokens[index];
5329
- if (token !== undefined) {
5330
- yield token;
5331
- }
5332
- }
5333
- }
5334
- return computeSourceSpan(iterTokens()) ?? null;
5335
- }
5336
- function demonstrativeTameKind(token) {
5337
- const source = token.dictionaryForm || token.surface;
5338
- if (source.startsWith("その")) {
5339
- return "sono";
5340
- }
5341
- if (source.startsWith("この")) {
5342
- return "kono";
5343
- }
5344
- return null;
5345
- }
5346
- function runtimeTokenFromPreprocess(token) {
5347
- const { splitA, splitB, longVowelReduction, ...flatToken } = token;
5348
- const alignedMetadata = longVowelReduction !== undefined &&
5349
- isLongVowelReductionAligned({ surface: token.surface, longVowelReduction })
5350
- ? longVowelReduction
5351
- : undefined;
5352
- return {
5353
- ...flatToken,
5354
- ...(alignedMetadata === undefined ? {} : { longVowelReduction: alignedMetadata }),
5355
- dictionaryId: token.dictionaryId ?? -1,
5356
- ...(splitA === undefined ? {} : { splitA: splitA.map((item) => runtimeTokenFromPreprocess(item)) }),
5357
- ...(splitB === undefined ? {} : { splitB: splitB.map((item) => runtimeTokenFromPreprocess(item)) })
5358
- };
5359
- }
5360
- function withMergedSourcePosition(tokens, start, consumed, token, role) {
5361
- const first = role.leading ? tokens[start] : undefined;
5362
- const last = role.trailing ? tokens[start + consumed - 1] : undefined;
5363
- return {
5364
- ...token,
5365
- ...(token.whitespaceBefore === undefined && first?.whitespaceBefore !== undefined
5366
- ? { whitespaceBefore: first.whitespaceBefore }
5367
- : {}),
5368
- ...(token.whitespaceAfter === undefined && last?.whitespaceAfter !== undefined
5369
- ? { whitespaceAfter: last.whitespaceAfter }
5370
- : {}),
5371
- ...(token.transparentPauseBefore === undefined && first?.transparentPauseBefore === true
5372
- ? { transparentPauseBefore: true }
5373
- : {}),
5374
- ...(token.transparentPauseAfter === undefined && last?.transparentPauseAfter === true
5375
- ? { transparentPauseAfter: true }
5376
- : {}),
5377
- ...(token.transparentPauseRunAfter === undefined && last?.transparentPauseRunAfter !== undefined
5378
- ? { transparentPauseRunAfter: last.transparentPauseRunAfter }
5379
- : {}),
5380
- ...(token.sourceLineBreakBefore === undefined && first?.sourceLineBreakBefore === true
5381
- ? { sourceLineBreakBefore: true }
5382
- : {})
5383
- };
5384
- }
5385
- function withSourcePositionFromConsumed(tokens, start, consumed, token, role) {
5386
- const positioned = withMergedSourcePosition(tokens, start, consumed, token, role);
5387
- const sourceSpan = sourceSpanForTokenIndexes(tokens, rangeIndexes(start, consumed));
5388
- if (sourceSpan === null) {
5389
- return positioned;
5390
- }
5391
- const sourceCharSpan = computeSourceCharSpan(tokens.slice(start, start + consumed));
5392
- const identified = sourceCharSpan === undefined
5393
- ? positioned
5394
- : { ...positioned, sourceCharSpan };
5395
- return withRuntimeTokenSourceSpan(identified, sourceSpan);
5396
- }
5397
- function collocationEmissionPreservesSourceRuby(source, start, consumed, emitted) {
5398
- const fragments = source
5399
- .slice(start, start + consumed)
5400
- .flatMap((token) => token.sourceRubyReadingFragments ?? []);
5401
- if (fragments.length === 0) {
5402
- return true;
5403
- }
5404
- const probe = emitted.map((token) => ({ ...token }));
5405
- return applySourceRubyReadingFragments(probe, fragments);
5406
- }
5407
- function rangeIndexes(start, count) {
5408
- return Array.from({ length: Math.max(0, count) }, (_value, offset) => start + offset);
5409
- }
5410
- function assemblerKaMarkerRelationAt(tokens, index) {
5411
- return kaMarkerRelationAt(tokens, index, ["assembler"]);
5412
- }
5413
- function isAssemblerTerminalQuestionKa(tokens, index) {
5414
- return assemblerKaMarkerRelationAt(tokens, index)?.particleSubtype1 === 終助詞;
5415
- }
5416
- const WO_TOOSU_PASS_OBJECTS = new Set(["申請", "法案", "予算案", "議案", "提案", "企画", "計画", "書類", "案"]);
5417
- const WO_TOOSU_PASS_OBJECT_PREFIXES = new Set(["法", "予算", "議"]);
5418
- const WO_TOOSU_BENEFACTIVE_TAILS = new Set(["いただける", "いただく", "頂ける", "頂く", "くれる", "くださる", "下さる", "もらう", "もらえる"]);
5419
- function shouldSkipCollocation(tokens, start, collocation, lookups) {
5420
- const [consumed, emitted] = collocation;
5421
- const emittedHead = emitted[0];
5422
- if (emittedHead === undefined) {
5423
- return false;
5424
- }
5425
- const dictionaryForm = emittedHead.dictionaryForm;
5426
- if (dictionaryForm === "いただきます") {
5427
- if (start <= 0) {
5428
- return false;
5429
- }
5430
- const relation = teDeContinuationRelationAt(tokens, start - 1, { consumers: ["assembler"], lookups });
5431
- return relation?.continuationKind === "benefactive" && relation.continuationIdx === start;
5432
- }
5433
- if (dictionaryForm === "を通して" || dictionaryForm === "を通し") {
5434
- return shouldSkipWoTooshiteCollocation(tokens, start, consumed);
5435
- }
5436
- if (dictionaryForm === "に応じ") {
5437
- return shouldSkipNiOujiCollocation(tokens, start, consumed);
5438
- }
5439
- if (dictionaryForm === "に比べて" || dictionaryForm === "に比べ") {
5440
- return shouldSkipNiKurabeteCollocation(tokens, start, consumed);
5441
- }
5442
- return false;
5443
- }
5444
- function shouldSkipNiKurabeteCollocation(tokens, start, consumed) {
5445
- if (start <= 0) {
5446
- return false;
5447
- }
5448
- const previousIndex = previousNonSpaceIndex(tokens, start);
5449
- if (previousIndex === null) {
5450
- return false;
5451
- }
5452
- const previous = tokens[previousIndex];
5453
- if (previous === undefined ||
5454
- predicateNominalizerRelationForToken(previous, previousIndex, {
5455
- requirement: "tail_connective_marker",
5456
- consumers: ["assembler"]
5457
- })?.nominalizerKind !== "no") {
5458
- return false;
5459
- }
5460
- const after = nextNonSpaceIndex(tokens, start + consumed, tokens.length) ?? tokens.length;
5461
- const tail = tokens[after];
5462
- if (tail === undefined) {
5463
- return false;
5464
- }
5465
- const tailForm = tail.dictionaryForm || tail.surface;
5466
- return (tail.pos & POS0) === 動詞
5467
- && ((tail.pos & POS1) === 非自立可能 || ["しまう", "みる", "くる", "いく", "おく", "いる", "ある"].includes(tailForm));
5468
- }
5469
- function shouldSkipWoTooshiteCollocation(tokens, start, consumed) {
5470
- if (start <= 0) {
5471
- return false;
5472
- }
5473
- const objectIndex = previousNonSpaceIndex(tokens, start);
5474
- if (objectIndex === null) {
5475
- return false;
5476
- }
5477
- const object = tokens[objectIndex];
5478
- if (object === undefined) {
5479
- return false;
5480
- }
5481
- const objectSurface = object.dictionaryForm || object.surface;
5482
- if (!WO_TOOSU_PASS_OBJECTS.has(objectSurface)) {
5483
- const previousIndex = previousNonSpaceIndex(tokens, objectIndex);
5484
- const previous = previousIndex === null ? undefined : tokens[previousIndex];
5485
- const previousSurface = previous === undefined ? undefined : previous.dictionaryForm || previous.surface;
5486
- if (!(objectSurface === "案" && previousSurface !== undefined && WO_TOOSU_PASS_OBJECT_PREFIXES.has(previousSurface))) {
5487
- return false;
5488
- }
5489
- }
5490
- const after = nextNonSpaceIndex(tokens, start + consumed, tokens.length) ?? tokens.length;
5491
- const tail = tokens[after];
5492
- if (tail === undefined) {
5493
- return false;
5494
- }
5495
- const tailForm = tail.dictionaryForm || tail.surface;
5496
- return WO_TOOSU_BENEFACTIVE_TAILS.has(tailForm);
5497
- }
5498
- function shouldSkipNiOujiCollocation(tokens, start, consumed) {
5499
- if (niOujiResponsePrevToken(tokens, start) === undefined) {
5500
- return false;
5501
- }
5502
- const after = nextNonSpaceIndex(tokens, start + consumed, tokens.length) ?? tokens.length;
5503
- const afterPos = tokens[after]?.pos ?? 0;
5504
- return (afterPos & POS0) === 助動詞;
5505
- }
5506
- function committedParticleAssignmentAt(contentMap, particleIdx, ownerIndex) {
5507
- const owned = ownerIndex === undefined
5508
- ? undefined
5509
- : committedParticleAssignmentFromSpan(contentMap.get(ownerIndex), particleIdx);
5510
- if (owned !== undefined) {
5511
- return owned;
5512
- }
5513
- for (const span of contentMap.values()) {
5514
- const committed = committedParticleAssignmentFromSpan(span, particleIdx);
5515
- if (committed?.commitmentSource === "slot_realization") {
5516
- return committed;
5517
- }
5518
- }
5519
- return undefined;
5520
- }
5521
- function committedParticleAssignmentFromSpan(span, particleIdx) {
5522
- const roles = span?.committedParticleRoles;
5523
- if (roles === undefined) {
5524
- return undefined;
5525
- }
5526
- if (roles instanceof Map) {
5527
- return roles.get(particleIdx);
5528
- }
5529
- return roles[particleIdx];
5530
- }
5531
- const NANDE_INSTRUMENT_PREDICATE_FOR_OBJECT = new Set([
5532
- "書く",
5533
- "描く",
5534
- "切る",
5535
- "撮る",
5536
- "録る",
5537
- "写す",
5538
- "拭く",
5539
- "洗う",
5540
- "磨く",
5541
- "掃除",
5542
- "清掃",
5543
- "洗濯",
5544
- "撮影",
5545
- "録音",
5546
- "録画"
5547
- ]);
5548
- const NANDE_INSTRUMENT_SAHEN_NOUNS = new Set(["掃除", "清掃", "洗濯", "撮影", "録音", "録画"]);
5549
- function nextNonSymbolTokenIndex(tokens, start, end) {
5550
- for (let index = start; index < end; index += 1) {
5551
- if (((tokens[index]?.pos ?? 0) & POS0) !== 補助記号) {
5552
- return index;
5553
- }
5554
- }
5555
- return undefined;
5556
- }
5557
- function bareQuestionPunctuationIndex(tokens, start, end) {
5558
- const index = nextNonSpaceIndex(tokens, start, end) ?? end;
5559
- const token = tokens[index];
5560
- if (token === undefined || (token.pos & POS0) !== 補助記号) {
5561
- return null;
5562
- }
5563
- return hasHardTerminalPunctuationClass(token, index, ["question"], ["assembler"]) ? index : null;
5564
- }
5565
- function plainQuestionSfpNode(token, tokenIdx) {
5566
- return {
5567
- effect: "plain_q",
5568
- surface: token.surface,
5569
- consumed: 1,
5570
- repeatCount: 1,
5571
- source: {
5572
- tokens: [token],
5573
- tokenIndices: [tokenIdx]
5574
- }
5575
- };
5576
- }
5577
- function applyCopulaFocusAdjunctRenderPlan(plan, span) {
5578
- const request = span.copulaFocusAdjunct;
5579
- if (plan === null || request === null || request === undefined) {
5580
- return plan;
5581
- }
5582
- const { nominalParticle, predicateEnding } = request.realization;
5583
- const lemmaPlan = plan.kind === "lemma" ? plan : null;
5584
- const winner = selectedCommitmentCandidate(span);
5585
- const baseLemma = lemmaPlan?.koreanLemma ?? winner?.koreanLemma ?? winner?.korean ?? null;
5586
- const basePos = lemmaPlan?.koreanPos ?? winner?.koreanPos ?? null;
5587
- if (baseLemma === null || baseLemma.length === 0 || basePos === null || basePos === 부사) {
5588
- return plan;
5589
- }
5590
- const [hostLemma, hostLemmaPos, hostIrregular] = resolveCopulaAdj(request.hostEntry ?? lemmaPlan?.entry ?? null, baseLemma, basePos, lemmaPlan?.irregular ?? winner?.irregular ?? null, request.hostPos);
5591
- if (hostLemmaPos === 형용사 || hostLemmaPos === 동사) {
5592
- return predicateEnding === null
5593
- ? plan
5594
- : {
5595
- kind: "conjugatedLemma",
5596
- koreanLemma: hostLemma,
5597
- irregular: hostIrregular ?? null,
5598
- koreanPos: hostLemmaPos,
5599
- ending: predicateEnding
5600
- };
5601
- }
5602
- return nominalParticle === null
5603
- ? plan
5604
- : { kind: "particleizedContent", content: plan, particle: nominalParticle, koreanPos: hostLemmaPos };
5605
- }
5606
- function applyBareQuestionRenderPlan(plan, tokens, afterContent, end) {
5607
- return plan === null ? null : applyBareQuestionToRenderPlan(plan, tokens, afterContent, end);
5608
- }
5609
- function applyBareQuestionToRenderPlan(plan, tokens, afterContent, end) {
5610
- const questionIdx = bareQuestionPunctuationIndex(tokens, afterContent, end);
5611
- if (questionIdx === null) {
5612
- return plan;
5613
- }
5614
- const questionToken = tokens[questionIdx];
5615
- if (questionToken === undefined) {
5616
- return plan;
5617
- }
5618
- if (plan.kind === "lemma" || plan.kind === "copulaPredicate") {
5619
- if (plan.sfp === undefined || plan.sfp === null) {
5620
- return { ...plan, sfp: "plain_q" };
5621
- }
5622
- const node = plan.terminalSfp ?? null;
5623
- const yielded = node === null ? null : authoredQuestionYieldEffect(node, tokens, (plan.auxTokens?.length ?? 0) > 0);
5624
- return yielded === null ? plan : { ...plan, sfp: yielded, terminalSfp: { ...node, effect: yielded } };
5625
- }
5626
- if (plan.kind === "noda") {
5627
- return plan.sfp === undefined || plan.sfp === null ? { ...plan, sfp: "plain_q" } : plan;
5628
- }
5629
- if (plan.kind === "headTailChain" && plan.realization.kind === "predicate") {
5630
- const root = plan.realization.root;
5631
- const existing = root.sfp;
5632
- if (existing !== null && !terminalSkipSfpYieldsToAuthoredQuestion(existing, root)) {
5633
- return plan;
5634
- }
5635
- const trailingEffect = existing === null || existing.effect === null
5636
- ? null
5637
- : authoredQuestionYieldEffect(existing, tokens, auxOpsInTailNode(root.tail).length > 0);
5638
- if (existing !== null && trailingEffect !== null && trailingEffect !== "plain_q") {
5639
- return {
5640
- ...plan,
5641
- realization: { ...plan.realization, root: { ...root, sfp: { ...existing, effect: trailingEffect } } }
5642
- };
5643
- }
5644
- if (!canInjectPlainQuestionIntoTailRoot(root)) {
5645
- return plan;
5646
- }
5647
- return {
5648
- ...plan,
5649
- realization: {
5650
- ...plan.realization,
5651
- root: {
5652
- ...root,
5653
- sfp: existing === null
5654
- ? plainQuestionSfpNode(questionToken, questionIdx)
5655
- : { ...existing, effect: "plain_q" }
5656
- }
5657
- }
5658
- };
5659
- }
5660
- return plan;
5661
- }
5662
- function authoredQuestionYieldEffect(node, tokens, hasAux) {
5663
- if (!sfpNodeYieldsToAuthoredQuestion(node)) {
5664
- return null;
5665
- }
5666
- const hostToken = tokens[(node.source.tokenIndices[0] ?? 0) - 1];
5667
- return trailingSfpEffectAfterFirst(node, (hostToken?.pos ?? 0) & POS0, hasAux) ?? "plain_q";
5668
- }
5669
- function terminalSkipSfpYieldsToAuthoredQuestion(sfp, root) {
5670
- const yieldingEffect = sfp.effect === null
5671
- ? isSfpSkipSurface(sfp.surface) || sfpNodeYieldsToAuthoredQuestion(sfp)
5672
- : sfpNodeYieldsToAuthoredQuestion(sfp);
5673
- return yieldingEffect &&
5674
- sfp.quoteProjection === undefined &&
5675
- sfp.questionRole === undefined &&
5676
- sfp.questionRealizationEffect === undefined &&
5677
- !auxOpsInTailNode(root.tail).some(auxOpCarriesCommandIllocution);
5678
- }
5679
- function canInjectPlainQuestionIntoTailRoot(root) {
5680
- const tail = root.tail;
5681
- if (tail.kind !== "auxLayer" || tail.terminal !== null) {
5682
- return false;
5683
- }
5684
- if (tail.ops.some((op) => op.kind === "copula" && op.variant === "conjecture")) {
5685
- return false;
5686
- }
5687
- if (tail.ops.some((op) => op.kind === "connective")) {
5688
- return false;
5689
- }
5690
- if (tail.stem.kind === "noun" && tail.ops.some((op) => op.kind === "conjecture")) {
5691
- return false;
5692
- }
5693
- return true;
5694
- }
5695
- function isSentencePunctuationUnit(unit) {
5696
- if (unit.jpPos !== 補助記号) {
5697
- return false;
5698
- }
5699
- return hasHardTerminalPunctuationRelation(translationUnitBoundaryToken(unit), 0, ["assembler"]);
5700
- }
5701
- function moodPunctuationAnchorAt(segments) {
5702
- const segmentIndex = lastOutputSegmentIndex(segments);
5703
- const segment = segmentIndex < 0 ? undefined : segments[segmentIndex];
5704
- if (segment === undefined || (segment.unit !== null && isSentencePunctuationUnit(segment.unit))) {
5705
- return null;
5706
- }
5707
- const marks = /[?!]+$/u.exec(segment.text)?.[0];
5708
- if (marks === undefined) {
5709
- return null;
5710
- }
5711
- return marks.includes("?") ? { marks } : { marks, unidentified: true };
5712
- }
5713
- function reconcileTerminalPunctuationUnit(unit, anchor) {
5714
- if (anchor === null) {
5715
- return { emit: true, moodPunctuation: null };
5716
- }
5717
- if (anchor.unidentified === true) {
5718
- return { emit: false, moodPunctuation: anchor };
5719
- }
5720
- const run = unit.terminalPunctuationRun;
5721
- if (run === null || !run.units.includes("question")) {
5722
- return { emit: false, moodPunctuation: anchor };
5723
- }
5724
- const mark = moodPunctuationMarkForRunUnit(terminalPunctuationRunUnitOf(unit, run));
5725
- if (mark === null) {
5726
- return { emit: true, moodPunctuation: anchor };
5727
- }
5728
- const markIndex = anchor.marks.indexOf(mark);
5729
- return markIndex < 0
5730
- ? { emit: true, moodPunctuation: anchor }
5731
- : {
5732
- emit: false,
5733
- moodPunctuation: {
5734
- marks: `${anchor.marks.slice(0, markIndex)}${anchor.marks.slice(markIndex + 1)}`
5735
- }
5736
- };
5737
- }
5738
- function terminalPunctuationRunPositionOf(unit, run) {
5739
- const tokenIdx = unit.jpIndices[0];
5740
- return tokenIdx === undefined ? -1 : run.tokenIndices.indexOf(tokenIdx);
5741
- }
5742
- function terminalPunctuationRunUnitOf(unit, run) {
5743
- const position = terminalPunctuationRunPositionOf(unit, run);
5744
- return position < 0 ? null : run.units[position] ?? null;
5745
- }
5746
- function authoredRunClosesWithQuestion(run) {
5747
- return run !== null &&
5748
- run.units.includes("question") &&
5749
- !run.units.includes("exclamation");
5750
- }
5751
- function moodPunctuationMarkForRunUnit(runUnit) {
5752
- return runUnit === "question" ? "?" : runUnit === "exclamation" ? "!" : null;
5753
- }
5754
- function terminalPeriodIsRedundant(segments, unit, anchor) {
5755
- const run = unit.terminalPunctuationRun;
5756
- if (run === null || !terminalRunUnitIsLonePeriod(run, terminalPunctuationRunPositionOf(unit, run))) {
5757
- return false;
5758
- }
5759
- if (anchor !== null) {
5760
- return true;
5761
- }
5762
- const previousSegment = segments[lastOutputSegmentIndex(segments)];
5763
- const previousUnit = previousSegment?.unit ?? null;
5764
- if (previousUnit === null || !isSentencePunctuationUnit(previousUnit)) {
5765
- return false;
5766
- }
5767
- const previousRun = previousUnit.terminalPunctuationRun;
5768
- const previousRunUnit = previousRun === null
5769
- ? null
5770
- : terminalPunctuationRunUnitOf(previousUnit, previousRun);
5771
- return previousRunUnit === "question" || previousRunUnit === "exclamation";
5772
- }
5773
- function terminalRunUnitIsLonePeriod(run, position) {
5774
- return position >= 0 &&
5775
- run.units[position] === "period" &&
5776
- run.units[position - 1] !== "period" &&
5777
- run.units[position + 1] !== "period";
5778
- }
5779
- function nominalLightVerbObjectLinkAt(tokens, nounIndex, nounConsumed, contentMap, layout) {
5780
- const particleIndex = nextNonSpaceIndex(tokens, nounIndex + nounConsumed, tokens.length) ?? tokens.length;
5781
- const particle = tokens[particleIndex];
5782
- if (caseParticleMarkerRelationForToken(particle, particleIndex, {
5783
- acceptedSurfaces: ["を"],
5784
- consumers: ["assembler"]
5785
- }) === null) {
5786
- return null;
5787
- }
5788
- const predicateIndex = nextNonSpaceIndex(tokens, particleIndex + 1, tokens.length) ?? tokens.length;
5789
- if (layout.ownerPredicateOfParticle(particleIndex) !== predicateIndex) {
5790
- return null;
5791
- }
5792
- const predicate = tokens[predicateIndex];
5793
- const predicateSpan = contentMap.get(predicateIndex);
5794
- if (predicate === undefined || predicateSpan === undefined) {
5795
- return null;
5796
- }
5797
- const predicateDictForm = predicate.dictionaryForm || predicate.surface;
5798
- if (predicateDictForm.length === 0) {
5799
- return null;
5800
- }
5801
- return {
5802
- particleIndex,
5803
- predicateIndex,
5804
- predicateDictForm,
5805
- predicateSpan
5806
- };
5807
- }
5808
- function rewriteCarrierIdiomRenderPlan(renderPlan, entry) {
5809
- if (renderPlan === null) {
5810
- return undefined;
5811
- }
5812
- return replaceLemmaRenderPlan(renderPlan, {
5813
- koreanLemma: entry.koreanCarrier,
5814
- koreanPos: 동사,
5815
- irregular: entry.irregular ?? null
5816
- });
5817
- }
5818
- function isClauseCommaPunctuationUnit(unit) {
5819
- if (unit.jpPos !== 補助記号) {
5820
- return false;
5821
- }
5822
- return hasWeakPunctuationRelation(translationUnitBoundaryToken(unit), 0, ["assembler"]);
5823
- }
5824
- function translationUnitBoundaryToken(unit) {
5825
- return { surface: unit.jpHead.surface, pos: unit.jpHead.pos };
5826
- }
5827
- function hasNegativePoliteBenefactiveQuestionAfter(cursor) {
5828
- const c = cursor.fork();
5829
- while (true) {
5830
- const token = c.current();
5831
- if (token === undefined) {
5832
- return false;
5833
- }
5834
- if (hasHardTerminalPunctuationRelation(token, c.pos, ["assembler"])) {
5835
- return false;
5836
- }
5837
- if (token.dictionaryForm !== "くれる" && token.dictionaryForm !== "いただける") {
5838
- c.advance();
5839
- continue;
5840
- }
5841
- let hasPolite = false;
5842
- let hasNegative = false;
5843
- const inner = c.fork(c.pos + 1);
5844
- while (true) {
5845
- const tail = inner.current();
5846
- if (tail === undefined) {
5847
- return false;
5848
- }
5849
- if (hasHardTerminalPunctuationRelation(tail, inner.pos, ["assembler"])) {
5850
- return false;
5851
- }
5852
- if (isAssemblerTerminalQuestionKa(cursor.tokens, inner.pos)) {
5853
- return hasPolite && hasNegative;
5854
- }
5855
- const pos4 = (tail.pos & POS4);
5856
- if ((pos4 === 助動詞_マス) || (pos4 === 助動詞_デス)) {
5857
- hasPolite = true;
5858
- }
5859
- if ((pos4 === 助動詞_ナイ) || (pos4 === 助動詞_ヌ)) {
5860
- hasNegative = true;
5861
- }
5862
- inner.advance();
5863
- }
5864
- return false;
5865
- }
5866
- return false;
5867
- }
5868
- function hasReasonQuestionContextAfter(cursor) {
5869
- let sawArgumentContent = false;
5870
- let sawInstrumentArgument = false;
5871
- let firstPredicateDictionaryForm;
5872
- let previousContentDictionaryForm;
5873
- const c = cursor.fork();
5874
- while (true) {
5875
- const token = c.current();
5876
- if (token === undefined) {
5877
- return false;
5878
- }
5879
- const surface = token.surface;
5880
- const pos0 = token.pos & POS0;
5881
- if ((pos0 === 補助記号)) {
5882
- if (!hasHardTerminalPunctuationClass(token, c.pos, ["question"], ["assembler"])) {
5883
- return false;
5884
- }
5885
- if (!sawArgumentContent) {
5886
- return false;
5887
- }
5888
- return !(sawInstrumentArgument && firstPredicateDictionaryForm !== undefined && NANDE_INSTRUMENT_PREDICATE_FOR_OBJECT.has(firstPredicateDictionaryForm));
5889
- }
5890
- if (isAssemblerTerminalQuestionKa(cursor.tokens, c.pos)) {
5891
- if (!sawArgumentContent) {
5892
- return false;
5893
- }
5894
- return !(sawInstrumentArgument && firstPredicateDictionaryForm !== undefined && NANDE_INSTRUMENT_PREDICATE_FOR_OBJECT.has(firstPredicateDictionaryForm));
5895
- }
5896
- if (sawArgumentContent &&
5897
- caseParticleMarkerRelationForToken(token, c.pos, {
5898
- acceptedSurfaces: ["を", "に", "で"],
5899
- consumers: ["assembler"]
5900
- }) !== null) {
5901
- sawInstrumentArgument = true;
5902
- c.advance();
5903
- continue;
5904
- }
5905
- if ((pos0 === 動詞) || (pos0 === 形容詞0) || (pos0 === 形状詞)) {
5906
- if (firstPredicateDictionaryForm === undefined) {
5907
- const dictionaryForm = token.dictionaryForm || surface;
5908
- firstPredicateDictionaryForm = dictionaryForm === "する" && previousContentDictionaryForm !== undefined && NANDE_INSTRUMENT_SAHEN_NOUNS.has(previousContentDictionaryForm)
5909
- ? previousContentDictionaryForm
5910
- : dictionaryForm;
5911
- }
5912
- c.advance();
5913
- continue;
5914
- }
5915
- if (isContentAdmissionToken(token)) {
5916
- sawArgumentContent = true;
5917
- previousContentDictionaryForm = token.dictionaryForm || surface;
5918
- }
5919
- c.advance();
5920
- }
5921
- return false;
5922
- }
5923
- function trySplitNandeReasonSpan(cursor) {
5924
- const tokens = cursor.tokens;
5925
- const index = cursor.pos;
5926
- const n = cursor.end;
5927
- const token = cursor.current();
5928
- if (token === undefined) {
5929
- return undefined;
5930
- }
5931
- if (!["何", "なん"].includes(token.surface) && !["何", "なん"].includes(token.dictionaryForm)) {
5932
- return undefined;
5933
- }
5934
- const deIndex = nextNonSymbolTokenIndex(tokens, index + 1, n);
5935
- if (deIndex === undefined) {
5936
- return undefined;
5937
- }
5938
- const deToken = tokens[deIndex];
5939
- if (caseParticleMarkerRelationForToken(deToken, deIndex, {
5940
- acceptedSurfaces: ["で"],
5941
- acceptedParticleSubtypes: ["格助詞", "接続助詞", "副助詞"],
5942
- consumers: ["assembler"]
5943
- }) === null) {
5944
- return undefined;
5945
- }
5946
- const reasonProbeOffset = deIndex + 1 - index;
5947
- if (!cursor.lookahead(reasonProbeOffset, hasNegativePoliteBenefactiveQuestionAfter) &&
5948
- !cursor.lookahead(reasonProbeOffset, hasReasonQuestionContextAfter)) {
5949
- return undefined;
5950
- }
5951
- const consumed = deIndex - index + 1;
5952
- const span = makeAssemblyContentSpan(index, consumed, "왜", 부사, null, UnitType.CONTENT);
5953
- cursor.advance(consumed);
5954
- return span;
5955
- }
5956
- const MAX_LEXICAL_PARTICLE_LAYOUT_HYPOTHESIS_SLOTS = 8;
5957
- function adoptLexicalLayoutHypothesis(variant, trace) {
5958
- for (const event of variant.trace?.events ?? []) {
5959
- trace?.record(event);
5960
- }
5961
- return {
5962
- contentMap: variant.contentMap,
5963
- layout: variant.layout,
5964
- protoLayout: variant.protoLayout,
5965
- contentPassMap: variant.contentPassMap
5966
- };
5967
- }
5968
- function sameLexicalAdverbialAffiliationFacts(left, right) {
5969
- if (left.size !== right.size) {
5970
- return false;
5971
- }
5972
- for (const [particleIdx, affiliation] of left) {
5973
- const other = right.get(particleIdx);
5974
- if (other === undefined || !sameLexicalAdverbialAffiliation(affiliation, other, { includeClauseOrdinals: true })) {
5975
- return false;
5976
- }
5977
- }
5978
- return true;
5979
- }
5980
- function lexicalParticleOwnershipHypothesisSlots(contentMap, tokens, lookups, numeric) {
5981
- const result = [];
5982
- const occupiedParticles = new Set();
5983
- for (const [start, span] of contentMap) {
5984
- const candidates = candidateSetCandidates(commitmentLaneCandidateSet(span.sourceCandidates));
5985
- if (candidates.length === 0) {
5986
- continue;
5987
- }
5988
- const hasContentOwner = candidates.some((candidate) => lexicalParticleOwnershipModeForCandidate(candidate) === "content_owner");
5989
- const hasParticle = candidates.some((candidate) => lexicalParticleOwnershipModeForCandidate(candidate) === "particle");
5990
- if (!hasContentOwner || !hasParticle) {
5991
- continue;
5992
- }
5993
- const particleIdx = candidates.find((candidate) => adverbialNiCandidateCommitment(candidate) !== null)
5994
- ?.lexicalParticleAdverbial?.particleIdx ?? start + 1;
5995
- occupiedParticles.add(particleIdx);
5996
- const selected = selectedLexicalParticleCandidate(span);
5997
- const selectedMode = selected === undefined
5998
- ? (span.particleRole === "adverbializer" ? "content_owner" : "particle")
5999
- : lexicalParticleOwnershipModeForCandidate(selected);
6000
- result.push({
6001
- start,
6002
- particleIdx,
6003
- markerEndExclusive: particleIdx + 1,
6004
- initialMode: selectedMode,
6005
- modes: ["content_owner", "particle"]
6006
- });
6007
- }
6008
- for (let markerIdx = 0; markerIdx < tokens.length; markerIdx += 1) {
6009
- if (occupiedParticles.has(markerIdx)) {
6010
- continue;
6011
- }
6012
- const markerSlot = lexicalParticleMarkerOwnerSlotAt(tokens, markerIdx, contentMap, lookups, numeric);
6013
- if (markerSlot !== null) {
6014
- result.push(markerSlot);
6015
- }
6016
- }
6017
- return result;
6018
- }
6019
- function lexicalParticleMarkerOwnerSlotAt(tokens, markerIdx, contentMap, lookups, numeric) {
6020
- const bridge = dewaScopeBridgeRelationAt(tokens, markerIdx, {
6021
- consumers: ["assembler"]
6022
- });
6023
- if (bridge === null) {
6024
- return null;
6025
- }
6026
- const parse = tryParseNominalFrame(new TokenCursor(tokens, markerIdx, tokens.length), { lookups, numeric });
6027
- if (parse === null ||
6028
- parse.frame.frameKind !== "lexical_particle" ||
6029
- parse.frame.source.start !== bridge.span.start ||
6030
- parse.frame.source.end !== bridge.span.endExclusive ||
6031
- parse.frame.markerSurface !== bridge.surface) {
6032
- return null;
6033
- }
6034
- const start = parse.root.source.start;
6035
- if (!contentMap.has(start)) {
6036
- return null;
6037
- }
6038
- return {
6039
- start,
6040
- particleIdx: markerIdx,
6041
- markerEndExclusive: bridge.span.endExclusive,
6042
- initialMode: "marker_owner",
6043
- modes: ["marker_owner", "particle"]
6044
- };
6045
- }
6046
- function lexicalParticleOwnershipModeForCandidate(candidate) {
6047
- return adverbialNiCandidateCommitment(candidate) !== null ? "content_owner" : "particle";
6048
- }
6049
- function lexicalParticleInitialOwnershipChoices(slots) {
6050
- return slots.map((slot) => ({
6051
- start: slot.start,
6052
- particleIdx: slot.particleIdx,
6053
- markerEndExclusive: slot.markerEndExclusive,
6054
- mode: slot.initialMode
6055
- }));
6056
- }
6057
- function cloneAssemblyContentMap(source) {
6058
- const result = new Map();
6059
- for (const [start, span] of source) {
6060
- result.set(start, cloneAssemblyContentSpan(span));
6061
- }
6062
- return result;
6063
- }
6064
- const HARVESTED_FAIL_CLOSED_OP_KINDS = new Set([
6065
- "candidate_set_no_fallback_member"
6066
- ]);
6067
- function harvestFailClosedSpanWarnings(contentMap) {
6068
- const harvested = [];
6069
- const seenSpans = new Set();
6070
- for (const span of contentMap.values()) {
6071
- if (seenSpans.has(span)) {
6072
- continue;
6073
- }
6074
- seenSpans.add(span);
6075
- if (span.korean.length > 0 || span.renderPlan !== null) {
6076
- continue;
6077
- }
6078
- for (const warning of span.warnings ?? []) {
6079
- if (HARVESTED_FAIL_CLOSED_OP_KINDS.has(warning.opKind ?? "")) {
6080
- harvested.push(warning);
6081
- }
6082
- }
6083
- }
6084
- return harvested;
6085
- }
6086
- function cloneAssemblyContentSpan(span) {
6087
- const clone = {
6088
- ...span,
6089
- renderPlan: spanLocalRenderPlanNode(span.renderPlan),
6090
- ownerCandidates: span.ownerCandidates === undefined ? undefined : [...span.ownerCandidates],
6091
- ownerCandidatePayloads: span.ownerCandidatePayloads === undefined ? undefined : [...span.ownerCandidatePayloads],
6092
- warnings: [...(span.warnings ?? [])],
6093
- traceEvents: [...(span.traceEvents ?? [])]
6094
- };
6095
- delete clone.voiceOpen;
6096
- Object.defineProperty(clone, "voiceOpen", {
6097
- enumerable: true,
6098
- get() {
6099
- return clone.voice === null;
6100
- }
6101
- });
6102
- return clone;
6103
- }
6104
- function isQuoteClosingCopulaHostAt(tokens, deIdx) {
6105
- const closeIdx = previousNonSpaceIndex(tokens, deIdx);
6106
- return closeIdx !== null &&
6107
- isParentheticalClosingToken(tokens[closeIdx]) &&
6108
- parentheticalSpanEndingAt(tokens, closeIdx, { consumers: ["assembler"] }) !== null;
6109
- }
6110
- function isNominalizedQuestionCopulaComplementAt(cursor, kaIdx) {
6111
- return looksEmbeddedQuestionKaNominalizedBoundary(cursor.fork(kaIdx, cursor.end, kaIdx)) ||
6112
- isKaDouKaMarker(cursor.tokens, kaIdx);
6113
- }
6114
- function politeCopulaSupportTailIsRealizable(tokens, aruAux, afterAux, end, lookups) {
6115
- if (aruAux.length === 0) {
6116
- return true;
6117
- }
6118
- if (aruAux.some(aux => isUnrealizableCopulaPoliteAuxiliaryMood(aux))) {
6119
- return false;
6120
- }
6121
- const lastAux = aruAux[aruAux.length - 1];
6122
- if (lastAux !== undefined && (lastAux.pos & POS4) === 助動詞_マス && hasRentaikei(lastAux)) {
6123
- return false;
6124
- }
6125
- const kaIdx = nextNonSpaceIndex(tokens, afterAux, end);
6126
- if (kaIdx !== null &&
6127
- terminalQuestionKaRelationAt(tokens, kaIdx, { lookups }) !== null) {
6128
- return false;
6129
- }
6130
- if (trailingCopulaSfpTail(new TokenCursor(tokens, afterAux, end)) !== null) {
6131
- return false;
6132
- }
6133
- return true;
6134
- }
6135
- function contentSpanCoversIndex(contentMap, index) {
6136
- for (const [start, span] of contentMap) {
6137
- if (start <= index && index < start + span.consumed) {
6138
- return true;
6139
- }
6140
- }
6141
- return false;
6142
- }
6143
- function applySourceCompoundContinuationToContentMap(tokens, contentMap) {
6144
- for (const [start, span] of contentMap) {
6145
- if (tokens[start]?.sourceCompoundContinuation !== true || span.attachLeft) {
6146
- continue;
6147
- }
6148
- span.attachLeft = true;
6149
- }
6150
- }
6151
- function applyLexicalParticleOwnershipChoice(contentMap, choice) {
6152
- if (choice.mode === "marker_owner") {
6153
- return;
6154
- }
6155
- const span = contentMap.get(choice.start);
6156
- const sourceCandidates = commitmentLaneCandidateSet(span?.sourceCandidates);
6157
- if (span === undefined || sourceCandidates === null || sourceCandidates.members.length === 0) {
6158
- return;
6159
- }
6160
- const ordered = candidateSetMembers(sourceCandidates)
6161
- .filter((member) => lexicalParticleOwnershipModeForCandidate(member.candidate) === choice.mode)
6162
- .sort((left, right) => compareAdverbialNiCandidateStaticOrder(left.candidate, right.candidate));
6163
- if (ordered.length === 0) {
6164
- return;
6165
- }
6166
- span.sourceCandidates = transformCandidateSet(sourceCandidates, {
6167
- map: () => dropCandidate("lexical_particle_ownership"),
6168
- introduce: ordered,
6169
- failClosedReason: "all_members_dropped"
6170
- });
6171
- hydrateAssemblyContentSpanFromCandidate(span, ordered[0].candidate, choice.mode);
6172
- }
6173
- function hydrateAssemblyContentSpanFromCandidate(span, candidate, mode) {
6174
- span.entry = candidate.entry ?? span.entry;
6175
- span.renderPlanPolicy = candidate.renderPlanPolicy ?? span.renderPlanPolicy;
6176
- const adverbialNi = adverbialNiCandidateCommitment(candidate);
6177
- if (mode === "content_owner" && adverbialNi !== null) {
6178
- span.consumed = adverbialNi.consumed;
6179
- span.particleRole = adverbialNi.particleRole;
6180
- span.renderPlan = spanLocalRenderPlanNode(adverbialNi.renderPlan);
6181
- span.korean = "";
6182
- span.koreanPos = candidate.koreanPos ?? 부사;
6183
- }
6184
- else {
6185
- span.consumed = 1;
6186
- span.particleRole = null;
6187
- span.renderPlan = spanLocalRenderPlanNode(candidate.renderPlan ?? null);
6188
- span.korean = candidate.korean ?? "";
6189
- span.koreanPos = candidate.koreanPos ?? span.koreanPos;
6190
- }
6191
- if (candidate.voice !== undefined)
6192
- span.voice = candidate.voice;
6193
- if (candidate.nareruReadings !== undefined)
6194
- span.nareruReadings = candidate.nareruReadings;
6195
- if (candidate.rareruReadings !== undefined)
6196
- span.rareruReadings = candidate.rareruReadings;
6197
- if (candidate.dekiruReadings !== undefined)
6198
- span.dekiruReadings = candidate.dekiruReadings;
6199
- if (candidate.hasNegative !== undefined)
6200
- span.hasNegative = candidate.hasNegative;
6201
- if (candidate.hasCausative !== undefined)
6202
- span.hasCausative = candidate.hasCausative;
6203
- if (candidate.hasCausativePassive !== undefined)
6204
- span.hasCausativePassive = candidate.hasCausativePassive;
6205
- if (candidate.hasRequestTail !== undefined)
6206
- span.hasRequestTail = candidate.hasRequestTail;
6207
- if (candidate.hasBenefactiveTail !== undefined)
6208
- span.hasBenefactiveTail = candidate.hasBenefactiveTail;
6209
- if (candidate.connectiveRole !== undefined)
6210
- span.connectiveRole = candidate.connectiveRole;
6211
- span.benefactive = candidate.benefactive ?? span.benefactive ?? null;
6212
- span.warnings = candidate.warnings ?? span.warnings ?? [];
6213
- }
6214
- function lexicalParticleConsumedIndicesForChoices(choices) {
6215
- const consumed = new Set();
6216
- for (const choice of choices) {
6217
- if (choice.mode === "particle") {
6218
- continue;
6219
- }
6220
- for (let index = choice.particleIdx; index < choice.markerEndExclusive; index += 1) {
6221
- consumed.add(index);
6222
- }
6223
- }
6224
- return [...consumed].sort((left, right) => left - right);
6225
- }
6226
- function lexicalParticleLayoutSemanticSignature(contentMap, layout, choices) {
6227
- return JSON.stringify(choices.map((choice) => {
6228
- const span = contentMap.get(choice.start);
6229
- const candidate = span === undefined ? undefined : selectedLexicalParticleCandidate(span);
6230
- return {
6231
- start: choice.start,
6232
- mode: lexicalParticleResolvedMode(span, layout, choice),
6233
- markerEndExclusive: choice.markerEndExclusive,
6234
- consumed: span?.consumed ?? null,
6235
- particleOwner: layout.predicateOfParticle.get(choice.particleIdx) ?? null,
6236
- particleClause: layout.clauseIndexOfToken(choice.particleIdx),
6237
- renderPlanKind: span?.renderPlan?.kind ?? null,
6238
- selected: adverbialNiCandidateSemanticKey(candidate)
6239
- };
6240
- }));
6241
- }
6242
- function lexicalParticleResolvedMode(span, layout, choice) {
6243
- if (span?.particleRole === "adverbializer") {
6244
- return "content_owner";
6245
- }
6246
- if (!layout.predicateOfParticle.has(choice.particleIdx) && choice.markerEndExclusive > choice.particleIdx + 1) {
6247
- return "marker_owner";
6248
- }
6249
- return "particle";
6250
- }
6251
- function adverbialNiCandidateSemanticKey(candidate) {
6252
- if (candidate === undefined) {
6253
- return [];
6254
- }
6255
- const translation = candidate.translation;
6256
- return [
6257
- candidate.koreanLemma ?? candidate.korean ?? null,
6258
- candidate.koreanPos ?? null,
6259
- candidate.derivation?.id ?? null,
6260
- translation?.priorityGroup ?? candidate.priority ?? null,
6261
- translation?.priorityInGroup ?? null,
6262
- translation?.senseIndex ?? null,
6263
- candidate.renderPlan?.kind ?? null
6264
- ];
6265
- }
6266
- function compareAdverbialNiCandidateStaticOrder(left, right) {
6267
- const [leftPriorityGroup, leftPriorityInGroup, leftSenseIndex] = adverbialNiCandidatePriorityTuple(left);
6268
- const [rightPriorityGroup, rightPriorityInGroup, rightSenseIndex] = adverbialNiCandidatePriorityTuple(right);
6269
- const priorityGroupDiff = leftPriorityGroup - rightPriorityGroup;
6270
- if (priorityGroupDiff !== 0)
6271
- return priorityGroupDiff;
6272
- const priorityInGroupDiff = leftPriorityInGroup - rightPriorityInGroup;
6273
- if (priorityInGroupDiff !== 0)
6274
- return priorityInGroupDiff;
6275
- return leftSenseIndex - rightSenseIndex;
6276
- }
6277
- function adverbialNiCandidatePriorityTuple(candidate) {
6278
- if (candidate === undefined) {
6279
- return [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER];
6280
- }
6281
- const translation = candidate.translation;
6282
- return [
6283
- translation?.priorityGroup ?? candidate.priority ?? 0,
6284
- translation?.priorityInGroup ?? 0,
6285
- translation?.senseIndex ?? Number.MAX_SAFE_INTEGER
6286
- ];
6287
- }
6288
- function lexicalParticleChoiceRank(contentMap, choice, initialContentMap) {
6289
- const span = contentMap.get(choice.start);
6290
- const selectedSet = commitmentLaneCandidateSet(span?.sourceCandidates);
6291
- const selectedIdx = isResolvedCandidateSet(selectedSet)
6292
- ? Math.max(0, selectedSet.members.indexOf(selectedSet.winner))
6293
- : 0;
6294
- const candidate = span === undefined ? undefined : selectedLexicalParticleCandidate(span);
6295
- const [priorityGroup, priorityInGroup] = adverbialNiCandidatePriorityTuple(candidate);
6296
- return {
6297
- priorityGroup,
6298
- priorityInGroup,
6299
- selectedIdx,
6300
- ownerModeRank: lexicalParticleOwnershipModeRank(choice.mode),
6301
- initialMismatch: lexicalParticleInitialOwnershipMode(initialContentMap.get(choice.start), choice) !== choice.mode
6302
- };
6303
- }
6304
- function compareLexicalParticleSlotRanks(left, right) {
6305
- const priorityGroupDiff = left.priorityGroup - right.priorityGroup;
6306
- if (priorityGroupDiff !== 0)
6307
- return priorityGroupDiff;
6308
- const priorityInGroupDiff = left.priorityInGroup - right.priorityInGroup;
6309
- if (priorityInGroupDiff !== 0)
6310
- return priorityInGroupDiff;
6311
- const ownerModeDiff = left.ownerModeRank - right.ownerModeRank;
6312
- if (ownerModeDiff !== 0)
6313
- return ownerModeDiff;
6314
- const selectedIdxDiff = left.selectedIdx - right.selectedIdx;
6315
- if (selectedIdxDiff !== 0)
6316
- return selectedIdxDiff;
6317
- if (left.initialMismatch !== right.initialMismatch) {
6318
- return left.initialMismatch ? 1 : -1;
6319
- }
6320
- return 0;
6321
- }
6322
- function lexicalParticleOwnershipModeRank(mode) {
6323
- switch (mode) {
6324
- case "content_owner":
6325
- return 0;
6326
- case "marker_owner":
6327
- return 1;
6328
- case "particle":
6329
- return 2;
6330
- }
6331
- }
6332
- function lexicalParticleChoiceIsRealized(contentMap, layout, choice) {
6333
- const span = contentMap.get(choice.start);
6334
- if (choice.mode === "content_owner") {
6335
- return span?.particleRole === "adverbializer" &&
6336
- span.consumed >= 2 &&
6337
- span.renderPlan?.kind === "lexicalParticleAdverbial" &&
6338
- span.renderPlan.particle === "に";
6339
- }
6340
- if (choice.mode === "marker_owner") {
6341
- if (span === undefined || layout.predicateOfParticle.has(choice.particleIdx)) {
6342
- return false;
6343
- }
6344
- for (let index = choice.particleIdx + 1; index < choice.markerEndExclusive; index += 1) {
6345
- if (layout.predicateOfParticle.has(index)) {
6346
- return false;
6347
- }
6348
- }
6349
- return true;
6350
- }
6351
- return span !== undefined &&
6352
- span.particleRole !== "adverbializer" &&
6353
- layout.predicateOfParticle.has(choice.particleIdx);
6354
- }
6355
- function lexicalParticleInitialOwnershipMode(span, choice) {
6356
- if (choice.markerEndExclusive > choice.particleIdx + 1) {
6357
- return "marker_owner";
6358
- }
6359
- const selected = span === undefined ? undefined : selectedLexicalParticleCandidate(span);
6360
- if (selected !== undefined) {
6361
- return lexicalParticleOwnershipModeForCandidate(selected);
6362
- }
6363
- return span?.particleRole === "adverbializer" ? "content_owner" : "particle";
6364
- }
6365
- function adverbialNiCandidateCommitment(candidate) {
6366
- const commitment = candidate?.lexicalParticleAdverbial;
6367
- if (commitment === undefined || commitment === null || commitment.renderPlan.particle !== "に") {
6368
- return null;
6369
- }
6370
- return commitment;
6371
- }
6372
- function isQuoteUtteranceClauseEndToken(token) {
6373
- if (token === undefined) {
6374
- return false;
6375
- }
6376
- if (pos0in(token.pos, INFLECTABLE_BITS)) {
6377
- return true;
6378
- }
6379
- if ((token.pos & POS0) === 助動詞) {
6380
- return true;
6381
- }
6382
- return (token.pos & POS01) === 助詞_終助詞;
6383
- }
6384
- function makeAssemblyContentSpan(start, consumed, korean, koreanPos, entry, unitType, options = {}) {
6385
- const span = {
6386
- start,
6387
- consumed,
6388
- korean,
6389
- koreanPos,
6390
- entry,
6391
- renderPlan: options.renderPlan ?? null,
6392
- koreanBase: options.koreanBase ?? null,
6393
- unitType,
6394
- attachLeft: options.attachLeft ?? false,
6395
- particleRole: options.particleRole ?? null,
6396
- provenance: options.provenance ?? "assembler",
6397
- provenanceReason: options.provenanceReason ?? null,
6398
- discourseConnective: options.discourseConnective ?? false,
6399
- warnings: options.warnings ?? [],
6400
- renderPlanPolicy: options.renderPlanPolicy ?? "normal",
6401
- traceEvents: []
6402
- };
6403
- Object.defineProperty(span, "voiceOpen", {
6404
- enumerable: true,
6405
- get() {
6406
- return span.voice === null;
6407
- }
6408
- });
6409
- return span;
6410
- }
6411
- function contentMapRepairSeed(contentMap, units, repairStart) {
6412
- const covered = new Set(units.flatMap((unit) => unit.jpIndices));
6413
- const seed = new Map();
6414
- for (const [start, span] of contentMap) {
6415
- const endExclusive = start + Math.max(1, span.consumed);
6416
- if (start < repairStart && repairStart < endExclusive) {
6417
- continue;
6418
- }
6419
- if (start >= repairStart && rangeContainsCoveredIndex(start, endExclusive, covered)) {
6420
- continue;
6421
- }
6422
- seed.set(start, span);
6423
- }
6424
- return seed;
6425
- }
6426
- function rangeContainsCoveredIndex(start, endExclusive, covered) {
6427
- for (let index = start; index < endExclusive; index += 1) {
6428
- if (covered.has(index)) {
6429
- return true;
6430
- }
6431
- }
6432
- return false;
6433
- }
6434
- function finalizeExtentPostpositionSpan(cursor, index, span, pending, numeric) {
6435
- applyPendingExtentPostposition(index, span, pending);
6436
- registerExtentPostpositionSource(cursor, index, span, pending, numeric);
6437
- }
6438
- function applyPendingExtentPostposition(index, span, pending) {
6439
- const postposition = pending.get(index);
6440
- if (postposition === undefined) {
6441
- return;
6442
- }
6443
- pending.delete(index);
6444
- span.extentPostposition = postposition;
6445
- }
6446
- function registerExtentPostpositionSource(cursor, index, span, pending, numeric) {
6447
- const translation = selectedSpanTranslation(span);
6448
- if (translation?.placement?.type !== "after_next_extent_phrase") {
6449
- return;
6450
- }
6451
- const reading = cursor.lookahead(index + span.consumed - cursor.pos, c => readExtentPhraseAt(c, numeric));
6452
- if (reading === null) {
6453
- return;
6454
- }
6455
- const modifier = translation.korean.trim();
6456
- if (modifier.length === 0) {
6457
- return;
6458
- }
6459
- pending.set(reading.start, {
6460
- modifier,
6461
- targetOverride: reading.immediateKorean
6462
- });
6463
- span.korean = "";
6464
- span.renderPlan = null;
6465
- span.extentPostpositionRelocated = true;
6466
- }
6467
- function selectedIntrinsicHonorificMetadata(set, entry) {
6468
- const laneSet = commitmentLaneCandidateSet(set);
6469
- const selected = isResolvedCandidateSet(laneSet)
6470
- ? laneSet.winner
6471
- : candidateSetSize(laneSet) === 1 ? candidateSetMembers(laneSet)[0] : undefined;
6472
- if (selected !== undefined) {
6473
- return selected.candidate.intrinsicHonorific ?? selected.candidate.translation?.intrinsicHonorific;
6474
- }
6475
- const senses = entry?.senses ?? [];
6476
- return senses.length === 1 ? senses[0]?.intrinsicHonorific : undefined;
6477
- }
6478
- function selectedLexicalParticleCandidate(span) {
6479
- const set = commitmentLaneCandidateSet(span.sourceCandidates);
6480
- return isResolvedCandidateSet(set) ? set.winner.candidate : undefined;
6481
- }
6482
- function tryContentNumeral(cursor, numeric, context) {
6483
- const before = cursor.pos;
6484
- const numeral = tryNumeral(cursor, numeric, context);
6485
- if (numeral === undefined) {
6486
- return undefined;
6487
- }
6488
- const consumed = cursor.pos - before;
6489
- const output = numeral;
6490
- if (typeof output === "string") {
6491
- return { consumed, korean: "", renderPlan: { kind: "fixedText", text: output, koreanPos: 수사 } };
6492
- }
6493
- return { consumed, korean: "", renderPlan: output };
6494
- }
6495
- function isVocativeYo(tokens, index) {
6496
- if (index < 1 || !pos0in((tokens[index - 1]?.pos ?? 0), NOMINAL_BITS)) {
6497
- return false;
6498
- }
6499
- const previousPrevious = index >= 2 ? tokens[index - 2] : undefined;
6500
- if (previousPrevious !== undefined && (previousPrevious.pos & POS0) === 助詞 && (previousPrevious.surface === "は" || previousPrevious.surface === "が" || previousPrevious.surface === "も")) {
6501
- return false;
6502
- }
6503
- return true;
6504
- }
6505
- function lastContentUnit(units) {
6506
- for (let index = units.length - 1; index >= 0; index -= 1) {
6507
- const unit = units[index];
6508
- if (unit?.unitType === UnitType.CONTENT) {
6509
- return unit;
6510
- }
6511
- }
6512
- return undefined;
6513
- }
6514
- function modifiedHeadNounMatchingSelectedSense(sense, tokens, index, lookups) {
6515
- const head = directModifiedHeadNoun(tokens, index);
6516
- if (head === null) {
6517
- return null;
6518
- }
6519
- for (const condition of modifiedHeadNounLookupConditions(sense)) {
6520
- if (lookupConditionMatches(condition, argumentNounLookupForms(head), lookups)) {
6521
- return head;
6522
- }
6523
- }
6524
- return null;
6525
- }
6526
- function directModifiedHeadNoun(tokens, index) {
6527
- const nextIndex = nextNonSpaceIndex(tokens, index + 1, tokens.length);
6528
- if (nextIndex === null) {
6529
- return null;
6530
- }
6531
- const next = tokens[nextIndex];
6532
- return next !== undefined && pos0in(next.pos, NOMINAL_BITS) ? next : null;
6533
- }
6534
- function modifiedHeadNounLookupConditions(sense) {
6535
- const frames = [
6536
- ...(sense.senseFrame === undefined ? [] : [sense.senseFrame]),
6537
- ...(sense.senseFrames ?? [])
6538
- ];
6539
- const conditions = [];
6540
- for (const frame of frames) {
6541
- const lexical = mappingValue(frame, "lexicalConditions") ?? mappingValue(frame, "lexical_conditions");
6542
- if (lexical === null) {
6543
- continue;
6544
- }
6545
- const value = valueFromMapping(lexical, "modifiedHeadNounLookup") ?? valueFromMapping(lexical, "modified_head_noun_lookup");
6546
- if (value !== undefined) {
6547
- conditions.push(value);
6548
- }
6549
- }
6550
- return conditions;
6551
- }
6552
- function mappingValue(value, key) {
6553
- const item = valueFromMapping(value, key);
6554
- return item !== null && typeof item === "object" && !Array.isArray(item)
6555
- ? item
6556
- : null;
6557
- }
6558
- function valueFromMapping(value, key) {
6559
- return value !== null && typeof value === "object" && !Array.isArray(value)
6560
- ? value[key]
6561
- : undefined;
6562
- }
6563
- function predicatePrenominalPlan(translation, koreanVerbEndingOverrides) {
6564
- const ending = predicatePrenominalEnding(translation, koreanVerbEndingOverrides);
6565
- const cacheValue = PipelineAssemblerMixin.predicatePrenominalText(translation.korean, {
6566
- koreanPos: translation.koreanPos,
6567
- irregular: translation.irregular ?? null,
6568
- ending
6569
- });
6570
- if (cacheValue === undefined) {
6571
- return null;
6572
- }
6573
- return {
6574
- renderPlan: {
6575
- kind: "conjugatedLemma",
6576
- koreanLemma: translation.korean,
6577
- irregular: translation.irregular ?? null,
6578
- koreanPos: translation.koreanPos,
6579
- auxTokens: [],
6580
- ending
6581
- }
4934
+ renderPlan: {
4935
+ kind: "conjugatedLemma",
4936
+ koreanLemma: translation.korean,
4937
+ irregular: translation.irregular ?? null,
4938
+ koreanPos: translation.koreanPos,
4939
+ auxTokens: [],
4940
+ ending
4941
+ }
6582
4942
  };
6583
4943
  }
6584
4944
  function predicatePrenominalEnding(translation, koreanVerbEndingOverrides) {
@@ -6587,378 +4947,3 @@ function predicatePrenominalEnding(translation, koreanVerbEndingOverrides) {
6587
4947
  }
6588
4948
  return "ㄴ/은";
6589
4949
  }
6590
- function particleAllomorphKey(token) {
6591
- const pos1 = token.pos & POS1;
6592
- if (pos1 !== undefined && SKIP_SUBPOS.has(pos1)) {
6593
- return undefined;
6594
- }
6595
- return ALLOMORPH_MAP[secondaryParticleCanonical(token) ?? token.surface];
6596
- }
6597
- function quoteMarkerFocusRealizationAt(cursor, lookups) {
6598
- const quote = quoteStructuralRelationAt(cursor, lookups)?.quote;
6599
- if (quote === undefined || quote.focusParticle === undefined || quote.markerIdx !== cursor.pos) {
6600
- return null;
6601
- }
6602
- const consumed = quote.markerSpan.endExclusive - (quote.markerIdx + 1);
6603
- if (consumed <= 0) {
6604
- return null;
6605
- }
6606
- const allomorphKey = quote.focusParticle === "でも"
6607
- ? "이라도/라도"
6608
- : quote.focusParticle === "も" ? "도" : "은/는";
6609
- return { consumed, allomorphKey };
6610
- }
6611
- function lastOutputUnit(units) {
6612
- for (let index = units.length - 1; index >= 0; index -= 1) {
6613
- const unit = units[index];
6614
- if (unit !== undefined && emitsOutput(unit)) {
6615
- return unit;
6616
- }
6617
- }
6618
- return undefined;
6619
- }
6620
- function nominalDakeCopulaHostUnit(units) {
6621
- const last = lastOutputUnit(units);
6622
- if (last === undefined) {
6623
- return null;
6624
- }
6625
- const direct = nominalDakeCopulaHostFromUnit(last);
6626
- if (direct !== null) {
6627
- return {
6628
- mode: "inline",
6629
- ...direct,
6630
- };
6631
- }
6632
- if (last.unitType !== UnitType.SYMBOL || !isTrailingPunctuationToken(last.jpHead)) {
6633
- return null;
6634
- }
6635
- for (let index = units.length - 2; index >= 0; index -= 1) {
6636
- const unit = units[index];
6637
- if (unit === undefined || !emitsOutput(unit)) {
6638
- continue;
6639
- }
6640
- if (unit.unitType === UnitType.SYMBOL) {
6641
- if (isTrailingPunctuationToken(unit.jpHead)) {
6642
- continue;
6643
- }
6644
- return null;
6645
- }
6646
- const host = nominalDakeCopulaHostFromUnit(unit);
6647
- return host === null
6648
- ? null
6649
- : {
6650
- mode: "suffix",
6651
- ...host,
6652
- };
6653
- }
6654
- return null;
6655
- }
6656
- function nominalDakeCopulaHostFromUnit(unit) {
6657
- const renderPlan = unit.renderPlan;
6658
- if (renderPlan === null ||
6659
- PREDICATE_POS.has(unit.koreanPos) ||
6660
- (unit.koreanPos !== 명사 && unit.koreanPos !== 대명사 && unit.koreanPos !== 수사 && unit.koreanPos !== 구)) {
6661
- return null;
6662
- }
6663
- return { unit, renderPlan };
6664
- }
6665
- function punctuatedCopulaTailHostUnit(units) {
6666
- const last = lastUnit(units);
6667
- if (last === undefined || last.unitType !== UnitType.SYMBOL || !isCopulaTailContinuationPunctuationUnit(last)) {
6668
- return undefined;
6669
- }
6670
- for (let index = units.length - 2; index >= 0; index -= 1) {
6671
- const unit = units[index];
6672
- if (unit === undefined || !emitsOutput(unit)) {
6673
- continue;
6674
- }
6675
- if (unit.unitType === UnitType.SYMBOL) {
6676
- if (isCopulaTailContinuationPunctuationUnit(unit)) {
6677
- continue;
6678
- }
6679
- return undefined;
6680
- }
6681
- return unit;
6682
- }
6683
- return undefined;
6684
- }
6685
- function isCopulaTailContinuationPunctuationUnit(unit) {
6686
- return isTrailingPunctuationToken(unit.jpHead) || isClauseCommaPunctuationUnit(unit);
6687
- }
6688
- function isEllipticConfirmationParticle(token, particles) {
6689
- return (token.pos & POS0) === 助詞 && particles.has(token.surface);
6690
- }
6691
- function isNaniDeConfirmationVeto(tokens, particleIdx) {
6692
- const particle = tokens[particleIdx];
6693
- if (particle === undefined || particle.surface !== "で" || (particle.pos & POS01) !== 助詞_格助詞) {
6694
- return false;
6695
- }
6696
- const nounIdx = previousNonSpaceIndex(tokens, particleIdx, 0);
6697
- const noun = nounIdx === null ? undefined : tokens[nounIdx];
6698
- if (noun === undefined) {
6699
- return false;
6700
- }
6701
- return noun.surface === "何" ||
6702
- noun.surface === "なに" ||
6703
- noun.dictionaryForm === "何" ||
6704
- noun.reading === "ナニ" ||
6705
- noun.reading === "ナン";
6706
- }
6707
- function matchEllipticConfirmationTerminal(tokens, desuIdx, end) {
6708
- const kaIdx = nextNonSpaceIndex(tokens, desuIdx + 1, end);
6709
- if (kaIdx === null) {
6710
- return null;
6711
- }
6712
- const ka = tokens[kaIdx];
6713
- if (ka === undefined || ka.surface !== "か" || (ka.pos & POS0) !== 助詞) {
6714
- return null;
6715
- }
6716
- const afterIdx = nextNonSpaceIndex(tokens, kaIdx + 1, end);
6717
- if (afterIdx === null) {
6718
- return { kaIdx, endExclusive: kaIdx + 1 };
6719
- }
6720
- const after = tokens[afterIdx];
6721
- if (after !== undefined &&
6722
- (after.pos & POS0) === 補助記号 &&
6723
- hasHardTerminalPunctuationClass(after, afterIdx, ["japanese_period", "question"], ["assembler"])) {
6724
- return { kaIdx, endExclusive: afterIdx + 1 };
6725
- }
6726
- return null;
6727
- }
6728
- function trailingCopulaConnectiveSuffix(preceding, connective, auxTokens, lookups) {
6729
- if (preceding.length === 0) {
6730
- return "";
6731
- }
6732
- const features = auxExtractFeatures(auxTokens, { lookups });
6733
- const full = nounCopulaConnective(preceding, connective, features.past);
6734
- return full.startsWith(preceding) ? full.slice(preceding.length) : "";
6735
- }
6736
- function nominalDakeTameReasonTail(cursor, contentIdx, lookups) {
6737
- const { tokens, pos: start } = cursor;
6738
- const headToken = tokens[start] ?? null;
6739
- if (!isTameReasonHeadContext(headToken, tokens, contentIdx, lookups)) {
6740
- return false;
6741
- }
6742
- cursor.advance(1);
6743
- return true;
6744
- }
6745
- function lastUnit(units) {
6746
- return units.length > 0 ? units[units.length - 1] : undefined;
6747
- }
6748
- function quotedDesireRenderPlan(plan, marker, markerIndex) {
6749
- if (!isPredicateHeadTailChainRenderPlan(plan) || plan.realization.root.tail.kind !== "auxLayer") {
6750
- return null;
6751
- }
6752
- const layer = plan.realization.root.tail;
6753
- if (!layer.ops.some((op) => op.kind === "desire") || layer.ops.some((op) => op.kind === "connective")) {
6754
- return null;
6755
- }
6756
- const connective = createConnectiveOp({
6757
- connective: "quotative",
6758
- surface: marker.surface,
6759
- source: { tokens: [marker], tokenIndices: [markerIndex] }
6760
- });
6761
- return {
6762
- ...plan,
6763
- realization: {
6764
- ...plan.realization,
6765
- root: {
6766
- ...plan.realization.root,
6767
- tail: {
6768
- ...layer,
6769
- ops: [...layer.ops, connective]
6770
- }
6771
- }
6772
- },
6773
- clauseRole: {
6774
- ...plan.clauseRole,
6775
- outgoingBoundary: {
6776
- kind: "接続助詞",
6777
- connectiveKind: "quotative",
6778
- surface: marker.surface,
6779
- tokenIdx: markerIndex,
6780
- tokenSpan: { start: markerIndex, end: markerIndex }
6781
- }
6782
- }
6783
- };
6784
- }
6785
- function kataVerbHostAttributivePlan(unit) {
6786
- const plan = unit.renderPlan;
6787
- if (plan?.kind !== "lemma" || plan.connective !== "고" || plan.koreanPos !== 동사) {
6788
- return null;
6789
- }
6790
- return {
6791
- kind: "conjugatedLemma",
6792
- koreanLemma: plan.koreanLemma,
6793
- irregular: plan.irregular,
6794
- koreanPos: plan.koreanPos,
6795
- ending: "ㄴ/는",
6796
- auxTokens: plan.auxTokens,
6797
- ...(plan.jpDictForm === undefined || plan.jpDictForm === null ? {} : { jpDictForm: plan.jpDictForm }),
6798
- ...(plan.verbConjType === undefined || plan.verbConjType === null ? {} : { verbConjType: plan.verbConjType }),
6799
- ...(plan.voice === undefined && plan.forcePassive !== true ? {} : { voice: plan.forcePassive === true ? "passive" : plan.voice }),
6800
- };
6801
- }
6802
- function suffixNominalizerAlreadyLexicalizedInPreviousUnit(token, korean, previousUnit) {
6803
- if (previousUnit === undefined ||
6804
- previousUnit.unitType !== UnitType.CONTENT ||
6805
- !unitHasNominalizedNounRenderPlan(previousUnit)) {
6806
- return false;
6807
- }
6808
- return korean === "함" &&
6809
- (token.dictionaryForm === "さ" || token.dictionaryForm === "ざ" || token.dictionaryForm === "がたみ");
6810
- }
6811
- function unitHasNominalizedNounRenderPlan(unit) {
6812
- const plan = unit.renderPlan;
6813
- if (plan?.kind !== "lemma" || plan.koreanPos !== 명사) {
6814
- return false;
6815
- }
6816
- const typed = unit.entry?.senses?.some((sense) => sense.nominalized === plan.koreanLemma &&
6817
- (sense.koreanPos === 형용사 || sense.koreanPos === 동사)) === true
6818
- ? "predicate_nominalized"
6819
- : "unknown";
6820
- return resolveNominalAttributiveEvidence(plan.koreanLemma, typed) === "predicate_nominalized";
6821
- }
6822
- function rewriteFunctionalAdjectivalSuffixHostToNominalized(suffixToken, previousUnit) {
6823
- if (previousUnit === undefined ||
6824
- previousUnit.unitType !== UnitType.CONTENT ||
6825
- (suffixToken.pos & POS01) !== 接尾辞_形容詞的) {
6826
- return;
6827
- }
6828
- const nominalized = selectedPredicateNominalizedLemma(previousUnit);
6829
- if (nominalized === null || nominalized === previousUnit.korean) {
6830
- return;
6831
- }
6832
- previousUnit.setRenderPlan({ kind: "fixedText", text: nominalized, koreanPos: 명사 }, { rule: "SUFFIX-ADJECTIVAL-NOMINALIZED-HOST", cacheValue: nominalized });
6833
- }
6834
- function selectedPredicateNominalizedLemma(unit) {
6835
- const selectedLemma = selectedPredicateLemmaForUnit(unit);
6836
- if (selectedLemma === null) {
6837
- return null;
6838
- }
6839
- const sense = unit.entry?.senses?.find((candidate) => candidate.korean === selectedLemma &&
6840
- (candidate.koreanPos === 형용사 || candidate.koreanPos === 동사) &&
6841
- typeof candidate.nominalized === "string" &&
6842
- candidate.nominalized.length > 0);
6843
- return sense?.nominalized ?? null;
6844
- }
6845
- function selectedPredicateLemmaForUnit(unit) {
6846
- const plan = unit.renderPlan;
6847
- if (plan?.kind === "lemma" && (plan.koreanPos === 형용사 || plan.koreanPos === 동사)) {
6848
- return plan.koreanLemma;
6849
- }
6850
- if ((unit.koreanPos === 형용사 || unit.koreanPos === 동사) && unit.korean.length > 0) {
6851
- return unit.korean;
6852
- }
6853
- return null;
6854
- }
6855
- function absorbOrphanShuujoshi(tokens, units) {
6856
- const covered = new Set(units.flatMap(u => u.jpIndices));
6857
- const unitIndex = TokenUnitIndex.build(units);
6858
- for (let i = tokens.length - 1; i >= 0; i--) {
6859
- const t = tokens[i];
6860
- if (t === undefined || covered.has(i))
6861
- continue;
6862
- if ((t.pos & POS01) !== 助詞_終助詞)
6863
- continue;
6864
- const prev = unitIndex.get(i - 1);
6865
- if (prev !== undefined) {
6866
- prev.jpIndices.push(i);
6867
- unitIndex.set(i, prev);
6868
- covered.add(i);
6869
- continue;
6870
- }
6871
- for (let j = i + 1; j < tokens.length; j++) {
6872
- if (covered.has(j)) {
6873
- const next = unitIndex.get(j);
6874
- if (next !== undefined) {
6875
- next.jpIndices.push(i);
6876
- unitIndex.set(i, next);
6877
- covered.add(i);
6878
- }
6879
- break;
6880
- }
6881
- if (!pos0in((tokens[j]?.pos ?? 0), (1 << 助詞)))
6882
- break;
6883
- }
6884
- }
6885
- }
6886
- function absorbOrphanHojokigou(tokens, units) {
6887
- const covered = new Set(units.flatMap(u => u.jpIndices));
6888
- const unitIndex = TokenUnitIndex.build(units);
6889
- for (let i = 0; i < tokens.length; i++) {
6890
- const t = tokens[i];
6891
- if (t === undefined || covered.has(i))
6892
- continue;
6893
- if ((t.pos & POS0) !== 補助記号)
6894
- continue;
6895
- const prev = unitIndex.get(i - 1);
6896
- if (prev !== undefined) {
6897
- prev.jpIndices.push(i);
6898
- unitIndex.set(i, prev);
6899
- covered.add(i);
6900
- continue;
6901
- }
6902
- const next = unitIndex.get(i + 1);
6903
- if (next !== undefined) {
6904
- next.jpIndices.push(i);
6905
- unitIndex.set(i, next);
6906
- covered.add(i);
6907
- }
6908
- }
6909
- }
6910
- function contentHeadDispatchLimit(tokens, index, protoLayout) {
6911
- const clause = protoLayout?.clauseOfToken(index);
6912
- if (clause === undefined) {
6913
- return tokens.length;
6914
- }
6915
- if (separatedAs(tokens, clause.end, SEPARATION_OPENS_BOUNDARY)) {
6916
- return clause.end;
6917
- }
6918
- if (protoLayout?.unmarkedMainClauseBoundaryAt(clause.end) === true) {
6919
- return clause.end;
6920
- }
6921
- let boundary = previousNonSpaceIndex(tokens, clause.end, clause.start);
6922
- while (boundary !== null && isTrailingPunctuationToken(tokens[boundary])) {
6923
- boundary = previousNonSpaceIndex(tokens, boundary, clause.start);
6924
- }
6925
- return boundary !== null && isHardTerminalPunctuationToken(tokens[boundary])
6926
- ? clause.end
6927
- : tokens.length;
6928
- }
6929
- function absorbIntoPrecedingUnit(units, tokenIndex) {
6930
- const unit = lastUnit(units);
6931
- if (unit !== undefined && !unit.jpIndices.includes(tokenIndex)) {
6932
- unit.jpIndices.push(tokenIndex);
6933
- return true;
6934
- }
6935
- return false;
6936
- }
6937
- function committedLookupEntry(entry) {
6938
- if (entry === undefined || !hasTranslationAccess(entry)) {
6939
- return null;
6940
- }
6941
- return commitWinner(entry);
6942
- }
6943
- function suffixRenderPlanFromCommittedEntry(entry, korean) {
6944
- if (entry === null) {
6945
- return null;
6946
- }
6947
- const selected = winner(entry);
6948
- if (korean.length === 0) {
6949
- return null;
6950
- }
6951
- return {
6952
- kind: "lemma",
6953
- entry,
6954
- koreanLemma: korean,
6955
- koreanPos: selected.koreanPos ?? 접미사,
6956
- irregular: selected.irregular ?? null,
6957
- auxTokens: [],
6958
- jpDictForm: entry.dictionaryForm ?? null,
6959
- verbConjType: null,
6960
- };
6961
- }
6962
- function hasUserDictOverride(unit, tokens) {
6963
- return unit.jpIndices.some(i => tokens[i]?.koreanOverride !== undefined);
6964
- }