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,37 +1,15 @@
1
- import { clauseProjectionEvidenceWindowForToken, nextNonSpaceIndex, previousNonSpaceIndex, punctuatedAttributiveTargetAnchor, utteranceClosedForAttributiveProjection } from "../clause-layout/index.js";
2
- import { isClauseEvidenceTransparentPunctuation, isClauseHardTerminalPunctuationToken, isClauseOpeningPunctuationToken, isClausePunctuationToken } from "../clause-layout/punctuation.js";
3
- import { hostedConnectiveMarkerAt, relationDiscontinuousClosureSpanAfter, relationConnectiveSpansAt, } from "../head-tail/tail/connective-span-scanner.js";
4
1
  import { TokenCursor } from "../token-cursor.js";
5
- import { matchCopulaNegation } from "../rules/copula.js";
6
- import { isTeConnectiveToken } from "../head-tail/tail/postverb-tail-classifier.js";
7
- import { TE_TAIL_CONTINUATION_LEXEME_ENTRY_BY_FORM } from "../head-tail/tail/te-tail-continuation-table.js";
8
- import { isQuestionParticleKaToken } from "../head-tail/boundary/marker.js";
9
- import { copulaClosedNominalPredicateBeforeMarkerAt, copulaClosedTokaKaRelationAt, directDiscourseChoiceQuestionKaRelationAt, isCopularTokaKaMarker, isKaDouKaMarker, isTokaListingKaMarker, kaOwnershipKindAt, previousTokenIsBasicCopula, previousTokenIsCopulaQuestionHost, terminalQuestionKaRelationAt, } from "../head-tail/boundary/ka-ownership.js";
10
- import { isStructuralKaParallelMarkerAt } from "./ka-parallel-ownership.js";
11
- import { enumerateClausePhrasesAfter, enumerateClausePhrasesBefore, enumerateQuoteInternalClausePhraseStreams, } from "../clause-layout/phrase-enumeration.js";
12
- import { isNominalizedConjectureMatrixQuestionPlan } from "./ka-parallel-plan.js";
13
- import { quoteMarkerRelationAt } from "../head-tail/boundary/quote-marker.js";
14
- import { isSayVerbToken } from "../head-tail/tail/predicate-root/classifiers/tokens.js";
15
- import { looksQuestionTakingAfterViaLayout } from "../quote/question-taking-enumeration.js";
16
- import { hardTerminalPunctuationSurfaceClassForToken, isBoundaryPunctuationCategoryToken, isHardTerminalPunctuationToken } from "../head-tail/boundary/punctuation.js";
17
- import { pronominalNoParticleContinuationForToken } from "../pronominal-no-dispatch.js";
18
- import { TYPIFICATION_QUOTATIVE_HEADS } from "../head-tail/data/semantic-helper-sets.js";
19
- import { IU_LEXEME_FORMS, NOMINAL_EXEMPLIFICATION_QUOTE_MARKERS } from "../head-tail/data/quoted-reporting-sets.js";
20
- import { tokenMatchesConnectiveKind } from "../head-tail/tail/connective-span-scanner.js";
21
- import { isTameHead } from "../lookup-tables.js";
22
- import { precedingTokenOpensStrictReason } from "../reason-source-evidence.js";
23
- import { isClauseClosingInflection, isIndependentWordToken, isNaAdjCapableNoun, isNominalLike, POS01, 助詞_接続助詞, 助詞_係助詞, 助詞_副助詞, 助詞_格助詞, 助詞_終助詞, 助詞_準体助詞, 명사, 대명사, 수사 } from "../../types/pos.js";
24
- import { isVerbLemma } from "../matchers.js";
25
- import { isPredicateHeadTailChainRenderPlan } from "../../types/render-plan.js";
26
- import { attributiveModifierPlanSourceFacts } from "../rendering/render-plan.js";
27
- import { tryResolveDemoDiscourseConnective } from "../demo-discourse.js";
28
- import { layoutBlocker, projectionUnavailable, structuralRelationDegraded } from "./diagnostics.js";
29
- import { collectBareKaQuestionContentRelations, collectCopulaClosedTokaQuoteRelations, collectQuoteStructuralRelations, copulaClosedContentAnchorIdx, quoteRelationWithRequestSourceEvidence, terminalSfpQuoteMarkerBridgeSpan } from "./quote.js";
30
- import { quoteHostMatchIsAttributiveIu } from "../quote/host-taxonomy.js";
31
- import { tailRootClosesWithBareKeijoujiAttributive, tailRootClosesWithCopulaAttributive, tailRootQuoteRequestSourceEvidence } from "../head-tail/tail/predicate-root/inspect.js";
32
- import { detectSfpWithNode } from "../semantics/grammar-runtime.js";
33
- import { tokaNominalListingContinuationAfter, tokaNominalListingMarkersInScope, tokaNominalMarkedRunAt, } from "./toka-nominal-listing-run.js";
34
- import { POS0, pos0in, POS1, POS4, POS5A, 形状詞, 形容詞0, 助詞, 助動詞, 代名詞, 動詞, 副助詞, 接尾辞, 接続助詞, 補助記号, 名詞, 連体形_, 連体詞, 非自立可能, 終止形_, 連用形_, 助動詞_タ, 助動詞_ダ, 助動詞_デス, 助動詞_ヌ, 助動詞_マス, 意志推量形_, 형용사, PREDICATE_AUX_BITS, PUNCTUATION_BITS, NOMINAL_BITS, stemFormName, conjectureCopulaPoliteness, isConditionalInflection, isPoliteCopulaPos, isPastAuxConditionalForm, isPastAuxiliaryPos, isReasonCopulaNegativeShellAuxiliary, isVolitionalInflection, } from "../../types/pos.js";
2
+ import { tokenSpansOverlap } from "./toka-nominal-listing-run.js";
3
+ import { collectTokaNominalListingRelations } from "./toka-nominal-listing-relations.js";
4
+ import { collectEmbeddedQuestionAttributiveQuoteRelations, collectKaParallelRelations } from "./ka-parallel-relations.js";
5
+ import { collectContiguousRelations, collectDiscontinuousRelations, collectTeAttendantSimultaneousRelations } from "./clause-connective-relations.js";
6
+ import { collectTariListingCoordinationRelations } from "./tari-listing-relations.js";
7
+ import { collectPurposeClauseCoordinationRelations } from "./purpose-relations.js";
8
+ import { buildStructuralRelationNodes } from "./relation-coordinates.js";
9
+ import { collectNariParallelRelations, collectImmediateNariSequenceRelations } from "./nari-relations.js";
10
+ import { collectPunctuatedAttributiveModifierRelations } from "./punctuated-attributive-relations.js";
11
+ import { collectReasonCopulaExplanationRelations } from "./reason-relations.js";
12
+ import { collectQuoteStructuralRelationsFromOptions } from "./quote-relation-enrichment.js";
35
13
  export function buildStructuralRelationGraph(options) {
36
14
  const nodes = buildStructuralRelationNodes(options.layout, options.contentMap);
37
15
  const rootCursor = new TokenCursor(options.tokens, 0, options.tokens.length);
@@ -84,3075 +62,3 @@ function structuralQuoteOwnerSpans(kaParallelRelations, embeddedQuestionRelation
84
62
  ]),
85
63
  ];
86
64
  }
87
- function collectTokaNominalListingRelations(options, quoteRelations) {
88
- const { tokens, layout } = options;
89
- const outsidePhrases = layout.clauses.flatMap((clause) => [
90
- ...enumerateClausePhrasesAfter(layout, tokens, clause.start - 1, { scope: "clause" }),
91
- ]);
92
- const phraseStreams = [
93
- { phrases: outsidePhrases, quoteSpan: null },
94
- ...layout.quoteSpans.flatMap((quoteSpan) => enumerateQuoteInternalClausePhraseStreams(layout, tokens, quoteSpan)
95
- .map((phrases) => ({ phrases, quoteSpan }))),
96
- ];
97
- return phraseStreams.flatMap(({ phrases, quoteSpan }) => collectTokaNominalListingRelationsFromPhraseStream(options, quoteRelations, phrases, quoteSpan));
98
- }
99
- function collectTokaNominalListingRelationsFromPhraseStream(options, quoteRelations, phrases, quoteSpan) {
100
- const { tokens, layout, lookups } = options;
101
- const relations = [];
102
- for (let phraseIndex = 0; phraseIndex < phrases.length; phraseIndex += 1) {
103
- const scopePhrase = phrases[phraseIndex];
104
- if (scopePhrase === undefined) {
105
- continue;
106
- }
107
- const enclosingQuoteSpan = layout.enclosingQuoteSpan(scopePhrase.headIdx);
108
- const belongsToSelectedQuote = quoteSpan !== null &&
109
- [...layout.enclosingQuoteSpans(scopePhrase.headIdx)]
110
- .some(([start, end]) => start === quoteSpan[0] && end === quoteSpan[1]);
111
- if (quoteSpan === null
112
- ? enclosingQuoteSpan !== undefined
113
- : enclosingQuoteSpan === undefined || !belongsToSelectedQuote) {
114
- continue;
115
- }
116
- const markers = tokaNominalListingMarkersInScope({
117
- tokens,
118
- layout,
119
- lookups,
120
- quoteRelations,
121
- scopeTokenIdx: scopePhrase.headIdx,
122
- phrases,
123
- });
124
- const run = tokaNominalMarkedRunAt({
125
- phrases,
126
- phraseIndex,
127
- tokens,
128
- layout,
129
- markers,
130
- scopeTokenIdx: scopePhrase.headIdx,
131
- });
132
- if (run === null) {
133
- continue;
134
- }
135
- const { first, markedItems, separatorSpans, nextPhraseIndex } = run;
136
- const firstPhrase = first.phrases[0];
137
- const lastMarked = markedItems.at(-1);
138
- const markerSpans = markedItems.map((item) => item.marker.markerSpan);
139
- if (markedItems.some((item) => item.marker.quoteOwned)) {
140
- continue;
141
- }
142
- const continuation = lastMarked.postMarkerParticleIdx === null
143
- ? tokaNominalListingContinuationAfter(markers, lastMarked.marker.markerSpan.endExclusive)
144
- : "none";
145
- if (continuation === "quote_owned") {
146
- continue;
147
- }
148
- const closure = continuation === "continues" ? "continues" : "closed";
149
- const trailingParticleSpan = closure === "continues"
150
- ? null
151
- : tokaNominalTrailingParticleSpan({
152
- tokens,
153
- layout,
154
- lastMarked,
155
- });
156
- const itemAnchors = markedItems.map((item) => spanAnchor({
157
- start: item.phrases[0].span.start,
158
- endExclusive: item.marker.markerSpan.start,
159
- clauseIndex: layout.clauseIndexOfToken(item.markerPhrase.headIdx),
160
- }));
161
- const payload = {
162
- itemAnchors,
163
- separatorSpans,
164
- trailingParticleSpan,
165
- closure,
166
- };
167
- const sourceEnd = trailingParticleSpan?.endExclusive ??
168
- Math.max(itemAnchors.at(-1)?.span.endExclusive ?? 0, markerSpans.at(-1)?.endExclusive ?? 0);
169
- relations.push({
170
- kind: "toka_nominal_listing",
171
- source: spanAnchor({
172
- start: itemAnchors[0]?.span.start ?? firstPhrase.span.start,
173
- endExclusive: sourceEnd,
174
- clauseIndex: layout.clauseIndexOfToken(firstPhrase.headIdx),
175
- }),
176
- target: null,
177
- markerSpans,
178
- candidateSuppressibleTokenSpans: [
179
- ...markerSpans.map((span) => ({
180
- start: span.start,
181
- endExclusive: span.endExclusive,
182
- reason: "relation_marker",
183
- })),
184
- ...separatorSpans.map((span) => ({
185
- start: span.start,
186
- endExclusive: span.endExclusive,
187
- reason: "relation_separator",
188
- })),
189
- ...(trailingParticleSpan === null ? [] : [{
190
- start: trailingParticleSpan.start,
191
- endExclusive: trailingParticleSpan.endExclusive,
192
- reason: "relation_trailing_particle",
193
- }]),
194
- ],
195
- projection: {
196
- sourceForm: "listing",
197
- connectiveKind: "toka_nominal_listing",
198
- targetSlot: "coordination",
199
- },
200
- confidence: "strict",
201
- renderEnabledByDefault: true,
202
- tokaNominalListing: payload,
203
- provenance: "structural_relation_owner",
204
- });
205
- phraseIndex = nextPhraseIndex - 1;
206
- }
207
- return relations;
208
- }
209
- function tokaNominalTrailingParticleSpan(options) {
210
- const { tokens, layout, lastMarked } = options;
211
- if (lastMarked.followedByTopicTte) {
212
- return null;
213
- }
214
- const particleIdx = lastMarked.postMarkerParticleIdx;
215
- if (particleIdx === null) {
216
- return null;
217
- }
218
- const particle = tokens[particleIdx];
219
- if (!isTokaNominalTrailingParticle(particle)) {
220
- return null;
221
- }
222
- if (nextNonSpaceIndex(tokens, particleIdx + 1, lastMarked.markerPhrase.span.endExclusive) !== null) {
223
- return null;
224
- }
225
- const ownerIdx = layout.ownerPredicateOfParticle(particleIdx);
226
- if (ownerIdx === undefined ||
227
- !layout.argumentRolesOf(ownerIdx).some((assignment) => assignment.particleIdx === particleIdx)) {
228
- return null;
229
- }
230
- return {
231
- start: particleIdx,
232
- endExclusive: particleIdx + 1,
233
- surface: particle?.surface ?? "",
234
- role: "toka_nominal_listing_trailing_particle",
235
- };
236
- }
237
- function isTokaNominalTrailingParticle(token) {
238
- return token !== undefined &&
239
- ((token.pos & POS01) === 助詞_格助詞 || (token.pos & POS01) === 助詞_係助詞);
240
- }
241
- function isTokaNominalTopicTte(token) {
242
- return token?.surface === "って" && (token.pos & POS01) === 助詞_副助詞;
243
- }
244
- function tokenSpansOverlap(left, right) {
245
- return left.start < right.endExclusive && right.start < left.endExclusive;
246
- }
247
- function collectEmbeddedQuestionAttributiveQuoteRelations(options, kaParallelRelations) {
248
- const { tokens, layout } = options;
249
- const parallelMarkerStarts = new Set(kaParallelRelations.flatMap((relation) => relation.kaParallel?.markerSpans.map((span) => span.start) ?? []));
250
- const relations = [];
251
- for (let index = 0; index < tokens.length; index += 1) {
252
- const marker = kaParallelMarkerAt(tokens, layout, index, options.lookups);
253
- if (marker === null ||
254
- !marker.nominalized ||
255
- parallelMarkerStarts.has(marker.markerSpan.start))
256
- continue;
257
- const itemStart = parallelItemStartBeforeMarker(tokens, layout, marker.markerSpan.start);
258
- if (itemStart === null || itemStart >= marker.markerSpan.start)
259
- continue;
260
- const itemClause = layout.clauses[marker.clauseIndex];
261
- if (itemClause !== undefined &&
262
- spanHasMarkerExternalBoundarySymbol(tokens, itemClause.start, itemStart))
263
- continue;
264
- if (hasHardSentenceBoundaryBetween(tokens, itemStart, marker.markerSpan.start))
265
- continue;
266
- if (spanHasMarkerExternalBoundarySymbol(tokens, itemStart, marker.markerSpan.start))
267
- continue;
268
- const itemKind = kaParallelItemKind(new TokenCursor(tokens, itemStart, marker.markerSpan.start), options, marker);
269
- if (itemKind === null || itemKind === "bare_nominal")
270
- continue;
271
- const closureResult = kaParallelClosureAfter(new TokenCursor(tokens, marker.markerSpan.endExclusive, tokens.length), options);
272
- if (closureResult.closure.kind !== "attributive_quote")
273
- continue;
274
- const closure = closureResult.closure;
275
- const item = {
276
- source: spanAnchor({
277
- start: itemStart,
278
- endExclusive: marker.markerSpan.start,
279
- clauseIndex: marker.clauseIndex,
280
- }),
281
- markerSpan: marker.markerSpan,
282
- itemKind,
283
- predicateIdx: kaParallelPredicateIndex(options, itemStart, marker.markerSpan.start),
284
- predicateCategory: "predicate",
285
- };
286
- relations.push({
287
- kind: "embedded_question_attributive_quote",
288
- source: spanAnchor({
289
- start: itemStart,
290
- endExclusive: marker.markerSpan.endExclusive,
291
- clauseIndex: marker.clauseIndex,
292
- }),
293
- target: {
294
- kind: "noun_phrase",
295
- span: tokenSpan(closure.headIdx, closure.headIdx + 1),
296
- headIdx: closure.headIdx,
297
- },
298
- markerSpans: [marker.markerSpan, closure.markerSpan, ...(closure.particleSpan === undefined ? [] : [closure.particleSpan])],
299
- candidateSuppressibleTokenSpans: [
300
- { start: marker.markerSpan.start, endExclusive: marker.markerSpan.endExclusive, reason: "question_content_marker" },
301
- { start: closure.markerSpan.start, endExclusive: closure.markerSpan.endExclusive, reason: "attributive_quote_marker" },
302
- ...(closure.particleSpan === undefined ? [] : [{
303
- start: closure.particleSpan.start,
304
- endExclusive: closure.particleSpan.endExclusive,
305
- reason: "pronominal_no_particle"
306
- }]),
307
- ],
308
- projection: {
309
- sourceForm: "nominalized",
310
- connectiveKind: "embedded_question_attributive_quote",
311
- targetSlot: "noun_modifier",
312
- },
313
- confidence: "strict",
314
- renderEnabledByDefault: true,
315
- embeddedQuestionAttributiveQuote: { item, closure },
316
- provenance: "structural_relation_owner",
317
- });
318
- }
319
- return relations;
320
- }
321
- function spanHasMarkerExternalBoundarySymbol(tokens, start, endExclusive) {
322
- for (let index = start; index < endExclusive; index += 1) {
323
- const token = tokens[index];
324
- if (token !== undefined &&
325
- (isClausePunctuationToken(token) || pos0in(token.pos & POS0, PUNCTUATION_BITS)) &&
326
- !isClauseOpeningPunctuationToken(token) &&
327
- !isClauseEvidenceTransparentPunctuation(token)) {
328
- return true;
329
- }
330
- }
331
- return false;
332
- }
333
- function collectContiguousRelations(options, nodes, cursor) {
334
- const relations = [];
335
- const diagnostics = [];
336
- const { tokens, layout } = options;
337
- while (cursor.pos < tokens.length) {
338
- const index = cursor.pos;
339
- const matches = relationConnectiveSpansAt(cursor);
340
- const nounModifierMatch = matches.find((candidate) => candidate.targetSlot === "noun_modifier");
341
- if (nounModifierMatch !== undefined) {
342
- if (shouldDeferContiguousForPurposeModifier(options, index, nounModifierMatch)) {
343
- cursor.advance(nounModifierMatch.tokenCount);
344
- continue;
345
- }
346
- }
347
- const match = matches.find((candidate) => candidate.markerPolicy !== "discontinuous" && candidate.targetSlot !== "noun_modifier") ?? null;
348
- if (match === null) {
349
- cursor.advance();
350
- continue;
351
- }
352
- const markerSpan = markerSpanFromMatch(index, match);
353
- const sourceClauseIndex = layout.clauseIndexOfToken(index);
354
- const markerEndClauseIndex = layout.clauseIndexOfToken(match.endExclusive - 1);
355
- if (sourceClauseIndex < 0 || markerEndClauseIndex < 0 || sourceClauseIndex !== markerEndClauseIndex) {
356
- diagnostics.push(layoutBlocker({
357
- message: `ClauseLayout splits relation marker ${match.surface}`,
358
- relationKind: match.relationPolicy,
359
- confidence: "strict",
360
- ...layoutBoundaryDiagnosticPayload(match),
361
- span: markerSpan,
362
- markerSpans: [markerSpan],
363
- }));
364
- cursor.advance(match.endExclusive - cursor.pos);
365
- continue;
366
- }
367
- const sourceClause = layout.clauses[sourceClauseIndex];
368
- const targetClauseIndex = nextClauseIndex(layout, sourceClauseIndex);
369
- const targetClause = targetClauseIndex === null ? undefined : layout.clauses[targetClauseIndex];
370
- if (sourceClause === undefined || targetClauseIndex === null || targetClause === undefined) {
371
- diagnostics.push(structuralRelationDegraded({
372
- message: `relation marker ${match.surface} has no target clause`,
373
- relationKind: match.relationPolicy,
374
- confidence: "weak",
375
- ...layoutBoundaryDiagnosticPayload(match),
376
- ...(sourceClauseIndex < 0 ? {} : { clauseId: structuralRelationNodeId(sourceClauseIndex) }),
377
- span: markerSpan,
378
- markerSpans: [markerSpan],
379
- }));
380
- cursor.advance(match.endExclusive - cursor.pos);
381
- continue;
382
- }
383
- if (match.relationPolicy === "reason" && !hasStrictReasonEvidence(tokens, sourceClause, markerSpan.start, match.endExclusive, options.contentMap)) {
384
- diagnostics.push(structuralRelationDegraded({
385
- message: `reason marker ${match.surface} lacks strict reason evidence`,
386
- relationKind: match.relationPolicy,
387
- confidence: "weak",
388
- ...layoutBoundaryDiagnosticPayload(match),
389
- clauseId: structuralRelationNodeId(sourceClauseIndex),
390
- span: markerSpan,
391
- markerSpans: [markerSpan],
392
- }));
393
- cursor.advance(match.endExclusive - cursor.pos);
394
- continue;
395
- }
396
- const projection = match.projection;
397
- if (projection === undefined) {
398
- diagnostics.push(projectionUnavailable({
399
- message: `relation marker ${match.surface} has no projection metadata`,
400
- relationKind: match.relationPolicy,
401
- confidence: "strict",
402
- ...layoutBoundaryDiagnosticPayload(match),
403
- clauseId: structuralRelationNodeId(sourceClauseIndex),
404
- span: markerSpan,
405
- markerSpans: [markerSpan],
406
- }));
407
- cursor.advance(match.endExclusive - cursor.pos);
408
- continue;
409
- }
410
- relations.push({
411
- kind: match.relationPolicy,
412
- source: clauseAnchor(nodes, sourceClauseIndex),
413
- target: clauseAnchor(nodes, targetClauseIndex),
414
- markerSpans: [markerSpan],
415
- candidateSuppressibleTokenSpans: [{
416
- start: markerSpan.start,
417
- endExclusive: markerSpan.endExclusive,
418
- reason: "relation_marker",
419
- }],
420
- projection: projectionRequest(projection, match),
421
- confidence: "strict",
422
- ...layoutBoundaryRelationPayload(match),
423
- ...renderEnabledRelationPayload(match),
424
- provenance: "structural_relation_owner",
425
- });
426
- cursor.advance(match.endExclusive - cursor.pos);
427
- }
428
- return { relations, diagnostics };
429
- }
430
- function collectDiscontinuousRelations(options, nodes, cursor) {
431
- const relations = [];
432
- const diagnostics = [];
433
- const { tokens } = options;
434
- while (cursor.pos < tokens.length) {
435
- const index = cursor.pos;
436
- const matches = relationConnectiveSpansAt(cursor);
437
- let consumed = 1;
438
- for (const match of matches) {
439
- if (match.relationPolicy === "listing_example" && match.markerPolicy === "discontinuous") {
440
- const result = collectListingExampleRelation(options, nodes, index, match);
441
- pushCollectResult(result, relations, diagnostics);
442
- consumed = Math.max(consumed, match.tokenCount);
443
- continue;
444
- }
445
- if (match.relationPolicy === "correlative_degree" && match.markerPolicy === "discontinuous" && match.markerRole === "conditional_marker") {
446
- const result = collectCorrelativeDegreeRelation(options, nodes, index, match);
447
- pushCollectResult(result, relations, diagnostics);
448
- consumed = Math.max(consumed, match.tokenCount);
449
- continue;
450
- }
451
- if (match.relationPolicy === "purpose_modifier" && match.targetSlot === "noun_modifier") {
452
- if (hasNounModifierTarget(options, index, match)) {
453
- const result = collectPurposeModifierRelation(options, nodes, index, match);
454
- pushCollectResult(result, relations, diagnostics);
455
- }
456
- consumed = Math.max(consumed, match.tokenCount);
457
- }
458
- }
459
- cursor.advance(consumed);
460
- }
461
- return { relations, diagnostics };
462
- }
463
- function collectTariListingCoordinationRelations(options, nodes) {
464
- const groups = collectTariListingGroups(options, nodes);
465
- return groups.flatMap((group) => {
466
- const itemAnchors = group.items.map((item) => ({
467
- source: item.source,
468
- markerSpan: item.markerSpan,
469
- }));
470
- const markerSpans = group.items.map((item) => item.markerSpan);
471
- return group.items.map((item, itemIndex) => ({
472
- kind: "tari_listing_coordination",
473
- source: item.source,
474
- target: group.target,
475
- markerSpans: [item.markerSpan],
476
- candidateSuppressibleTokenSpans: [{
477
- start: item.markerSpan.start,
478
- endExclusive: item.markerSpan.endExclusive,
479
- reason: "relation_marker",
480
- }],
481
- projection: {
482
- sourceForm: "listing",
483
- connectiveKind: "alternative",
484
- targetSlot: "coordination",
485
- },
486
- confidence: "strict",
487
- renderEnabledByDefault: true,
488
- tariListing: {
489
- itemAnchors,
490
- markerSpans,
491
- separatorSpans: group.separatorSpans,
492
- itemIndex,
493
- closure: group.closure,
494
- },
495
- provenance: "structural_relation_owner",
496
- }));
497
- });
498
- }
499
- function collectTariListingGroups(options, nodes) {
500
- const items = collectTariListingItems(options, nodes);
501
- if (items.length === 0) {
502
- return [];
503
- }
504
- const groups = [];
505
- let pending = [];
506
- for (const item of items) {
507
- const previous = pending[pending.length - 1] ?? null;
508
- if (previous !== null && !tariItemsCanBelongToSameGroup(options, previous, item)) {
509
- pushTariListingGroup(options, nodes, pending, groups);
510
- pending = [];
511
- }
512
- pending.push(item);
513
- }
514
- pushTariListingGroup(options, nodes, pending, groups);
515
- return groups;
516
- }
517
- function collectTeAttendantSimultaneousRelations(options, nodes) {
518
- const relations = [];
519
- const { tokens, layout, contentMap } = options;
520
- for (let clauseIndex = 0; clauseIndex < layout.clauses.length - 1; clauseIndex += 1) {
521
- const sourceClause = layout.clauses[clauseIndex];
522
- const targetClauseIndex = nextClauseIndex(layout, clauseIndex);
523
- const targetClause = targetClauseIndex === null ? undefined : layout.clauses[targetClauseIndex];
524
- if (sourceClause === undefined || targetClauseIndex === null || targetClause === undefined) {
525
- continue;
526
- }
527
- if (sourceClause.terminatedBy !== "connective") {
528
- continue;
529
- }
530
- const sourcePredicate = sourceClause.predicates[sourceClause.predicates.length - 1] ?? null;
531
- if (sourcePredicate === null) {
532
- continue;
533
- }
534
- const span = contentMap.get(sourcePredicate);
535
- if (span?.teConnectiveClassificationState?.committed?.surfaceRole !== "manner") {
536
- continue;
537
- }
538
- const markerSpan = teConnectiveMarkerSpanForCommittedSpan(tokens, sourcePredicate, span.consumed);
539
- if (markerSpan === null) {
540
- continue;
541
- }
542
- relations.push({
543
- kind: "te_attendant_simultaneous",
544
- source: predicateAnchor(sourcePredicate, clauseIndex),
545
- target: clauseAnchor(nodes, targetClauseIndex),
546
- markerSpans: [markerSpan],
547
- candidateSuppressibleTokenSpans: [{
548
- start: markerSpan.start,
549
- endExclusive: markerSpan.endExclusive,
550
- reason: "relation_marker",
551
- }],
552
- projection: {
553
- sourceForm: "connective",
554
- connectiveKind: "simultaneous",
555
- targetSlot: "clause_prefix",
556
- },
557
- confidence: "strict",
558
- renderEnabledByDefault: true,
559
- provenance: "structural_relation_owner",
560
- });
561
- }
562
- return relations;
563
- }
564
- function teConnectiveMarkerSpanForCommittedSpan(tokens, predicateIdx, consumed) {
565
- const endExclusive = consumed === undefined ? predicateIdx + 1 : predicateIdx + consumed;
566
- const c = new TokenCursor(tokens, predicateIdx + 1, Math.min(tokens.length, endExclusive));
567
- while (c.current()) {
568
- const token = c.current();
569
- if ((token.pos & POS01) === 助詞_接続助詞 && (token.surface === "て" || token.surface === "で")) {
570
- return {
571
- start: c.pos,
572
- endExclusive: c.pos + 1,
573
- surface: token.surface,
574
- role: "te_attendant_marker",
575
- };
576
- }
577
- c.advance();
578
- }
579
- return null;
580
- }
581
- function collectTariListingItems(options, _nodes) {
582
- const { tokens, layout, contentMap } = options;
583
- const items = [];
584
- const c = new TokenCursor(tokens, 0, tokens.length);
585
- while (c.current()) {
586
- const token = c.current();
587
- if (!isTariListingMarkerToken(token) || isTariListingExampleMarker(tokens, c.pos)) {
588
- c.advance();
589
- continue;
590
- }
591
- const clauseIndex = layout.clauseIndexOfToken(c.pos);
592
- const clause = clauseIndex < 0 ? undefined : layout.clauses[clauseIndex];
593
- if (clause === undefined) {
594
- c.advance();
595
- continue;
596
- }
597
- const predicateIdx = tariListingItemPredicateIndex(contentMap, clause, c.pos);
598
- if (predicateIdx === null) {
599
- c.advance();
600
- continue;
601
- }
602
- const markerSpan = tariListingMarkerSpan(tokens, c.pos);
603
- items.push({
604
- markerIdx: c.pos,
605
- predicateIdx,
606
- clauseIndex,
607
- source: predicateAnchor(predicateIdx, clauseIndex),
608
- markerSpan,
609
- });
610
- c.advance();
611
- }
612
- return items;
613
- }
614
- function tariListingMarkerSpan(tokens, markerIdx) {
615
- const marker = tokens[markerIdx];
616
- const focusIdx = nextNonSpaceIndex(tokens, markerIdx + 1);
617
- const focus = focusIdx === null ? undefined : tokens[focusIdx];
618
- if (marker !== undefined && focusIdx === markerIdx + 1 && focus !== undefined && focus.surface === "は" && (focus.pos & POS01) === 助詞_係助詞) {
619
- return {
620
- start: markerIdx,
621
- endExclusive: focusIdx + 1,
622
- surface: `${marker.surface}${focus.surface}`,
623
- role: "listing_tail_focus",
624
- };
625
- }
626
- return {
627
- start: markerIdx,
628
- endExclusive: markerIdx + 1,
629
- surface: marker?.surface ?? "",
630
- role: "listing_tail",
631
- };
632
- }
633
- function collectPurposeClauseCoordinationRelations(options, nodes) {
634
- const relations = [];
635
- for (let index = 0; index < options.tokens.length; index += 1) {
636
- const evidence = purposeClauseCoordinationEvidenceAt(options, index);
637
- if (evidence === null) {
638
- continue;
639
- }
640
- const purposeMarkerSpan = {
641
- start: evidence.tameIdx,
642
- endExclusive: evidence.tameIdx + 1,
643
- surface: options.tokens[evidence.tameIdx]?.surface ?? "ため",
644
- role: "purpose_marker",
645
- };
646
- const coordinationMarkerSpan = {
647
- start: evidence.coordinationIdx,
648
- endExclusive: evidence.coordinationIdx + 1,
649
- surface: options.tokens[evidence.coordinationIdx]?.surface ?? "と",
650
- role: "purpose_coordination_marker",
651
- };
652
- const targetPurposeMarkerSpan = {
653
- start: evidence.targetTameIdx,
654
- endExclusive: purposeTameMarkerEndExclusive(options.tokens, evidence.targetTameIdx),
655
- surface: markerSurface(options.tokens, evidence.targetTameIdx, purposeTameMarkerEndExclusive(options.tokens, evidence.targetTameIdx)),
656
- role: "target_purpose_marker",
657
- };
658
- const payload = {
659
- sourcePredicateIdx: evidence.sourcePredicateIdx,
660
- purposeMarkerSpan,
661
- coordinationMarkerSpan,
662
- targetPurposeMarkerSpan,
663
- };
664
- relations.push({
665
- kind: "purpose_clause_coordination",
666
- source: predicateAnchor(evidence.sourcePredicateIdx, evidence.sourceClauseIndex),
667
- target: clauseAnchor(nodes, evidence.targetClauseIndex),
668
- markerSpans: [purposeMarkerSpan, coordinationMarkerSpan, targetPurposeMarkerSpan],
669
- candidateSuppressibleTokenSpans: [
670
- { start: purposeMarkerSpan.start, endExclusive: purposeMarkerSpan.endExclusive, reason: "relation_marker" },
671
- { start: coordinationMarkerSpan.start, endExclusive: coordinationMarkerSpan.endExclusive, reason: "relation_marker" },
672
- ],
673
- projection: {
674
- sourceForm: "connective",
675
- connectiveKind: "tame_purpose",
676
- targetSlot: "coordination",
677
- },
678
- confidence: "strict",
679
- renderEnabledByDefault: true,
680
- purposeClauseCoordination: payload,
681
- provenance: "structural_relation_owner",
682
- });
683
- }
684
- return relations;
685
- }
686
- function purposeClauseCoordinationEvidenceAt(options, tameIdx) {
687
- const { tokens, layout } = options;
688
- if (!isTameHead(tokens[tameIdx])) {
689
- return null;
690
- }
691
- const coordinationIdx = nextNonSpaceIndex(tokens, tameIdx + 1);
692
- const coordination = coordinationIdx === null ? undefined : tokens[coordinationIdx];
693
- if (coordinationIdx === null ||
694
- coordination === undefined ||
695
- (coordination.pos & POS0) !== 助詞 ||
696
- coordination.surface !== "と") {
697
- return null;
698
- }
699
- const sourcePredicate = purposeSourcePredicateBeforeTame(options, tameIdx, 0);
700
- if (sourcePredicate === null ||
701
- !hasPurposeClauseCoordinationSourceEvidence(options, sourcePredicate, tameIdx)) {
702
- return null;
703
- }
704
- const targetTameIdx = followingPurposeTameMarkerIndex(options, coordinationIdx + 1);
705
- if (targetTameIdx === null) {
706
- return null;
707
- }
708
- const targetPredicate = purposeSourcePredicateBeforeTame(options, targetTameIdx, coordinationIdx + 1);
709
- if (targetPredicate === null ||
710
- !hasPurposeClauseCoordinationSourceEvidence(options, targetPredicate, targetTameIdx)) {
711
- return null;
712
- }
713
- if (!layout.sameQuoteScope(tameIdx, targetTameIdx)) {
714
- return null;
715
- }
716
- return {
717
- tameIdx,
718
- coordinationIdx,
719
- sourcePredicateIdx: sourcePredicate.predicateIdx,
720
- sourceClauseIndex: sourcePredicate.clauseIndex,
721
- targetTameIdx,
722
- targetClauseIndex: targetPredicate.clauseIndex,
723
- };
724
- }
725
- function purposeSourcePredicateBeforeTame(options, tameIdx, lowerBoundInclusive) {
726
- const { layout, contentMap } = options;
727
- const predicateIdx = layout.primaryPredicateOfChildClause(tameIdx)
728
- ?? layout.previousPredicateInClause(tameIdx);
729
- if (predicateIdx === undefined || predicateIdx < lowerBoundInclusive || !contentMap.has(predicateIdx)) {
730
- return null;
731
- }
732
- const clauseIndex = layout.clauseIndexOfPredicate(predicateIdx);
733
- return clauseIndex === undefined ? null : { predicateIdx, clauseIndex };
734
- }
735
- function hasPurposeClauseCoordinationSourceEvidence(options, source, tameIdx) {
736
- const clause = options.layout.clauses[source.clauseIndex];
737
- if (clause === undefined || !options.contentMap.has(source.predicateIdx)) {
738
- return false;
739
- }
740
- if (hasStrictReasonEvidence(options.tokens, clause, tameIdx, purposeTameMarkerEndExclusive(options.tokens, tameIdx), options.contentMap)) {
741
- return false;
742
- }
743
- const last = previousContentTokenIndex(options.tokens, tameIdx - 1, clause.start);
744
- const finalPredicate = last === null ? undefined : options.tokens[last];
745
- return finalPredicate !== undefined && (finalPredicate.pos & (POS0 | POS5A)) === (動詞 | 連体形_);
746
- }
747
- function followingPurposeTameMarkerIndex(options, start) {
748
- const { tokens } = options;
749
- const c = new TokenCursor(tokens, start, tokens.length);
750
- while (c.current()) {
751
- const token = c.current();
752
- if (isHardTerminalPunctuationToken(token)) {
753
- return null;
754
- }
755
- if (isClauseEvidenceTransparentPunctuation(token)) {
756
- c.advance();
757
- continue;
758
- }
759
- if (!isTameHead(token)) {
760
- c.advance();
761
- continue;
762
- }
763
- const next = nextNonSpaceIndex(tokens, c.pos + 1);
764
- const nextToken = next === null ? undefined : tokens[next];
765
- if (next === null ||
766
- (nextToken !== undefined &&
767
- (nextToken.pos & POS0) === 助詞 &&
768
- (nextToken.surface === "に" || nextToken.surface === "と"))) {
769
- return c.pos;
770
- }
771
- c.advance();
772
- }
773
- return null;
774
- }
775
- function purposeTameMarkerEndExclusive(tokens, tameIdx) {
776
- const next = nextNonSpaceIndex(tokens, tameIdx + 1);
777
- const nextToken = next === null ? undefined : tokens[next];
778
- if (next !== null &&
779
- nextToken !== undefined &&
780
- (nextToken.pos & POS0) === 助詞 &&
781
- nextToken.surface === "に") {
782
- return next + 1;
783
- }
784
- return tameIdx + 1;
785
- }
786
- function pushTariListingGroup(options, nodes, pending, groups) {
787
- if (pending.length === 0) {
788
- return;
789
- }
790
- const closure = tariListingClosureForGroup(options, nodes, pending);
791
- if (pending.length < 2 && !singleTariClosureShouldProjectAsListing(options, closure.closure)) {
792
- return;
793
- }
794
- groups.push({
795
- items: [...pending],
796
- separatorSpans: tariListingSeparatorSpans(options.tokens, pending),
797
- closure: closure.closure,
798
- target: closure.target,
799
- });
800
- }
801
- function singleTariClosureShouldProjectAsListing(options, closure) {
802
- if (closure.kind !== "explicit_predicate") {
803
- return false;
804
- }
805
- const span = options.contentMap.get(closure.predicateIdx);
806
- if (span?.hasNegative === true) {
807
- return true;
808
- }
809
- const plan = span?.renderPlan;
810
- if (!isPredicateHeadTailChainRenderPlan(plan) || plan.realization.root.tail.kind !== "auxLayer") {
811
- return false;
812
- }
813
- return plan.realization.root.tail.ops.some((op) => op.kind === "negation");
814
- }
815
- function isTariListingMarkerToken(token) {
816
- return (token.pos & POS01) === 助詞_副助詞 && (token.surface === "たり" || token.surface === "だり");
817
- }
818
- function isTariListingExampleMarker(tokens, markerIdx) {
819
- const next = nextNonSpaceIndex(tokens, markerIdx + 1);
820
- const token = next === null ? undefined : tokens[next];
821
- return token !== undefined && token.surface === "と" && (token.pos & POS0) === 助詞;
822
- }
823
- function tariListingItemPredicateIndex(contentMap, clause, markerIdx) {
824
- for (let index = clause.predicates.length - 1; index >= 0; index -= 1) {
825
- const predicateIdx = clause.predicates[index];
826
- if (predicateIdx !== undefined && predicateIdx < markerIdx && contentMap.has(predicateIdx)) {
827
- return predicateIdx;
828
- }
829
- }
830
- return null;
831
- }
832
- function tariItemsCanBelongToSameGroup(options, previous, next) {
833
- if (next.markerIdx <= previous.markerIdx || next.clauseIndex < previous.clauseIndex) {
834
- return false;
835
- }
836
- for (let clauseIdx = previous.clauseIndex + 1; clauseIdx < next.clauseIndex; clauseIdx += 1) {
837
- const between = options.layout.clauses[clauseIdx];
838
- if (between === undefined || between.terminatedBy !== "connective" || options.layout.chuushiClosureAt(between.end)?.right !== "governed") {
839
- return false;
840
- }
841
- }
842
- if (hasHardSentenceBoundaryBetween(options.tokens, previous.markerSpan.endExclusive, next.markerIdx)) {
843
- return false;
844
- }
845
- if (!options.layout.sameQuoteScope(previous.markerIdx, next.markerIdx)) {
846
- return false;
847
- }
848
- return true;
849
- }
850
- function hasHardSentenceBoundaryBetween(tokens, start, endExclusive) {
851
- for (let index = start; index < endExclusive; index += 1) {
852
- const token = tokens[index];
853
- if (token !== undefined && isHardTerminalPunctuationToken(token)) {
854
- return true;
855
- }
856
- }
857
- return false;
858
- }
859
- function tariListingClosureForGroup(options, nodes, items) {
860
- const last = items[items.length - 1];
861
- if (last === undefined) {
862
- return {
863
- closure: { kind: "sentence_fragment" },
864
- target: null,
865
- };
866
- }
867
- const closurePredicateIdx = nextNonSpaceIndex(options.tokens, last.markerSpan.endExclusive);
868
- const closurePredicate = closurePredicateIdx === null ? undefined : options.tokens[closurePredicateIdx];
869
- if (closurePredicateIdx !== null &&
870
- closurePredicate !== undefined &&
871
- isTariClosurePredicate(closurePredicate) &&
872
- options.layout.sameQuoteScope(last.markerIdx, closurePredicateIdx)) {
873
- const closureClauseIndex = options.layout.clauseIndexOfToken(closurePredicateIdx);
874
- return {
875
- closure: {
876
- kind: "explicit_predicate",
877
- predicateIdx: closurePredicateIdx,
878
- },
879
- target: predicateAnchor(closurePredicateIdx, closureClauseIndex),
880
- };
881
- }
882
- if (closurePredicateIdx !== null) {
883
- const quote = quoteMarkerRelationAt(options.tokens, closurePredicateIdx, {
884
- consumers: ["structural_relation_tari_listing"]
885
- });
886
- const sayIdx = quote?.canonicalSurface === "と"
887
- ? nextNonSpaceIndex(options.tokens, quote.span.endExclusive)
888
- : null;
889
- const say = sayIdx === null ? undefined : options.tokens[sayIdx];
890
- const headIdx = sayIdx === null ? null : nextNonSpaceIndex(options.tokens, sayIdx + 1, options.tokens.length);
891
- const head = headIdx === null ? undefined : options.tokens[headIdx];
892
- if (quote?.canonicalSurface === "と" &&
893
- sayIdx !== null &&
894
- say !== undefined &&
895
- isSayVerbToken(say) &&
896
- stemFormName(say.pos)?.startsWith("連体形") === true &&
897
- headIdx !== null &&
898
- head !== undefined &&
899
- pos0in(head.pos, NOMINAL_BITS) &&
900
- options.layout.sameQuoteScope(last.markerIdx, headIdx)) {
901
- return {
902
- closure: {
903
- kind: "attributive_quote",
904
- markerSpan: {
905
- start: quote.span.start,
906
- endExclusive: sayIdx + 1,
907
- surface: `${quote.surface}${say.surface}`,
908
- role: "attributive_quote_marker"
909
- },
910
- headIdx
911
- },
912
- target: {
913
- kind: "noun_phrase",
914
- span: tokenSpan(headIdx, headIdx + 1),
915
- headIdx
916
- }
917
- };
918
- }
919
- }
920
- const followingClauseIndex = nextClauseIndex(options.layout, last.clauseIndex);
921
- const followingClause = followingClauseIndex === null ? undefined : options.layout.clauses[followingClauseIndex];
922
- if (followingClauseIndex !== null && followingClause !== undefined) {
923
- const targetEvidenceIdx = followingClause.primaryPredicate ?? followingClause.start;
924
- if (!options.layout.sameQuoteScope(last.markerIdx, targetEvidenceIdx)) {
925
- return {
926
- closure: { kind: "sentence_fragment" },
927
- target: null,
928
- };
929
- }
930
- return {
931
- closure: {
932
- kind: "following_clause",
933
- clauseId: structuralRelationNodeId(followingClauseIndex),
934
- },
935
- target: clauseAnchor(nodes, followingClauseIndex),
936
- };
937
- }
938
- return {
939
- closure: { kind: "sentence_fragment" },
940
- target: null,
941
- };
942
- }
943
- function isTariClosurePredicate(token) {
944
- return isVerbLemma(token, "する", "為る");
945
- }
946
- function tariListingSeparatorSpans(tokens, items) {
947
- const spans = [];
948
- for (let itemIndex = 0; itemIndex < items.length - 1; itemIndex += 1) {
949
- const previous = items[itemIndex];
950
- const next = items[itemIndex + 1];
951
- if (previous === undefined || next === undefined) {
952
- continue;
953
- }
954
- for (let tokenIndex = previous.markerSpan.endExclusive; tokenIndex < next.source.span.start; tokenIndex += 1) {
955
- const token = tokens[tokenIndex];
956
- if (token === undefined || !isClauseEvidenceTransparentPunctuation(token)) {
957
- continue;
958
- }
959
- spans.push({
960
- start: tokenIndex,
961
- endExclusive: tokenIndex + 1,
962
- surface: token.surface,
963
- role: "listing_separator",
964
- });
965
- }
966
- }
967
- return spans;
968
- }
969
- function collectKaParallelRelations(options, _nodes, quoteRelations) {
970
- const relations = [];
971
- const consumedMarkers = new Set();
972
- const { tokens, layout } = options;
973
- const c = new TokenCursor(tokens, 0, tokens.length);
974
- while (c.current()) {
975
- if (consumedMarkers.has(c.pos)) {
976
- c.advance();
977
- continue;
978
- }
979
- const firstMarker = kaParallelMarkerAt(tokens, layout, c.pos, options.lookups);
980
- if (firstMarker === null) {
981
- c.advance();
982
- continue;
983
- }
984
- const firstStart = parallelItemStartBeforeMarker(tokens, layout, firstMarker.markerSpan.start);
985
- if (firstStart === null || firstStart >= firstMarker.markerSpan.start) {
986
- c.advance();
987
- continue;
988
- }
989
- const markers = [firstMarker];
990
- const itemStarts = [firstStart];
991
- let currentMarker = firstMarker;
992
- while (true) {
993
- if (quotativeToFollowsKaMarker(tokens, currentMarker)) {
994
- break;
995
- }
996
- const nextStart = nextParallelItemStart(c.fork(currentMarker.markerSpan.endExclusive));
997
- if (nextStart === null) {
998
- break;
999
- }
1000
- const nextMarker = nextKaParallelMarker(c.fork(nextStart), layout, options.lookups);
1001
- if (nextMarker === null || nextMarker.kaIdx <= currentMarker.kaIdx) {
1002
- break;
1003
- }
1004
- if (hasHardSentenceBoundaryBetween(tokens, currentMarker.markerSpan.endExclusive, nextMarker.kaIdx)) {
1005
- break;
1006
- }
1007
- if (hasTokaListingKaBetween(tokens, currentMarker.markerSpan.endExclusive, nextMarker.kaIdx)) {
1008
- break;
1009
- }
1010
- if (!layout.sameQuoteScope(firstMarker.kaIdx, nextMarker.kaIdx)) {
1011
- break;
1012
- }
1013
- if (nextStart >= nextMarker.markerSpan.start) {
1014
- break;
1015
- }
1016
- markers.push(nextMarker);
1017
- itemStarts.push(nextStart);
1018
- currentMarker = nextMarker;
1019
- }
1020
- const soloClosure = markers.length === 1
1021
- ? soloCopulaClosedTokaListingClosure(c, tokens, layout, firstMarker, quoteRelations)
1022
- : null;
1023
- const soloCopularTokaListing = soloClosure !== null;
1024
- if (markers.length < 2 && !soloCopularTokaListing) {
1025
- c.advance();
1026
- continue;
1027
- }
1028
- if (soloClosure !== null) {
1029
- itemStarts[0] = soloCopulaClosedTokaItemStart(layout, tokens, firstMarker, soloClosure);
1030
- }
1031
- const copularTokaShape = markers.map((marker) => isCopularTokaKaMarker(tokens, marker.kaIdx));
1032
- if (copularTokaShape.some(Boolean) && !copularTokaShape.every(Boolean)) {
1033
- c.advance();
1034
- continue;
1035
- }
1036
- const copularTokaListing = copularTokaShape.every(Boolean);
1037
- const lastMarker = markers[markers.length - 1];
1038
- if (!soloCopularTokaListing && hasTokaListingKaBetween(tokens, lastMarker.markerSpan.endExclusive, Math.min(tokens.length, lastMarker.markerSpan.endExclusive + 3))) {
1039
- c.advance();
1040
- continue;
1041
- }
1042
- const terminal = kaParallelTerminalPunctuationAfter(tokens, lastMarker.markerSpan.endExclusive);
1043
- const terminalSpan = terminal.span;
1044
- const sourceEnd = terminalSpan?.endExclusive ?? lastMarker.markerSpan.endExclusive;
1045
- const rawItemKinds = markers.map((marker, markerIndex) => kaParallelItemKind(c.fork(itemStarts[markerIndex], marker.markerSpan.start), options, marker));
1046
- if (rawItemKinds.some((kind) => kind === null)) {
1047
- c.advance();
1048
- continue;
1049
- }
1050
- const itemKinds = rawItemKinds;
1051
- const commonKind = soloCopularTokaListing
1052
- ? itemKinds[0] ?? null
1053
- : kaParallelCommonItemKind(itemKinds);
1054
- if (commonKind === null) {
1055
- c.advance();
1056
- continue;
1057
- }
1058
- const separatorSpans = markers.slice(0, -1).flatMap((marker, markerIndex) => parallelSeparatorSpans(c.fork(marker.markerSpan.endExclusive, itemStarts[markerIndex + 1]), "ka_parallel_separator"));
1059
- const hasDiscourseChoiceSeparator = itemStarts.slice(1).some((itemStart) => tryResolveDemoDiscourseConnective(c.fork(itemStart, tokens.length, itemStart), options.lookups) !== null);
1060
- const lastPredicateIdx = kaParallelPredicateIndex(options, itemStarts.at(-1), lastMarker.markerSpan.start);
1061
- const precedingMarkerIndexes = new Set(markers.slice(0, -1).map((marker) => marker.kaIdx));
1062
- const precedingQuestionContentConsumedBeforeFinalPredicate = lastPredicateIdx !== null && quoteRelations.some((relation) => relation.quote?.slotKind === "question_content" &&
1063
- precedingMarkerIndexes.has(relation.quote.markerIdx) &&
1064
- relation.quote.hostPredicateIdx < lastPredicateIdx);
1065
- const matrixQuestionTakingHost = lastPredicateIdx !== null &&
1066
- !hasDiscourseChoiceSeparator &&
1067
- quoteRelations.some((relation) => relation.quote?.slotKind === "question_content" &&
1068
- relation.quote.hostPredicateIdx === lastPredicateIdx &&
1069
- precedingMarkerIndexes.has(relation.quote.markerIdx));
1070
- const mixesNominalizedAndPredicateItems = itemKinds.includes("nominalized_question") && itemKinds.includes("predicate_question");
1071
- const terminalNominalizedConjecture = lastPredicateIdx !== null &&
1072
- isNominalizedConjectureMatrixQuestionPlan(options.contentMap.get(lastPredicateIdx)?.renderPlan ?? null);
1073
- if (mixesNominalizedAndPredicateItems &&
1074
- !matrixQuestionTakingHost &&
1075
- !precedingQuestionContentConsumedBeforeFinalPredicate &&
1076
- !terminalNominalizedConjecture) {
1077
- c.advance();
1078
- continue;
1079
- }
1080
- const closure = kaParallelClosureAfter(c.fork(lastMarker.markerSpan.endExclusive), options);
1081
- const itemAnchors = markers.map((marker, markerIndex) => {
1082
- const itemKind = itemKinds[markerIndex];
1083
- const item = {
1084
- source: spanAnchor({
1085
- start: itemStarts[markerIndex],
1086
- endExclusive: marker.markerSpan.start,
1087
- clauseIndex: marker.clauseIndex,
1088
- }),
1089
- markerSpan: marker.markerSpan,
1090
- itemKind,
1091
- predicateIdx: kaParallelPredicateIndex(options, itemStarts[markerIndex], marker.markerSpan.start),
1092
- };
1093
- return {
1094
- ...item,
1095
- predicateCategory: tokaParallelItemPredicateCategory(options, item),
1096
- };
1097
- });
1098
- const terminalPlanEvidence = lastPredicateIdx === null
1099
- ? null
1100
- : predicatePlanTerminalKaEvidence(options.contentMap.get(lastPredicateIdx)?.renderPlan ?? null, lastMarker.kaIdx);
1101
- const terminalRelation = terminalQuestionKaRelationAt(tokens, lastMarker.kaIdx, { lookups: options.lookups });
1102
- const terminalOwnerBoundary = !hasDiscourseChoiceSeparator && (matrixQuestionTakingHost ||
1103
- precedingQuestionContentConsumedBeforeFinalPredicate ||
1104
- (terminalPlanEvidence === "polite_sfp" && terminalRelation?.evidence !== "volitional_host") ||
1105
- terminalPlanEvidence === "polite_question_quotative");
1106
- const questionReformulationOwnsLastItem = terminalPlanEvidence === "question_reformulation";
1107
- const uniformPredicateQuestions = itemAnchors.every((item) => item.predicateIdx !== null && (item.itemKind === "predicate_question" ||
1108
- item.itemKind === "nominalized_question" ||
1109
- item.itemKind === "negative_alternative")) && new Set(itemAnchors.map((item) => kaParallelItemPredicateCategory(options, item))).size <= 1;
1110
- const matrixQuestionItems = !uniformPredicateQuestions &&
1111
- itemAnchors.every((item) => item.itemKind === "predicate_question") &&
1112
- separatorSpans.length === 0 &&
1113
- terminal.traits.length > 0;
1114
- const allItemsHaveCopulaQuestionHosts = markers.every((marker) => previousTokenIsCopulaQuestionHost(tokens, marker.kaIdx));
1115
- const allItemsAreDirectDiscourseQuestions = markers.every((marker) => directDiscourseChoiceQuestionKaRelationAt(tokens, marker.kaIdx, options.lookups) !== null);
1116
- if (terminalSpan !== null &&
1117
- allItemsHaveCopulaQuestionHosts &&
1118
- !matrixQuestionTakingHost) {
1119
- c.advance();
1120
- continue;
1121
- }
1122
- if (terminalSpan !== null &&
1123
- hasDiscourseChoiceSeparator &&
1124
- allItemsAreDirectDiscourseQuestions) {
1125
- c.advance();
1126
- continue;
1127
- }
1128
- const markerSpans = markers.map((marker) => marker.markerSpan);
1129
- const suppressibleSpans = [
1130
- ...markerSpans.map((span) => ({ start: span.start, endExclusive: span.endExclusive, reason: "relation_marker" })),
1131
- ...separatorSpans.map((span) => ({ start: span.start, endExclusive: span.endExclusive, reason: "relation_separator" })),
1132
- ...(terminalSpan === null ? [] : [{ start: terminalSpan.start, endExclusive: terminalSpan.endExclusive, reason: "relation_terminal_punctuation" }]),
1133
- ];
1134
- const relationKind = copularTokaListing
1135
- ? "toka_parallel_listing"
1136
- : commonKind === "bare_nominal" ? "ka_parallel_choice" : "ka_parallel_question_content";
1137
- relations.push({
1138
- kind: relationKind,
1139
- source: spanAnchor({
1140
- start: itemStarts[0] ?? firstStart,
1141
- endExclusive: sourceEnd,
1142
- clauseIndex: firstMarker.clauseIndex,
1143
- }),
1144
- target: closure.target,
1145
- markerSpans,
1146
- candidateSuppressibleTokenSpans: suppressibleSpans,
1147
- projection: {
1148
- sourceForm: commonKind === "bare_nominal" ? "nominalized" : "listing",
1149
- connectiveKind: relationKind,
1150
- targetSlot: "coordination",
1151
- },
1152
- confidence: "strict",
1153
- renderEnabledByDefault: true,
1154
- kaParallel: {
1155
- itemAnchors,
1156
- markerSpans,
1157
- separatorSpans,
1158
- itemKind: commonKind,
1159
- terminalPunctuation: terminal.kind,
1160
- terminalPunctuationTraits: terminal.traits,
1161
- terminalPunctuationRun: terminal.run,
1162
- closure: closure.closure,
1163
- hasDiscourseChoiceSeparator,
1164
- matrixQuestionItems,
1165
- ...(terminalOwnerBoundary
1166
- ? { terminalOwnerBoundary: "matrix_terminal_question" }
1167
- : questionReformulationOwnsLastItem
1168
- ? { terminalOwnerBoundary: "question_reformulation" }
1169
- : {}),
1170
- },
1171
- provenance: "structural_relation_owner",
1172
- });
1173
- for (const marker of markers) {
1174
- consumedMarkers.add(marker.kaIdx);
1175
- }
1176
- c.advance();
1177
- }
1178
- return relations;
1179
- }
1180
- function kaParallelMarkerAt(tokens, layout, index, lookups) {
1181
- const copularTokaListing = isCopularTokaKaMarker(tokens, index);
1182
- if ((!isStructuralKaParallelMarkerAt(tokens, index, lookups) && !copularTokaListing) ||
1183
- (isTokaListingKaMarker(tokens, index) && !copularTokaListing)) {
1184
- return null;
1185
- }
1186
- const nominalizerIdx = previousNonSpaceIndex(tokens, index);
1187
- const nominalizer = nominalizerIdx === null ? undefined : tokens[nominalizerIdx];
1188
- const quoteMarkerIdx = nominalizerIdx !== null &&
1189
- nominalizer?.surface === "と" &&
1190
- previousTokenIsBasicCopula(tokens, nominalizerIdx)
1191
- ? nominalizerIdx
1192
- : null;
1193
- const nominalized = nominalizerIdx !== null &&
1194
- nominalizer !== undefined &&
1195
- (nominalizer.surface === "の" || nominalizer.surface === "ん") &&
1196
- !isKaDouKaMarker(tokens, nominalizerIdx);
1197
- const markerStart = nominalized
1198
- ? nominalizerIdx
1199
- : quoteMarkerIdx ?? index;
1200
- const clauseIndex = layout.clauseIndexOfToken(index);
1201
- return {
1202
- kaIdx: index,
1203
- markerSpan: {
1204
- start: markerStart,
1205
- endExclusive: index + 1,
1206
- surface: markerSurface(tokens, markerStart, index + 1),
1207
- role: nominalized ? "nominalized_question_marker" : quoteMarkerIdx === null ? "ka_parallel_marker" : "quoted_ka_parallel_marker",
1208
- },
1209
- clauseIndex,
1210
- nominalized,
1211
- };
1212
- }
1213
- function quotativeToFollowsKaMarker(tokens, marker) {
1214
- for (let index = marker.markerSpan.endExclusive; index < tokens.length; index += 1) {
1215
- const token = tokens[index];
1216
- if (token === undefined) {
1217
- return false;
1218
- }
1219
- if ((token.pos & POS01) === 助詞_終助詞) {
1220
- continue;
1221
- }
1222
- if ((token.pos & POS01) === 助詞_格助詞 && token.surface === "と") {
1223
- return true;
1224
- }
1225
- return (token.pos & POS01) === 助詞_副助詞 && token.surface === "って";
1226
- }
1227
- return false;
1228
- }
1229
- function hasTokaListingKaBetween(tokens, start, endExclusive) {
1230
- for (let index = start; index < endExclusive; index += 1) {
1231
- if (isQuestionParticleKaToken(tokens[index]) && isTokaListingKaMarker(tokens, index)) {
1232
- return true;
1233
- }
1234
- }
1235
- return false;
1236
- }
1237
- function soloCopulaClosedTokaListingClosure(cursor, tokens, layout, marker, quoteRelations) {
1238
- const closure = copulaClosedTokaKaRelationAt(tokens, marker.kaIdx);
1239
- if (closure === null || closure.sfpSpan.start !== closure.sfpSpan.endExclusive) {
1240
- return null;
1241
- }
1242
- if (quoteRelations.some((relation) => relation.markerSpans.some((span) => tokenSpansOverlap(span, marker.markerSpan)))) {
1243
- return null;
1244
- }
1245
- return tokaListingContinuesAfterMarker(cursor.fork(marker.markerSpan.endExclusive), layout, marker.kaIdx)
1246
- ? closure
1247
- : null;
1248
- }
1249
- const TOKA_LISTING_ITEM_PHRASE_KINDS = new Set([
1250
- "nominal",
1251
- "predicate",
1252
- "predicate_evidence",
1253
- ]);
1254
- function tokaListingContinuesAfterMarker(cursor, layout, markerKaIdx) {
1255
- for (const item of enumerateClausePhrasesAfter(layout, cursor.tokens, markerKaIdx, { scope: "sentence" })) {
1256
- if (item.kind === "punctuation_weak" || item.kind === "adverbial") {
1257
- continue;
1258
- }
1259
- return TOKA_LISTING_ITEM_PHRASE_KINDS.has(item.kind) &&
1260
- layout.sameQuoteScope(markerKaIdx, item.headIdx);
1261
- }
1262
- return false;
1263
- }
1264
- function soloCopulaClosedTokaItemStart(layout, tokens, marker, closure) {
1265
- for (const item of enumerateClausePhrasesBefore(layout, tokens, marker.markerSpan.start, { scope: "clause" })) {
1266
- if (item.span.endExclusive <= closure.nounIdx) {
1267
- break;
1268
- }
1269
- if (item.kind === "nominal" && item.span.start <= closure.nounIdx) {
1270
- return item.span.start;
1271
- }
1272
- }
1273
- return closure.nounIdx;
1274
- }
1275
- function nextParallelItemStart(cursor) {
1276
- const c = cursor.fork();
1277
- while (c.current()) {
1278
- const token = c.current();
1279
- if (isClauseEvidenceTransparentPunctuation(token)) {
1280
- c.advance();
1281
- continue;
1282
- }
1283
- return c.pos;
1284
- }
1285
- return null;
1286
- }
1287
- function nextKaParallelMarker(cursor, layout, lookups) {
1288
- const c = cursor.fork();
1289
- while (c.current()) {
1290
- const token = c.current();
1291
- if (isHardTerminalPunctuationToken(token)) {
1292
- return null;
1293
- }
1294
- const marker = kaParallelMarkerAt(c.tokens, layout, c.pos, lookups);
1295
- if (marker !== null) {
1296
- return marker;
1297
- }
1298
- c.advance();
1299
- }
1300
- return null;
1301
- }
1302
- function parallelItemStartBeforeMarker(tokens, layout, markerStart) {
1303
- const clauseIndex = layout.clauseIndexOfToken(markerStart);
1304
- const clause = clauseIndex < 0 ? undefined : layout.clauses[clauseIndex];
1305
- let start = clause?.start ?? 0;
1306
- for (let index = markerStart - 1; index >= start; index -= 1) {
1307
- const token = tokens[index];
1308
- if (token === undefined) {
1309
- continue;
1310
- }
1311
- if (isClauseEvidenceTransparentPunctuation(token)) {
1312
- start = index + 1;
1313
- break;
1314
- }
1315
- }
1316
- return nextParallelItemStart(new TokenCursor(tokens, start, markerStart));
1317
- }
1318
- function kaParallelItemKind(itemCursor, options, marker) {
1319
- if (marker.nominalized) {
1320
- return "nominalized_question";
1321
- }
1322
- if (spanIsKaParallelNegativeAlternative(itemCursor)) {
1323
- return "negative_alternative";
1324
- }
1325
- if (spanHasPredicateLikeToken(itemCursor, options.contentMap)) {
1326
- return "predicate_question";
1327
- }
1328
- if (spanHeadIsNaAdjCapableNoun(itemCursor.tokens, itemCursor.pos, itemCursor.end)) {
1329
- return "na_adjectival_nominal";
1330
- }
1331
- return spanHeadIsNominalish(itemCursor.tokens, itemCursor.pos, itemCursor.end)
1332
- ? "bare_nominal"
1333
- : null;
1334
- }
1335
- function spanHeadIsNominalish(tokens, start, endExclusive) {
1336
- for (let index = endExclusive - 1; index >= start; index -= 1) {
1337
- const token = tokens[index];
1338
- if (token === undefined) {
1339
- continue;
1340
- }
1341
- return pos0in(token.pos, (1 << 名詞) | (1 << 代名詞) | (1 << 形状詞) | (1 << 接尾辞));
1342
- }
1343
- return false;
1344
- }
1345
- function clauseScopedScanEnd(layout, scanStart, fallbackEnd) {
1346
- const clauseEnd = layout.clauseOfToken(scanStart)?.end;
1347
- return clauseEnd === undefined ? fallbackEnd : Math.min(fallbackEnd, clauseEnd);
1348
- }
1349
- function spanHeadIsNaAdjCapableNoun(tokens, start, endExclusive) {
1350
- for (let index = endExclusive - 1; index >= start; index -= 1) {
1351
- const token = tokens[index];
1352
- if (token === undefined) {
1353
- continue;
1354
- }
1355
- return isNaAdjCapableNoun(token);
1356
- }
1357
- return false;
1358
- }
1359
- function kaParallelCommonItemKind(itemKinds) {
1360
- if (itemKinds.length < 2) {
1361
- return null;
1362
- }
1363
- if (itemKinds.every((kind) => kind === "bare_nominal" || kind === "na_adjectival_nominal")) {
1364
- return "bare_nominal";
1365
- }
1366
- if (itemKinds.some((kind) => kind === "bare_nominal")) {
1367
- return null;
1368
- }
1369
- if (itemKinds.some((kind) => kind === "na_adjectival_nominal")) {
1370
- const others = itemKinds.filter((kind) => kind !== "na_adjectival_nominal");
1371
- return others.every((kind) => kind === "predicate_question" || kind === "nominalized_question")
1372
- ? "predicate_question"
1373
- : null;
1374
- }
1375
- if (itemKinds.every((kind) => kind === "nominalized_question")) {
1376
- return "nominalized_question";
1377
- }
1378
- return "predicate_question";
1379
- }
1380
- function spanIsKaParallelNegativeAlternative(cursor) {
1381
- let contentToken = null;
1382
- const c = cursor.fork();
1383
- while (c.current()) {
1384
- const token = c.current();
1385
- if (contentToken !== null) {
1386
- return false;
1387
- }
1388
- contentToken = token;
1389
- c.advance();
1390
- }
1391
- return contentToken?.surface === "否";
1392
- }
1393
- function kaParallelPredicateIndex(options, start, endExclusive) {
1394
- for (let index = endExclusive - 1; index >= start; index -= 1) {
1395
- const plan = options.contentMap.get(index)?.renderPlan ?? null;
1396
- if (isKaParallelPredicateEvidencePlan(plan)) {
1397
- return index;
1398
- }
1399
- if (options.contentMap.has(index) && isParallelPredicateToken(options.tokens[index])) {
1400
- return index;
1401
- }
1402
- }
1403
- return null;
1404
- }
1405
- function kaParallelItemPredicateCategory(options, item) {
1406
- if (item.itemKind === "nominalized_question") {
1407
- return "predicate";
1408
- }
1409
- const plan = item.predicateIdx === null
1410
- ? null
1411
- : options.contentMap.get(item.predicateIdx)?.renderPlan ?? null;
1412
- if (!isPredicateHeadTailChainRenderPlan(plan) || plan.realization.root.tail.kind !== "auxLayer") {
1413
- return item.itemKind;
1414
- }
1415
- return plan.realization.root.tail.stem.sourcePredicateShape ?? item.itemKind;
1416
- }
1417
- function tokaParallelItemPredicateCategory(options, item) {
1418
- const plan = item.predicateIdx === null
1419
- ? [...options.contentMap.entries()]
1420
- .filter(([tokenIdx]) => item.source.span.start <= tokenIdx && tokenIdx < item.source.span.endExclusive)
1421
- .sort(([left], [right]) => left - right)
1422
- .at(-1)?.[1].renderPlan ?? null
1423
- : options.contentMap.get(item.predicateIdx)?.renderPlan ?? null;
1424
- if (plan?.kind === "lemma") {
1425
- return plan.koreanPos === 명사 || plan.koreanPos === 대명사 || plan.koreanPos === 수사
1426
- ? "nominal"
1427
- : "predicate";
1428
- }
1429
- if (isPredicateHeadTailChainRenderPlan(plan) && plan.realization.root.tail.kind === "auxLayer") {
1430
- return plan.realization.root.tail.stem.kind === "noun" ? "nominal" : "predicate";
1431
- }
1432
- return item.itemKind === "bare_nominal" ? "nominal" : "predicate";
1433
- }
1434
- function predicatePlanTerminalKaEvidence(plan, kaIdx) {
1435
- if (!isPredicateHeadTailChainRenderPlan(plan)) {
1436
- return null;
1437
- }
1438
- const tail = plan.realization.root.tail;
1439
- const polite = tail.kind === "auxLayer" && tail.ops.some((op) => op.kind === "polite" || (op.kind === "copula" && op.polite));
1440
- const sfp = plan.realization.root.sfp;
1441
- if (sfp !== null && sfp.source.tokenIndices.includes(kaIdx)) {
1442
- return polite ? "polite_sfp" : "plain_sfp";
1443
- }
1444
- if (tail.kind !== "auxLayer") {
1445
- return null;
1446
- }
1447
- if (tail.ops.some((op) => op.kind === "connective" &&
1448
- op.connective === "question_reformulation" &&
1449
- op.source.tokenIndices.includes(kaIdx))) {
1450
- return "question_reformulation";
1451
- }
1452
- const questionQuotative = tail.ops.some((op) => op.kind === "connective" &&
1453
- op.connective === "question_quotative" &&
1454
- op.source.tokenIndices.includes(kaIdx));
1455
- if (!questionQuotative) {
1456
- return null;
1457
- }
1458
- return polite
1459
- ? "polite_question_quotative"
1460
- : "question_quotative";
1461
- }
1462
- function spanHasPredicateLikeToken(cursor, contentMap) {
1463
- const c = cursor.fork();
1464
- while (c.current()) {
1465
- const token = c.current();
1466
- if (isParallelPredicateToken(token)) {
1467
- return true;
1468
- }
1469
- const plan = contentMap?.get(c.pos)?.renderPlan ?? null;
1470
- if (isKaParallelPredicateEvidencePlan(plan)) {
1471
- return true;
1472
- }
1473
- c.advance();
1474
- }
1475
- return false;
1476
- }
1477
- function isKaParallelPredicateEvidencePlan(plan) {
1478
- return isPredicateHeadTailChainRenderPlan(plan) &&
1479
- !tailRootClosesWithBareKeijoujiAttributive(plan.realization.root);
1480
- }
1481
- function isParallelPredicateToken(token) {
1482
- const pos0 = (token?.pos ?? 0) & POS0;
1483
- return pos0in(pos0, PREDICATE_AUX_BITS);
1484
- }
1485
- function kaParallelClosureAfter(parentCursor, options) {
1486
- const closureStart = nextNonSpaceIndex(parentCursor.tokens, parentCursor.pos, parentCursor.end);
1487
- if (closureStart === null) {
1488
- return { closure: { kind: "terminal_fragment" }, target: null };
1489
- }
1490
- const scanEnd = clauseScopedScanEnd(options.layout, closureStart, parentCursor.end);
1491
- const quote = quoteMarkerRelationAt(parentCursor.tokens, closureStart, {
1492
- consumers: ["structural_relation_ka_parallel"]
1493
- });
1494
- if (quote?.canonicalSurface === "と") {
1495
- const sayIdx = quote.span.endExclusive;
1496
- const say = parentCursor.tokens[sayIdx];
1497
- const headIdx = nextContentTokenIndex(parentCursor.tokens, sayIdx + 1, parentCursor.end);
1498
- const head = headIdx === null ? undefined : parentCursor.tokens[headIdx];
1499
- const pronominalNo = head !== undefined && (head.pos & POS01) === 助詞_準体助詞;
1500
- const particleIdx = pronominalNo && headIdx !== null
1501
- ? nextNonSpaceIndex(parentCursor.tokens, headIdx + 1, parentCursor.end)
1502
- : null;
1503
- const pronominalParticle = particleIdx === null
1504
- ? null
1505
- : pronominalNoParticleContinuationForToken(parentCursor.tokens[particleIdx], particleIdx);
1506
- if (say !== undefined &&
1507
- isSayVerbToken(say) &&
1508
- stemFormName(say.pos)?.startsWith("連体形") === true &&
1509
- headIdx !== null &&
1510
- head !== undefined &&
1511
- (pos0in(head.pos, NOMINAL_BITS) || pronominalNo)) {
1512
- return {
1513
- closure: {
1514
- kind: "attributive_quote",
1515
- markerSpan: {
1516
- start: quote.span.start,
1517
- endExclusive: pronominalNo ? headIdx + 1 : sayIdx + 1,
1518
- surface: `${quote.surface}${say.surface}${pronominalNo ? head.surface : ""}`
1519
- },
1520
- headIdx,
1521
- realization: pronominalNo
1522
- ? "pronominal_no"
1523
- : (head.dictionaryForm || head.surface) === "こと" ? "light_koto" : "appositive",
1524
- ...(pronominalParticle === null || particleIdx === null ? {} : {
1525
- particleSpan: {
1526
- start: particleIdx,
1527
- endExclusive: particleIdx + 1,
1528
- surface: pronominalParticle.surface,
1529
- role: "pronominal_no_particle"
1530
- },
1531
- particleSurface: pronominalParticle.surface
1532
- })
1533
- },
1534
- target: null
1535
- };
1536
- }
1537
- }
1538
- if (looksQuestionTakingAfterViaLayout(options.layout, parentCursor.tokens, closureStart, scanEnd, options.lookups)) {
1539
- const hostIdx = nextContentTokenIndex(options.tokens, closureStart, scanEnd);
1540
- if (hostIdx !== null) {
1541
- return {
1542
- closure: { kind: "question_taking_host", predicateIdx: hostIdx },
1543
- target: predicateAnchor(hostIdx, options.layout.clauseIndexOfToken(hostIdx)),
1544
- };
1545
- }
1546
- }
1547
- return {
1548
- closure: { kind: "terminal_fragment" },
1549
- target: null,
1550
- };
1551
- }
1552
- function kaParallelTerminalPunctuationAfter(tokens, markerEndExclusive) {
1553
- const next = nextNonSpaceIndex(tokens, markerEndExclusive, tokens.length);
1554
- if (next === null) {
1555
- return { kind: null, span: null, traits: [], run: [] };
1556
- }
1557
- let endExclusive = next;
1558
- let hasQuestion = false;
1559
- let hasExclamation = false;
1560
- let hasPeriod = false;
1561
- const run = [];
1562
- let cursor = next;
1563
- while (cursor !== null) {
1564
- const token = tokens[cursor];
1565
- if (token === undefined)
1566
- break;
1567
- const surfaceClass = hardTerminalPunctuationSurfaceClassForToken(token, cursor, ["structural_relation_ka_parallel"]);
1568
- if (surfaceClass === "question") {
1569
- hasQuestion = true;
1570
- run.push("question");
1571
- }
1572
- else if (surfaceClass === "exclamation") {
1573
- hasExclamation = true;
1574
- run.push("exclamation");
1575
- }
1576
- else if (surfaceClass === "japanese_period" || surfaceClass === "ascii_period") {
1577
- hasPeriod = true;
1578
- run.push("period");
1579
- }
1580
- else
1581
- break;
1582
- endExclusive = cursor + 1;
1583
- cursor = nextNonSpaceIndex(tokens, endExclusive, tokens.length);
1584
- }
1585
- if (endExclusive === next)
1586
- return { kind: null, span: null, traits: [], run: [] };
1587
- const traits = [
1588
- ...(hasQuestion ? ["question"] : []),
1589
- ...(hasExclamation ? ["exclamation"] : []),
1590
- ];
1591
- const kind = hasExclamation
1592
- ? "exclamation"
1593
- : hasQuestion
1594
- ? "question"
1595
- : hasPeriod
1596
- ? "period"
1597
- : null;
1598
- return {
1599
- kind,
1600
- span: {
1601
- start: next,
1602
- endExclusive,
1603
- surface: tokens.slice(next, endExclusive).map((token) => token.surface).join(""),
1604
- role: "terminal_punctuation"
1605
- },
1606
- traits,
1607
- run,
1608
- };
1609
- }
1610
- function parallelSeparatorSpans(cursor, role) {
1611
- const spans = [];
1612
- const c = cursor.fork();
1613
- while (c.current()) {
1614
- const token = c.current();
1615
- if (isClauseEvidenceTransparentPunctuation(token)) {
1616
- spans.push({
1617
- start: c.pos,
1618
- endExclusive: c.pos + 1,
1619
- surface: token.surface,
1620
- role,
1621
- });
1622
- }
1623
- c.advance();
1624
- }
1625
- return spans;
1626
- }
1627
- function collectNariParallelRelations(options, _nodes) {
1628
- const relations = [];
1629
- const consumedMarkers = new Set();
1630
- const { tokens, layout } = options;
1631
- const c = new TokenCursor(tokens, 0, tokens.length);
1632
- while (c.current()) {
1633
- if (consumedMarkers.has(c.pos)) {
1634
- c.advance();
1635
- continue;
1636
- }
1637
- const firstMarker = nariParallelMarkerAt(tokens, layout, c.pos);
1638
- if (firstMarker === null) {
1639
- c.advance();
1640
- continue;
1641
- }
1642
- const firstStart = parallelItemStartBeforeMarker(tokens, layout, firstMarker.markerSpan.start);
1643
- if (firstStart === null || firstStart >= firstMarker.markerSpan.start) {
1644
- c.advance();
1645
- continue;
1646
- }
1647
- const markers = [firstMarker];
1648
- const itemStarts = [firstStart];
1649
- let currentMarker = firstMarker;
1650
- while (true) {
1651
- const nextStart = nextParallelItemStart(c.fork(currentMarker.markerSpan.endExclusive));
1652
- if (nextStart === null) {
1653
- break;
1654
- }
1655
- const nextMarker = nextNariParallelMarker(c.fork(nextStart), layout);
1656
- if (nextMarker === null || nextMarker.nariIdx <= currentMarker.nariIdx) {
1657
- break;
1658
- }
1659
- if (hasHardSentenceBoundaryBetween(tokens, currentMarker.markerSpan.endExclusive, nextMarker.nariIdx)) {
1660
- break;
1661
- }
1662
- if (!layout.sameQuoteScope(firstMarker.nariIdx, nextMarker.nariIdx)) {
1663
- break;
1664
- }
1665
- if (nextStart >= nextMarker.markerSpan.start) {
1666
- break;
1667
- }
1668
- markers.push(nextMarker);
1669
- itemStarts.push(nextStart);
1670
- currentMarker = nextMarker;
1671
- }
1672
- if (markers.length < 2) {
1673
- c.advance();
1674
- continue;
1675
- }
1676
- const itemKinds = markers.map((marker, markerIndex) => nariParallelItemKind(c.fork(itemStarts[markerIndex], marker.markerSpan.start), options.contentMap));
1677
- const wildcardFlags = markers.map((marker, markerIndex) => isWildcardPronounNariItem(tokens, itemStarts[markerIndex], marker.markerSpan.start));
1678
- const commonKind = nariParallelCommonItemKind(itemKinds, wildcardFlags);
1679
- if (commonKind === null) {
1680
- c.advance();
1681
- continue;
1682
- }
1683
- const lastMarker = markers[markers.length - 1];
1684
- const trailingParticleSpan = nariParallelTrailingParticleSpan(tokens, lastMarker.markerSpan.endExclusive);
1685
- const sourceEnd = trailingParticleSpan?.endExclusive ?? lastMarker.markerSpan.endExclusive;
1686
- const itemAnchors = markers.map((marker, markerIndex) => ({
1687
- source: spanAnchor({
1688
- start: itemStarts[markerIndex],
1689
- endExclusive: marker.markerSpan.start,
1690
- clauseIndex: marker.clauseIndex,
1691
- }),
1692
- markerSpan: marker.markerSpan,
1693
- itemKind: itemKinds[markerIndex],
1694
- predicateIdx: nariParallelPredicateIndex(options, itemStarts[markerIndex], marker.markerSpan.start),
1695
- }));
1696
- const separatorSpans = markers.slice(0, -1).flatMap((marker, markerIndex) => parallelSeparatorSpans(c.fork(marker.markerSpan.endExclusive, itemStarts[markerIndex + 1]), "nari_parallel_separator"));
1697
- const markerSpans = markers.map((marker) => marker.markerSpan);
1698
- const suppressibleSpans = [
1699
- ...markerSpans.map((span) => ({ start: span.start, endExclusive: span.endExclusive, reason: "relation_marker" })),
1700
- ...separatorSpans.map((span) => ({ start: span.start, endExclusive: span.endExclusive, reason: "relation_separator" })),
1701
- ...(trailingParticleSpan === null ? [] : [{
1702
- start: trailingParticleSpan.start,
1703
- endExclusive: trailingParticleSpan.endExclusive,
1704
- reason: "relation_trailing_particle",
1705
- }]),
1706
- ];
1707
- relations.push({
1708
- kind: "nari_parallel_choice",
1709
- source: spanAnchor({
1710
- start: firstStart,
1711
- endExclusive: sourceEnd,
1712
- clauseIndex: firstMarker.clauseIndex,
1713
- }),
1714
- target: null,
1715
- markerSpans,
1716
- candidateSuppressibleTokenSpans: suppressibleSpans,
1717
- projection: {
1718
- sourceForm: "listing",
1719
- connectiveKind: "nari_parallel_choice",
1720
- targetSlot: "coordination",
1721
- },
1722
- confidence: "strict",
1723
- renderEnabledByDefault: true,
1724
- nariParallel: {
1725
- itemAnchors,
1726
- markerSpans,
1727
- separatorSpans,
1728
- itemKind: commonKind,
1729
- trailingParticleSpan,
1730
- },
1731
- provenance: "structural_relation_owner",
1732
- });
1733
- for (const marker of markers) {
1734
- consumedMarkers.add(marker.nariIdx);
1735
- }
1736
- c.advance();
1737
- }
1738
- return relations;
1739
- }
1740
- function nariParallelMarkerAt(tokens, layout, index) {
1741
- const token = tokens[index];
1742
- if (!isNariParallelMarkerToken(token)) {
1743
- return null;
1744
- }
1745
- const clauseIndex = layout.clauseIndexOfToken(index);
1746
- return {
1747
- nariIdx: index,
1748
- markerSpan: {
1749
- start: index,
1750
- endExclusive: index + 1,
1751
- surface: token.surface,
1752
- role: "nari_parallel_marker",
1753
- },
1754
- clauseIndex,
1755
- };
1756
- }
1757
- function isNariParallelMarkerToken(token) {
1758
- if (token === undefined || token.surface !== "なり") {
1759
- return false;
1760
- }
1761
- const pos0 = token.pos & POS0;
1762
- const pos1 = token.pos & POS1;
1763
- return (pos0 === 助詞 && (pos1 === 副助詞 || pos1 === 接続助詞)) || pos0 === 接尾辞;
1764
- }
1765
- function nextNariParallelMarker(cursor, layout) {
1766
- const c = cursor.fork();
1767
- while (c.current()) {
1768
- const token = c.current();
1769
- if (isHardTerminalPunctuationToken(token)) {
1770
- return null;
1771
- }
1772
- const marker = nariParallelMarkerAt(c.tokens, layout, c.pos);
1773
- if (marker !== null) {
1774
- return marker;
1775
- }
1776
- c.advance();
1777
- }
1778
- return null;
1779
- }
1780
- function nariParallelItemKind(itemCursor, contentMap) {
1781
- return spanHasPredicateLikeToken(itemCursor, contentMap) ? "predicate" : "nominal";
1782
- }
1783
- function nariParallelCommonItemKind(itemKinds, wildcardFlags) {
1784
- const first = itemKinds[0] ?? null;
1785
- if (first === null) {
1786
- return null;
1787
- }
1788
- if (itemKinds.every((kind) => kind === first)) {
1789
- return first;
1790
- }
1791
- const mixedAcceptable = itemKinds.every((kind, index) => kind === "predicate" || wildcardFlags[index] === true) && itemKinds.some((kind) => kind === "predicate");
1792
- return mixedAcceptable ? "predicate" : null;
1793
- }
1794
- function isWildcardPronounNariItem(tokens, start, endExclusive) {
1795
- let sole = null;
1796
- for (let index = start; index < endExclusive; index += 1) {
1797
- const token = tokens[index];
1798
- if (token === undefined) {
1799
- continue;
1800
- }
1801
- if (sole !== null) {
1802
- return false;
1803
- }
1804
- sole = token;
1805
- }
1806
- return sole !== null &&
1807
- (sole.pos & POS0) === 代名詞 &&
1808
- ["何", "なん", "なに"].includes(sole.surface);
1809
- }
1810
- function nariParallelPredicateIndex(options, start, endExclusive) {
1811
- for (let index = endExclusive - 1; index >= start; index -= 1) {
1812
- if (options.contentMap.has(index) && isParallelPredicateToken(options.tokens[index])) {
1813
- return index;
1814
- }
1815
- }
1816
- return null;
1817
- }
1818
- function nariParallelTrailingParticleSpan(tokens, markerEndExclusive) {
1819
- const index = nextNonSpaceIndex(tokens, markerEndExclusive, tokens.length);
1820
- const token = index === null ? undefined : tokens[index];
1821
- if (index === null || token === undefined || (token.pos & POS01) !== 助詞_格助詞) {
1822
- return null;
1823
- }
1824
- return {
1825
- start: index,
1826
- endExclusive: index + 1,
1827
- surface: token.surface,
1828
- role: "nari_parallel_trailing_particle",
1829
- };
1830
- }
1831
- function collectImmediateNariSequenceRelations(options, nodes, nariParallelRelations) {
1832
- const relations = [];
1833
- const { tokens, layout, contentMap } = options;
1834
- const pairedMarkerStarts = nariParallelMarkerStarts(nariParallelRelations);
1835
- const c = new TokenCursor(tokens, 0, tokens.length);
1836
- while (c.current()) {
1837
- const hosted = immediateSequenceHostedMarkerAt(tokens, c.pos);
1838
- const marker = immediateNariSequenceMarkerAt(tokens, c.pos) ??
1839
- stativeHoldNariMarkerAt(tokens, c.pos) ??
1840
- hosted?.marker ??
1841
- null;
1842
- if (marker === null || pairedMarkerStarts.has(marker.start)) {
1843
- c.advance();
1844
- continue;
1845
- }
1846
- const sourceClauseIndex = layout.clauseIndexOfToken(c.pos);
1847
- const sourceClause = sourceClauseIndex < 0 ? undefined : layout.clauses[sourceClauseIndex];
1848
- if (sourceClause === undefined) {
1849
- c.advance();
1850
- continue;
1851
- }
1852
- const sourcePredicate = immediateNariSourcePredicate(contentMap, sourceClause, c.pos);
1853
- if (sourcePredicate === null ||
1854
- (hosted !== null && !sourcePredicateContentEndsWithHost(contentMap, sourcePredicate, hosted.hostIndex))) {
1855
- c.advance();
1856
- continue;
1857
- }
1858
- const target = immediateNariTargetAnchor(options, nodes, marker.endExclusive);
1859
- if (target === null) {
1860
- c.advance();
1861
- continue;
1862
- }
1863
- const stativeHold = marker.role === "stative_hold_marker";
1864
- relations.push({
1865
- kind: stativeHold ? "stative_hold_sequence" : "immediate_sequence",
1866
- source: predicateAnchor(sourcePredicate, sourceClauseIndex),
1867
- target,
1868
- markerSpans: [marker],
1869
- candidateSuppressibleTokenSpans: [{
1870
- start: marker.start,
1871
- endExclusive: marker.endExclusive,
1872
- reason: "relation_marker",
1873
- }],
1874
- projection: {
1875
- sourceForm: "connective",
1876
- connectiveKind: stativeHold ? "stative_hold" : "sequence_immediate",
1877
- targetSlot: "clause_prefix",
1878
- },
1879
- confidence: "strict",
1880
- renderEnabledByDefault: true,
1881
- provenance: "structural_relation_owner",
1882
- });
1883
- c.advance();
1884
- }
1885
- return relations;
1886
- }
1887
- function nariParallelMarkerStarts(relations) {
1888
- const starts = new Set();
1889
- for (const relation of relations) {
1890
- if (relation.kind !== "nari_parallel_choice") {
1891
- continue;
1892
- }
1893
- for (const marker of relation.markerSpans) {
1894
- if (marker.role === "nari_parallel_marker") {
1895
- starts.add(marker.start);
1896
- }
1897
- }
1898
- }
1899
- return starts;
1900
- }
1901
- function immediateNariSequenceMarkerAt(tokens, index) {
1902
- const token = tokens[index];
1903
- if (token === undefined || token.surface !== "なり" || (token.pos & POS01) !== 助詞_接続助詞) {
1904
- return null;
1905
- }
1906
- const previous = previousNonSpaceIndex(tokens, index, 0);
1907
- const previousToken = previous === null ? undefined : tokens[previous];
1908
- if (previousToken === undefined ||
1909
- (previousToken.pos & POS0) !== 動詞 ||
1910
- ((previousToken.pos & POS5A) !== 終止形_ && (previousToken.pos & POS5A) !== 連体形_)) {
1911
- return null;
1912
- }
1913
- return {
1914
- start: index,
1915
- endExclusive: index + 1,
1916
- surface: token.surface,
1917
- role: "immediate_sequence_marker",
1918
- };
1919
- }
1920
- function immediateSequenceHostedMarkerAt(tokens, index) {
1921
- const hosted = hostedConnectiveMarkerAt(tokens, index, "sequence_immediate");
1922
- if (hosted === null) {
1923
- return null;
1924
- }
1925
- return {
1926
- marker: {
1927
- start: index,
1928
- endExclusive: index + 1,
1929
- surface: hosted.surface,
1930
- role: "immediate_sequence_marker",
1931
- },
1932
- hostIndex: hosted.hostIndex,
1933
- };
1934
- }
1935
- function sourcePredicateContentEndsWithHost(contentMap, sourcePredicate, hostIndex) {
1936
- const span = contentMap.get(sourcePredicate);
1937
- return span !== undefined && span.start <= hostIndex && span.start + span.consumed - 1 === hostIndex;
1938
- }
1939
- function stativeHoldNariMarkerAt(tokens, index) {
1940
- const token = tokens[index];
1941
- if (token === undefined || token.surface !== "なり" || (token.pos & POS01) !== 助詞_副助詞) {
1942
- return null;
1943
- }
1944
- const previous = previousNonSpaceIndex(tokens, index, 0);
1945
- const previousToken = previous === null ? undefined : tokens[previous];
1946
- if (previousToken === undefined || (previousToken.pos & POS4) !== 助動詞_タ) {
1947
- return null;
1948
- }
1949
- return {
1950
- start: index,
1951
- endExclusive: index + 1,
1952
- surface: token.surface,
1953
- role: "stative_hold_marker",
1954
- };
1955
- }
1956
- function immediateNariSourcePredicate(contentMap, sourceClause, markerIdx) {
1957
- for (let index = sourceClause.predicates.length - 1; index >= 0; index -= 1) {
1958
- const predicateIdx = sourceClause.predicates[index];
1959
- if (predicateIdx !== undefined && predicateIdx < markerIdx && contentMap.has(predicateIdx)) {
1960
- return predicateIdx;
1961
- }
1962
- }
1963
- return null;
1964
- }
1965
- function immediateNariTargetAnchor(options, nodes, start) {
1966
- const { tokens, layout } = options;
1967
- const targetTokenIdx = nextContentTokenIndex(tokens, start, tokens.length);
1968
- if (targetTokenIdx === null) {
1969
- return null;
1970
- }
1971
- const targetClauseIndex = layout.clauseIndexOfToken(targetTokenIdx);
1972
- if (targetClauseIndex < 0) {
1973
- return null;
1974
- }
1975
- const targetClause = layout.clauses[targetClauseIndex];
1976
- if (targetClause === undefined) {
1977
- return null;
1978
- }
1979
- if (targetClause.start >= start) {
1980
- return clauseAnchor(nodes, targetClauseIndex);
1981
- }
1982
- const predicateIdx = targetClause.predicates.find((candidate) => candidate >= targetTokenIdx) ?? null;
1983
- return predicateIdx === null
1984
- ? clauseAnchor(nodes, targetClauseIndex)
1985
- : predicateAnchor(predicateIdx, targetClauseIndex);
1986
- }
1987
- function markerSurface(tokens, start, endExclusive) {
1988
- return tokens.slice(start, endExclusive).map((token) => token.surface).join("");
1989
- }
1990
- function punctuatedAttributiveTargetClauses(layout) {
1991
- return layout.clauses.map((clause) => ({
1992
- start: clause.start,
1993
- end: clause.end,
1994
- kind: clause.kind,
1995
- parentIdx: clause.parentIdx,
1996
- predicates: clause.predicates,
1997
- particleIndices: clause.particleIndices,
1998
- adverbialAdjunctIndices: clause.predicates.flatMap((predicateIdx) => [...layout.adverbialAdjunctsOf(predicateIdx)]),
1999
- }));
2000
- }
2001
- function collectPunctuatedAttributiveModifierRelations(options, _nodes, quoteRelations) {
2002
- const relations = [];
2003
- const { tokens, layout, contentMap, lookups } = options;
2004
- for (let clauseIndex = 0; clauseIndex < layout.clauses.length - 1; clauseIndex += 1) {
2005
- const sourceClause = layout.clauses[clauseIndex];
2006
- const targetClause = layout.clauses[clauseIndex + 1];
2007
- if (sourceClause === undefined || targetClause === undefined) {
2008
- continue;
2009
- }
2010
- if (sourceClause.end !== targetClause.start || sourceClause.terminatedBy !== "punctuation") {
2011
- continue;
2012
- }
2013
- const markerSpan = punctuationMarkerSpanAtClauseEnd(tokens, sourceClause);
2014
- if (markerSpan === null) {
2015
- continue;
2016
- }
2017
- const sourcePredicate = punctuatedAttributiveSourcePredicate(contentMap, sourceClause, markerSpan.start);
2018
- if (sourcePredicate === null || !contentMap.has(sourcePredicate)) {
2019
- continue;
2020
- }
2021
- if (!sourceClauseCanProjectPunctuatedAttributive(tokens, sourceClause, sourcePredicate, markerSpan.start, contentMap.get(sourcePredicate)?.renderPlan ?? null, {
2022
- closureRun: layout.utteranceClosureRunAt(markerSpan.start) ?? null,
2023
- sfpEffect: renderPlanTerminalSfp(contentMap.get(sourcePredicate)?.renderPlan ?? null)?.effect ?? null,
2024
- closingEffects: lookups.SFP_UTTERANCE_CLOSING_EFFECTS
2025
- })) {
2026
- continue;
2027
- }
2028
- if (targetClause.leadingConnectiveIdx !== null || targetClause.leadingQuoteMarkerIdx !== null) {
2029
- continue;
2030
- }
2031
- const exemplification = nominalExemplificationCarrierEvidence(options, quoteRelations, sourceClause, sourcePredicate, markerSpan);
2032
- const target = punctuatedAttributiveTargetAnchor(tokens, punctuatedAttributiveTargetClauses(layout), clauseIndex + 1, exemplification === null ? "salient_nominal" : "source_required_head");
2033
- if (target === null) {
2034
- continue;
2035
- }
2036
- relations.push({
2037
- kind: "punctuated_attributive_modifier",
2038
- source: predicateAnchor(sourcePredicate, clauseIndex),
2039
- target: nounPhraseAnchor(target),
2040
- markerSpans: [markerSpan],
2041
- ...(exemplification === null ? {} : {
2042
- candidateSuppressibleTokenSpans: [
2043
- { ...exemplification.quoteMarkerSpan, reason: "relation_marker" },
2044
- ...(exemplification.exemplificationMarkerSpan === null
2045
- ? []
2046
- : [{ ...exemplification.exemplificationMarkerSpan, reason: "relation_marker" }]),
2047
- ],
2048
- nominalExemplification: exemplification,
2049
- }),
2050
- projection: {
2051
- sourceForm: "attributive",
2052
- targetSlot: "noun_modifier",
2053
- },
2054
- confidence: "strict",
2055
- renderEnabledByDefault: true,
2056
- provenance: "structural_relation_owner",
2057
- });
2058
- }
2059
- return relations;
2060
- }
2061
- function nominalExemplificationCarrierEvidence(options, quoteRelations, sourceClause, sourcePredicate, pauseMarkerSpan) {
2062
- const { tokens, layout } = options;
2063
- const quote = quoteRelations.find((relation) => relation.quote !== undefined && relation.quote.hostMatch.hostIdx === sourcePredicate)?.quote;
2064
- if (quote === undefined ||
2065
- !IU_LEXEME_FORMS.has(quote.hostMatch.hostForm) ||
2066
- !NOMINAL_EXEMPLIFICATION_QUOTE_MARKERS.has(quote.markerBaseSurface)) {
2067
- return null;
2068
- }
2069
- const ownsEventArgument = layout.argumentRolesOf(sourcePredicate).some(({ particleIdx }) => !(quote.markerSpan.start <= particleIdx && particleIdx < quote.markerSpan.endExclusive) &&
2070
- !(quote.contentSpan.start <= particleIdx && particleIdx < quote.contentSpan.endExclusive));
2071
- if (ownsEventArgument || layout.adverbialAdjunctsOf(sourcePredicate).length > 0) {
2072
- return null;
2073
- }
2074
- const pastIdx = nextNonSpaceIndex(tokens, sourcePredicate + 1, sourceClause.end);
2075
- const pastToken = pastIdx === null ? undefined : tokens[pastIdx];
2076
- if (pastIdx === null || pastToken === undefined || !isPastAuxiliaryPos(pastToken.pos) ||
2077
- nextNonSpaceIndex(tokens, pastIdx + 1, sourceClause.end) !== pauseMarkerSpan.start) {
2078
- return null;
2079
- }
2080
- let lastIdx = quote.contentSpan.endExclusive - 1;
2081
- while (lastIdx >= quote.contentSpan.start) {
2082
- const token = tokens[lastIdx];
2083
- const closesQuote = layout.quoteSpans.some(([opening, closingIdx]) => closingIdx === lastIdx && opening >= quote.contentSpan.start);
2084
- if (token === undefined ||
2085
- !(closesQuote || ((token.pos & POS0) === 補助記号 &&
2086
- !isClauseHardTerminalPunctuationToken(token) &&
2087
- !isClauseOpeningPunctuationToken(token)))) {
2088
- break;
2089
- }
2090
- lastIdx -= 1;
2091
- }
2092
- const lastToken = tokens[lastIdx];
2093
- if (lastToken === undefined || lastIdx < quote.contentSpan.start) {
2094
- return null;
2095
- }
2096
- const exemplificationMarker = tokenMatchesConnectiveKind(lastToken, "exemplification") ? lastIdx : null;
2097
- const headIdx = exemplificationMarker === null ? lastIdx : lastIdx - 1;
2098
- const headToken = tokens[headIdx];
2099
- if (headToken === undefined ||
2100
- headIdx < quote.contentSpan.start ||
2101
- !isNominalLike(headToken) ||
2102
- layout.clauses.some((clause) => clause.predicates.includes(headIdx))) {
2103
- return null;
2104
- }
2105
- return {
2106
- contentSpan: { start: quote.contentSpan.start, endExclusive: quote.contentSpan.endExclusive },
2107
- quoteMarkerSpan: { start: quote.markerSpan.start, endExclusive: quote.markerSpan.endExclusive },
2108
- hostIdx: quote.hostMatch.hostIdx,
2109
- exemplificationMarkerSpan: exemplificationMarker === null
2110
- ? null
2111
- : { start: exemplificationMarker, endExclusive: exemplificationMarker + 1 },
2112
- };
2113
- }
2114
- function pushCollectResult(result, relations, diagnostics) {
2115
- if (result.kind === "relation") {
2116
- relations.push(result.relation);
2117
- return;
2118
- }
2119
- if (result.kind === "diagnostic") {
2120
- diagnostics.push(result.diagnostic);
2121
- }
2122
- }
2123
- function collectListingExampleRelation(options, nodes, markerStart, match) {
2124
- const { tokens, layout } = options;
2125
- const sourceClauseIndex = layout.clauseIndexOfToken(markerStart);
2126
- const sourceClause = sourceClauseIndex < 0 ? undefined : layout.clauses[sourceClauseIndex];
2127
- if (sourceClause === undefined) {
2128
- return degraded(match, markerStart, "listing marker has no source clause");
2129
- }
2130
- const closure = relationDiscontinuousClosureSpanAfter(new TokenCursor(tokens, match.endExclusive, sourceClause.end), match);
2131
- if (closure === null) {
2132
- return degraded(match, markerStart, "listing marker has no closure と");
2133
- }
2134
- if (!listingClosureCanCloseBeforeClauseBoundary(tokens, closure.endExclusive, sourceClause.end, options.lookups)) {
2135
- return degraded(match, markerStart, "listing closure と is not a clause-final example marker");
2136
- }
2137
- const targetClauseIndex = nextClauseIndex(layout, sourceClauseIndex);
2138
- const targetClause = targetClauseIndex === null ? undefined : layout.clauses[targetClauseIndex];
2139
- if (targetClauseIndex === null || targetClause === undefined) {
2140
- return degraded(match, markerStart, "listing relation has no target clause");
2141
- }
2142
- const markerSpan = markerSpanFromMatch(markerStart, match, match.markerRole ?? "listing_tail");
2143
- const closureSpan = {
2144
- start: closure.start,
2145
- endExclusive: closure.endExclusive,
2146
- surface: closure.surface,
2147
- role: closure.role ?? "closure_marker",
2148
- };
2149
- const clauseSource = clauseAnchor(nodes, sourceClauseIndex);
2150
- const markerHostPredicate = layout.previousPredicateInClause(markerStart);
2151
- return {
2152
- kind: "relation",
2153
- relation: {
2154
- kind: match.relationPolicy,
2155
- source: clauseSource.kind === "clause" && markerHostPredicate !== undefined
2156
- ? { ...clauseSource, predicateIdx: markerHostPredicate }
2157
- : clauseSource,
2158
- target: clauseAnchor(nodes, targetClauseIndex),
2159
- markerSpans: [markerSpan, closureSpan],
2160
- candidateSuppressibleTokenSpans: [
2161
- { start: markerSpan.start, endExclusive: markerSpan.endExclusive, reason: "relation_marker" },
2162
- { start: closureSpan.start, endExclusive: closureSpan.endExclusive, reason: "relation_marker" },
2163
- ],
2164
- projection: projectionRequest(match.projection ?? "listing", match),
2165
- confidence: "strict",
2166
- ...layoutBoundaryRelationPayload(match),
2167
- ...renderEnabledRelationPayload(match),
2168
- provenance: "structural_relation_owner",
2169
- },
2170
- };
2171
- }
2172
- function collectCorrelativeDegreeRelation(options, nodes, markerStart, match) {
2173
- const { tokens, layout, contentMap } = options;
2174
- const searchEnd = correlativeSearchEnd(tokens, match.endExclusive);
2175
- const degree = findCorrelativeDegreeMarker(tokens, match.endExclusive, searchEnd);
2176
- if (degree === null) {
2177
- return degraded(match, markerStart, "correlative marker has no degree marker");
2178
- }
2179
- const sourceClauseIndex = layout.clauseIndexOfToken(markerStart);
2180
- const degreeClauseIndex = layout.clauseIndexOfToken(degree.start);
2181
- const targetIndex = nextContentTokenIndex(tokens, degree.endExclusive, tokens.length);
2182
- const targetClauseIndex = targetIndex === null ? null : layout.clauseIndexOfToken(targetIndex);
2183
- if (sourceClauseIndex < 0 || degreeClauseIndex < 0 || targetClauseIndex === null || targetClauseIndex < 0) {
2184
- return degraded(match, markerStart, "correlative relation has no target clause");
2185
- }
2186
- const targetClause = layout.clauses[targetClauseIndex];
2187
- if (targetClause === undefined) {
2188
- return degraded(match, markerStart, "correlative relation target clause missing");
2189
- }
2190
- const leftPredicate = layout.predicateOccurrenceBefore(tokens, contentMap, markerStart);
2191
- const rightPredicate = layout.predicateOccurrenceBefore(tokens, contentMap, degree.start);
2192
- const confidence = correlativeConfidence(tokens, leftPredicate, rightPredicate);
2193
- if (confidence === "weak") {
2194
- return {
2195
- kind: "diagnostic",
2196
- diagnostic: structuralRelationDegraded({
2197
- message: "correlative degree markers lack strict predicate compatibility",
2198
- relationKind: match.relationPolicy,
2199
- confidence,
2200
- ...layoutBoundaryDiagnosticPayload(match),
2201
- clauseId: structuralRelationNodeId(sourceClauseIndex),
2202
- span: markerSpanFromMatch(markerStart, match, match.markerRole ?? "conditional_marker"),
2203
- markerSpans: [
2204
- markerSpanFromMatch(markerStart, match, match.markerRole ?? "conditional_marker"),
2205
- degree.markerSpan,
2206
- ],
2207
- }),
2208
- };
2209
- }
2210
- const markerSpan = markerSpanFromMatch(markerStart, match, match.markerRole ?? "conditional_marker");
2211
- return {
2212
- kind: "relation",
2213
- relation: {
2214
- kind: match.relationPolicy,
2215
- source: clauseAnchor(nodes, sourceClauseIndex),
2216
- target: spanAnchor({
2217
- start: degree.endExclusive,
2218
- endExclusive: targetClause.end,
2219
- clauseIndex: targetClauseIndex,
2220
- }),
2221
- markerSpans: [markerSpan, degree.markerSpan],
2222
- candidateSuppressibleTokenSpans: [
2223
- { start: markerSpan.start, endExclusive: markerSpan.endExclusive, reason: "relation_marker" },
2224
- { start: degree.markerSpan.start, endExclusive: degree.markerSpan.endExclusive, reason: "relation_marker" },
2225
- ],
2226
- projection: projectionRequest(match.projection ?? "correlative_degree", match),
2227
- confidence,
2228
- ...layoutBoundaryRelationPayload(match),
2229
- ...renderEnabledRelationPayload(match),
2230
- provenance: "structural_relation_owner",
2231
- },
2232
- };
2233
- }
2234
- function collectPurposeModifierRelation(options, nodes, markerStart, match) {
2235
- const evidence = purposeModifierEvidence(options, markerStart, match);
2236
- if (!evidence.ok) {
2237
- return degraded(match, markerStart, evidence.reason);
2238
- }
2239
- const markerSpan = markerSpanFromMatch(markerStart, match, "purpose_marker");
2240
- return {
2241
- kind: "relation",
2242
- relation: {
2243
- kind: match.relationPolicy,
2244
- source: clauseAnchor(nodes, evidence.sourceClauseIndex),
2245
- target: targetSpanAnchor(evidence.targetSpan),
2246
- markerSpans: [markerSpan],
2247
- candidateSuppressibleTokenSpans: [{
2248
- start: markerSpan.start,
2249
- endExclusive: markerSpan.endExclusive,
2250
- reason: "relation_marker",
2251
- }],
2252
- projection: projectionRequest(match.projection ?? "purpose_attributive", match),
2253
- confidence: "strict",
2254
- ...layoutBoundaryRelationPayload(match),
2255
- ...renderEnabledRelationPayload(match),
2256
- provenance: "structural_relation_owner",
2257
- },
2258
- };
2259
- }
2260
- function purposeModifierEvidence(options, markerStart, match) {
2261
- const { tokens, layout } = options;
2262
- const sourcePredicate = layout.predicateBeforeNominalClosure(markerStart)
2263
- ?? layout.previousPredicateInClause(markerStart);
2264
- const sourceClauseIndex = sourcePredicate === undefined ? -1 : layout.clauseIndexOfPredicate(sourcePredicate) ?? -1;
2265
- if (sourcePredicate === undefined || sourceClauseIndex < 0 || !options.contentMap.has(sourcePredicate)) {
2266
- return { ok: false, reason: "purpose modifier marker has no source predicate" };
2267
- }
2268
- const sourceClause = layout.clauses[sourceClauseIndex];
2269
- if (sourceClause !== undefined &&
2270
- hasStrictReasonEvidence(tokens, sourceClause, markerStart, match.endExclusive, options.contentMap)) {
2271
- return { ok: false, reason: "purpose modifier marker conflicts with strict reason evidence" };
2272
- }
2273
- if (!hasPurposeModifierSourceEvidence(tokens, sourcePredicate, markerStart, sourceClause?.start ?? 0)) {
2274
- return { ok: false, reason: "purpose modifier marker lacks purpose source evidence" };
2275
- }
2276
- if (explicitNominalPurposeFrameFollows(tokens, match.endExclusive)) {
2277
- return { ok: false, reason: "purpose modifier marker is owned by explicit nominal frame" };
2278
- }
2279
- const targetSpan = nounPhraseTargetAfter(tokens, match.endExclusive, purposeModifierTargetSearchEnd(tokens, match.endExclusive));
2280
- if (targetSpan === null) {
2281
- return { ok: false, reason: "purpose modifier marker has no target noun phrase" };
2282
- }
2283
- if (!hasPurposeModifierTargetArgumentEvidence(tokens, targetSpan)) {
2284
- return { ok: false, reason: "purpose modifier target lacks argument evidence" };
2285
- }
2286
- return { ok: true, sourcePredicate, sourceClauseIndex, targetSpan };
2287
- }
2288
- function hasPurposeModifierSourceEvidence(tokens, sourcePredicate, markerStart, lowerBoundInclusive) {
2289
- const predicate = tokens[sourcePredicate];
2290
- if (predicate === undefined) {
2291
- return false;
2292
- }
2293
- const conj5A = predicate.pos & POS5A;
2294
- const pos0 = predicate.pos & POS0;
2295
- if (pos0 !== 動詞 || conj5A !== 連体形_) {
2296
- return false;
2297
- }
2298
- const last = previousContentTokenIndex(tokens, markerStart - 1, lowerBoundInclusive);
2299
- return last === sourcePredicate;
2300
- }
2301
- function explicitNominalPurposeFrameFollows(tokens, markerEndExclusive) {
2302
- const next = nextContentTokenIndex(tokens, markerEndExclusive, tokens.length);
2303
- if (next === null) {
2304
- return false;
2305
- }
2306
- const token = tokens[next];
2307
- return token !== undefined && (token.pos & POS0) === 助詞 && (token.surface === "の" || token.surface === "に");
2308
- }
2309
- function purposeModifierTargetSearchEnd(tokens, start) {
2310
- const c = new TokenCursor(tokens, start, tokens.length);
2311
- while (c.current()) {
2312
- const token = c.current();
2313
- if (isHardTerminalPunctuationToken(token) || isClausePunctuationToken(token)) {
2314
- return c.pos;
2315
- }
2316
- c.advance();
2317
- }
2318
- return tokens.length;
2319
- }
2320
- function hasPurposeModifierTargetArgumentEvidence(tokens, targetSpan) {
2321
- const next = nextContentTokenIndex(tokens, targetSpan.endExclusive, tokens.length);
2322
- if (next === null) {
2323
- return true;
2324
- }
2325
- const token = tokens[next];
2326
- if (token === undefined ||
2327
- (token.pos & POS0) !== 助詞 ||
2328
- !(token.surface === "が" || token.surface === "は" || token.surface === "も" || token.surface === "を")) {
2329
- return false;
2330
- }
2331
- if ((token.surface === "が" || token.surface === "は" || token.surface === "も") && !targetSpanHasPrenominalModifier(tokens, targetSpan)) {
2332
- return false;
2333
- }
2334
- return true;
2335
- }
2336
- function targetSpanHasPrenominalModifier(tokens, targetSpan) {
2337
- const c = new TokenCursor(tokens, targetSpan.start, targetSpan.endExclusive - 1);
2338
- while (c.current()) {
2339
- const token = c.current();
2340
- const pos0 = token.pos & POS0;
2341
- if (pos0 === 形状詞 || pos0 === 形容詞0 || pos0 === 連体詞 || token.surface === "な" || token.surface === "の") {
2342
- return true;
2343
- }
2344
- c.advance();
2345
- }
2346
- return false;
2347
- }
2348
- function punctuationMarkerSpanAtClauseEnd(tokens, clause) {
2349
- for (let index = clause.end - 1; index >= clause.start; index -= 1) {
2350
- const token = tokens[index];
2351
- if (token === undefined) {
2352
- continue;
2353
- }
2354
- if (!isClauseEvidenceTransparentPunctuation(token)) {
2355
- return null;
2356
- }
2357
- return {
2358
- start: index,
2359
- endExclusive: index + 1,
2360
- surface: token.surface,
2361
- role: "punctuated_attributive_marker",
2362
- };
2363
- }
2364
- return null;
2365
- }
2366
- function sourceClauseCanProjectPunctuatedAttributive(tokens, clause, predicateIdx, markerStart, sourcePlan, closure) {
2367
- const predicate = tokens[predicateIdx];
2368
- if (predicate === undefined) {
2369
- return false;
2370
- }
2371
- if (utteranceClosedForAttributiveProjection(closure.closureRun, closure.sfpEffect, closure.closingEffects)) {
2372
- return false;
2373
- }
2374
- const last = previousNonSpaceIndex(tokens, markerStart, clause.start);
2375
- const token = last === null ? undefined : tokens[last];
2376
- if (token === undefined) {
2377
- return false;
2378
- }
2379
- const predicatePos0 = predicate.pos & POS0;
2380
- const pos5a = token.pos & POS5A;
2381
- if (predicatePos0 === 動詞 || sourceClauseHasVerbPredicateTail(tokens, predicateIdx, markerStart)) {
2382
- return pos5a === 終止形_ || pos5a === 連体形_;
2383
- }
2384
- if (predicatePos0 === 形容詞0 &&
2385
- (last === predicateIdx || sourceClauseHasAdjectivePredicateTail(tokens, predicateIdx, markerStart))) {
2386
- return pos5a === 終止形_ || pos5a === 連体形_;
2387
- }
2388
- if (isPredicateHeadTailChainRenderPlan(sourcePlan) &&
2389
- tailRootClosesWithCopulaAttributive(sourcePlan.realization.root)) {
2390
- return pos5a === 連体形_;
2391
- }
2392
- return false;
2393
- }
2394
- function punctuatedAttributiveSourcePredicate(contentMap, clause, markerStart) {
2395
- for (let index = clause.predicates.length - 1; index >= 0; index -= 1) {
2396
- const predicateIdx = clause.predicates[index];
2397
- if (predicateIdx !== undefined && predicateIdx < markerStart && contentMap.has(predicateIdx)) {
2398
- return predicateIdx;
2399
- }
2400
- }
2401
- return null;
2402
- }
2403
- function sourceClauseHasVerbPredicateTail(tokens, predicateIdx, markerStart) {
2404
- const c = new TokenCursor(tokens, predicateIdx + 1, markerStart);
2405
- while (c.current()) {
2406
- const token = c.current();
2407
- if (pos0in(token.pos, (1 << 補助記号))) {
2408
- c.advance();
2409
- continue;
2410
- }
2411
- if ((token.pos & POS0) === 動詞) {
2412
- return true;
2413
- }
2414
- c.advance();
2415
- }
2416
- return false;
2417
- }
2418
- function sourceClauseHasAdjectivePredicateTail(tokens, predicateIdx, markerStart) {
2419
- let sawTailToken = false;
2420
- const c = new TokenCursor(tokens, predicateIdx + 1, markerStart);
2421
- while (c.current()) {
2422
- const token = c.current();
2423
- if ((token.pos & POS0) === 助動詞 && token.dictionaryForm === "た") {
2424
- sawTailToken = true;
2425
- c.advance();
2426
- continue;
2427
- }
2428
- if ((token.pos & POS01) === (形容詞0 | 非自立可能) && token.dictionaryForm === "ない") {
2429
- sawTailToken = true;
2430
- c.advance();
2431
- continue;
2432
- }
2433
- return false;
2434
- }
2435
- return sawTailToken;
2436
- }
2437
- function degraded(match, markerStart, message) {
2438
- const markerSpan = markerSpanFromMatch(markerStart, match);
2439
- return {
2440
- kind: "diagnostic",
2441
- diagnostic: structuralRelationDegraded({
2442
- message,
2443
- relationKind: match.relationPolicy,
2444
- confidence: "weak",
2445
- ...layoutBoundaryDiagnosticPayload(match),
2446
- span: markerSpan,
2447
- markerSpans: [markerSpan],
2448
- }),
2449
- };
2450
- }
2451
- function hasNounModifierTarget(options, markerStart, match) {
2452
- return purposeModifierEvidence(options, markerStart, match).ok;
2453
- }
2454
- function shouldDeferContiguousForPurposeModifier(options, markerStart, match) {
2455
- return purposeModifierEvidence(options, markerStart, match).ok;
2456
- }
2457
- function buildStructuralRelationNodes(layout, contentMap) {
2458
- return layout.clauses.map((clause, clauseIndex) => {
2459
- const contentSpanStart = contentSpanStartForClause(clause.start, clause.end, clause.primaryPredicate, contentMap);
2460
- return {
2461
- id: structuralRelationNodeId(clauseIndex),
2462
- span: tokenSpan(clause.start, clause.end),
2463
- kind: clause.kind,
2464
- predicateIndex: clause.primaryPredicate,
2465
- renderHandle: null,
2466
- contentSpanId: contentSpanStart === null ? null : structuralRelationContentSpanId(contentSpanStart),
2467
- };
2468
- });
2469
- }
2470
- function clauseAnchor(nodes, clauseIndex) {
2471
- const node = nodes[clauseIndex];
2472
- return {
2473
- kind: "clause",
2474
- clauseId: node?.id ?? structuralRelationNodeId(clauseIndex),
2475
- span: node?.span ?? tokenSpan(0, 0),
2476
- predicateIdx: node?.predicateIndex ?? null,
2477
- };
2478
- }
2479
- function spanAnchor(options) {
2480
- return {
2481
- kind: "span",
2482
- span: tokenSpan(options.start, options.endExclusive),
2483
- clauseId: options.clauseIndex === null || options.clauseIndex < 0
2484
- ? null
2485
- : structuralRelationNodeId(options.clauseIndex),
2486
- };
2487
- }
2488
- function predicateAnchor(predicateIdx, clauseIndex) {
2489
- return {
2490
- kind: "predicate",
2491
- predicateIdx,
2492
- clauseId: clauseIndex === null || clauseIndex < 0
2493
- ? null
2494
- : structuralRelationNodeId(clauseIndex),
2495
- span: tokenSpan(predicateIdx, predicateIdx + 1),
2496
- };
2497
- }
2498
- function targetSpanAnchor(targetSpan) {
2499
- if (targetSpan.kind === "noun_phrase") {
2500
- return {
2501
- kind: "noun_phrase",
2502
- span: tokenSpan(targetSpan.start, targetSpan.endExclusive),
2503
- headIdx: targetSpan.endExclusive > targetSpan.start ? targetSpan.endExclusive - 1 : null,
2504
- };
2505
- }
2506
- return {
2507
- kind: "span",
2508
- span: tokenSpan(targetSpan.start, targetSpan.endExclusive),
2509
- clauseId: null,
2510
- };
2511
- }
2512
- function nounPhraseAnchor(anchor) {
2513
- return {
2514
- kind: "noun_phrase",
2515
- span: tokenSpan(anchor.span.start, anchor.span.endExclusive),
2516
- headIdx: anchor.headIdx,
2517
- };
2518
- }
2519
- function collectReasonCopulaExplanationRelations(options, nodes) {
2520
- const relations = [];
2521
- const { tokens, layout, contentMap } = options;
2522
- for (let index = 0; index < tokens.length; index += 1) {
2523
- const token = tokens[index];
2524
- if (!isStrictReasonKaraToken(token)) {
2525
- continue;
2526
- }
2527
- const sourceClauseIndex = layout.clauseIndexOfToken(index);
2528
- const sourceClause = sourceClauseIndex < 0 ? undefined : layout.clauses[sourceClauseIndex];
2529
- if (sourceClause === undefined || !hasReasonCleftEvidence(layout, tokens, contentMap, sourceClause, index, index + 1)) {
2530
- continue;
2531
- }
2532
- const copulaStart = nextContentTokenIndex(tokens, index + 1, tokens.length);
2533
- if (copulaStart === null) {
2534
- continue;
2535
- }
2536
- const copulaShell = matchReasonCopulaShellAt(tokens, copulaStart);
2537
- if (copulaShell === null) {
2538
- continue;
2539
- }
2540
- const afterCopula = nextContentTokenIndex(tokens, copulaShell.endExclusive, tokens.length);
2541
- const quoteMarkerSpan = quoteMarkerSpanForHostlessReasonCopula(tokens, afterCopula);
2542
- const sfpMatch = quoteMarkerSpan === null
2543
- ? reasonCopulaTerminalSfpAt(tokens, afterCopula, copulaShell.payload)
2544
- : null;
2545
- const relationEnd = quoteMarkerSpan?.endExclusive ?? sfpMatch?.markerSpan.endExclusive ?? copulaShell.endExclusive;
2546
- const afterRelation = nextContentTokenIndex(tokens, relationEnd, tokens.length);
2547
- if (!hostlessReasonCopulaCanEndBefore(afterRelation === null ? undefined : tokens[afterRelation])) {
2548
- continue;
2549
- }
2550
- const reasonMarkerSpan = {
2551
- start: index,
2552
- endExclusive: index + 1,
2553
- surface: token.surface,
2554
- role: "reason_marker",
2555
- };
2556
- const copulaMarkerSpan = {
2557
- start: copulaShell.start,
2558
- endExclusive: copulaShell.endExclusive,
2559
- surface: copulaShell.surface,
2560
- role: "explanatory_copula",
2561
- };
2562
- const trailingMarkerSpan = quoteMarkerSpan ?? sfpMatch?.markerSpan ?? null;
2563
- const markerSpans = trailingMarkerSpan === null
2564
- ? [reasonMarkerSpan, copulaMarkerSpan]
2565
- : [reasonMarkerSpan, copulaMarkerSpan, trailingMarkerSpan];
2566
- relations.push({
2567
- kind: "reason_copula_explanation",
2568
- source: clauseAnchor(nodes, sourceClauseIndex),
2569
- target: null,
2570
- markerSpans,
2571
- candidateSuppressibleTokenSpans: markerSpans.map((span) => ({
2572
- start: span.start,
2573
- endExclusive: span.endExclusive,
2574
- reason: span.role ?? "reason_copula_marker",
2575
- })),
2576
- projection: {
2577
- sourceForm: "reason",
2578
- targetSlot: "clause_prefix",
2579
- },
2580
- reasonCopula: sfpMatch === null ? copulaShell.payload : { ...copulaShell.payload, sfp: sfpMatch.sfp },
2581
- confidence: "strict",
2582
- renderEnabledByDefault: true,
2583
- provenance: "structural_relation_owner",
2584
- });
2585
- }
2586
- return relations;
2587
- }
2588
- function matchReasonCopulaShellAt(tokens, start) {
2589
- const negativeCursor = new TokenCursor(tokens, start, tokens.length);
2590
- const negative = matchCopulaNegation(negativeCursor);
2591
- if (negative !== undefined) {
2592
- const negativeHead = tokens[negativeCursor.pos - negative[5].length - 1];
2593
- const conjecture = reasonCopulaNegativeConjecture(negativeHead, negative[5]);
2594
- if (conjecture === undefined ||
2595
- negative[4] ||
2596
- (negativeHead !== undefined && isConditionalInflection(negativeHead.pos))) {
2597
- return null;
2598
- }
2599
- const trailingTe = negative[2] ? negativeCursor.current() : undefined;
2600
- if (trailingTe?.surface === "て" && isTeConnectiveToken(trailingTe)) {
2601
- negativeCursor.advance(1);
2602
- }
2603
- return {
2604
- start,
2605
- endExclusive: negativeCursor.pos,
2606
- surface: markerSurface(tokens, start, negativeCursor.pos),
2607
- payload: {
2608
- negative: true,
2609
- polite: negative[0],
2610
- past: negative[1],
2611
- connective: negative[2],
2612
- additiveMo: negative[3],
2613
- conditionalNara: negative[4],
2614
- conjecture,
2615
- sfp: null,
2616
- },
2617
- };
2618
- }
2619
- const first = tokens[start];
2620
- if (!isBasicCopulaAuxToken(first)) {
2621
- return null;
2622
- }
2623
- const conjectureShell = reasonCopulaConjectureShellAt(tokens, start);
2624
- if (conjectureShell !== null) {
2625
- return conjectureShell;
2626
- }
2627
- const next = nextContentTokenIndex(tokens, start + 1, tokens.length);
2628
- const nextToken = next === null ? undefined : tokens[next];
2629
- if (next !== null && nextToken !== undefined && isPastAuxiliaryPos(nextToken.pos)) {
2630
- if (isPastAuxConditionalForm(nextToken.pos)) {
2631
- return null;
2632
- }
2633
- return {
2634
- start,
2635
- endExclusive: next + 1,
2636
- surface: markerSurface(tokens, start, next + 1),
2637
- payload: {
2638
- negative: false,
2639
- polite: reasonCopulaTokenPoliteness(first),
2640
- past: true,
2641
- connective: false,
2642
- additiveMo: false,
2643
- conditionalNara: false,
2644
- conjecture: null,
2645
- sfp: null,
2646
- },
2647
- };
2648
- }
2649
- return {
2650
- start,
2651
- endExclusive: start + 1,
2652
- surface: first.surface,
2653
- payload: {
2654
- negative: false,
2655
- polite: reasonCopulaTokenPoliteness(first),
2656
- past: false,
2657
- connective: isCopulaDaRenyouToken(first),
2658
- additiveMo: false,
2659
- conditionalNara: false,
2660
- conjecture: null,
2661
- sfp: null,
2662
- },
2663
- };
2664
- }
2665
- function reasonCopulaTokenPoliteness(token) {
2666
- return isPoliteCopulaPos(token.pos) || token.dictionaryForm === "です";
2667
- }
2668
- function reasonCopulaConjectureShellAt(tokens, start) {
2669
- const first = tokens[start];
2670
- if (first === undefined) {
2671
- return null;
2672
- }
2673
- const firstPoliteness = conjectureCopulaPoliteness(first.pos);
2674
- if (firstPoliteness !== null) {
2675
- return reasonCopulaConjectureShell(tokens, start, start + 1, firstPoliteness, false);
2676
- }
2677
- const next = nextContentTokenIndex(tokens, start + 1, tokens.length);
2678
- const nextToken = next === null ? undefined : tokens[next];
2679
- if (next === null || nextToken === undefined || !isPastAuxiliaryPos(nextToken.pos)) {
2680
- return null;
2681
- }
2682
- if (isVolitionalInflection(nextToken.pos)) {
2683
- return reasonCopulaConjectureShell(tokens, start, next + 1, reasonCopulaTokenPoliteness(first) ? "polite" : "plain", true);
2684
- }
2685
- if (isPastAuxConditionalForm(nextToken.pos)) {
2686
- return null;
2687
- }
2688
- const after = nextContentTokenIndex(tokens, next + 1, tokens.length);
2689
- const afterToken = after === null ? undefined : tokens[after];
2690
- const afterPoliteness = afterToken === undefined ? null : conjectureCopulaPoliteness(afterToken.pos);
2691
- if (after === null || afterToken === undefined || afterPoliteness === null || !isBasicCopulaAuxToken(afterToken)) {
2692
- return null;
2693
- }
2694
- return reasonCopulaConjectureShell(tokens, start, after + 1, afterPoliteness, true);
2695
- }
2696
- function reasonCopulaConjectureShell(tokens, start, endExclusive, politeness, past) {
2697
- const polite = politeness === "polite";
2698
- return {
2699
- start,
2700
- endExclusive,
2701
- surface: markerSurface(tokens, start, endExclusive),
2702
- payload: {
2703
- negative: false,
2704
- polite,
2705
- past,
2706
- connective: false,
2707
- additiveMo: false,
2708
- conditionalNara: false,
2709
- conjecture: { polite },
2710
- sfp: null,
2711
- },
2712
- };
2713
- }
2714
- function reasonCopulaNegativeConjecture(negativeHead, auxTokens) {
2715
- let conjecture = negativeHead !== undefined && isVolitionalInflection(negativeHead.pos)
2716
- ? { polite: false }
2717
- : null;
2718
- for (const token of auxTokens) {
2719
- const conjecturePoliteness = conjectureCopulaPoliteness(token.pos);
2720
- if (conjecturePoliteness !== null) {
2721
- if (conjecture !== null)
2722
- return undefined;
2723
- conjecture = { polite: conjecturePoliteness === "polite" };
2724
- continue;
2725
- }
2726
- if (!isReasonCopulaNegativeShellAuxiliary(token.pos))
2727
- return undefined;
2728
- }
2729
- return conjecture;
2730
- }
2731
- const REASON_COPULA_REALIZABLE_SFP_EFFECTS = new Set(["ne", "na_excl", "jan", "yone_confirm", "explanatory"]);
2732
- function isRealizableReasonCopulaSfpEffect(effect) {
2733
- return REASON_COPULA_REALIZABLE_SFP_EFFECTS.has(effect);
2734
- }
2735
- function reasonCopulaTerminalSfpAt(tokens, index, payload) {
2736
- if (index === null || tokens[index] === undefined) {
2737
- return null;
2738
- }
2739
- if (payload.negative || payload.connective) {
2740
- return null;
2741
- }
2742
- const cursor = new TokenCursor(tokens, index, tokens.length);
2743
- const detected = detectSfpWithNode(cursor, 助動詞, true);
2744
- if (detected === null || cursor.pos <= index) {
2745
- return null;
2746
- }
2747
- const effect = detected.node.effect;
2748
- if (effect !== null && !isRealizableReasonCopulaSfpEffect(effect)) {
2749
- return null;
2750
- }
2751
- return {
2752
- markerSpan: {
2753
- start: index,
2754
- endExclusive: cursor.pos,
2755
- surface: markerSurface(tokens, index, cursor.pos),
2756
- role: "terminal_sfp",
2757
- },
2758
- sfp: { effect, surface: detected.node.surface },
2759
- };
2760
- }
2761
- function quoteMarkerSpanForHostlessReasonCopula(tokens, index) {
2762
- const token = index === null ? undefined : tokens[index];
2763
- if (index === null || token === undefined) {
2764
- return null;
2765
- }
2766
- if (token.surface !== "と" && token.surface !== "って") {
2767
- return null;
2768
- }
2769
- return {
2770
- start: index,
2771
- endExclusive: index + 1,
2772
- surface: token.surface,
2773
- role: "quotative_marker",
2774
- };
2775
- }
2776
- function hostlessReasonCopulaCanEndBefore(token) {
2777
- return token === undefined || isClausePunctuationToken(token);
2778
- }
2779
- function isStrictReasonKaraToken(token) {
2780
- return token !== undefined &&
2781
- (token.surface === "から" || token.dictionaryForm === "から") &&
2782
- (token.pos & POS01) === 助詞_接続助詞;
2783
- }
2784
- function isBasicCopulaAuxToken(token) {
2785
- if (token === undefined || (token.pos & POS0) !== 助動詞) {
2786
- return false;
2787
- }
2788
- const pos4 = token.pos & POS4;
2789
- return pos4 === 助動詞_ダ ||
2790
- pos4 === 助動詞_デス ||
2791
- token.dictionaryForm === "だ" ||
2792
- token.dictionaryForm === "です";
2793
- }
2794
- function isCopulaDaRenyouToken(token) {
2795
- return token.surface === "で" &&
2796
- (token.pos & (POS4 | POS5A)) === (助動詞_ダ | 連用形_);
2797
- }
2798
- function collectQuoteStructuralRelationsFromOptions(options) {
2799
- const tokens = options.tokens;
2800
- const existingQuoteRelations = collectQuoteStructuralRelations({
2801
- tokens,
2802
- cursor: new TokenCursor(tokens, 0, tokens.length),
2803
- lookups: options.lookups,
2804
- });
2805
- const copulaClosedTokaRelations = collectCopulaClosedTokaQuoteRelations({
2806
- tokens,
2807
- layout: options.layout,
2808
- contentMap: options.contentMap,
2809
- lookups: options.lookups,
2810
- });
2811
- const relations = [
2812
- ...existingQuoteRelations.filter((relation) => !copulaClosedTokaRelations.some((full) => supersedesPartialQuoteMarkerRelation(full, relation))),
2813
- ...collectBareKaQuestionContentRelations({
2814
- tokens,
2815
- layout: options.layout,
2816
- contentMap: options.contentMap,
2817
- lookups: options.lookups,
2818
- }),
2819
- ...copulaClosedTokaRelations,
2820
- ];
2821
- return relations.map((relation) => {
2822
- const quote = relation.quote;
2823
- if (quote === undefined)
2824
- return relation;
2825
- if (quote.questionBoundaryKind === "bare_ka" || quote.questionBoundaryKind === "nominalized_no_ka") {
2826
- return relation;
2827
- }
2828
- if (quote.explicitQuotation === true && relation.renderEnabledByDefault !== true) {
2829
- return relation;
2830
- }
2831
- if (quote.markerRealization !== undefined) {
2832
- return relation;
2833
- }
2834
- const hostPlan = options.contentMap.get(quote.hostMatch.hostIdx)?.renderPlan ?? null;
2835
- const attributiveTypification = TYPIFICATION_QUOTATIVE_HEADS.has(attributiveModifierPlanSourceFacts(hostPlan)?.headDictionaryForm ?? "");
2836
- const contentPredicateIdx = options.layout.clauses.flatMap((clause) => clause.end <= quote.contentSpan.start || quote.contentSpan.endExclusive <= clause.start
2837
- ? []
2838
- : clause.predicates).filter((index) => quote.contentSpan.start <= index &&
2839
- index < quote.contentSpan.endExclusive &&
2840
- options.contentMap.has(index)).at(-1) ?? null;
2841
- const startPlan = options.contentMap.get(quote.contentSpan.start)?.renderPlan ?? null;
2842
- const contentPredicatePlan = contentPredicateIdx === null
2843
- ? null
2844
- : options.contentMap.get(contentPredicateIdx)?.renderPlan ?? null;
2845
- const conjectureQuote = renderPlanHasConjectureQuote(contentPredicatePlan);
2846
- const predicateIdx = contentPredicateIdx !== null
2847
- ? renderPlanTerminalSfp(options.contentMap.get(contentPredicateIdx)?.renderPlan ?? null) !== null
2848
- ? contentPredicateIdx
2849
- : null
2850
- : renderPlanTerminalSfp(startPlan) !== null && options.contentMap.has(quote.contentSpan.start)
2851
- ? quote.contentSpan.start
2852
- : null;
2853
- if (predicateIdx === null) {
2854
- const absorbed = attributiveTypification || conjectureQuote
2855
- ? null
2856
- : markerAbsorbedContentCopula(options.layout, tokens, quote, options.contentMap);
2857
- if (absorbed !== null) {
2858
- return {
2859
- ...relation,
2860
- renderEnabledByDefault: true,
2861
- quote: {
2862
- ...quote,
2863
- contentPredicateIdx: absorbed.nounIdx,
2864
- markerAbsorbedContentCopulaIdx: absorbed.copulaIdx,
2865
- },
2866
- };
2867
- }
2868
- const withoutAbsorption = quote.markerAbsorbedContentCopulaIdx === undefined
2869
- ? relation
2870
- : { ...relation, quote: withoutMarkerAbsorbedCopula(quote) };
2871
- return attributiveTypification || conjectureQuote
2872
- ? { ...withoutAbsorption, renderEnabledByDefault: true }
2873
- : withoutAbsorption;
2874
- }
2875
- const span = options.contentMap.get(predicateIdx);
2876
- if (span === undefined)
2877
- return relation;
2878
- const sfp = renderPlanTerminalSfp(span.renderPlan);
2879
- if (sfp === null)
2880
- return relation;
2881
- const requestSource = quote.request === undefined && isPredicateHeadTailChainRenderPlan(contentPredicatePlan)
2882
- ? tailRootQuoteRequestSourceEvidence(contentPredicatePlan.realization.root) : null;
2883
- const enriched = requestSource === null ? relation
2884
- : quoteRelationWithRequestSourceEvidence(tokens, relation, requestSource, options.lookups);
2885
- return {
2886
- ...enriched,
2887
- renderEnabledByDefault: true,
2888
- quote: {
2889
- ...enriched.quote,
2890
- terminalSfp: sfp,
2891
- terminalSfpMarkerBridgeSpan: terminalSfpQuoteMarkerBridgeSpan(tokens, sfp, enriched.quote.markerIdx),
2892
- contentPredicateIdx: predicateIdx
2893
- },
2894
- };
2895
- });
2896
- }
2897
- function markerAbsorbedContentCopula(layout, tokens, quote, contentMap) {
2898
- if (quoteHostMatchIsAttributiveIu(tokens, quote.hostMatch)) {
2899
- return null;
2900
- }
2901
- const closure = copulaClosedNominalPredicateBeforeMarkerAt(tokens, quote.markerSpan.start);
2902
- const contentAnchorIdx = closure === null
2903
- ? null
2904
- : copulaClosedContentAnchorIdx(layout, tokens, contentMap, closure.nounIdx, closure.copulaIdx);
2905
- if (closure === null ||
2906
- contentAnchorIdx === null ||
2907
- closure.nounIdx < quote.contentSpan.start ||
2908
- quote.contentSpan.endExclusive <= closure.copulaIdx) {
2909
- return null;
2910
- }
2911
- const contentPlan = contentMap.get(contentAnchorIdx)?.renderPlan ?? null;
2912
- if (contentPlan?.kind !== "lemma" ||
2913
- (contentPlan.koreanPos !== 명사 && contentPlan.koreanPos !== 대명사)) {
2914
- return null;
2915
- }
2916
- if (renderPlanTerminalSfp(contentPlan) !== null) {
2917
- return null;
2918
- }
2919
- return { nounIdx: contentAnchorIdx, copulaIdx: closure.copulaIdx };
2920
- }
2921
- function withoutMarkerAbsorbedCopula(quote) {
2922
- const { markerAbsorbedContentCopulaIdx: _removed, ...rest } = quote;
2923
- return rest;
2924
- }
2925
- function supersedesPartialQuoteMarkerRelation(full, partial) {
2926
- const fullQuote = full.quote;
2927
- const partialQuote = partial.quote;
2928
- return fullQuote !== undefined &&
2929
- partialQuote !== undefined &&
2930
- fullQuote.hostMatch.hostIdx === partialQuote.hostMatch.hostIdx &&
2931
- fullQuote.markerSpan.start <= partialQuote.markerSpan.start &&
2932
- partialQuote.markerSpan.endExclusive <= fullQuote.markerSpan.endExclusive;
2933
- }
2934
- function renderPlanHasConjectureQuote(plan) {
2935
- if (!isPredicateHeadTailChainRenderPlan(plan))
2936
- return false;
2937
- const layers = plan.realization.root.tail.kind === "auxLayer"
2938
- ? [plan.realization.root.tail]
2939
- : [plan.realization.root.tail.inner, ...collectConjectureQuoteOuterLayers(plan.realization.root.tail.outer)];
2940
- return layers.some((layer) => {
2941
- const quoteIdx = layer.ops.findIndex((op) => op.kind === "connective" && op.connective === "quotative");
2942
- return quoteIdx >= 0 && layer.ops.slice(0, quoteIdx).some((op) => op.kind === "conjecture" || (op.kind === "copula" && op.variant === "conjecture"));
2943
- });
2944
- }
2945
- function collectConjectureQuoteOuterLayers(node) {
2946
- return node.kind === "auxLayer"
2947
- ? [node]
2948
- : [node.inner, ...collectConjectureQuoteOuterLayers(node.outer)];
2949
- }
2950
- function renderPlanTerminalSfp(plan) {
2951
- if (plan === null)
2952
- return null;
2953
- if (isPredicateHeadTailChainRenderPlan(plan))
2954
- return plan.realization.root.sfp;
2955
- if (plan.kind === "lemma" || plan.kind === "copulaPredicate")
2956
- return plan.terminalSfp ?? null;
2957
- return null;
2958
- }
2959
- function contentSpanStartForClause(start, endExclusive, primaryPredicate, contentMap) {
2960
- if (primaryPredicate !== null && contentMap.has(primaryPredicate)) {
2961
- return primaryPredicate;
2962
- }
2963
- const sortedContentStarts = Array.from(contentMap.keys()).sort((left, right) => left - right);
2964
- for (const contentStart of sortedContentStarts) {
2965
- if (start <= contentStart && contentStart < endExclusive) {
2966
- return contentStart;
2967
- }
2968
- }
2969
- return null;
2970
- }
2971
- export function structuralRelationNodeId(clauseIndex) {
2972
- return `clause:${clauseIndex}`;
2973
- }
2974
- export function structuralRelationContentSpanId(contentStart) {
2975
- return `content:${contentStart}`;
2976
- }
2977
- function markerSpanFromMatch(start, match, role = `${match.relationPolicy}_marker`) {
2978
- return {
2979
- start,
2980
- endExclusive: match.endExclusive,
2981
- surface: match.surface,
2982
- role,
2983
- };
2984
- }
2985
- function nextClauseIndex(layout, sourceClauseIndex) {
2986
- const next = sourceClauseIndex + 1;
2987
- return next < layout.clauses.length ? next : null;
2988
- }
2989
- function hasStrictReasonBoundary(tokens, markerStart, markerEndExclusive, sourceClauseEndExclusive) {
2990
- if (markerStart >= sourceClauseEndExclusive) {
2991
- return new TokenCursor(tokens, sourceClauseEndExclusive, markerStart).current() === undefined;
2992
- }
2993
- const c = new TokenCursor(tokens, markerEndExclusive, sourceClauseEndExclusive);
2994
- while (c.current()) {
2995
- const token = c.current();
2996
- if (isClausePunctuationToken(token)) {
2997
- return true;
2998
- }
2999
- return false;
3000
- }
3001
- return markerEndExclusive === sourceClauseEndExclusive;
3002
- }
3003
- function hasStrictReasonEvidence(tokens, sourceClause, markerStart, markerEndExclusive, contentMap) {
3004
- return hasStrictReasonBoundary(tokens, markerStart, markerEndExclusive, sourceClause.end) &&
3005
- hasStrictReasonSource(tokens, sourceClause, markerStart, contentMap);
3006
- }
3007
- function hasReasonCleftEvidence(layout, tokens, contentMap, sourceClause, markerStart, markerEndExclusive) {
3008
- return hasStrictReasonBoundary(tokens, markerStart, markerEndExclusive, sourceClause.end) &&
3009
- hasReasonCleftSource(layout, tokens, contentMap, markerStart);
3010
- }
3011
- function listingClosureCanCloseBeforeClauseBoundary(tokens, start, upperBoundExclusive, lookups) {
3012
- const next = nextContentTokenIndex(tokens, start, upperBoundExclusive);
3013
- if (next === null) {
3014
- return true;
3015
- }
3016
- const nextToken = tokens[next];
3017
- if (nextToken !== undefined && isClausePunctuationToken(nextToken)) {
3018
- return true;
3019
- }
3020
- if (nextToken !== undefined && (nextToken.pos & POS0) === 動詞 && lookups.SPEECH_VERBS.has(nextToken.dictionaryForm || nextToken.surface)) {
3021
- return false;
3022
- }
3023
- return false;
3024
- }
3025
- function findCorrelativeDegreeMarker(tokens, start, upperBoundExclusive) {
3026
- let index = start;
3027
- while (index < upperBoundExclusive) {
3028
- const token = tokens[index];
3029
- if (token === undefined) {
3030
- break;
3031
- }
3032
- if (isClausePunctuationToken(token)) {
3033
- return null;
3034
- }
3035
- const degreeMatch = relationConnectiveSpansAt(new TokenCursor(tokens, index))
3036
- .find((match) => match.relationPolicy === "correlative_degree" && match.markerRole === "degree_marker");
3037
- if (degreeMatch !== undefined) {
3038
- return {
3039
- start: index,
3040
- endExclusive: degreeMatch.endExclusive,
3041
- markerSpan: markerSpanFromMatch(index, degreeMatch, degreeMatch.markerRole ?? "degree_marker"),
3042
- };
3043
- }
3044
- index += 1;
3045
- }
3046
- return null;
3047
- }
3048
- function correlativeSearchEnd(tokens, start) {
3049
- const c = new TokenCursor(tokens, start, tokens.length);
3050
- while (c.current()) {
3051
- const token = c.current();
3052
- if (isHardTerminalPunctuationToken(token)) {
3053
- return c.pos;
3054
- }
3055
- c.advance();
3056
- }
3057
- return tokens.length;
3058
- }
3059
- const relationTokenLemma = (token) => token.dictionaryForm || token.surface;
3060
- function correlativeConfidence(tokens, leftPredicate, rightPredicate) {
3061
- if (leftPredicate === undefined ||
3062
- rightPredicate === undefined ||
3063
- leftPredicate.predicateIdx === rightPredicate.predicateIdx) {
3064
- return "weak";
3065
- }
3066
- const headLemma = relationTokenLemma(tokens[leftPredicate.predicateIdx]);
3067
- const closureLemma = relationTokenLemma(tokens[leftPredicate.closureIdx]);
3068
- const rightHeadLemma = relationTokenLemma(tokens[rightPredicate.predicateIdx]);
3069
- const rightClosureLemma = relationTokenLemma(tokens[rightPredicate.closureIdx]);
3070
- const carrierIdentity = TE_TAIL_CONTINUATION_LEXEME_ENTRY_BY_FORM.get(closureLemma) ?? closureLemma;
3071
- return ((headLemma.length > 0 && headLemma === rightHeadLemma) ||
3072
- (carrierIdentity === (TE_TAIL_CONTINUATION_LEXEME_ENTRY_BY_FORM.get(rightHeadLemma) ?? rightHeadLemma) &&
3073
- carrierIdentity === (TE_TAIL_CONTINUATION_LEXEME_ENTRY_BY_FORM.get(rightClosureLemma) ?? rightClosureLemma))) ? "strict" : "weak";
3074
- }
3075
- function nounPhraseTargetAfter(tokens, start, upperBoundExclusive) {
3076
- const first = nextContentTokenIndex(tokens, start, upperBoundExclusive);
3077
- if (first === null) {
3078
- return null;
3079
- }
3080
- const c = new TokenCursor(tokens, first, upperBoundExclusive);
3081
- while (c.current()) {
3082
- const token = c.current();
3083
- const pos0 = token.pos & POS0;
3084
- if (pos0in(pos0, NOMINAL_BITS)) {
3085
- return tokenSpanWithKind(first, c.pos + 1, "noun_phrase");
3086
- }
3087
- if (pos0 === 形状詞 || pos0 === 形容詞0 || pos0 === 連体詞 || token.surface === "な" || token.surface === "の") {
3088
- c.advance();
3089
- continue;
3090
- }
3091
- return null;
3092
- }
3093
- return null;
3094
- }
3095
- function hasStrictReasonSource(tokens, sourceClause, markerStart, contentMap) {
3096
- const primaryPredicate = sourceClause.primaryPredicate;
3097
- if (primaryPredicate === null || primaryPredicate >= markerStart) {
3098
- return false;
3099
- }
3100
- const sourceSpan = contentMap.get(primaryPredicate);
3101
- if (sourceSpan?.koreanPos === 형용사) {
3102
- return true;
3103
- }
3104
- return precedingTokenOpensStrictReason(tokens, markerStart - 1, sourceClause.start);
3105
- }
3106
- function hasReasonCleftSource(layout, tokens, contentMap, markerStart) {
3107
- const occurrence = layout.predicateOccurrenceBefore(tokens, contentMap, markerStart);
3108
- if (occurrence === undefined || occurrence.predicateIdx >= markerStart) {
3109
- return false;
3110
- }
3111
- const closure = tokens[occurrence.closureIdx];
3112
- return closure !== undefined && isClauseClosingInflection(closure.pos);
3113
- }
3114
- function previousContentTokenIndex(tokens, start, lowerBoundInclusive) {
3115
- for (let index = start; index >= lowerBoundInclusive; index -= 1) {
3116
- const token = tokens[index];
3117
- if (token === undefined) {
3118
- continue;
3119
- }
3120
- if (isClausePunctuationToken(token)) {
3121
- continue;
3122
- }
3123
- return index;
3124
- }
3125
- return null;
3126
- }
3127
- function nextContentTokenIndex(tokens, start, upperBoundExclusive) {
3128
- for (let index = start; index < upperBoundExclusive; index += 1) {
3129
- const token = tokens[index];
3130
- if (token === undefined) {
3131
- continue;
3132
- }
3133
- return index;
3134
- }
3135
- return null;
3136
- }
3137
- function projectionRequest(sourceForm, match) {
3138
- return {
3139
- sourceForm,
3140
- connectiveKind: match.connectiveKind,
3141
- ...(match.targetSlot === undefined ? {} : { targetSlot: match.targetSlot }),
3142
- };
3143
- }
3144
- function layoutBoundaryRelationPayload(match) {
3145
- return match.layoutBoundaryPolicy === undefined ? {} : { layoutBoundaryPolicy: match.layoutBoundaryPolicy };
3146
- }
3147
- function renderEnabledRelationPayload(match) {
3148
- return match.renderEnabledByDefault === true ? { renderEnabledByDefault: true } : {};
3149
- }
3150
- function layoutBoundaryDiagnosticPayload(match) {
3151
- return match.layoutBoundaryPolicy === undefined ? {} : { layoutBoundaryPolicy: match.layoutBoundaryPolicy };
3152
- }
3153
- function tokenSpan(start, endExclusive) {
3154
- return { start, endExclusive };
3155
- }
3156
- function tokenSpanWithKind(start, endExclusive, kind) {
3157
- return { start, endExclusive, kind };
3158
- }