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.
- package/CHANGELOG.md +11 -0
- package/README.en.md +24 -21
- package/README.md +66 -73
- package/data/config/lookup_tables.toml +9 -4
- package/dist/analyzer/config.js +1 -3
- package/dist/analyzer/connect.d.ts +1 -1
- package/dist/analyzer/connect.js +2 -1
- package/dist/analyzer/dictionary-provider.d.ts +2 -0
- package/dist/analyzer/dictionary-provider.js +3 -0
- package/dist/analyzer/haru-dictionary-provider.js +17 -6
- package/dist/analyzer/node-dictionary-provider.d.ts +19 -8
- package/dist/analyzer/node-dictionary-provider.js +109 -48
- package/dist/analyzer/node-helpers.js +12 -18
- package/dist/analyzer/page-cached-source.d.ts +59 -0
- package/dist/analyzer/page-cached-source.js +157 -0
- package/dist/analyzer-lexicon.js +6 -1
- package/dist/default-provider.d.ts +1 -1
- package/dist/default-provider.js +14 -6
- package/dist/dictionary/derivation.d.ts +0 -1
- package/dist/dictionary/morpheme.js +13 -7
- package/dist/dictionary/pattern.js +1 -1
- package/dist/dictionary/sense-normalization.js +3 -3
- package/dist/generator/aux-map.d.ts +1 -0
- package/dist/generator/aux-map.js +1 -1
- package/dist/generator/conjugator.d.ts +0 -1
- package/dist/generator/conjugator.js +0 -3
- package/dist/generator/numerals.d.ts +0 -1
- package/dist/generator/numerals.js +0 -3
- package/dist/pipeline/assembler/affix-helpers.d.ts +14 -0
- package/dist/pipeline/assembler/affix-helpers.js +154 -0
- package/dist/pipeline/assembler/content-override.d.ts +3 -0
- package/dist/pipeline/assembler/content-override.js +79 -0
- package/dist/pipeline/assembler/copula-focus-plan.d.ts +10 -0
- package/dist/pipeline/assembler/copula-focus-plan.js +32 -0
- package/dist/pipeline/assembler/copula-helpers.d.ts +31 -0
- package/dist/pipeline/assembler/copula-helpers.js +192 -0
- package/dist/pipeline/assembler/lexical-layout-hypothesis.d.ts +59 -0
- package/dist/pipeline/assembler/lexical-layout-hypothesis.js +357 -0
- package/dist/pipeline/assembler/light-verb-projection.d.ts +21 -0
- package/dist/pipeline/assembler/light-verb-projection.js +43 -0
- package/dist/pipeline/assembler/nande-reason.d.ts +4 -0
- package/dist/pipeline/assembler/nande-reason.js +162 -0
- package/dist/pipeline/assembler/particle-helpers.d.ts +10 -0
- package/dist/pipeline/assembler/particle-helpers.js +57 -0
- package/dist/pipeline/assembler/quantity-spans.d.ts +24 -0
- package/dist/pipeline/assembler/quantity-spans.js +58 -0
- package/dist/pipeline/assembler/question-plan.d.ts +5 -0
- package/dist/pipeline/assembler/question-plan.js +121 -0
- package/dist/pipeline/assembler/quote-helpers.d.ts +11 -0
- package/dist/pipeline/assembler/quote-helpers.js +67 -0
- package/dist/pipeline/assembler.d.ts +47 -31
- package/dist/pipeline/assembler.js +1219 -3234
- package/dist/pipeline/assembly-content-span.d.ts +59 -0
- package/dist/pipeline/assembly-content-span.js +149 -0
- package/dist/pipeline/attributive.d.ts +2 -2
- package/dist/pipeline/attributive.js +2 -5
- package/dist/pipeline/candidate-runtime.d.ts +2 -30
- package/dist/pipeline/candidate-runtime.js +4 -125
- package/dist/pipeline/clause-layout/adverbial-predicate.d.ts +22 -0
- package/dist/pipeline/clause-layout/adverbial-predicate.js +180 -0
- package/dist/pipeline/clause-layout/attributive-boundaries.d.ts +12 -0
- package/dist/pipeline/clause-layout/attributive-boundaries.js +325 -0
- package/dist/pipeline/clause-layout/boundary-detection.d.ts +100 -0
- package/dist/pipeline/clause-layout/boundary-detection.js +729 -0
- package/dist/pipeline/clause-layout/boundary-event-common.d.ts +8 -0
- package/dist/pipeline/clause-layout/boundary-event-common.js +50 -0
- package/dist/pipeline/clause-layout/boundary-settlement.d.ts +40 -0
- package/dist/pipeline/clause-layout/boundary-settlement.js +534 -0
- package/dist/pipeline/clause-layout/chuushi-closure.js +1 -2
- package/dist/pipeline/clause-layout/connective-boundaries.d.ts +34 -0
- package/dist/pipeline/clause-layout/connective-boundaries.js +1049 -0
- package/dist/pipeline/clause-layout/final-layout.d.ts +155 -0
- package/dist/pipeline/clause-layout/final-layout.js +544 -0
- package/dist/pipeline/clause-layout/index.d.ts +5 -597
- package/dist/pipeline/clause-layout/index.js +69 -6576
- package/dist/pipeline/clause-layout/juncture-verdict.d.ts +1 -3
- package/dist/pipeline/clause-layout/layout-types.d.ts +142 -0
- package/dist/pipeline/clause-layout/layout-types.js +16 -0
- package/dist/pipeline/clause-layout/lexical-adverbial-affiliation.d.ts +1 -1
- package/dist/pipeline/clause-layout/navigation.d.ts +48 -0
- package/dist/pipeline/clause-layout/navigation.js +264 -0
- package/dist/pipeline/clause-layout/nominal-anchor-evidence.d.ts +57 -0
- package/dist/pipeline/clause-layout/nominal-anchor-evidence.js +180 -0
- package/dist/pipeline/clause-layout/nominal-anchors.d.ts +9 -0
- package/dist/pipeline/clause-layout/nominal-anchors.js +318 -0
- package/dist/pipeline/clause-layout/nominal-binding.d.ts +1 -1
- package/dist/pipeline/clause-layout/nominal-binding.js +1 -1
- package/dist/pipeline/clause-layout/nominal-frame-reach.d.ts +7 -0
- package/dist/pipeline/clause-layout/nominal-frame-reach.js +77 -0
- package/dist/pipeline/clause-layout/particle-phrase-copula.d.ts +1 -1
- package/dist/pipeline/clause-layout/phrase-enumeration.d.ts +1 -1
- package/dist/pipeline/clause-layout/phrase-enumeration.js +2 -1
- package/dist/pipeline/clause-layout/predicate-ownership.d.ts +22 -0
- package/dist/pipeline/clause-layout/predicate-ownership.js +323 -0
- package/dist/pipeline/clause-layout/predicate-parallel.d.ts +2 -1
- package/dist/pipeline/clause-layout/predicate-parallel.js +16 -1
- package/dist/pipeline/clause-layout/predicate-shape.d.ts +49 -0
- package/dist/pipeline/clause-layout/predicate-shape.js +369 -0
- package/dist/pipeline/clause-layout/predicate-token-shape.d.ts +15 -0
- package/dist/pipeline/clause-layout/predicate-token-shape.js +142 -0
- package/dist/pipeline/clause-layout/prenominal-head-reach.d.ts +29 -0
- package/dist/pipeline/clause-layout/prenominal-head-reach.js +349 -0
- package/dist/pipeline/clause-layout/proto-layout.d.ts +144 -0
- package/dist/pipeline/clause-layout/proto-layout.js +327 -0
- package/dist/pipeline/clause-layout/proto-state.d.ts +2 -1
- package/dist/pipeline/clause-layout/punctuated-copula.d.ts +1 -1
- package/dist/pipeline/clause-layout/punctuation.d.ts +8 -0
- package/dist/pipeline/clause-layout/punctuation.js +33 -0
- package/dist/pipeline/clause-layout/quote-classification.d.ts +48 -0
- package/dist/pipeline/clause-layout/quote-classification.js +430 -0
- package/dist/pipeline/clause-layout/quote-delimiters.d.ts +2 -0
- package/dist/pipeline/clause-layout/quote-delimiters.js +16 -0
- package/dist/pipeline/clause-layout/renyou-verb-reading.d.ts +1 -1
- package/dist/pipeline/clause-layout/speech-act.js +1 -1
- package/dist/pipeline/clause-layout/token-evidence.d.ts +11 -0
- package/dist/pipeline/clause-layout/token-evidence.js +41 -0
- package/dist/pipeline/clause-layout/trivia.d.ts +5 -0
- package/dist/pipeline/clause-layout/trivia.js +18 -1
- package/dist/pipeline/clause-layout/utterance-boundaries.d.ts +41 -0
- package/dist/pipeline/clause-layout/utterance-boundaries.js +627 -0
- package/dist/pipeline/clause-layout/vocative.d.ts +5 -0
- package/dist/pipeline/clause-layout/vocative.js +91 -0
- package/dist/pipeline/clause-layout/whitespace-attributive-reading.d.ts +1 -1
- package/dist/pipeline/clause-layout/whitespace-attributive-reading.js +4 -1
- package/dist/pipeline/commitment/adverbial-adjunct-routing.d.ts +3 -0
- package/dist/pipeline/commitment/adverbial-adjunct-routing.js +109 -0
- package/dist/pipeline/commitment/benefactive-span-hydration.d.ts +5 -0
- package/dist/pipeline/commitment/benefactive-span-hydration.js +49 -0
- package/dist/pipeline/commitment/candidate-projection.d.ts +29 -0
- package/dist/pipeline/commitment/candidate-projection.js +512 -0
- package/dist/pipeline/commitment/connective-refinement.d.ts +8 -0
- package/dist/pipeline/commitment/connective-refinement.js +152 -0
- package/dist/pipeline/commitment/deferred-reanalysis.d.ts +1 -1
- package/dist/pipeline/commitment/final-sense-sync.d.ts +8 -0
- package/dist/pipeline/commitment/final-sense-sync.js +264 -0
- package/dist/pipeline/commitment/head-owner-candidate-selection.d.ts +15 -0
- package/dist/pipeline/commitment/head-owner-candidate-selection.js +158 -0
- package/dist/pipeline/commitment/particle-roles.d.ts +1 -1
- package/dist/pipeline/commitment/particle-roles.js +546 -398
- package/dist/pipeline/commitment/passive-class.d.ts +1 -1
- package/dist/pipeline/commitment/passive-class.js +2 -3
- package/dist/pipeline/commitment/quantity-span-commitment.d.ts +4 -0
- package/dist/pipeline/commitment/quantity-span-commitment.js +37 -0
- package/dist/pipeline/commitment/quote-refinement.d.ts +6 -0
- package/dist/pipeline/commitment/quote-refinement.js +130 -0
- package/dist/pipeline/commitment/role-case-shadow.d.ts +0 -4
- package/dist/pipeline/commitment/role-case-shadow.js +0 -3
- package/dist/pipeline/commitment/semantic-frame.d.ts +1 -1
- package/dist/pipeline/commitment/semantic-frame.js +2 -3
- package/dist/pipeline/commitment/span-evidence.d.ts +2 -3
- package/dist/pipeline/commitment/span-evidence.js +7 -18
- package/dist/pipeline/commitment/stem-candidate-selection.d.ts +24 -0
- package/dist/pipeline/commitment/stem-candidate-selection.js +663 -0
- package/dist/pipeline/commitment/te-connective-resolution.d.ts +1 -1
- package/dist/pipeline/commitment/te-connective-resolution.js +0 -1
- package/dist/pipeline/commitment/types.d.ts +1 -1
- package/dist/pipeline/commitment/types.js +1 -1
- package/dist/pipeline/commitment/voice-reading-resolution.d.ts +1 -1
- package/dist/pipeline/commitment/voice-reading-resolution.js +117 -34
- package/dist/pipeline/compounds/compound-tail-tokens.d.ts +12 -0
- package/dist/pipeline/compounds/compound-tail-tokens.js +37 -0
- package/dist/pipeline/compounds/compound-translation-candidates.d.ts +49 -0
- package/dist/pipeline/compounds/compound-translation-candidates.js +154 -0
- package/dist/pipeline/compounds/compound-verbs.js +4 -9
- package/dist/pipeline/compounds/index.d.ts +24 -29
- package/dist/pipeline/compounds/index.js +361 -383
- package/dist/pipeline/content-resolver/postaux-pattern-rendering.d.ts +0 -2
- package/dist/pipeline/content-resolver/postaux-pattern-rendering.js +1 -5
- package/dist/pipeline/content-resolver/types.d.ts +0 -4
- package/dist/pipeline/content-resolver.js +641 -492
- package/dist/pipeline/context.d.ts +2 -1
- package/dist/pipeline/context.js +4 -3
- package/dist/pipeline/core.d.ts +8 -95
- package/dist/pipeline/core.js +1339 -7183
- package/dist/pipeline/deferred-commitment.d.ts +2 -17
- package/dist/pipeline/deferred-commitment.js +406 -2353
- package/dist/pipeline/demo-discourse.d.ts +1 -1
- package/dist/pipeline/fallback/index.d.ts +0 -1
- package/dist/pipeline/fallback/index.js +3 -7
- package/dist/pipeline/fallback/orphan-unit-absorption.d.ts +4 -0
- package/dist/pipeline/fallback/orphan-unit-absorption.js +57 -0
- package/dist/pipeline/fallback/unsupported-raw.d.ts +0 -2
- package/dist/pipeline/fallback/unsupported-raw.js +0 -10
- package/dist/pipeline/head-tail/boundary/clause-start.js +1 -10
- package/dist/pipeline/head-tail/boundary/ka-ownership.d.ts +3 -2
- package/dist/pipeline/head-tail/boundary/ka-ownership.js +16 -9
- package/dist/pipeline/head-tail/boundary/marker.js +1 -1
- package/dist/pipeline/head-tail/boundary/punctuation.d.ts +0 -1
- package/dist/pipeline/head-tail/boundary/punctuation.js +1 -6
- package/dist/pipeline/head-tail/boundary/quote-marker.js +1 -1
- package/dist/pipeline/head-tail/candidate/collect.d.ts +3 -3
- package/dist/pipeline/head-tail/candidate/context.d.ts +1 -1
- package/dist/pipeline/head-tail/candidate/context.js +1 -1
- package/dist/pipeline/head-tail/candidate/evidence.d.ts +0 -2
- package/dist/pipeline/head-tail/candidate/evidence.js +0 -22
- package/dist/pipeline/head-tail/candidate/owner-payload.d.ts +1 -1
- package/dist/pipeline/head-tail/candidate/semantic-classifiers.d.ts +2 -1
- package/dist/pipeline/head-tail/data/honorific-formulaic-arm-table.d.ts +0 -1
- package/dist/pipeline/head-tail/data/honorific-formulaic-arm-table.js +0 -3
- package/dist/pipeline/head-tail/data/quoted-reporting-sets.d.ts +2 -0
- package/dist/pipeline/head-tail/data/quoted-reporting-sets.js +4 -0
- package/dist/pipeline/head-tail/grammar.d.ts +0 -1
- package/dist/pipeline/head-tail/head/adapters/nominal/commit.js +3 -2
- package/dist/pipeline/head-tail/head/adapters/nominal/grammar.d.ts +2 -1
- package/dist/pipeline/head-tail/head/adapters/nominal/integration.d.ts +2 -2
- package/dist/pipeline/head-tail/head/adapters/nominal/integration.js +6 -6
- package/dist/pipeline/head-tail/head/adapters/nominal/owner-arbitration.d.ts +1 -1
- package/dist/pipeline/head-tail/head/adapters/nominal/parser.d.ts +1 -2
- package/dist/pipeline/head-tail/head/adapters/nominal/parser.js +20 -24
- package/dist/pipeline/head-tail/head/adapters/nominal/plan-lifecycle.d.ts +1 -1
- package/dist/pipeline/head-tail/head/adapters/nominal/renyou-nominal-head.js +2 -2
- package/dist/pipeline/head-tail/integration/content-head-dispatch.d.ts +5 -6
- package/dist/pipeline/head-tail/integration/content-head-dispatch.js +2 -5
- package/dist/pipeline/head-tail/integration/copula-focus-adjunct.js +1 -1
- package/dist/pipeline/head-tail/integration/copula-host-chain.js +1 -1
- package/dist/pipeline/head-tail/integration/honorific-formulaic-host.d.ts +25 -0
- package/dist/pipeline/head-tail/integration/honorific-formulaic-host.js +142 -0
- package/dist/pipeline/head-tail/integration/nominal-assembly.d.ts +2 -2
- package/dist/pipeline/head-tail/integration/nominal-assembly.js +1 -1
- package/dist/pipeline/head-tail/integration/particle-phrase-copula.d.ts +1 -1
- package/dist/pipeline/head-tail/integration/semantic-carrier-predicate.js +3 -20
- package/dist/pipeline/head-tail/integration/tail-assembly.d.ts +2 -3
- package/dist/pipeline/head-tail/integration/tail-assembly.js +20 -145
- package/dist/pipeline/head-tail/lifecycle/commit-context.d.ts +1 -1
- package/dist/pipeline/head-tail/lifecycle/head-tail-render-plan.d.ts +1 -1
- package/dist/pipeline/head-tail/lifecycle/hooks.d.ts +2 -3
- package/dist/pipeline/head-tail/lifecycle/hooks.js +0 -9
- package/dist/pipeline/head-tail/lifecycle/plan-context.d.ts +1 -1
- package/dist/pipeline/head-tail/lifecycle/plan-context.js +1 -1
- package/dist/pipeline/head-tail/lifecycle/registry.d.ts +3 -4
- package/dist/pipeline/head-tail/lifecycle/registry.js +1 -4
- package/dist/pipeline/head-tail/lifecycle/render.js +2 -2
- package/dist/pipeline/head-tail/line-memo.d.ts +1 -1
- package/dist/pipeline/head-tail/line-memo.js +25 -6
- package/dist/pipeline/head-tail/tail/chain.d.ts +3 -3
- package/dist/pipeline/head-tail/tail/families/tokoro-semantics.d.ts +0 -1
- package/dist/pipeline/head-tail/tail/families/tokoro-semantics.js +2 -1
- package/dist/pipeline/head-tail/tail/families/youda-semantics.js +1 -4
- package/dist/pipeline/head-tail/tail/postverb-events.d.ts +0 -180
- package/dist/pipeline/head-tail/tail/postverb-events.js +2 -2249
- package/dist/pipeline/head-tail/tail/postverb-tail-classifier.js +3 -4
- package/dist/pipeline/head-tail/tail/predicate-root/aspect-semantics.d.ts +10 -8
- package/dist/pipeline/head-tail/tail/predicate-root/aspect-semantics.js +2 -55
- package/dist/pipeline/head-tail/tail/predicate-root/benefactive-hydration.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/benefactive-hydration.js +1 -18
- package/dist/pipeline/head-tail/tail/predicate-root/boundary-semantics.js +4 -2
- package/dist/pipeline/head-tail/tail/predicate-root/classifiers/causative-aux.d.ts +4 -0
- package/dist/pipeline/head-tail/tail/predicate-root/classifiers/causative-aux.js +11 -0
- package/dist/pipeline/head-tail/tail/predicate-root/classifiers/copula-concessive.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/classifiers/copula-concessive.js +14 -3
- package/dist/pipeline/head-tail/tail/predicate-root/classifiers/tokens.d.ts +0 -2
- package/dist/pipeline/head-tail/tail/predicate-root/classifiers/tokens.js +3 -12
- package/dist/pipeline/head-tail/tail/predicate-root/commit.d.ts +2 -1
- package/dist/pipeline/head-tail/tail/predicate-root/commit.js +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/commitment-bridge.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/connective-ops.d.ts +9 -0
- package/dist/pipeline/head-tail/tail/predicate-root/connective-ops.js +69 -0
- package/dist/pipeline/head-tail/tail/predicate-root/connective-render.d.ts +7 -0
- package/dist/pipeline/head-tail/tail/predicate-root/connective-render.js +52 -0
- package/dist/pipeline/head-tail/tail/predicate-root/connective-surface-lookup.d.ts +11 -0
- package/dist/pipeline/head-tail/tail/predicate-root/connective-surface-lookup.js +114 -0
- package/dist/pipeline/head-tail/tail/predicate-root/derivational-host-base.js +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/grammar.d.ts +2 -14
- package/dist/pipeline/head-tail/tail/predicate-root/grammar.js +19 -128
- package/dist/pipeline/head-tail/tail/predicate-root/head-contract-table.d.ts +2 -1
- package/dist/pipeline/head-tail/tail/predicate-root/head-contract-table.js +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/head-hydration.js +2 -17
- package/dist/pipeline/head-tail/tail/predicate-root/inspect.d.ts +2 -8
- package/dist/pipeline/head-tail/tail/predicate-root/inspect.js +12 -16
- package/dist/pipeline/head-tail/tail/predicate-root/integration/attributive-boundary.d.ts +35 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/attributive-boundary.js +1079 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/clause-boundaries.d.ts +69 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/clause-boundaries.js +2972 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/contracts.d.ts +118 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/end-boundary-inference.d.ts +22 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/end-boundary-inference.js +698 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/head-admission.d.ts +39 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/head-admission.js +689 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/head-profiles.d.ts +13 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/head-profiles.js +138 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/parse-clause.d.ts +60 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/parse-clause.js +2013 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/predicate-evidence.d.ts +15 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/predicate-evidence.js +109 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/predicate-start-evidence.d.ts +48 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/predicate-start-evidence.js +608 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/readiness.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/integration/readiness.js +3 -2
- package/dist/pipeline/head-tail/tail/predicate-root/integration/stem-candidates.d.ts +177 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/stem-candidates.js +1885 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/tail-arbitration.d.ts +13 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/tail-arbitration.js +283 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/tail-chunk-scan-end.d.ts +8 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/tail-chunk-scan-end.js +389 -0
- package/dist/pipeline/head-tail/tail/predicate-root/integration/zero-head.js +3 -2
- package/dist/pipeline/head-tail/tail/predicate-root/integration.d.ts +9 -166
- package/dist/pipeline/head-tail/tail/predicate-root/integration.js +254 -10644
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/connective-tail.d.ts +51 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/connective-tail.js +808 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/connective.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/connective.js +5 -3
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/copula-tail.d.ts +22 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/copula-tail.js +156 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/copula.d.ts +8 -2
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/copula.js +177 -51
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/lexical-idioms.d.ts +37 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/lexical-idioms.js +959 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/likeness-modal.d.ts +15 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/likeness-modal.js +327 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/modal-tail.d.ts +44 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/modal-tail.js +998 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/obligation-tail.d.ts +20 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/obligation-tail.js +424 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/obligation.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/obligation.js +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/postverb-operator.d.ts +25 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/postverb-operator.js +722 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/predicate-projection-connective.js +143 -9
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/predicate-quote.d.ts +44 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/predicate-quote.js +856 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/projection-tail.d.ts +45 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/projection-tail.js +573 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/quantity-extent.d.ts +2 -1
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/quantity-extent.js +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/te-aspect.d.ts +23 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/te-aspect.js +598 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/te-host.d.ts +11 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/te-host.js +52 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/terminal-sfp.d.ts +24 -0
- package/dist/pipeline/head-tail/tail/predicate-root/matchers/terminal-sfp.js +873 -0
- package/dist/pipeline/head-tail/tail/predicate-root/mid-chain-connective-license.js +2 -1
- package/dist/pipeline/head-tail/tail/predicate-root/nominal-host-phrase.d.ts +0 -1
- package/dist/pipeline/head-tail/tail/predicate-root/nominal-host-phrase.js +0 -3
- package/dist/pipeline/head-tail/tail/predicate-root/op-builders.d.ts +5 -1
- package/dist/pipeline/head-tail/tail/predicate-root/op-builders.js +21 -0
- package/dist/pipeline/head-tail/tail/predicate-root/operator-head.d.ts +1 -3
- package/dist/pipeline/head-tail/tail/predicate-root/operator-head.js +0 -16
- package/dist/pipeline/head-tail/tail/predicate-root/parse-boundary-hint.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/parse-closure.d.ts +15 -0
- package/dist/pipeline/head-tail/tail/predicate-root/parse-closure.js +158 -0
- package/dist/pipeline/head-tail/tail/predicate-root/parse-coordinates.d.ts +10 -0
- package/dist/pipeline/head-tail/tail/predicate-root/parse-coordinates.js +29 -0
- package/dist/pipeline/head-tail/tail/predicate-root/parse-stem.d.ts +14 -0
- package/dist/pipeline/head-tail/tail/predicate-root/parse-stem.js +150 -0
- package/dist/pipeline/head-tail/tail/predicate-root/parse-tail.d.ts +40 -0
- package/dist/pipeline/head-tail/tail/predicate-root/parse-tail.js +1625 -0
- package/dist/pipeline/head-tail/tail/predicate-root/parser.d.ts +26 -137
- package/dist/pipeline/head-tail/tail/predicate-root/parser.js +153 -9225
- package/dist/pipeline/head-tail/tail/predicate-root/plan-lifecycle.d.ts +2 -2
- package/dist/pipeline/head-tail/tail/predicate-root/postverb-host-attachment.d.ts +8 -0
- package/dist/pipeline/head-tail/tail/predicate-root/postverb-host-attachment.js +105 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-admission-contract.js +261 -215
- package/dist/pipeline/head-tail/tail/predicate-root/production-claim-access.d.ts +0 -1
- package/dist/pipeline/head-tail/tail/predicate-root/production-claim-access.js +0 -3
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/attributive-change.d.ts +3 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/attributive-change.js +327 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/attributive.d.ts +54 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/attributive.js +1212 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/chain-patterns.d.ts +191 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/chain-patterns.js +127 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/clause-chain.d.ts +17 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/clause-chain.js +1071 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/conditional-carriers.d.ts +4 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/conditional-carriers.js +366 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/confirmation.d.ts +3 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/confirmation.js +289 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/copula.d.ts +8 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/copula.js +868 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/desiderative.d.ts +4 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/desiderative.js +414 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/exemplification.d.ts +2 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/exemplification.js +290 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/imperative.d.ts +6 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/imperative.js +468 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/mid-chain-quote.d.ts +4 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/mid-chain-quote.js +558 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/nominalization.d.ts +6 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/nominalization.js +332 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/nominalized-quote.d.ts +3 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/nominalized-quote.js +393 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/normalization.d.ts +7 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/normalization.js +334 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/potential.d.ts +3 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/potential.js +304 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/reason-and-sequence.d.ts +6 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/reason-and-sequence.js +687 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/request.d.ts +4 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/request.js +1013 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/shared.d.ts +25 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/shared.js +53 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/subordination.d.ts +5 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/subordination.js +318 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/terminal.d.ts +14 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/terminal.js +976 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/volitional.d.ts +10 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families/volitional.js +677 -0
- package/dist/pipeline/head-tail/tail/predicate-root/production-families.d.ts +1 -8
- package/dist/pipeline/head-tail/tail/predicate-root/production-families.js +19 -11025
- package/dist/pipeline/head-tail/tail/predicate-root/production-lowering-bindings.js +9 -3
- package/dist/pipeline/head-tail/tail/predicate-root/production-registry.d.ts +2 -3
- package/dist/pipeline/head-tail/tail/predicate-root/production-registry.js +15 -19
- package/dist/pipeline/head-tail/tail/predicate-root/quote-tail-context.d.ts +8 -0
- package/dist/pipeline/head-tail/tail/predicate-root/quote-tail-context.js +66 -0
- package/dist/pipeline/head-tail/tail/predicate-root/render-derivational-host-projection.d.ts +11 -0
- package/dist/pipeline/head-tail/tail/predicate-root/render-derivational-host-projection.js +67 -0
- package/dist/pipeline/head-tail/tail/predicate-root/render-root.d.ts +10 -0
- package/dist/pipeline/head-tail/tail/predicate-root/render-root.js +203 -0
- package/dist/pipeline/head-tail/tail/predicate-root/render-sfp-terminal.d.ts +3 -0
- package/dist/pipeline/head-tail/tail/predicate-root/render-sfp-terminal.js +647 -0
- package/dist/pipeline/head-tail/tail/predicate-root/render.d.ts +9 -25
- package/dist/pipeline/head-tail/tail/predicate-root/render.js +715 -5879
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/aspect-bases.d.ts +23 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/aspect-bases.js +523 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/aspect-benefactive.js +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/attributive-tail-forms.d.ts +71 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/attributive-tail-forms.js +907 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/aux-layer-context.d.ts +48 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/aux-layer-context.js +1 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/base-model.d.ts +3 -1
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/base-model.js +35 -1
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/base-support.d.ts +8 -1
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/base-support.js +90 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/command-render.d.ts +1 -13
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/command-render.js +3 -10
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/command-tail.d.ts +17 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/command-tail.js +439 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/conjecture-compose.d.ts +34 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/conjecture-compose.js +358 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/connective-compose.d.ts +2 -120
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/connective-compose.js +90 -1670
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/connective-ending.d.ts +7 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/connective-ending.js +36 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/continuative-copula.d.ts +7 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/continuative-copula.js +61 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/desire-bases.d.ts +9 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/desire-bases.js +69 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/hostless-conditional-quote.d.ts +12 -2
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/hostless-conditional-quote.js +19 -1
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/idiom-bases.d.ts +119 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/idiom-bases.js +393 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/modal-bases.d.ts +77 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/modal-bases.js +1243 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/non-chain-tail.d.ts +3 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/non-chain-tail.js +1045 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-attributive-forms.d.ts +38 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-attributive-forms.js +507 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-conjecture-compose.d.ts +5 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-conjecture-compose.js +108 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-tail-forms.d.ts +72 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula-tail-forms.js +1343 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/noun-copula.js +9 -3
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/op-chain.js +1229 -1107
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/operator-chain-tail.d.ts +23 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/operator-chain-tail.js +443 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/postverb-auxiliary-bases.d.ts +12 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/postverb-auxiliary-bases.js +1193 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-base-projection.d.ts +18 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-base-projection.js +284 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-bases.d.ts +3 -271
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-bases.js +438 -5062
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-terminal-compose.d.ts +10 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/predicate-terminal-compose.js +167 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/purpose-manner-compose.d.ts +9 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/purpose-manner-compose.js +92 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/quote-complement-compose.d.ts +53 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/quote-complement-compose.js +534 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/reason-quote-carrier.js +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/scope-bridge-bases.d.ts +5 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/scope-bridge-bases.js +571 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/sequence-after-copula.js +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/sfp-question.d.ts +2 -1
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/sfp-question.js +9 -12
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/tail-host-trace.d.ts +15 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/tail-host-trace.js +134 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/voice-benefactive-bases.d.ts +41 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/voice-benefactive-bases.js +648 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/voice-benefactive-tail.d.ts +12 -0
- package/dist/pipeline/head-tail/tail/predicate-root/renderers/voice-benefactive-tail.js +306 -0
- package/dist/pipeline/head-tail/tail/predicate-root/span-provenance.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/suffix-handoff.d.ts +0 -1
- package/dist/pipeline/head-tail/tail/predicate-root/suffix-handoff.js +0 -13
- package/dist/pipeline/head-tail/tail/predicate-root/tail-evidence-decision.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/tail-evidence-decision.js +5 -45
- package/dist/pipeline/head-tail/tail/predicate-root/tame-reason-evidence.d.ts +8 -1
- package/dist/pipeline/head-tail/tail/predicate-root/tame-reason-evidence.js +15 -0
- package/dist/pipeline/head-tail/tail/predicate-root/trace.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/predicate-root/trace.js +2 -1
- package/dist/pipeline/head-tail/tail/segments/nominal-frame.d.ts +1 -1
- package/dist/pipeline/head-tail/tail/te-tail-continuation-table.js +1 -3
- package/dist/pipeline/index.d.ts +0 -4
- package/dist/pipeline/lexical-nominal-head-claims.d.ts +1 -1
- package/dist/pipeline/lexical-particle-boundary-claims.d.ts +1 -1
- package/dist/pipeline/lexical-renyou-head-claims.d.ts +1 -1
- package/dist/pipeline/lexical-renyou-head-claims.js +1 -1
- package/dist/pipeline/lookup-tables.d.ts +1 -0
- package/dist/pipeline/lookup-tables.js +1 -0
- package/dist/pipeline/matchers.d.ts +0 -3
- package/dist/pipeline/matchers.js +1 -8
- package/dist/pipeline/particle-head-dispatch.d.ts +1 -1
- package/dist/pipeline/particle-head-dispatch.js +472 -442
- package/dist/pipeline/particles/index.d.ts +3 -3
- package/dist/pipeline/particles/secondary-particle.d.ts +1 -0
- package/dist/pipeline/particles/secondary-particle.js +4 -0
- package/dist/pipeline/pattern-runtime.d.ts +0 -61
- package/dist/pipeline/pattern-runtime.js +3 -684
- package/dist/pipeline/preprocess/analyzer-input-offsets.d.ts +5 -0
- package/dist/pipeline/preprocess/analyzer-input-offsets.js +23 -0
- package/dist/pipeline/preprocess/auxiliary-variant-retag.d.ts +7 -0
- package/dist/pipeline/preprocess/auxiliary-variant-retag.js +178 -0
- package/dist/pipeline/preprocess/bungo-nasal-n-retag.d.ts +9 -0
- package/dist/pipeline/preprocess/bungo-nasal-n-retag.js +318 -0
- package/dist/pipeline/preprocess/cat-meow.d.ts +4 -0
- package/dist/pipeline/preprocess/cat-meow.js +46 -0
- package/dist/pipeline/preprocess/causative-aux-lemma.d.ts +2 -0
- package/dist/pipeline/preprocess/causative-aux-lemma.js +10 -0
- package/dist/pipeline/preprocess/collapsed-aspect-aux.d.ts +3 -0
- package/dist/pipeline/preprocess/collapsed-aspect-aux.js +217 -0
- package/dist/pipeline/preprocess/collapsed-te-oku.d.ts +3 -0
- package/dist/pipeline/preprocess/collapsed-te-oku.js +210 -0
- package/dist/pipeline/preprocess/collocation-emission.d.ts +14 -0
- package/dist/pipeline/preprocess/collocation-emission.js +148 -0
- package/dist/pipeline/preprocess/colloquial-vowel-fusion.d.ts +4 -0
- package/dist/pipeline/preprocess/colloquial-vowel-fusion.js +164 -0
- package/dist/{transform → pipeline/preprocess}/compound-particle-merge.d.ts +2 -2
- package/dist/{transform → pipeline/preprocess}/compound-particle-merge.js +5 -5
- package/dist/pipeline/preprocess/copula-focus-negative-state-change.d.ts +3 -0
- package/dist/pipeline/preprocess/copula-focus-negative-state-change.js +79 -0
- package/dist/pipeline/preprocess/copula-renyou-retag.d.ts +3 -0
- package/dist/pipeline/preprocess/copula-renyou-retag.js +56 -0
- package/dist/pipeline/preprocess/emphasis-sokuon.d.ts +10 -0
- package/dist/pipeline/preprocess/emphasis-sokuon.js +182 -0
- package/dist/{transform → pipeline/preprocess}/explanatory-mon-sfp-retag.d.ts +1 -1
- package/dist/{transform → pipeline/preprocess}/explanatory-mon-sfp-retag.js +2 -2
- package/dist/pipeline/preprocess/follower-context.d.ts +7 -0
- package/dist/pipeline/preprocess/follower-context.js +33 -0
- package/dist/pipeline/preprocess/fused-conditional.d.ts +3 -0
- package/dist/pipeline/preprocess/fused-conditional.js +97 -0
- package/dist/pipeline/preprocess/imperative-mistag-recovery.d.ts +7 -0
- package/dist/pipeline/preprocess/imperative-mistag-recovery.js +135 -0
- package/dist/pipeline/preprocess/input-text-normalization.d.ts +3 -0
- package/dist/pipeline/preprocess/input-text-normalization.js +39 -0
- package/dist/pipeline/preprocess/kansai-dialect.d.ts +9 -0
- package/dist/pipeline/preprocess/kansai-dialect.js +501 -0
- package/dist/{transform → pipeline/preprocess}/keijouji-copula-de-retag.d.ts +1 -1
- package/dist/{transform → pipeline/preprocess}/keijouji-copula-de-retag.js +2 -2
- package/dist/{transform → pipeline/preprocess}/ni-complement-matrix-flip.d.ts +1 -1
- package/dist/{transform → pipeline/preprocess}/ni-complement-matrix-flip.js +2 -2
- package/dist/pipeline/preprocess/past-quotative-tte-resplit.d.ts +3 -0
- package/dist/pipeline/preprocess/past-quotative-tte-resplit.js +55 -0
- package/dist/pipeline/preprocess/prolonged-orthography.d.ts +5 -0
- package/dist/pipeline/preprocess/prolonged-orthography.js +79 -0
- package/dist/pipeline/preprocess/prolonged-surface-canonicalization.d.ts +5 -0
- package/dist/pipeline/preprocess/prolonged-surface-canonicalization.js +161 -0
- package/dist/pipeline/preprocess/punctuation-canonicalization.d.ts +5 -0
- package/dist/pipeline/preprocess/punctuation-canonicalization.js +160 -0
- package/dist/{transform → pipeline/preprocess}/quotative-manner-noun-flip.d.ts +2 -2
- package/dist/{transform → pipeline/preprocess}/quotative-manner-noun-flip.js +10 -10
- package/dist/{transform → pipeline/preprocess}/reduplicated-mimetic.d.ts +1 -1
- package/dist/{transform → pipeline/preprocess}/reduplicated-mimetic.js +3 -3
- package/dist/{transform → pipeline/preprocess}/rentaishi-no-nominalizer-retag.d.ts +1 -1
- package/dist/{transform → pipeline/preprocess}/rentaishi-no-nominalizer-retag.js +2 -2
- package/dist/pipeline/preprocess/runtime-token-from-analyzer.d.ts +5 -0
- package/dist/pipeline/preprocess/runtime-token-from-analyzer.js +77 -0
- package/dist/pipeline/preprocess/runtime-token-from-preprocess.d.ts +13 -0
- package/dist/pipeline/preprocess/runtime-token-from-preprocess.js +15 -0
- package/dist/pipeline/preprocess/standalone-voice-mark.d.ts +9 -0
- package/dist/pipeline/preprocess/standalone-voice-mark.js +73 -0
- package/dist/pipeline/preprocess/synthetic-token.d.ts +10 -0
- package/dist/pipeline/preprocess/synthetic-token.js +26 -0
- package/dist/pipeline/preprocess/te-contraction.d.ts +4 -0
- package/dist/pipeline/preprocess/te-contraction.js +150 -0
- package/dist/pipeline/preprocess/terminal-role-tail.d.ts +5 -0
- package/dist/pipeline/preprocess/terminal-role-tail.js +148 -0
- package/dist/{transform → pipeline/preprocess}/terminal-sfp-retag-closure.d.ts +2 -2
- package/dist/{transform → pipeline/preprocess}/terminal-sfp-retag-closure.js +4 -4
- package/dist/pipeline/preprocess/to-iu-contraction.d.ts +2 -0
- package/dist/pipeline/preprocess/to-iu-contraction.js +65 -0
- package/dist/{transform → pipeline/preprocess}/volitional-resolution-sfp-retag.d.ts +1 -1
- package/dist/{transform → pipeline/preprocess}/volitional-resolution-sfp-retag.js +2 -2
- package/dist/{transform → pipeline/preprocess}/youon-remerge.d.ts +1 -1
- package/dist/{transform → pipeline/preprocess}/youon-remerge.js +3 -3
- package/dist/pipeline/projection/narou-ruby-input.d.ts +17 -0
- package/dist/pipeline/projection/narou-ruby-input.js +149 -0
- package/dist/pipeline/projection/parenthetical-delimiter-annotation.d.ts +6 -0
- package/dist/pipeline/projection/parenthetical-delimiter-annotation.js +117 -0
- package/dist/pipeline/projection/parenthetical-ruby-absorption.d.ts +6 -0
- package/dist/pipeline/projection/parenthetical-ruby-absorption.js +198 -0
- package/dist/pipeline/projection/parenthetical-source-boundary.d.ts +12 -0
- package/dist/pipeline/projection/parenthetical-source-boundary.js +117 -0
- package/dist/pipeline/projection/parenthetical-source-identity.d.ts +14 -0
- package/dist/pipeline/projection/parenthetical-source-identity.js +443 -0
- package/dist/pipeline/projection/parenthetical-target-insertion.d.ts +22 -0
- package/dist/pipeline/projection/parenthetical-target-insertion.js +584 -0
- package/dist/pipeline/projection/prepared-translation.d.ts +52 -0
- package/dist/pipeline/projection/prepared-translation.js +1 -0
- package/dist/pipeline/projection/prepared-tree.d.ts +6 -0
- package/dist/pipeline/projection/prepared-tree.js +66 -0
- package/dist/pipeline/projection/raw-parenthetical-split.d.ts +15 -0
- package/dist/pipeline/projection/raw-parenthetical-split.js +78 -0
- package/dist/pipeline/projection/ruby-annotation.d.ts +5 -0
- package/dist/pipeline/projection/ruby-annotation.js +161 -0
- package/dist/pipeline/projection/text-offset-projection.d.ts +7 -0
- package/dist/pipeline/projection/text-offset-projection.js +111 -0
- package/dist/pipeline/projection/transparent-pause-island.d.ts +8 -0
- package/dist/pipeline/projection/transparent-pause-island.js +188 -0
- package/dist/pipeline/pronominal-no-dispatch.js +1 -1
- package/dist/pipeline/quote/host-runtime.js +3 -2
- package/dist/pipeline/quote/host-taxonomy.d.ts +1 -0
- package/dist/pipeline/quote/host-taxonomy.js +2 -2
- package/dist/pipeline/quote/question-taking-enumeration.d.ts +1 -1
- package/dist/pipeline/quote/question-taking-enumeration.js +0 -4
- package/dist/pipeline/reason-source-evidence.d.ts +1 -0
- package/dist/pipeline/reason-source-evidence.js +1 -1
- package/dist/pipeline/rendering/functional-chain.d.ts +2 -0
- package/dist/pipeline/rendering/functional-chain.js +14 -0
- package/dist/pipeline/rendering/nominal-head-tail-plan-trace.d.ts +10 -0
- package/dist/pipeline/rendering/nominal-head-tail-plan-trace.js +336 -0
- package/dist/pipeline/rendering/render-plan-inspect.d.ts +9 -0
- package/dist/pipeline/rendering/render-plan-inspect.js +121 -0
- package/dist/pipeline/rendering/render-plan-payloads.d.ts +28 -0
- package/dist/pipeline/rendering/render-plan-payloads.js +125 -0
- package/dist/pipeline/rendering/render-plan-rewrite.d.ts +32 -0
- package/dist/pipeline/rendering/render-plan-rewrite.js +540 -0
- package/dist/pipeline/rendering/render-plan-segments.d.ts +42 -0
- package/dist/pipeline/rendering/render-plan-segments.js +263 -0
- package/dist/pipeline/rendering/render-plan.d.ts +4 -57
- package/dist/pipeline/rendering/render-plan.js +52 -1433
- package/dist/pipeline/rendering/request-normalization.d.ts +0 -1
- package/dist/pipeline/rendering/request-normalization.js +0 -3
- package/dist/pipeline/rendering/segment-allomorph.d.ts +17 -0
- package/dist/pipeline/rendering/segment-allomorph.js +152 -0
- package/dist/pipeline/rendering/segment-annotation-keys.d.ts +6 -0
- package/dist/pipeline/rendering/segment-annotation-keys.js +137 -0
- package/dist/pipeline/rendering/stem-derivation.js +1 -1
- package/dist/pipeline/rendering/target-segment-build.d.ts +13 -0
- package/dist/pipeline/rendering/target-segment-build.js +167 -0
- package/dist/pipeline/rendering/terminal-unit-punctuation.d.ts +16 -0
- package/dist/pipeline/rendering/terminal-unit-punctuation.js +96 -0
- package/dist/pipeline/rendering/unit-surface.d.ts +9 -0
- package/dist/pipeline/rendering/unit-surface.js +35 -0
- package/dist/pipeline/resource-cache.d.ts +19 -0
- package/dist/pipeline/resource-cache.js +164 -0
- package/dist/pipeline/rules/common.d.ts +0 -1
- package/dist/pipeline/rules/common.js +0 -1
- package/dist/pipeline/rules/entry-aux.d.ts +0 -2
- package/dist/pipeline/rules/entry-aux.js +0 -4
- package/dist/pipeline/rules/postaux-unsupported.js +1 -5
- package/dist/pipeline/rules/pre-entry.d.ts +0 -1
- package/dist/pipeline/rules/pre-entry.js +0 -1
- package/dist/pipeline/rules/tail-finalization.js +4 -5
- package/dist/pipeline/semantics/conditional.d.ts +2 -1
- package/dist/pipeline/semantics/conditional.js +3 -2
- package/dist/pipeline/semantics/copula-tail-runtime.js +2 -2
- package/dist/pipeline/semantics/explanatory-mon-reading.d.ts +1 -1
- package/dist/pipeline/semantics/explanatory-mon-reading.js +2 -2
- package/dist/pipeline/semantics/extent-phrase.js +1 -1
- package/dist/pipeline/semantics/frame.d.ts +3 -3
- package/dist/pipeline/semantics/frame.js +4 -4
- package/dist/pipeline/semantics/gano-conversion.d.ts +1 -2
- package/dist/pipeline/semantics/gano-conversion.js +1 -9
- package/dist/pipeline/semantics/grammar-runtime.d.ts +0 -7
- package/dist/pipeline/semantics/grammar-runtime.js +0 -92
- package/dist/pipeline/semantics/honorific.d.ts +1 -2
- package/dist/pipeline/semantics/honorific.js +0 -3
- package/dist/pipeline/semantics/mono-modal.d.ts +1 -1
- package/dist/pipeline/semantics/numeric.js +1 -3
- package/dist/pipeline/semantics/sfp-surface.js +8 -0
- package/dist/pipeline/source-candidate-set.d.ts +1 -2
- package/dist/pipeline/source-candidate-set.js +0 -3
- package/dist/pipeline/source-coordinate.d.ts +20 -0
- package/dist/pipeline/source-coordinate.js +42 -0
- package/dist/pipeline/structural-relation/clause-connective-relations.d.ts +12 -0
- package/dist/pipeline/structural-relation/clause-connective-relations.js +327 -0
- package/dist/pipeline/structural-relation/collect.d.ts +1 -12
- package/dist/pipeline/structural-relation/collect.js +11 -3105
- package/dist/pipeline/structural-relation/connective-relation-match.d.ts +17 -0
- package/dist/pipeline/structural-relation/connective-relation-match.js +39 -0
- package/dist/pipeline/structural-relation/diagnostics.d.ts +0 -2
- package/dist/pipeline/structural-relation/diagnostics.js +0 -7
- package/dist/pipeline/structural-relation/ka-parallel-relations.d.ts +3 -0
- package/dist/pipeline/structural-relation/ka-parallel-relations.js +695 -0
- package/dist/pipeline/structural-relation/nari-relations.d.ts +3 -0
- package/dist/pipeline/structural-relation/nari-relations.js +367 -0
- package/dist/pipeline/structural-relation/parallel-item-evidence.d.ts +12 -0
- package/dist/pipeline/structural-relation/parallel-item-evidence.js +73 -0
- package/dist/pipeline/structural-relation/punctuated-attributive-relations.d.ts +2 -0
- package/dist/pipeline/structural-relation/punctuated-attributive-relations.js +224 -0
- package/dist/pipeline/structural-relation/purpose-relations.d.ts +7 -0
- package/dist/pipeline/structural-relation/purpose-relations.js +306 -0
- package/dist/pipeline/structural-relation/quote-clause-boundary.d.ts +47 -0
- package/dist/pipeline/structural-relation/quote-clause-boundary.js +216 -0
- package/dist/pipeline/structural-relation/quote-closed-toka.d.ts +22 -0
- package/dist/pipeline/structural-relation/quote-closed-toka.js +158 -0
- package/dist/pipeline/structural-relation/quote-content-endings.d.ts +20 -0
- package/dist/pipeline/structural-relation/quote-content-endings.js +163 -0
- package/dist/pipeline/structural-relation/quote-content-span.d.ts +23 -0
- package/dist/pipeline/structural-relation/quote-content-span.js +270 -0
- package/dist/pipeline/structural-relation/quote-nominal-and-passive.d.ts +22 -0
- package/dist/pipeline/structural-relation/quote-nominal-and-passive.js +724 -0
- package/dist/pipeline/structural-relation/quote-payload.d.ts +33 -0
- package/dist/pipeline/structural-relation/quote-payload.js +137 -0
- package/dist/pipeline/structural-relation/quote-question-content.d.ts +18 -0
- package/dist/pipeline/structural-relation/quote-question-content.js +588 -0
- package/dist/pipeline/structural-relation/quote-reason-copula.d.ts +18 -0
- package/dist/pipeline/structural-relation/quote-reason-copula.js +84 -0
- package/dist/pipeline/structural-relation/quote-relation-enrichment.d.ts +4 -0
- package/dist/pipeline/structural-relation/quote-relation-enrichment.js +174 -0
- package/dist/pipeline/structural-relation/quote-request.d.ts +16 -0
- package/dist/pipeline/structural-relation/quote-request.js +249 -0
- package/dist/pipeline/structural-relation/quote.d.ts +4 -130
- package/dist/pipeline/structural-relation/quote.js +105 -2627
- package/dist/pipeline/structural-relation/reason-relations.d.ts +6 -0
- package/dist/pipeline/structural-relation/reason-relations.js +328 -0
- package/dist/pipeline/structural-relation/relation-coordinates.d.ts +21 -0
- package/dist/pipeline/structural-relation/relation-coordinates.js +110 -0
- package/dist/pipeline/structural-relation/render-attributive.d.ts +25 -0
- package/dist/pipeline/structural-relation/render-attributive.js +195 -0
- package/dist/pipeline/structural-relation/render-clause-connective.d.ts +29 -0
- package/dist/pipeline/structural-relation/render-clause-connective.js +114 -0
- package/dist/pipeline/structural-relation/render-connective-plan.d.ts +28 -0
- package/dist/pipeline/structural-relation/render-connective-plan.js +164 -0
- package/dist/pipeline/structural-relation/render-parallel.d.ts +60 -0
- package/dist/pipeline/structural-relation/render-parallel.js +1088 -0
- package/dist/pipeline/structural-relation/render-quote.d.ts +75 -0
- package/dist/pipeline/structural-relation/render-quote.js +968 -0
- package/dist/pipeline/structural-relation/render-reason-copula.d.ts +24 -0
- package/dist/pipeline/structural-relation/render-reason-copula.js +324 -0
- package/dist/pipeline/structural-relation/render-source-sequence.d.ts +11 -0
- package/dist/pipeline/structural-relation/render-source-sequence.js +154 -0
- package/dist/pipeline/structural-relation/render-unit-spans.d.ts +35 -0
- package/dist/pipeline/structural-relation/render-unit-spans.js +71 -0
- package/dist/pipeline/structural-relation/render.d.ts +2 -25
- package/dist/pipeline/structural-relation/render.js +10 -3043
- package/dist/pipeline/structural-relation/source-predicate-operator.d.ts +2 -1
- package/dist/pipeline/structural-relation/tari-listing-relations.d.ts +5 -0
- package/dist/pipeline/structural-relation/tari-listing-relations.js +354 -0
- package/dist/pipeline/structural-relation/toka-nominal-listing-relations.d.ts +2 -0
- package/dist/pipeline/structural-relation/toka-nominal-listing-relations.js +154 -0
- package/dist/pipeline/structural-relation/toka-nominal-listing-run.d.ts +11 -1
- package/dist/pipeline/structural-relation/toka-nominal-listing-run.js +16 -4
- package/dist/pipeline/structural-relation/types.d.ts +10 -1
- package/dist/pipeline/translation/access.d.ts +0 -3
- package/dist/pipeline/translation/unit.d.ts +4 -1
- package/dist/pipeline/translation/unit.js +29 -9
- package/dist/pipeline/translation/warnings.d.ts +9 -0
- package/dist/pipeline/translation/warnings.js +251 -0
- package/dist/pipeline-factory.js +2 -1
- package/dist/scripts/diagnose.js +3 -2
- package/dist/types/pos.d.ts +3 -0
- package/dist/types/pos.js +8 -0
- package/dist/types/reanalysis.d.ts +0 -1
- package/dist/types/reanalysis.js +0 -1
- package/dist/types/render-plan.d.ts +1 -2
- package/dist/utils/char-class.d.ts +2 -0
- package/dist/utils/char-class.js +6 -0
- package/dist/utils/record.d.ts +1 -0
- package/dist/utils/record.js +3 -0
- package/dist/webext-provider.d.ts +7 -0
- package/dist/webext-provider.js +56 -16
- package/package.json +1 -1
- package/dist/pipeline/head-tail/audit/types.d.ts +0 -7
- /package/dist/pipeline/head-tail/{audit/types.js → tail/predicate-root/integration/contracts.js} +0 -0
|
@@ -1,33 +1,17 @@
|
|
|
1
|
-
import { isNominalHeadTailChainRenderPlan, isPredicateHeadTailChainRenderPlan } from "../../types/render-plan.js";
|
|
2
1
|
import { lazyValue } from "../../data-loader.js";
|
|
3
|
-
import { isClauseEvidenceTransparentPunctuation, isClauseOpeningPunctuationToken } from "../clause-layout/punctuation.js";
|
|
4
|
-
import { previousNonSpaceIndex } from "../clause-layout/trivia.js";
|
|
5
|
-
import { attachParticleRenderPlan, contractPossessivePronounPlan, particleKeyFromAllomorph } from "../rendering/particle-plan.js";
|
|
6
|
-
import { matchCopulaTailWithOptionalConditional } from "../semantics/copula-tail-runtime.js";
|
|
7
|
-
import { TokenCursor } from "../token-cursor.js";
|
|
8
2
|
import { loadConnectiveSurfaceEntries } from "../head-tail/tail/predicate-root/connective-surface-table.js";
|
|
9
|
-
import {
|
|
10
|
-
import { nominalPhraseOwnerPrefix } from "../head-tail/head/adapters/nominal/commit.js";
|
|
11
|
-
import { resolveCandidateSetLayer, resolveCandidateSetStem } from "../head-tail/tail/predicate-root/commit.js";
|
|
12
|
-
import { isConditionalQuoteProductionMatch, normalizeProductionMatch, probeProductionDispatch, } from "../head-tail/tail/predicate-root/production-registry.js";
|
|
13
|
-
import { SFP_NA_EXCLAMATORY_NOMINALIZERS, TYPIFICATION_QUOTATIVE_HEADS } from "../head-tail/data/semantic-helper-sets.js";
|
|
14
|
-
import { quoteProjectionForSfpEffect } from "../semantics/sfp-quote-projection.js";
|
|
15
|
-
import {} from "../head-tail/tail/predicate-root/grammar.js";
|
|
16
|
-
import { firstAuxLayer, isBenefactiveAspectOp, tailPredicateHostPrefersTameReason, tailRootVoiceOps } from "../head-tail/tail/predicate-root/inspect.js";
|
|
17
|
-
import { stemCandidateIdentitiesEqual, stemCandidateIdentity } from "../head-tail/tail/predicate-root/stem-candidate-identity.js";
|
|
18
|
-
import { REASON_BECAUSE_BOUND_NOUN, attributiveModifierPlanSourceFacts, realizeRenderPlan } from "../rendering/render-plan.js";
|
|
3
|
+
import { realizeRenderPlan } from "../rendering/render-plan.js";
|
|
19
4
|
import { TranslationUnit, UnitType } from "../translation/unit.js";
|
|
20
|
-
import { selectPlainVerbAttributiveEnding } from "../attributive.js";
|
|
21
5
|
import { projectionUnavailable, relationConflict } from "./diagnostics.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
6
|
+
import { POS0, 구 } from "../../types/pos.js";
|
|
7
|
+
import { sourceSpanForTokenIndexes } from "../source-coordinate.js";
|
|
8
|
+
import { projectionEdgeAttachment, unitIndexesInSpan, unitFullyCoveredBySpans, uniqueSorted, opSourceForMarkerSpans } from "./render-unit-spans.js";
|
|
9
|
+
import { buildBareKaQuestionContentStructuredRenderOperation, buildKaParallelStructuredRenderOperation, buildEmbeddedQuestionAttributiveQuoteStructuredRenderOperation, buildNariParallelStructuredRenderOperation, buildTokaNominalListingStructuredRenderOperation } from "./render-parallel.js";
|
|
10
|
+
import { buildConjectureQuoteStructuredRenderOperation, buildAttributiveTypificationQuoteStructuredRenderOperation, buildMarkerAbsorbedContentCopulaRenderOperation, buildSfpQuoteStructuredRenderOperation, buildConditionalWishQuoteStructuredRenderOperation, buildConditionalThoughtQuoteMarkerStructuredRenderOperation, buildConditionalReportQuoteStructuredRenderOperation, buildPredicateBoundTameQuoteStructuredRenderOperation } from "./render-quote.js";
|
|
11
|
+
import { buildReasonCopulaQuoteStructuredRenderOperation, buildReasonCopulaExplanationStructuredRenderOperation } from "./render-reason-copula.js";
|
|
12
|
+
import { buildPunctuatedAttributiveStructuredRenderOperation, buildPurposeModifierStructuredRenderOperation } from "./render-attributive.js";
|
|
13
|
+
import { buildNominalConcessionStructuredRenderOperation, buildCorrelativeDegreeStructuredRenderOperation, sourcePredicateProjectionCandidateUnitIndexes, sourcePredicateConnectiveProjection } from "./render-clause-connective.js";
|
|
14
|
+
import { projectUnitPredicateConnectivePlan } from "./render-connective-plan.js";
|
|
31
15
|
const DEFAULT_RENDER_ENABLED_RELATION_KINDS = lazyValue(() => new Set(loadConnectiveSurfaceEntries({
|
|
32
16
|
isSupportedKind: (value) => typeof value === "string" && value.length > 0,
|
|
33
17
|
})
|
|
@@ -415,2712 +399,6 @@ function buildDefaultStructuredRenderOperation(options) {
|
|
|
415
399
|
}
|
|
416
400
|
return null;
|
|
417
401
|
}
|
|
418
|
-
function buildBareKaQuestionContentStructuredRenderOperation(options) {
|
|
419
|
-
const quote = options.relation.quote;
|
|
420
|
-
if (quote?.slotKind !== "question_content" ||
|
|
421
|
-
(quote.questionBoundaryKind !== "bare_ka" && quote.questionBoundaryKind !== "nominalized_no_ka") ||
|
|
422
|
-
quote.contentPredicateIdx === undefined ||
|
|
423
|
-
quote.contentPredicateIdx === null) {
|
|
424
|
-
return null;
|
|
425
|
-
}
|
|
426
|
-
const sourceUnitIndex = options.sourceUnitIndexes.find((unitIndex) => options.units[unitIndex]?.jpIndices.includes(quote.contentPredicateIdx) === true);
|
|
427
|
-
const sourceUnit = sourceUnitIndex === undefined ? undefined : options.units[sourceUnitIndex];
|
|
428
|
-
if (sourceUnitIndex === undefined || sourceUnit === undefined) {
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
const sourcePlan = sourceUnit.renderPlan;
|
|
432
|
-
if (quote.contentPredicateAnchorKind === "interrogative_head" && isPredicateHeadTailChainRenderPlan(sourcePlan)) {
|
|
433
|
-
const tail = sourcePlan.realization.root.tail;
|
|
434
|
-
const anchoredAtHead = tail.kind === "auxLayer" &&
|
|
435
|
-
tail.stem.semanticAnchors.some((anchor) => tail.stem.source.tokenIndices[anchor] === quote.contentPredicateIdx);
|
|
436
|
-
if (!anchoredAtHead) {
|
|
437
|
-
return null;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
const projectedPlan = projectNominalizedConjectureMatrixQuestionContinuationPlan(sourceUnit.renderPlan, quote.markerIdx, quote.markerBaseSurface) ?? normalizeConfirmedQuestionContentAlternativePlan(sourceUnit.renderPlan, quote.markerIdx, quote.markerBaseSurface) ?? projectUnitHeadTailConnectivePlan(sourceUnit, { connective: "question_content", surface: quote.markerBaseSurface }, opSourceForMarkerSpans(options.tokens, options.relation.markerSpans), true) ?? projectBareNounZeroCopulaQuestionContentPlan(sourceUnit.renderPlan, quote.contentPredicateAnchorKind, quote.markerBaseSurface) ?? projectNominalFrameQuestionContentPlan(sourceUnit.renderPlan, quote.markerBaseSurface) ?? (quote.contentPredicateAnchorKind === "zero_copula_nominal"
|
|
441
|
-
? null
|
|
442
|
-
: projectNominalQuestionContentPlan(sourceUnit.renderPlan));
|
|
443
|
-
if (projectedPlan === null) {
|
|
444
|
-
return null;
|
|
445
|
-
}
|
|
446
|
-
const suppressUnitIndexes = uniqueSorted(options.markerUnitIndexes.filter((unitIndex) => unitIndex !== sourceUnitIndex));
|
|
447
|
-
return {
|
|
448
|
-
relation: options.relation,
|
|
449
|
-
insertBeforeUnitIndex: sourceUnitIndex,
|
|
450
|
-
replaceUnitIndex: sourceUnitIndex,
|
|
451
|
-
suppressUnitIndexes,
|
|
452
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
453
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
454
|
-
projectionTokenIndexes: uniqueSorted([
|
|
455
|
-
...sourceUnit.jpIndices,
|
|
456
|
-
...suppressUnitIndexes.flatMap((unitIndex) => options.units[unitIndex]?.jpIndices ?? []),
|
|
457
|
-
]),
|
|
458
|
-
renderPlan: markStructuralKaParallelQuestionContentPlan(projectedPlan),
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
function projectBareNounZeroCopulaQuestionContentPlan(plan, anchorKind, markerSurface) {
|
|
462
|
-
if (anchorKind !== "zero_copula_nominal" || plan?.kind !== "lemma") {
|
|
463
|
-
return null;
|
|
464
|
-
}
|
|
465
|
-
if (plan.koreanPos !== 명사 && plan.koreanPos !== 대명사 && plan.koreanPos !== 수사) {
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
const ending = CONNECTIVE_RENDER_MAP.get(markerSurface)?.korean;
|
|
469
|
-
if (ending === undefined) {
|
|
470
|
-
return null;
|
|
471
|
-
}
|
|
472
|
-
const { connective: _legacyConnective, suffix: _legacySuffix, ...head } = plan;
|
|
473
|
-
return { ...head, connective: ending, sfp: null, terminalSfp: null };
|
|
474
|
-
}
|
|
475
|
-
function projectNominalFrameQuestionContentPlan(plan, markerSurface) {
|
|
476
|
-
if (!isNominalHeadTailChainRenderPlan(plan) || plan.realization.frame.projection.kind !== "headLexicalForm") {
|
|
477
|
-
return null;
|
|
478
|
-
}
|
|
479
|
-
const ending = CONNECTIVE_RENDER_MAP.get(markerSurface)?.korean;
|
|
480
|
-
if (ending === undefined) {
|
|
481
|
-
return null;
|
|
482
|
-
}
|
|
483
|
-
const headText = nominalPhraseOwnerPrefix(plan, "");
|
|
484
|
-
if (headText.length === 0) {
|
|
485
|
-
return null;
|
|
486
|
-
}
|
|
487
|
-
const hintPos = plan.realization.root.kind === "nominalPhrase"
|
|
488
|
-
? plan.realization.root.head.allomorphHint?.koreanPos
|
|
489
|
-
: undefined;
|
|
490
|
-
return {
|
|
491
|
-
kind: "lemma",
|
|
492
|
-
entry: null,
|
|
493
|
-
koreanLemma: headText,
|
|
494
|
-
koreanPos: hintPos === 대명사 ? 대명사 : 명사,
|
|
495
|
-
irregular: null,
|
|
496
|
-
auxTokens: [],
|
|
497
|
-
connective: ending,
|
|
498
|
-
sfp: null,
|
|
499
|
-
terminalSfp: null,
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
function projectNominalQuestionContentPlan(plan) {
|
|
503
|
-
if (plan?.kind === "fixedText") {
|
|
504
|
-
return structuralRelationSequencePlan([
|
|
505
|
-
plan,
|
|
506
|
-
{ kind: "structuralText", text: "인지", koreanPos: 구 },
|
|
507
|
-
]);
|
|
508
|
-
}
|
|
509
|
-
if (plan?.kind === "registerText") {
|
|
510
|
-
return structuralRelationSequencePlan([
|
|
511
|
-
plan,
|
|
512
|
-
{ kind: "structuralText", text: "인지", koreanPos: 구 },
|
|
513
|
-
]);
|
|
514
|
-
}
|
|
515
|
-
return null;
|
|
516
|
-
}
|
|
517
|
-
function normalizeConfirmedQuestionContentAlternativePlan(plan, markerIdx, markerSurface) {
|
|
518
|
-
if (!isPredicateHeadTailChainRenderPlan(plan) || plan.realization.root.tail.kind !== "auxLayer") {
|
|
519
|
-
return null;
|
|
520
|
-
}
|
|
521
|
-
const alternative = plan.realization.root.tail.ops.find((op) => op.kind === "connective" &&
|
|
522
|
-
op.connective === "alternative" &&
|
|
523
|
-
op.source.tokenIndices.includes(markerIdx));
|
|
524
|
-
if (alternative === undefined) {
|
|
525
|
-
return null;
|
|
526
|
-
}
|
|
527
|
-
return projectHeadTailConnectivePlan(plan, { connective: "question_content", surface: markerSurface }, alternative.source, true);
|
|
528
|
-
}
|
|
529
|
-
function buildConjectureQuoteStructuredRenderOperation(options) {
|
|
530
|
-
const quote = options.relation.quote;
|
|
531
|
-
if (quote === undefined || quote.slotKind !== "quoted_content")
|
|
532
|
-
return null;
|
|
533
|
-
const sourceUnitIndex = [...options.sourceUnitIndexes].reverse().find((unitIndex) => isPredicateHeadTailChainRenderPlan(options.units[unitIndex]?.renderPlan));
|
|
534
|
-
if (sourceUnitIndex === undefined)
|
|
535
|
-
return null;
|
|
536
|
-
const unit = options.units[sourceUnitIndex];
|
|
537
|
-
const sourcePlan = unit?.renderPlan;
|
|
538
|
-
if (unit === undefined || !isPredicateHeadTailChainRenderPlan(sourcePlan))
|
|
539
|
-
return null;
|
|
540
|
-
const committed = materializeSfpOwnerStem(sourcePlan);
|
|
541
|
-
const layer = firstAuxLayer(committed.realization.root.tail);
|
|
542
|
-
if (layer === null)
|
|
543
|
-
return null;
|
|
544
|
-
const quoteIdx = layer.ops.findIndex((op) => op.kind === "connective" && op.connective === "quotative");
|
|
545
|
-
if (quoteIdx < 0)
|
|
546
|
-
return null;
|
|
547
|
-
const beforeQuote = layer.ops.slice(0, quoteIdx);
|
|
548
|
-
const conjectural = layer.stem.kind === "noun"
|
|
549
|
-
? beforeQuote.some((op) => op.kind === "copula" && op.variant === "conjecture")
|
|
550
|
-
: (layer.stem.kind === "verb" || layer.stem.kind === "adj") &&
|
|
551
|
-
beforeQuote.some((op) => op.kind === "conjecture");
|
|
552
|
-
if (!conjectural)
|
|
553
|
-
return null;
|
|
554
|
-
const suppressUnitIndexes = options.markerUnitIndexes.filter((unitIndex) => unitIndex !== sourceUnitIndex);
|
|
555
|
-
return {
|
|
556
|
-
relation: options.relation,
|
|
557
|
-
insertBeforeUnitIndex: sourceUnitIndex,
|
|
558
|
-
replaceUnitIndex: sourceUnitIndex,
|
|
559
|
-
suppressUnitIndexes,
|
|
560
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
561
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
562
|
-
projectionTokenIndexes: uniqueSorted([
|
|
563
|
-
...unit.jpIndices,
|
|
564
|
-
...suppressUnitIndexes.flatMap((unitIndex) => options.units[unitIndex]?.jpIndices ?? []),
|
|
565
|
-
]),
|
|
566
|
-
renderPlan: {
|
|
567
|
-
kind: "conjectureThoughtQuote",
|
|
568
|
-
root: committed.realization.root,
|
|
569
|
-
...(committed.realization.hostProjection === undefined
|
|
570
|
-
? {}
|
|
571
|
-
: { hostProjection: committed.realization.hostProjection }),
|
|
572
|
-
koreanPos: 구
|
|
573
|
-
},
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
function buildAttributiveTypificationQuoteStructuredRenderOperation(options) {
|
|
577
|
-
const quote = options.relation.quote;
|
|
578
|
-
if (quote === undefined || !IU_LEXEME_FORMS.has(quote.hostMatch.hostForm)) {
|
|
579
|
-
return null;
|
|
580
|
-
}
|
|
581
|
-
const hostUnitIndex = options.units.findIndex((unit) => {
|
|
582
|
-
if (!unit.jpIndices.includes(quote.hostMatch.hostIdx))
|
|
583
|
-
return false;
|
|
584
|
-
const facts = attributiveModifierPlanSourceFacts(unit.renderPlan);
|
|
585
|
-
return facts !== null && facts.sourcePast &&
|
|
586
|
-
TYPIFICATION_QUOTATIVE_HEADS.has(facts.headDictionaryForm ?? "");
|
|
587
|
-
});
|
|
588
|
-
if (hostUnitIndex < 0)
|
|
589
|
-
return null;
|
|
590
|
-
const predicateUnitIndex = [...options.sourceUnitIndexes].reverse().find((unitIndex) => isPredicateHeadTailChainRenderPlan(options.units[unitIndex]?.renderPlan)) ?? null;
|
|
591
|
-
const predicateUnit = predicateUnitIndex === null ? undefined : options.units[predicateUnitIndex];
|
|
592
|
-
if (predicateUnitIndex === null || predicateUnit === undefined)
|
|
593
|
-
return null;
|
|
594
|
-
const unquoted = projectUnitWithoutQuoteMarkerConnectivePlan(predicateUnit, opSourceForMarkerSpans(options.tokens, options.relation.markerSpans));
|
|
595
|
-
const attributive = unquoted === null ? null : projectPredicateHeadTailAttributivePlan(unquoted);
|
|
596
|
-
if (attributive === null)
|
|
597
|
-
return null;
|
|
598
|
-
const sourcePlan = composeRelationSourceUnitPlans(options.tokens, options.units, options.sourceUnitIndexes, new Map([[predicateUnitIndex, attributive]]));
|
|
599
|
-
if (sourcePlan === null)
|
|
600
|
-
return null;
|
|
601
|
-
const renderPlan = structuralRelationSequencePlan([
|
|
602
|
-
sourcePlan,
|
|
603
|
-
{ kind: "structuralText", text: " 등의", koreanPos: 구 },
|
|
604
|
-
]);
|
|
605
|
-
if (renderPlan === null)
|
|
606
|
-
return null;
|
|
607
|
-
const suppressUnitIndexes = uniqueSorted([
|
|
608
|
-
...options.sourceUnitIndexes,
|
|
609
|
-
...options.markerUnitIndexes,
|
|
610
|
-
hostUnitIndex,
|
|
611
|
-
]).filter((unitIndex) => options.units[unitIndex]?.unitType !== UnitType.SYMBOL);
|
|
612
|
-
return {
|
|
613
|
-
relation: options.relation,
|
|
614
|
-
insertBeforeUnitIndex: options.sourceUnitIndexes[0] ?? predicateUnitIndex,
|
|
615
|
-
suppressUnitIndexes,
|
|
616
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
617
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
618
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((unitIndex) => options.units[unitIndex]?.jpIndices ?? [])),
|
|
619
|
-
renderPlan,
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
function buildMarkerAbsorbedContentCopulaRenderOperation(options) {
|
|
623
|
-
const quote = options.relation.quote;
|
|
624
|
-
const copulaIdx = quote?.markerAbsorbedContentCopulaIdx;
|
|
625
|
-
const contentPredicateIdx = quote?.contentPredicateIdx;
|
|
626
|
-
if (quote === undefined ||
|
|
627
|
-
copulaIdx === undefined ||
|
|
628
|
-
contentPredicateIdx === undefined ||
|
|
629
|
-
contentPredicateIdx === null ||
|
|
630
|
-
quote.terminalSfp !== undefined && quote.terminalSfp !== null) {
|
|
631
|
-
return null;
|
|
632
|
-
}
|
|
633
|
-
const sourceUnitIndex = options.sourceUnitIndexes.find((unitIndex) => options.units[unitIndex]?.jpIndices.includes(contentPredicateIdx) === true);
|
|
634
|
-
const sourceUnit = sourceUnitIndex === undefined ? undefined : options.units[sourceUnitIndex];
|
|
635
|
-
const plan = sourceUnit?.renderPlan;
|
|
636
|
-
const absorbedAux = plan?.kind === "lemma" ? plan.auxTokens[0] : undefined;
|
|
637
|
-
if (sourceUnitIndex === undefined ||
|
|
638
|
-
sourceUnit === undefined ||
|
|
639
|
-
plan?.kind !== "lemma" ||
|
|
640
|
-
(plan.koreanPos !== 명사 && plan.koreanPos !== 대명사) ||
|
|
641
|
-
(plan.terminalSfp !== undefined && plan.terminalSfp !== null) ||
|
|
642
|
-
plan.auxTokens.length !== 1 ||
|
|
643
|
-
absorbedAux === undefined ||
|
|
644
|
-
!sourceUnit.jpIndices.includes(copulaIdx) ||
|
|
645
|
-
absorbedAux.surface !== "だ" ||
|
|
646
|
-
!isTerminalAssertiveCopulaToken(absorbedAux)) {
|
|
647
|
-
return null;
|
|
648
|
-
}
|
|
649
|
-
const quotativeMarkerUnitIndex = options.markerUnitIndexes.find((unitIndex) => unitIndex !== sourceUnitIndex &&
|
|
650
|
-
options.units[unitIndex]?.unitType === UnitType.FUNCTIONAL);
|
|
651
|
-
return {
|
|
652
|
-
relation: options.relation,
|
|
653
|
-
insertBeforeUnitIndex: sourceUnitIndex,
|
|
654
|
-
replaceUnitIndex: sourceUnitIndex,
|
|
655
|
-
suppressUnitIndexes: [],
|
|
656
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
657
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
658
|
-
projectionTokenIndexes: uniqueSorted(sourceUnit.jpIndices),
|
|
659
|
-
renderPlan: { ...plan, auxTokens: [] },
|
|
660
|
-
...(quotativeMarkerUnitIndex === undefined ? {} : { quotativeMarkerUnitIndex }),
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
function buildSfpQuoteStructuredRenderOperation(options) {
|
|
664
|
-
const quote = options.relation.quote;
|
|
665
|
-
if (quote === undefined ||
|
|
666
|
-
(quote.slotKind !== "quoted_content" && quote.slotKind !== "question_content" && quote.slotKind !== "request_content") ||
|
|
667
|
-
quote.terminalSfp === undefined ||
|
|
668
|
-
quote.terminalSfp === null) {
|
|
669
|
-
return null;
|
|
670
|
-
}
|
|
671
|
-
const sourceUnitIndex = quote.contentPredicateIdx === undefined || quote.contentPredicateIdx === null
|
|
672
|
-
? null
|
|
673
|
-
: options.sourceUnitIndexes.find((unitIndex) => options.units[unitIndex]?.jpIndices.includes(quote.contentPredicateIdx) === true) ?? null;
|
|
674
|
-
const sourceUnit = sourceUnitIndex === null ? undefined : options.units[sourceUnitIndex];
|
|
675
|
-
if (sourceUnitIndex === null || sourceUnit === undefined)
|
|
676
|
-
return null;
|
|
677
|
-
const ownerPlan = sourceUnit.renderPlan;
|
|
678
|
-
if (ownerPlan === null)
|
|
679
|
-
return null;
|
|
680
|
-
const requestReportedAsSpeech = quote.slotKind === "request_content" && (quote.hostMatch.requestReportingRole === "speech" || options.targetUnitIndexes.some((unitIndex) => {
|
|
681
|
-
const targetPlan = options.units[unitIndex]?.renderPlan;
|
|
682
|
-
if (targetPlan?.kind === "quoteHostReportingPassive")
|
|
683
|
-
return true;
|
|
684
|
-
if (targetPlan?.kind === "lemma" &&
|
|
685
|
-
(targetPlan.voice === "passive" || targetPlan.forcePassive === true || targetPlan.passiveClass !== undefined))
|
|
686
|
-
return true;
|
|
687
|
-
if (targetPlan?.kind === "attributive" && targetPlan.voice === "passive")
|
|
688
|
-
return true;
|
|
689
|
-
return isPredicateHeadTailChainRenderPlan(targetPlan) &&
|
|
690
|
-
tailRootVoiceOps(targetPlan.realization.root).some((op) => op.voice === "passive");
|
|
691
|
-
}));
|
|
692
|
-
const requestAttributiveHostUnitIndex = quote.slotKind === "request_content"
|
|
693
|
-
? options.targetUnitIndexes.find((unitIndex) => {
|
|
694
|
-
const unit = options.units[unitIndex];
|
|
695
|
-
return unit?.jpIndices.includes(quote.hostMatch.hostIdx) === true &&
|
|
696
|
-
attributiveModifierPlanSourceFacts(unit.renderPlan)?.carriesNonTenseOperator === false;
|
|
697
|
-
})
|
|
698
|
-
: undefined;
|
|
699
|
-
const requestAttributive = requestAttributiveHostUnitIndex !== undefined && (requestReportedAsSpeech || quote.hostMatch.kind === "report");
|
|
700
|
-
if (quote.slotKind === "request_content") {
|
|
701
|
-
if (quote.terminalSfp.effect !== "na_prohib" && quote.terminalSfp.effect !== "na_soft_imperative")
|
|
702
|
-
return null;
|
|
703
|
-
}
|
|
704
|
-
const wishProjection = quote.hostMatch.kind === "thought" && quote.terminalSfp.effect === "na_excl"
|
|
705
|
-
? projectSufficiencyWishQuotePlan(ownerPlan)
|
|
706
|
-
: null;
|
|
707
|
-
const nominalRequestFocus = requestReportedAsSpeech ? quote.focusParticle : undefined;
|
|
708
|
-
const projected = wishProjection ?? quoteSfpOwnerInPlacePlan(ownerPlan, quote.terminalSfp, requestReportedAsSpeech, requestAttributive, nominalRequestFocus, quote.terminalSfpMarkerBridgeSpan != null);
|
|
709
|
-
if (projected === null)
|
|
710
|
-
return null;
|
|
711
|
-
const markerUnitIndex = projected.retainQuotativeMarker
|
|
712
|
-
? options.markerUnitIndexes.find((unitIndex) => options.units[unitIndex]?.jpIndices.includes(quote.markerIdx) === true)
|
|
713
|
-
: undefined;
|
|
714
|
-
const markerSharesOwnerUnit = markerUnitIndex === sourceUnitIndex;
|
|
715
|
-
const ownerProjection = projected.retainQuotativeMarker && (markerUnitIndex === undefined || markerSharesOwnerUnit)
|
|
716
|
-
? completeSfpQuoteOwnerPlan(projected.plan, quote.terminalSfp)
|
|
717
|
-
: projected.plan;
|
|
718
|
-
if (ownerProjection === null)
|
|
719
|
-
return null;
|
|
720
|
-
const retainsSeparateMarker = projected.retainQuotativeMarker && markerUnitIndex !== undefined && !markerSharesOwnerUnit;
|
|
721
|
-
const focusParticleKey = quote.focusParticle === "は" ? "은/는"
|
|
722
|
-
: quote.focusParticle === "も" ? "도"
|
|
723
|
-
: quote.focusParticle === "でも" ? "이라도/라도"
|
|
724
|
-
: null;
|
|
725
|
-
const ownerChainRealizesQuoteFocus = isPredicateHeadTailChainRenderPlan(ownerProjection) &&
|
|
726
|
-
ownerProjection.realization.root.sfp?.quoteProjection === "terminal_mood" &&
|
|
727
|
-
ownerProjection.realization.root.sfp.quoteFocusParticle !== undefined;
|
|
728
|
-
const focusedPlan = focusParticleKey === null || retainsSeparateMarker ||
|
|
729
|
-
ownerChainRealizesQuoteFocus ||
|
|
730
|
-
(nominalRequestFocus !== undefined && wishProjection === null)
|
|
731
|
-
? ownerProjection
|
|
732
|
-
: attachParticleRenderPlan(ownerProjection, focusParticleKey);
|
|
733
|
-
if (focusedPlan === null)
|
|
734
|
-
return null;
|
|
735
|
-
const quotativeMarkerUnitIndex = retainsSeparateMarker ? markerUnitIndex : undefined;
|
|
736
|
-
const suppressUnitIndexes = options.markerUnitIndexes.filter((unitIndex) => unitIndex !== quotativeMarkerUnitIndex && unitIndex !== sourceUnitIndex).concat(!requestAttributive || requestAttributiveHostUnitIndex === undefined ? [] : [requestAttributiveHostUnitIndex]);
|
|
737
|
-
return {
|
|
738
|
-
relation: options.relation,
|
|
739
|
-
insertBeforeUnitIndex: sourceUnitIndex,
|
|
740
|
-
suppressUnitIndexes,
|
|
741
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
742
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
743
|
-
projectionTokenIndexes: uniqueSorted([
|
|
744
|
-
...sourceUnit.jpIndices,
|
|
745
|
-
...suppressUnitIndexes.flatMap((unitIndex) => options.units[unitIndex]?.jpIndices ?? []),
|
|
746
|
-
]),
|
|
747
|
-
renderPlan: focusedPlan,
|
|
748
|
-
replaceUnitIndex: sourceUnitIndex,
|
|
749
|
-
...(quotativeMarkerUnitIndex === undefined ? {} : { quotativeMarkerUnitIndex }),
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
function projectSufficiencyWishQuotePlan(plan) {
|
|
753
|
-
if (!isPredicateHeadTailChainRenderPlan(plan))
|
|
754
|
-
return null;
|
|
755
|
-
const ownerPlan = materializeSfpOwnerStem(plan);
|
|
756
|
-
const tail = rewriteSufficiencyWishTail(ownerPlan.realization.root.tail);
|
|
757
|
-
if (tail === null)
|
|
758
|
-
return null;
|
|
759
|
-
const conditionalPlan = {
|
|
760
|
-
...ownerPlan,
|
|
761
|
-
realization: {
|
|
762
|
-
...ownerPlan.realization,
|
|
763
|
-
root: { ...ownerPlan.realization.root, tail, sfp: null },
|
|
764
|
-
},
|
|
765
|
-
};
|
|
766
|
-
const renderPlan = structuralRelationSequencePlan([
|
|
767
|
-
conditionalPlan,
|
|
768
|
-
{ kind: "structuralText", text: " 좋겠다고", koreanPos: 구 },
|
|
769
|
-
]);
|
|
770
|
-
return renderPlan === null ? null : { plan: renderPlan, retainQuotativeMarker: false };
|
|
771
|
-
}
|
|
772
|
-
function rewriteSufficiencyWishTail(node) {
|
|
773
|
-
if (node.kind === "connective") {
|
|
774
|
-
const inner = rewriteSufficiencyWishAuxLayer(node.inner);
|
|
775
|
-
if (inner !== null)
|
|
776
|
-
return { ...node, inner };
|
|
777
|
-
const outer = rewriteSufficiencyWishTail(node.outer);
|
|
778
|
-
return outer === null ? null : { ...node, outer };
|
|
779
|
-
}
|
|
780
|
-
return rewriteSufficiencyWishAuxLayer(node);
|
|
781
|
-
}
|
|
782
|
-
function rewriteSufficiencyWishAuxLayer(layer) {
|
|
783
|
-
const index = layer.ops.findIndex((op) => op.kind === "idiom" && op.idiom === "sufficiency_conditional");
|
|
784
|
-
const idiom = index < 0 ? undefined : layer.ops[index];
|
|
785
|
-
if (idiom === undefined)
|
|
786
|
-
return null;
|
|
787
|
-
const conditional = createConnectiveOp({
|
|
788
|
-
connective: "conditional",
|
|
789
|
-
surface: "ば",
|
|
790
|
-
conditionalFlavor: "plain",
|
|
791
|
-
source: idiom.source,
|
|
792
|
-
});
|
|
793
|
-
const prefixOps = layer.ops.slice(0, index).map((op) => {
|
|
794
|
-
if (op.kind !== "voice" || op.candidates?.includes("potential") !== true)
|
|
795
|
-
return op;
|
|
796
|
-
const { candidates: _candidates, passiveClass: _passiveClass, ...voice } = op;
|
|
797
|
-
return { ...voice, voice: "potential" };
|
|
798
|
-
});
|
|
799
|
-
return {
|
|
800
|
-
...layer,
|
|
801
|
-
terminal: null,
|
|
802
|
-
ops: [...prefixOps, conditional, ...layer.ops.slice(index + 1)],
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
function completeSfpQuoteOwnerPlan(plan, sfp) {
|
|
806
|
-
if (isPredicateHeadTailChainRenderPlan(plan)) {
|
|
807
|
-
return {
|
|
808
|
-
...plan,
|
|
809
|
-
realization: {
|
|
810
|
-
...plan.realization,
|
|
811
|
-
root: {
|
|
812
|
-
...plan.realization.root,
|
|
813
|
-
sfp: { ...(plan.realization.root.sfp ?? sfp), quoteProjection: "terminal_mood" },
|
|
814
|
-
},
|
|
815
|
-
},
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
return structuralRelationSequencePlan([
|
|
819
|
-
plan,
|
|
820
|
-
{ kind: "structuralText", text: "라고", koreanPos: 구 },
|
|
821
|
-
]);
|
|
822
|
-
}
|
|
823
|
-
function quoteSfpOwnerInPlacePlan(plan, sfp, requestReportedAsSpeech = false, requestAttributive = false, nominalRequestFocus, markerSeparatedByPunctuation = false) {
|
|
824
|
-
if (isPredicateHeadTailChainRenderPlan(plan)) {
|
|
825
|
-
const ownerPlan = materializeSfpOwnerStem(plan);
|
|
826
|
-
const terminalStem = firstAuxLayer(ownerPlan.realization.root.tail)?.stem;
|
|
827
|
-
const terminalStemSourceForm = terminalStem?.source.tokens[terminalStem.semanticAnchors[0] ?? 0]?.dictionaryForm ??
|
|
828
|
-
terminalStem?.source.tokens[terminalStem.semanticAnchors[0] ?? 0]?.surface;
|
|
829
|
-
const plainNominalNa = sfp.effect === "na_excl" && sfp.surface === "な" && terminalStem?.kind === "noun" &&
|
|
830
|
-
!SFP_NA_EXCLAMATORY_NOMINALIZERS.has(terminalStemSourceForm ?? "");
|
|
831
|
-
if (plainNominalNa) {
|
|
832
|
-
const withoutSfp = {
|
|
833
|
-
...ownerPlan,
|
|
834
|
-
realization: {
|
|
835
|
-
...ownerPlan.realization,
|
|
836
|
-
root: { ...ownerPlan.realization.root, sfp: null },
|
|
837
|
-
},
|
|
838
|
-
};
|
|
839
|
-
const quoted = projectHeadTailConnectivePlan(withoutSfp, { connective: "quotative", surface: "" }, sfp.source);
|
|
840
|
-
return quoted === null ? null : { plan: quoted, retainQuotativeMarker: false };
|
|
841
|
-
}
|
|
842
|
-
const imperative = ownerPlan.realization.root.tail.kind === "auxLayer" &&
|
|
843
|
-
ownerPlan.realization.root.tail.terminal === "imperative";
|
|
844
|
-
if (sfp.effect === "na_soft_imperative" &&
|
|
845
|
-
ownerPlan.realization.root.tail.kind === "auxLayer" &&
|
|
846
|
-
ownerPlan.realization.root.tail.stem.kind === "verb" &&
|
|
847
|
-
ownerPlan.realization.root.tail.ops.length === 0) {
|
|
848
|
-
const stem = ownerPlan.realization.root.tail.stem;
|
|
849
|
-
return {
|
|
850
|
-
plan: {
|
|
851
|
-
kind: "conjugatedLemma",
|
|
852
|
-
koreanLemma: stem.lemma,
|
|
853
|
-
irregular: stem.irregular,
|
|
854
|
-
koreanPos: 동사,
|
|
855
|
-
ending: "(으)라고",
|
|
856
|
-
auxTokens: [],
|
|
857
|
-
},
|
|
858
|
-
retainQuotativeMarker: false,
|
|
859
|
-
};
|
|
860
|
-
}
|
|
861
|
-
const quoteProjection = quoteProjectionForSfpEffect(sfp.effect, imperative);
|
|
862
|
-
if (quoteProjection === "assertive") {
|
|
863
|
-
const withoutSfp = {
|
|
864
|
-
...ownerPlan,
|
|
865
|
-
realization: {
|
|
866
|
-
...ownerPlan.realization,
|
|
867
|
-
root: { ...ownerPlan.realization.root, sfp: null },
|
|
868
|
-
},
|
|
869
|
-
};
|
|
870
|
-
const quoted = projectHeadTailConnectivePlan(withoutSfp, { connective: "quotative", surface: "" }, sfp.source);
|
|
871
|
-
return quoted === null ? null : { plan: quoted, retainQuotativeMarker: false };
|
|
872
|
-
}
|
|
873
|
-
if (quoteProjection === "terminal_mood" && !imperative) {
|
|
874
|
-
if (markerSeparatedByPunctuation) {
|
|
875
|
-
return { plan: ownerPlan, retainQuotativeMarker: true };
|
|
876
|
-
}
|
|
877
|
-
if (sfp.effect === "na_soft_imperative") {
|
|
878
|
-
const withoutSfp = {
|
|
879
|
-
...ownerPlan,
|
|
880
|
-
realization: {
|
|
881
|
-
...ownerPlan.realization,
|
|
882
|
-
root: { ...ownerPlan.realization.root, sfp: null },
|
|
883
|
-
},
|
|
884
|
-
};
|
|
885
|
-
const quoted = projectHeadTailConnectivePlan(withoutSfp, { connective: "quotative", surface: "", quotativeMood: "imperative" }, sfp.source);
|
|
886
|
-
return quoted === null ? null : { plan: quoted, retainQuotativeMarker: false };
|
|
887
|
-
}
|
|
888
|
-
return {
|
|
889
|
-
plan: {
|
|
890
|
-
...ownerPlan,
|
|
891
|
-
realization: {
|
|
892
|
-
...ownerPlan.realization,
|
|
893
|
-
root: {
|
|
894
|
-
...ownerPlan.realization.root,
|
|
895
|
-
sfp: { ...(ownerPlan.realization.root.sfp ?? sfp), quoteProjection: "terminal_mood" },
|
|
896
|
-
},
|
|
897
|
-
},
|
|
898
|
-
},
|
|
899
|
-
retainQuotativeMarker: false,
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
const prohibitiveProjection = requestReportedAsSpeech
|
|
903
|
-
? "reported_request"
|
|
904
|
-
: requestAttributive
|
|
905
|
-
? "attributive_request"
|
|
906
|
-
: "prohibitive";
|
|
907
|
-
const projected = {
|
|
908
|
-
...ownerPlan,
|
|
909
|
-
realization: {
|
|
910
|
-
...ownerPlan.realization,
|
|
911
|
-
root: {
|
|
912
|
-
...ownerPlan.realization.root,
|
|
913
|
-
sfp: quoteProjection === "prohibitive"
|
|
914
|
-
? {
|
|
915
|
-
...(ownerPlan.realization.root.sfp ?? sfp),
|
|
916
|
-
quoteProjection: prohibitiveProjection,
|
|
917
|
-
...(prohibitiveProjection === "reported_request" && nominalRequestFocus !== undefined
|
|
918
|
-
? { quoteFocusParticle: nominalRequestFocus }
|
|
919
|
-
: {}),
|
|
920
|
-
}
|
|
921
|
-
: null,
|
|
922
|
-
},
|
|
923
|
-
},
|
|
924
|
-
};
|
|
925
|
-
if (imperative) {
|
|
926
|
-
const quoted = projectHeadTailConnectivePlan(projected, { connective: "quotative", surface: "", quotativeMood: "imperative" }, sfp.source);
|
|
927
|
-
return quoted === null ? null : { plan: quoted, retainQuotativeMarker: false };
|
|
928
|
-
}
|
|
929
|
-
return { plan: projected, retainQuotativeMarker: false };
|
|
930
|
-
}
|
|
931
|
-
if (plan.kind === "lemma") {
|
|
932
|
-
const predicate = plan.koreanPos === 동사 || plan.koreanPos === 형용사;
|
|
933
|
-
if (sfp.effect === "ka") {
|
|
934
|
-
const questionPlan = { ...plan, sfp: null, terminalSfp: null, connective: "는지" };
|
|
935
|
-
if (plan.koreanPos === 명사)
|
|
936
|
-
return { plan: questionPlan, retainQuotativeMarker: false };
|
|
937
|
-
const quotedQuestion = structuralRelationSequencePlan([
|
|
938
|
-
questionPlan,
|
|
939
|
-
{ kind: "structuralText", text: "라고", koreanPos: 구 },
|
|
940
|
-
]);
|
|
941
|
-
return quotedQuestion === null ? null : { plan: quotedQuestion, retainQuotativeMarker: false };
|
|
942
|
-
}
|
|
943
|
-
if (!predicate) {
|
|
944
|
-
const preserve = quoteProjectionForSfpEffect(sfp.effect, false) === "terminal_mood" &&
|
|
945
|
-
(sfp.effect !== "na_excl" || sfp.surface !== "な" || SFP_NA_EXCLAMATORY_NOMINALIZERS.has(plan.jpDictForm ?? ""));
|
|
946
|
-
return {
|
|
947
|
-
plan: preserve ? plan : { ...plan, auxTokens: [], sfp: null, connective: null },
|
|
948
|
-
retainQuotativeMarker: true,
|
|
949
|
-
};
|
|
950
|
-
}
|
|
951
|
-
const projected = quoteLemmaSfpOwnerPlan(plan, sfp.effect);
|
|
952
|
-
if (projected === null)
|
|
953
|
-
return null;
|
|
954
|
-
const retain = plan.isImperative !== true &&
|
|
955
|
-
sfp.effect !== "na_prohib" &&
|
|
956
|
-
sfp.effect !== "na_soft_imperative" &&
|
|
957
|
-
quoteProjectionForSfpEffect(sfp.effect, false) === "terminal_mood";
|
|
958
|
-
return { plan: retain ? plan : projected, retainQuotativeMarker: retain };
|
|
959
|
-
}
|
|
960
|
-
if (plan.kind === "copulaPredicate") {
|
|
961
|
-
const preserve = quoteProjectionForSfpEffect(sfp.effect, false) === "terminal_mood";
|
|
962
|
-
return preserve
|
|
963
|
-
? { plan, retainQuotativeMarker: true }
|
|
964
|
-
: { plan: { ...plan, sfp: null, connective: "다고" }, retainQuotativeMarker: false };
|
|
965
|
-
}
|
|
966
|
-
return null;
|
|
967
|
-
}
|
|
968
|
-
function materializeSfpOwnerStem(plan) {
|
|
969
|
-
const materializedTail = clearTailNodeTerminal(materializeTailNodeStem(plan.realization.root.tail));
|
|
970
|
-
return materializedTail === plan.realization.root.tail
|
|
971
|
-
? plan
|
|
972
|
-
: {
|
|
973
|
-
...plan,
|
|
974
|
-
realization: {
|
|
975
|
-
...plan.realization,
|
|
976
|
-
root: { ...plan.realization.root, tail: materializedTail },
|
|
977
|
-
},
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
function clearTailNodeTerminal(node) {
|
|
981
|
-
if (node.kind === "connective") {
|
|
982
|
-
const inner = node.inner.terminal === null ? node.inner : { ...node.inner, terminal: null };
|
|
983
|
-
const outer = clearTailNodeTerminal(node.outer);
|
|
984
|
-
return inner === node.inner && outer === node.outer ? node : { ...node, inner, outer };
|
|
985
|
-
}
|
|
986
|
-
return node.terminal === null ? node : { ...node, terminal: null };
|
|
987
|
-
}
|
|
988
|
-
function materializeTailNodeStem(node) {
|
|
989
|
-
if (node.kind === "connective") {
|
|
990
|
-
const inner = materializeAuxLayerStem(node.inner);
|
|
991
|
-
const outer = materializeTailNodeStem(node.outer);
|
|
992
|
-
return inner === node.inner && outer === node.outer ? node : { ...node, inner, outer };
|
|
993
|
-
}
|
|
994
|
-
return materializeAuxLayerStem(node);
|
|
995
|
-
}
|
|
996
|
-
function materializeAuxLayerStem(node) {
|
|
997
|
-
return resolveCandidateSetLayer(node);
|
|
998
|
-
}
|
|
999
|
-
function quoteLemmaSfpOwnerPlan(sourcePlan, effect) {
|
|
1000
|
-
const predicate = sourcePlan.koreanPos === 동사 || sourcePlan.koreanPos === 형용사;
|
|
1001
|
-
if (!predicate) {
|
|
1002
|
-
return null;
|
|
1003
|
-
}
|
|
1004
|
-
if (effect === "na_prohib") {
|
|
1005
|
-
return {
|
|
1006
|
-
kind: "conjugatedLemma",
|
|
1007
|
-
koreanLemma: sourcePlan.koreanLemma,
|
|
1008
|
-
irregular: sourcePlan.irregular,
|
|
1009
|
-
koreanPos: sourcePlan.koreanPos,
|
|
1010
|
-
ending: "지 말라고",
|
|
1011
|
-
auxTokens: sourcePlan.auxTokens,
|
|
1012
|
-
...(typeof sourcePlan.prefix === "string" ? { prefix: sourcePlan.prefix } : {}),
|
|
1013
|
-
...(sourcePlan.jpDictForm === undefined ? {} : { jpDictForm: sourcePlan.jpDictForm }),
|
|
1014
|
-
...(sourcePlan.verbConjType === undefined ? {} : { verbConjType: sourcePlan.verbConjType }),
|
|
1015
|
-
...(sourcePlan.voice === undefined ? {} : { voice: sourcePlan.voice }),
|
|
1016
|
-
};
|
|
1017
|
-
}
|
|
1018
|
-
if (effect === "na_soft_imperative") {
|
|
1019
|
-
return {
|
|
1020
|
-
kind: "conjugatedLemma",
|
|
1021
|
-
koreanLemma: sourcePlan.koreanLemma,
|
|
1022
|
-
irregular: sourcePlan.irregular,
|
|
1023
|
-
koreanPos: sourcePlan.koreanPos,
|
|
1024
|
-
ending: "(으)라고",
|
|
1025
|
-
auxTokens: sourcePlan.auxTokens,
|
|
1026
|
-
...(typeof sourcePlan.prefix === "string" ? { prefix: sourcePlan.prefix } : {}),
|
|
1027
|
-
...(sourcePlan.jpDictForm === undefined ? {} : { jpDictForm: sourcePlan.jpDictForm }),
|
|
1028
|
-
...(sourcePlan.verbConjType === undefined ? {} : { verbConjType: sourcePlan.verbConjType }),
|
|
1029
|
-
...(sourcePlan.voice === undefined ? {} : { voice: sourcePlan.voice }),
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
if (sourcePlan.isImperative === true) {
|
|
1033
|
-
return {
|
|
1034
|
-
kind: "conjugatedLemma",
|
|
1035
|
-
koreanLemma: sourcePlan.koreanLemma,
|
|
1036
|
-
irregular: sourcePlan.irregular,
|
|
1037
|
-
koreanPos: sourcePlan.koreanPos,
|
|
1038
|
-
ending: "(으)라고",
|
|
1039
|
-
auxTokens: sourcePlan.auxTokens,
|
|
1040
|
-
...(typeof sourcePlan.prefix === "string" ? { prefix: sourcePlan.prefix } : {}),
|
|
1041
|
-
...(sourcePlan.jpDictForm === undefined ? {} : { jpDictForm: sourcePlan.jpDictForm }),
|
|
1042
|
-
...(sourcePlan.verbConjType === undefined ? {} : { verbConjType: sourcePlan.verbConjType }),
|
|
1043
|
-
...(sourcePlan.voice === undefined ? {} : { voice: sourcePlan.voice }),
|
|
1044
|
-
};
|
|
1045
|
-
}
|
|
1046
|
-
if (quoteProjectionForSfpEffect(effect, false) === "terminal_mood") {
|
|
1047
|
-
return sourcePlan;
|
|
1048
|
-
}
|
|
1049
|
-
return {
|
|
1050
|
-
...sourcePlan,
|
|
1051
|
-
connective: "다고",
|
|
1052
|
-
sfp: null,
|
|
1053
|
-
};
|
|
1054
|
-
}
|
|
1055
|
-
function buildReasonCopulaQuoteStructuredRenderOperation(options) {
|
|
1056
|
-
const relation = options.relation;
|
|
1057
|
-
const quote = relation.quote;
|
|
1058
|
-
if (quote === undefined ||
|
|
1059
|
-
quote.slotKind !== "quoted_content" ||
|
|
1060
|
-
quote.contentSpan.endExclusive !== quote.markerIdx) {
|
|
1061
|
-
return null;
|
|
1062
|
-
}
|
|
1063
|
-
const match = reasonCopulaQuoteContentMatchBeforeMarker(options.tokens, quote.contentSpan, quote.markerIdx);
|
|
1064
|
-
if (match === null) {
|
|
1065
|
-
return null;
|
|
1066
|
-
}
|
|
1067
|
-
const predicateUnitIndex = sourceUnitIndexesWithToken(options.units, options.sourceUnitIndexes, match.reasonMarkerIdx)
|
|
1068
|
-
.find((unitIndex) => options.units[unitIndex]?.renderPlan?.kind === "headTailChain") ?? null;
|
|
1069
|
-
const predicateUnit = predicateUnitIndex === null ? undefined : options.units[predicateUnitIndex];
|
|
1070
|
-
if (predicateUnitIndex === null || predicateUnit === undefined || predicateUnit.unitType === UnitType.SYMBOL) {
|
|
1071
|
-
return null;
|
|
1072
|
-
}
|
|
1073
|
-
const reasonPlan = reasonBecauseNominalPlanFromUnit(predicateUnit, match.reasonMarkerIdx);
|
|
1074
|
-
if (reasonPlan === null) {
|
|
1075
|
-
return null;
|
|
1076
|
-
}
|
|
1077
|
-
const sourcePlan = composeRelationSourceUnitPlans(options.tokens, options.units, sourceUnitIndexesExcludingFullyCoveredSpans(options.units, options.sourceUnitIndexes, [
|
|
1078
|
-
{ start: match.reasonMarkerIdx, endExclusive: match.reasonMarkerIdx + 1 },
|
|
1079
|
-
{ start: match.copulaStart, endExclusive: match.copulaEndExclusive },
|
|
1080
|
-
]), new Map([[predicateUnitIndex, reasonPlan]]));
|
|
1081
|
-
if (sourcePlan === null) {
|
|
1082
|
-
return null;
|
|
1083
|
-
}
|
|
1084
|
-
const quotedPlan = reasonCopulaQuotedRenderPlan(sourcePlan, match, sourceSpanForStructuralTokenSpan(options.tokens, quote.markerSpan));
|
|
1085
|
-
if (quotedPlan === null) {
|
|
1086
|
-
return null;
|
|
1087
|
-
}
|
|
1088
|
-
const suppressUnitIndexes = uniqueSorted([...options.sourceUnitIndexes, ...options.markerUnitIndexes])
|
|
1089
|
-
.filter((unitIndex) => options.units[unitIndex]?.unitType !== UnitType.SYMBOL);
|
|
1090
|
-
return {
|
|
1091
|
-
relation,
|
|
1092
|
-
insertBeforeUnitIndex: options.sourceUnitIndexes[0] ?? predicateUnitIndex,
|
|
1093
|
-
suppressUnitIndexes,
|
|
1094
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
1095
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1096
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
1097
|
-
renderPlan: quotedPlan,
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
function buildReasonCopulaExplanationStructuredRenderOperation(options) {
|
|
1101
|
-
const reasonMarker = options.relation.markerSpans.find((span) => span.role === "reason_marker") ?? null;
|
|
1102
|
-
const copulaMarker = options.relation.markerSpans.find((span) => span.role === "explanatory_copula") ?? null;
|
|
1103
|
-
const reasonCopula = options.relation.reasonCopula;
|
|
1104
|
-
if (reasonMarker === null || copulaMarker === null || reasonCopula === undefined) {
|
|
1105
|
-
return null;
|
|
1106
|
-
}
|
|
1107
|
-
const predicateUnitIndex = sourceUnitIndexesWithToken(options.units, options.sourceUnitIndexes, reasonMarker.start)
|
|
1108
|
-
.find((unitIndex) => options.units[unitIndex]?.renderPlan?.kind === "headTailChain") ?? null;
|
|
1109
|
-
const predicateUnit = predicateUnitIndex === null ? undefined : options.units[predicateUnitIndex];
|
|
1110
|
-
if (predicateUnitIndex === null || predicateUnit === undefined || predicateUnit.unitType === UnitType.SYMBOL) {
|
|
1111
|
-
return null;
|
|
1112
|
-
}
|
|
1113
|
-
const reasonPlan = reasonBecauseNominalPlanFromUnit(predicateUnit, reasonMarker.start);
|
|
1114
|
-
if (reasonPlan === null) {
|
|
1115
|
-
return null;
|
|
1116
|
-
}
|
|
1117
|
-
const match = {
|
|
1118
|
-
reasonMarkerIdx: reasonMarker.start,
|
|
1119
|
-
copulaStart: copulaMarker.start,
|
|
1120
|
-
copulaEndExclusive: copulaMarker.endExclusive,
|
|
1121
|
-
past: reasonCopula.past,
|
|
1122
|
-
polite: reasonCopula.polite,
|
|
1123
|
-
conjunctive: reasonCopula.connective,
|
|
1124
|
-
negative: reasonCopula.negative,
|
|
1125
|
-
additiveMo: reasonCopula.additiveMo,
|
|
1126
|
-
conjecture: reasonCopula.conjecture,
|
|
1127
|
-
};
|
|
1128
|
-
const projectedUnitIndexes = options.sourceSpanUnitIndexes;
|
|
1129
|
-
const sourcePlan = composeRelationSourceUnitPlans(options.tokens, options.units, projectedUnitIndexes, new Map([[predicateUnitIndex, reasonPlan]]));
|
|
1130
|
-
if (sourcePlan === null) {
|
|
1131
|
-
return null;
|
|
1132
|
-
}
|
|
1133
|
-
const quoteMarker = options.relation.markerSpans.find((span) => span.role === "quotative_marker") ?? null;
|
|
1134
|
-
const renderPlan = quoteMarker === null
|
|
1135
|
-
? reasonCopulaTerminalRenderPlan(sourcePlan, match, sourceSpanForStructuralTokenSpan(options.tokens, copulaMarker), reasonCopula.sfp)
|
|
1136
|
-
: reasonCopulaQuotedRenderPlan(sourcePlan, match, sourceSpanForStructuralTokenSpan(options.tokens, quoteMarker));
|
|
1137
|
-
if (renderPlan === null) {
|
|
1138
|
-
return null;
|
|
1139
|
-
}
|
|
1140
|
-
const suppressUnitIndexes = uniqueSorted([...projectedUnitIndexes, ...options.markerUnitIndexes]);
|
|
1141
|
-
const edgeAttachment = projectionEdgeAttachment(options.units, projectedUnitIndexes);
|
|
1142
|
-
return {
|
|
1143
|
-
relation: options.relation,
|
|
1144
|
-
insertBeforeUnitIndex: projectedUnitIndexes[0] ?? predicateUnitIndex,
|
|
1145
|
-
suppressUnitIndexes,
|
|
1146
|
-
...edgeAttachment,
|
|
1147
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
1148
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1149
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
1150
|
-
renderPlan,
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
function reasonBecauseNominalPlanFromUnit(unit, reasonMarkerIdx) {
|
|
1154
|
-
const plan = unit.renderPlan;
|
|
1155
|
-
if (!isPredicateHeadTailChainRenderPlan(plan) || plan.realization.root.tail.kind !== "auxLayer") {
|
|
1156
|
-
return null;
|
|
1157
|
-
}
|
|
1158
|
-
const layer = plan.realization.root.tail;
|
|
1159
|
-
const stem = layer.stem.kind === "candidateSet"
|
|
1160
|
-
? layer.stem.committedSense === undefined
|
|
1161
|
-
? null
|
|
1162
|
-
: resolveCandidateSetStem(layer.stem)
|
|
1163
|
-
: layer.stem;
|
|
1164
|
-
if (stem === null) {
|
|
1165
|
-
return null;
|
|
1166
|
-
}
|
|
1167
|
-
if (stem.kind !== "verb" && stem.kind !== "adj" && stem.kind !== "noun") {
|
|
1168
|
-
return null;
|
|
1169
|
-
}
|
|
1170
|
-
const ops = layer.ops.filter((op) => (op.kind !== "connective" &&
|
|
1171
|
-
op.source.tokenIndices.every((tokenIndex) => tokenIndex < reasonMarkerIdx)));
|
|
1172
|
-
const voiceOp = [...ops].reverse().find((op) => op.kind === "voice") ?? null;
|
|
1173
|
-
const voice = voiceOp?.kind === "voice"
|
|
1174
|
-
? voiceFromTailVoice(voiceOp.voice)
|
|
1175
|
-
: "active";
|
|
1176
|
-
const projectionOps = reasonProjectionOpsWithStemMood(ops, stem);
|
|
1177
|
-
const payload = {
|
|
1178
|
-
entry: plan.realization.entry ?? null,
|
|
1179
|
-
koreanLemma: stem.lemma,
|
|
1180
|
-
irregular: stem.kind === "noun" ? null : stem.irregular,
|
|
1181
|
-
auxTokens: auxTokensForOps(ops.filter((op) => op.kind !== "adjCopulaBridge")),
|
|
1182
|
-
koreanPos: stem.kind === "verb" ? 동사 : stem.kind === "adj" ? 형용사 : 명사,
|
|
1183
|
-
projection: "nominal",
|
|
1184
|
-
voice,
|
|
1185
|
-
jpDictForm: stem.source.tokens[stem.semanticAnchors[0] ?? 0]?.dictionaryForm ?? null,
|
|
1186
|
-
sahenCompound: false,
|
|
1187
|
-
sahenNoun: stem.kind === "noun" && stem.sahen ? stem.lemma : null,
|
|
1188
|
-
negative: ops.some((op) => op.kind === "negation" || ("polarity" in op && op.polarity === "negative")),
|
|
1189
|
-
past: ops.some((op) => (op.kind === "tense" && op.tense === "past") ||
|
|
1190
|
-
(op.kind === "negation" && op.chainPast)),
|
|
1191
|
-
predicateRoot: {
|
|
1192
|
-
...plan.realization.root,
|
|
1193
|
-
tail: {
|
|
1194
|
-
...layer,
|
|
1195
|
-
ops: projectionOps,
|
|
1196
|
-
terminal: null
|
|
1197
|
-
},
|
|
1198
|
-
sfp: null
|
|
1199
|
-
},
|
|
1200
|
-
...(plan.realization.hostProjection === undefined
|
|
1201
|
-
? {}
|
|
1202
|
-
: { predicateHostProjection: plan.realization.hostProjection }),
|
|
1203
|
-
...(voiceOp?.kind === "voice" && voiceOp.passiveClass !== undefined
|
|
1204
|
-
? { passiveClass: voiceOp.passiveClass }
|
|
1205
|
-
: {}),
|
|
1206
|
-
};
|
|
1207
|
-
return {
|
|
1208
|
-
kind: "reasonBecause",
|
|
1209
|
-
payload,
|
|
1210
|
-
};
|
|
1211
|
-
}
|
|
1212
|
-
function reasonProjectionOpsWithStemMood(ops, stem) {
|
|
1213
|
-
if (stem.stemMood !== "conjectural" || ops.some((op) => op.kind === "conjecture")) {
|
|
1214
|
-
return ops;
|
|
1215
|
-
}
|
|
1216
|
-
const moodToken = stem.source.tokens[stem.conjugationAnchor];
|
|
1217
|
-
if (moodToken === undefined) {
|
|
1218
|
-
return ops;
|
|
1219
|
-
}
|
|
1220
|
-
return [
|
|
1221
|
-
...ops,
|
|
1222
|
-
createConjectureOp({
|
|
1223
|
-
polite: false,
|
|
1224
|
-
source: {
|
|
1225
|
-
tokens: [moodToken],
|
|
1226
|
-
tokenIndices: [stem.source.tokenIndices[stem.conjugationAnchor] ?? -1],
|
|
1227
|
-
},
|
|
1228
|
-
}),
|
|
1229
|
-
];
|
|
1230
|
-
}
|
|
1231
|
-
function reasonCopulaQuotedRenderPlan(reasonPlan, match, sourceSpan) {
|
|
1232
|
-
if (match.negative || match.conjecture !== null) {
|
|
1233
|
-
return null;
|
|
1234
|
-
}
|
|
1235
|
-
if (!match.past) {
|
|
1236
|
-
return attachParticleRenderPlan(reasonPlan, "이라고/라고");
|
|
1237
|
-
}
|
|
1238
|
-
return structuralRelationSequencePlan([
|
|
1239
|
-
reasonPlan,
|
|
1240
|
-
{
|
|
1241
|
-
kind: "structuralText",
|
|
1242
|
-
text: "이었다고",
|
|
1243
|
-
koreanPos: 구,
|
|
1244
|
-
sourceSpan,
|
|
1245
|
-
},
|
|
1246
|
-
]);
|
|
1247
|
-
}
|
|
1248
|
-
function reasonCopulaTerminalRenderPlan(reasonPlan, match, _sourceSpan, sfp = null) {
|
|
1249
|
-
if (match.negative) {
|
|
1250
|
-
if (match.conjecture !== null) {
|
|
1251
|
-
const focusedPlan = attachParticleRenderPlan(reasonPlan, match.additiveMo ? "도" : "은/는");
|
|
1252
|
-
if (focusedPlan === null)
|
|
1253
|
-
return null;
|
|
1254
|
-
const suffix = match.conjecture.polite
|
|
1255
|
-
? match.past ? "아니었겠죠" : "아니겠죠"
|
|
1256
|
-
: match.past ? "아니었겠지" : "아니겠지";
|
|
1257
|
-
return structuralRelationSequencePlan([
|
|
1258
|
-
focusedPlan,
|
|
1259
|
-
{
|
|
1260
|
-
kind: "structuralText",
|
|
1261
|
-
text: ` ${suffix}`,
|
|
1262
|
-
koreanPos: 구,
|
|
1263
|
-
},
|
|
1264
|
-
]);
|
|
1265
|
-
}
|
|
1266
|
-
const particle = match.additiveMo ? "도" : match.conjunctive ? "이/가" : "은/는";
|
|
1267
|
-
const focusedPlan = attachParticleRenderPlan(reasonPlan, particle);
|
|
1268
|
-
if (focusedPlan === null) {
|
|
1269
|
-
return null;
|
|
1270
|
-
}
|
|
1271
|
-
const suffix = match.conjunctive
|
|
1272
|
-
? match.past
|
|
1273
|
-
? { casual: "아니었고", formal: "아니었고" }
|
|
1274
|
-
: { casual: "아니고", formal: "아니고" }
|
|
1275
|
-
: match.past && match.polite
|
|
1276
|
-
? { casual: "아니었어요", formal: "아니었습니다" }
|
|
1277
|
-
: match.past
|
|
1278
|
-
? { casual: "아니었어", formal: "아니었다" }
|
|
1279
|
-
: match.polite
|
|
1280
|
-
? { casual: "아니에요", formal: "아닙니다" }
|
|
1281
|
-
: { casual: "아니야", formal: "아니다" };
|
|
1282
|
-
return structuralRelationSequencePlan([
|
|
1283
|
-
focusedPlan,
|
|
1284
|
-
{
|
|
1285
|
-
kind: "registerText",
|
|
1286
|
-
casual: ` ${suffix.casual}`,
|
|
1287
|
-
formal: ` ${suffix.formal}`,
|
|
1288
|
-
koreanPos: 구,
|
|
1289
|
-
},
|
|
1290
|
-
]);
|
|
1291
|
-
}
|
|
1292
|
-
if (match.conjunctive) {
|
|
1293
|
-
return structuralRelationSequencePlan([
|
|
1294
|
-
reasonPlan,
|
|
1295
|
-
{
|
|
1296
|
-
kind: "structuralText",
|
|
1297
|
-
text: "이고",
|
|
1298
|
-
koreanPos: 구,
|
|
1299
|
-
},
|
|
1300
|
-
]);
|
|
1301
|
-
}
|
|
1302
|
-
const suffix = reasonCopulaTerminalSuffix(match, sfp);
|
|
1303
|
-
if (suffix === null) {
|
|
1304
|
-
return null;
|
|
1305
|
-
}
|
|
1306
|
-
return structuralRelationSequencePlan([
|
|
1307
|
-
reasonPlan,
|
|
1308
|
-
{
|
|
1309
|
-
kind: "registerText",
|
|
1310
|
-
casual: suffix.casual,
|
|
1311
|
-
formal: suffix.formal,
|
|
1312
|
-
koreanPos: 구,
|
|
1313
|
-
},
|
|
1314
|
-
]);
|
|
1315
|
-
}
|
|
1316
|
-
function reasonCopulaTerminalSuffix(match, sfp) {
|
|
1317
|
-
const effect = sfp?.effect ?? null;
|
|
1318
|
-
const conjecture = match.conjecture !== null;
|
|
1319
|
-
const polite = match.conjecture?.polite ?? match.polite;
|
|
1320
|
-
if (effect !== null) {
|
|
1321
|
-
const casual = nounCopulaDiscursiveSfpEnding(REASON_BECAUSE_BOUND_NOUN, match.past, false, polite, effect, conjecture);
|
|
1322
|
-
const formal = nounCopulaDiscursiveSfpEnding(REASON_BECAUSE_BOUND_NOUN, match.past, true, polite, effect, conjecture);
|
|
1323
|
-
return casual === null || formal === null ? null : { casual, formal };
|
|
1324
|
-
}
|
|
1325
|
-
if (conjecture) {
|
|
1326
|
-
const suffix = polite
|
|
1327
|
-
? match.past ? "이었겠죠" : "이겠죠"
|
|
1328
|
-
: match.past ? "이었겠지" : "이겠지";
|
|
1329
|
-
return { casual: suffix, formal: suffix };
|
|
1330
|
-
}
|
|
1331
|
-
return match.past && match.polite
|
|
1332
|
-
? { casual: "이었어요", formal: "이었습니다" }
|
|
1333
|
-
: match.past
|
|
1334
|
-
? { casual: "이었어", formal: "이었다" }
|
|
1335
|
-
: match.polite
|
|
1336
|
-
? { casual: "이에요", formal: "입니다" }
|
|
1337
|
-
: { casual: "이야", formal: "이다" };
|
|
1338
|
-
}
|
|
1339
|
-
function voiceFromTailVoice(voice) {
|
|
1340
|
-
if (voice === "potential") {
|
|
1341
|
-
return "potential";
|
|
1342
|
-
}
|
|
1343
|
-
if (voice === "passive" || voice === "causative_passive" || voice === "honorific") {
|
|
1344
|
-
return "passive";
|
|
1345
|
-
}
|
|
1346
|
-
return "active";
|
|
1347
|
-
}
|
|
1348
|
-
function auxTokensForOps(ops) {
|
|
1349
|
-
const byIndex = new Map();
|
|
1350
|
-
for (const op of ops) {
|
|
1351
|
-
for (const [offset, tokenIndex] of op.source.tokenIndices.entries()) {
|
|
1352
|
-
const token = op.source.tokens[offset];
|
|
1353
|
-
if (token !== undefined) {
|
|
1354
|
-
byIndex.set(tokenIndex, token);
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
return [...byIndex.entries()]
|
|
1359
|
-
.sort(([left], [right]) => left - right)
|
|
1360
|
-
.map(([, token]) => token);
|
|
1361
|
-
}
|
|
1362
|
-
function sourceUnitIndexesExcludingFullyCoveredSpans(units, sourceUnitIndexes, spans) {
|
|
1363
|
-
return sourceUnitIndexes.filter((unitIndex) => {
|
|
1364
|
-
const unit = units[unitIndex];
|
|
1365
|
-
return unit !== undefined && !unitFullyCoveredBySpans(unit, spans);
|
|
1366
|
-
});
|
|
1367
|
-
}
|
|
1368
|
-
function conditionalClauseSpanAt(graph, conditionalIdx) {
|
|
1369
|
-
return graph.nodes
|
|
1370
|
-
.filter((node) => node.span.start <= conditionalIdx && conditionalIdx < node.span.endExclusive)
|
|
1371
|
-
.sort((left, right) => (left.span.endExclusive - left.span.start) - (right.span.endExclusive - right.span.start))[0]?.span ?? null;
|
|
1372
|
-
}
|
|
1373
|
-
function conditionalClauseSourceUnitIndexes(graph, units, sourceUnitIndexes, conditionalIdx) {
|
|
1374
|
-
const span = conditionalClauseSpanAt(graph, conditionalIdx);
|
|
1375
|
-
if (span === null)
|
|
1376
|
-
return sourceUnitIndexes;
|
|
1377
|
-
return sourceUnitIndexes.filter((unitIndex) => units[unitIndex]?.jpIndices.some((tokenIndex) => span.start <= tokenIndex && tokenIndex < span.endExclusive) === true);
|
|
1378
|
-
}
|
|
1379
|
-
function rootWithStructuralQuoteMarker(root, quote, markerSource, connective) {
|
|
1380
|
-
if (root.tail.kind !== "auxLayer")
|
|
1381
|
-
return root;
|
|
1382
|
-
const last = root.tail.ops.at(-1);
|
|
1383
|
-
if (last?.kind === "connective" &&
|
|
1384
|
-
(last.connective === "quotative" ||
|
|
1385
|
-
last.connective === "question_quotative" ||
|
|
1386
|
-
last.connective === "wish_complement")) {
|
|
1387
|
-
return root;
|
|
1388
|
-
}
|
|
1389
|
-
const markerConnective = createConnectiveOp({
|
|
1390
|
-
connective,
|
|
1391
|
-
surface: quote.markerBaseSurface,
|
|
1392
|
-
source: markerSource,
|
|
1393
|
-
});
|
|
1394
|
-
return {
|
|
1395
|
-
...root,
|
|
1396
|
-
tail: { ...root.tail, ops: [...root.tail.ops, markerConnective] },
|
|
1397
|
-
};
|
|
1398
|
-
}
|
|
1399
|
-
function thoughtHostHasConditionalContinuation(options) {
|
|
1400
|
-
const hostUnitIndex = sourceUnitIndexesWithToken(options.units, options.targetUnitIndexes, options.hostIdx).find((unitIndex) => isPredicateHeadTailChainRenderPlan(options.units[unitIndex]?.renderPlan ?? null));
|
|
1401
|
-
if (hostUnitIndex === undefined)
|
|
1402
|
-
return false;
|
|
1403
|
-
const plan = options.units[hostUnitIndex]?.renderPlan;
|
|
1404
|
-
if (!isPredicateHeadTailChainRenderPlan(plan) || plan.realization.root.tail.kind !== "auxLayer") {
|
|
1405
|
-
return false;
|
|
1406
|
-
}
|
|
1407
|
-
const finalOp = plan.realization.root.tail.ops.at(-1);
|
|
1408
|
-
return finalOp?.kind === "connective" && finalOp.connective === "conditional";
|
|
1409
|
-
}
|
|
1410
|
-
function rootHasDirectPositivePotentialRecipientBenefactiveWishEvidence(root) {
|
|
1411
|
-
if (root.tail.kind !== "auxLayer")
|
|
1412
|
-
return false;
|
|
1413
|
-
return root.tail.ops.some((op, index, ops) => {
|
|
1414
|
-
if (!isBenefactiveAspectOp(op) ||
|
|
1415
|
-
!op.benefactive.potential ||
|
|
1416
|
-
(op.benefactive.kind !== "morau" && op.benefactive.kind !== "itadaku")) {
|
|
1417
|
-
return false;
|
|
1418
|
-
}
|
|
1419
|
-
const conditional = ops[index + 1];
|
|
1420
|
-
return conditional?.kind === "connective" && conditional.connective === "conditional";
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
function quoteMarkerDirectlyPrecedesHost(tokens, quote) {
|
|
1424
|
-
const hostStart = quote.hostMatch.supportIdx ?? quote.hostMatch.hostIdx;
|
|
1425
|
-
const previous = previousNonSpaceIndex(tokens, hostStart);
|
|
1426
|
-
return previous !== null &&
|
|
1427
|
-
quote.markerSpan.start <= previous &&
|
|
1428
|
-
previous < quote.markerSpan.endExclusive;
|
|
1429
|
-
}
|
|
1430
|
-
function buildConditionalWishQuoteStructuredRenderOperation(options) {
|
|
1431
|
-
const relation = options.relation;
|
|
1432
|
-
const quote = relation.quote;
|
|
1433
|
-
if (quote === undefined ||
|
|
1434
|
-
!((quote.slotKind === "quoted_content" && quote.hostMatch.kind === "thought") ||
|
|
1435
|
-
(quote.slotKind === "wish_content" && quote.hostMatch.kind === "wish")) ||
|
|
1436
|
-
quote.contentSpan.endExclusive !== quote.markerIdx) {
|
|
1437
|
-
return null;
|
|
1438
|
-
}
|
|
1439
|
-
if (quote.conditionalContent?.subtype !== "affirmative_wish") {
|
|
1440
|
-
return null;
|
|
1441
|
-
}
|
|
1442
|
-
const thoughtHostConditionalContinuation = quote.hostMatch.kind === "thought" &&
|
|
1443
|
-
thoughtHostHasConditionalContinuation({
|
|
1444
|
-
units: options.units,
|
|
1445
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1446
|
-
hostIdx: quote.hostMatch.hostIdx,
|
|
1447
|
-
});
|
|
1448
|
-
const conditionalIdx = quote.conditionalContent.tokenIdx;
|
|
1449
|
-
const predicateUnitIndex = sourceUnitIndexesWithToken(options.units, uniqueSorted([...options.sourceUnitIndexes, ...options.markerUnitIndexes]), conditionalIdx)
|
|
1450
|
-
.find((unitIndex) => options.units[unitIndex]?.renderPlan?.kind === "headTailChain") ?? null;
|
|
1451
|
-
const predicateUnit = predicateUnitIndex === null ? undefined : options.units[predicateUnitIndex];
|
|
1452
|
-
if (predicateUnitIndex === null || predicateUnit === undefined || predicateUnit.unitType === UnitType.SYMBOL) {
|
|
1453
|
-
return null;
|
|
1454
|
-
}
|
|
1455
|
-
const predicateRenderPlan = predicateUnit.renderPlan;
|
|
1456
|
-
if (!isPredicateHeadTailChainRenderPlan(predicateRenderPlan) ||
|
|
1457
|
-
predicateRenderPlan.realization.root.tail.kind !== "auxLayer") {
|
|
1458
|
-
return null;
|
|
1459
|
-
}
|
|
1460
|
-
if (thoughtHostConditionalContinuation &&
|
|
1461
|
-
!rootHasDirectPositivePotentialRecipientBenefactiveWishEvidence(predicateRenderPlan.realization.root)) {
|
|
1462
|
-
return null;
|
|
1463
|
-
}
|
|
1464
|
-
const quoteMarkerSource = opSourceForMarkerSpans(options.tokens, relation.markerSpans);
|
|
1465
|
-
if (quoteMarkerSource === null) {
|
|
1466
|
-
return null;
|
|
1467
|
-
}
|
|
1468
|
-
const productionRoot = rootWithStructuralQuoteMarker(predicateRenderPlan.realization.root, quote, quoteMarkerSource, "wish_complement");
|
|
1469
|
-
const productionDispatch = probeProductionDispatch(productionRoot, {
|
|
1470
|
-
relations: [relation],
|
|
1471
|
-
intake: { site: "committed_render", partial: false }
|
|
1472
|
-
});
|
|
1473
|
-
if (productionDispatch.kind !== "registry" ||
|
|
1474
|
-
!isConditionalQuoteProductionMatch(productionDispatch.match)) {
|
|
1475
|
-
return null;
|
|
1476
|
-
}
|
|
1477
|
-
const predicatePlan = projectUnitWithoutQuoteMarkerConnectivePlan(predicateUnit, quoteMarkerSource, rootHasDirectPositivePotentialRecipientBenefactiveWishEvidence(predicateRenderPlan.realization.root) ||
|
|
1478
|
-
quoteMarkerDirectlyPrecedesHost(options.tokens, quote), normalizeProductionMatch(productionRoot, productionDispatch.match));
|
|
1479
|
-
if (predicatePlan === null) {
|
|
1480
|
-
return null;
|
|
1481
|
-
}
|
|
1482
|
-
const localSourceUnitIndexes = conditionalClauseSourceUnitIndexes(options.graph, options.units, options.sourceUnitIndexes, conditionalIdx);
|
|
1483
|
-
const conditionalClauseSpan = conditionalClauseSpanAt(options.graph, conditionalIdx) ?? quote.contentSpan;
|
|
1484
|
-
const internalSymbolUnitIndexes = unitIndexesInSpan(options.units, conditionalClauseSpan)
|
|
1485
|
-
.filter((unitIndex) => options.units[unitIndex]?.unitType === UnitType.SYMBOL);
|
|
1486
|
-
const wishSourceUnitIndexes = uniqueSorted([
|
|
1487
|
-
...localSourceUnitIndexes,
|
|
1488
|
-
...internalSymbolUnitIndexes,
|
|
1489
|
-
]);
|
|
1490
|
-
const sourcePlan = composeRelationSourceUnitPlans(options.tokens, options.units, wishSourceUnitIndexes, new Map([[predicateUnitIndex, predicatePlan]]));
|
|
1491
|
-
if (sourcePlan === null) {
|
|
1492
|
-
return null;
|
|
1493
|
-
}
|
|
1494
|
-
const thoughtSuffix = {
|
|
1495
|
-
kind: "structuralText",
|
|
1496
|
-
text: " 좋겠다고",
|
|
1497
|
-
koreanPos: 구,
|
|
1498
|
-
sourceSpan: sourceSpanForStructuralTokenSpan(options.tokens, relation.markerSpans[0] ?? quote.markerSpan),
|
|
1499
|
-
};
|
|
1500
|
-
const renderPlan = structuralRelationSequencePlan([sourcePlan, thoughtSuffix]);
|
|
1501
|
-
if (renderPlan === null) {
|
|
1502
|
-
return null;
|
|
1503
|
-
}
|
|
1504
|
-
const suppressUnitIndexes = uniqueSorted([...wishSourceUnitIndexes, ...options.markerUnitIndexes]);
|
|
1505
|
-
return {
|
|
1506
|
-
relation,
|
|
1507
|
-
insertBeforeUnitIndex: wishSourceUnitIndexes[0] ?? predicateUnitIndex,
|
|
1508
|
-
suppressUnitIndexes,
|
|
1509
|
-
sourceUnitIndexes: wishSourceUnitIndexes,
|
|
1510
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1511
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
1512
|
-
renderPlan,
|
|
1513
|
-
};
|
|
1514
|
-
}
|
|
1515
|
-
function sourceTokensOverlap(left, right) {
|
|
1516
|
-
if (left.sourceSpan !== undefined && left.sourceSpan !== null && right.sourceSpan !== undefined && right.sourceSpan !== null) {
|
|
1517
|
-
return left.sourceSpan.startOrdinal < right.sourceSpan.endOrdinal &&
|
|
1518
|
-
right.sourceSpan.startOrdinal < left.sourceSpan.endOrdinal;
|
|
1519
|
-
}
|
|
1520
|
-
return left.sourceOrdinal !== undefined &&
|
|
1521
|
-
right.sourceOrdinal !== undefined &&
|
|
1522
|
-
left.sourceOrdinal === right.sourceOrdinal;
|
|
1523
|
-
}
|
|
1524
|
-
function buildConditionalThoughtQuoteMarkerStructuredRenderOperation(options) {
|
|
1525
|
-
const relation = options.relation;
|
|
1526
|
-
const quote = relation.quote;
|
|
1527
|
-
const conditionalContent = quote?.conditionalContent;
|
|
1528
|
-
const conditionalSubtype = conditionalContent?.subtype;
|
|
1529
|
-
const continuationHandoff = quote !== undefined &&
|
|
1530
|
-
conditionalSubtype === "affirmative_wish" &&
|
|
1531
|
-
thoughtHostHasConditionalContinuation({
|
|
1532
|
-
units: options.units,
|
|
1533
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1534
|
-
hostIdx: quote.hostMatch.hostIdx,
|
|
1535
|
-
});
|
|
1536
|
-
if (quote === undefined ||
|
|
1537
|
-
quote.slotKind !== "quoted_content" ||
|
|
1538
|
-
quote.hostMatch.kind !== "thought" ||
|
|
1539
|
-
quote.contentSpan.endExclusive !== quote.markerIdx ||
|
|
1540
|
-
conditionalContent === undefined ||
|
|
1541
|
-
!(conditionalSubtype === "conditional" || continuationHandoff)) {
|
|
1542
|
-
return null;
|
|
1543
|
-
}
|
|
1544
|
-
const conditionalIdx = conditionalContent.tokenIdx;
|
|
1545
|
-
const predicateUnitIndex = sourceUnitIndexesWithToken(options.units, uniqueSorted([...options.sourceUnitIndexes, ...options.markerUnitIndexes]), conditionalIdx)
|
|
1546
|
-
.find((unitIndex) => options.units[unitIndex]?.renderPlan?.kind === "headTailChain") ?? null;
|
|
1547
|
-
const predicateUnit = predicateUnitIndex === null ? undefined : options.units[predicateUnitIndex];
|
|
1548
|
-
if (predicateUnitIndex === null || predicateUnit === undefined || predicateUnit.unitType === UnitType.SYMBOL) {
|
|
1549
|
-
return null;
|
|
1550
|
-
}
|
|
1551
|
-
const quoteMarkerSource = opSourceForMarkerSpans(options.tokens, relation.markerSpans);
|
|
1552
|
-
const predicateRenderPlan = predicateUnit.renderPlan;
|
|
1553
|
-
if (!isPredicateHeadTailChainRenderPlan(predicateRenderPlan) ||
|
|
1554
|
-
predicateRenderPlan.realization.root.tail.kind !== "auxLayer" ||
|
|
1555
|
-
quoteMarkerSource === null) {
|
|
1556
|
-
return null;
|
|
1557
|
-
}
|
|
1558
|
-
const productionRoot = rootWithStructuralQuoteMarker(predicateRenderPlan.realization.root, quote, quoteMarkerSource, "quotative");
|
|
1559
|
-
const productionDispatch = probeProductionDispatch(productionRoot, {
|
|
1560
|
-
relations: [relation],
|
|
1561
|
-
intake: { site: "committed_render", partial: false },
|
|
1562
|
-
});
|
|
1563
|
-
if (productionDispatch.kind !== "registry" ||
|
|
1564
|
-
!isConditionalQuoteProductionMatch(productionDispatch.match)) {
|
|
1565
|
-
return null;
|
|
1566
|
-
}
|
|
1567
|
-
if (continuationHandoff &&
|
|
1568
|
-
rootHasDirectPositivePotentialRecipientBenefactiveWishEvidence(predicateRenderPlan.realization.root)) {
|
|
1569
|
-
return null;
|
|
1570
|
-
}
|
|
1571
|
-
const predicatePlan = projectUnitWithoutQuoteMarkerConnectivePlan(predicateUnit, quoteMarkerSource, continuationHandoff, normalizeProductionMatch(productionRoot, productionDispatch.match));
|
|
1572
|
-
const obligationPlan = predicatePlan === null
|
|
1573
|
-
? null
|
|
1574
|
-
: continuationHandoff
|
|
1575
|
-
? predicatePlan
|
|
1576
|
-
: projectNegativeConditionalObligationPlan(predicatePlan, options.tokens, conditionalIdx) ?? predicatePlan;
|
|
1577
|
-
const quotedPredicatePlan = obligationPlan === null
|
|
1578
|
-
? null
|
|
1579
|
-
: projectHeadTailConnectivePlan(obligationPlan, { connective: "quotative", surface: quote.markerBaseSurface }, quoteMarkerSource, false, null, "append");
|
|
1580
|
-
if (quotedPredicatePlan === null) {
|
|
1581
|
-
return null;
|
|
1582
|
-
}
|
|
1583
|
-
const sourcePlan = composeRelationSourceUnitPlans(options.tokens, options.units, options.sourceUnitIndexes, new Map([[predicateUnitIndex, quotedPredicatePlan]]));
|
|
1584
|
-
if (sourcePlan === null) {
|
|
1585
|
-
return null;
|
|
1586
|
-
}
|
|
1587
|
-
const suppressUnitIndexes = uniqueSorted([...options.sourceUnitIndexes, ...options.markerUnitIndexes])
|
|
1588
|
-
.filter((unitIndex) => options.units[unitIndex]?.unitType !== UnitType.SYMBOL);
|
|
1589
|
-
return {
|
|
1590
|
-
relation,
|
|
1591
|
-
insertBeforeUnitIndex: options.sourceUnitIndexes[0] ?? predicateUnitIndex,
|
|
1592
|
-
suppressUnitIndexes,
|
|
1593
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
1594
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1595
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
1596
|
-
renderPlan: sourcePlan,
|
|
1597
|
-
};
|
|
1598
|
-
}
|
|
1599
|
-
function buildConditionalReportQuoteStructuredRenderOperation(options) {
|
|
1600
|
-
const relation = options.relation;
|
|
1601
|
-
const quote = relation.quote;
|
|
1602
|
-
if (quote === undefined ||
|
|
1603
|
-
quote.slotKind !== "quoted_content" ||
|
|
1604
|
-
quote.contentSpan.endExclusive !== quote.markerIdx ||
|
|
1605
|
-
quote.hostMatch.kind !== "report" ||
|
|
1606
|
-
quote.conditionalContent === undefined) {
|
|
1607
|
-
return null;
|
|
1608
|
-
}
|
|
1609
|
-
const conditionalIdx = quote.conditionalContent.tokenIdx;
|
|
1610
|
-
const predicateUnitIndex = sourceUnitIndexesWithToken(options.units, uniqueSorted([...options.sourceUnitIndexes, ...options.markerUnitIndexes]), conditionalIdx)
|
|
1611
|
-
.find((unitIndex) => options.units[unitIndex]?.renderPlan?.kind === "headTailChain") ?? null;
|
|
1612
|
-
const predicateUnit = predicateUnitIndex === null ? undefined : options.units[predicateUnitIndex];
|
|
1613
|
-
if (predicateUnitIndex === null || predicateUnit === undefined || predicateUnit.unitType === UnitType.SYMBOL) {
|
|
1614
|
-
return null;
|
|
1615
|
-
}
|
|
1616
|
-
const predicatePlan = projectUnitWithoutQuoteMarkerConnectivePlan(predicateUnit, opSourceForMarkerSpans(options.tokens, relation.markerSpans));
|
|
1617
|
-
if (predicatePlan === null) {
|
|
1618
|
-
return null;
|
|
1619
|
-
}
|
|
1620
|
-
const internalSymbolUnitIndexes = unitIndexesInSpan(options.units, quote.contentSpan)
|
|
1621
|
-
.filter((unitIndex) => options.units[unitIndex]?.unitType === UnitType.SYMBOL);
|
|
1622
|
-
const reportSourceUnitIndexes = uniqueSorted([
|
|
1623
|
-
...options.sourceUnitIndexes,
|
|
1624
|
-
...internalSymbolUnitIndexes,
|
|
1625
|
-
]);
|
|
1626
|
-
const sourcePlan = composeRelationSourceUnitPlans(options.tokens, options.units, reportSourceUnitIndexes, new Map([[predicateUnitIndex, predicatePlan]]));
|
|
1627
|
-
if (sourcePlan === null) {
|
|
1628
|
-
return null;
|
|
1629
|
-
}
|
|
1630
|
-
const quoteSuffix = {
|
|
1631
|
-
kind: "structuralText",
|
|
1632
|
-
text: " 하고",
|
|
1633
|
-
koreanPos: 구,
|
|
1634
|
-
sourceSpan: sourceSpanForStructuralTokenSpan(options.tokens, relation.markerSpans[0] ?? quote.markerSpan),
|
|
1635
|
-
};
|
|
1636
|
-
const renderPlan = structuralRelationSequencePlan([sourcePlan, quoteSuffix]);
|
|
1637
|
-
if (renderPlan === null) {
|
|
1638
|
-
return null;
|
|
1639
|
-
}
|
|
1640
|
-
const suppressUnitIndexes = uniqueSorted([...reportSourceUnitIndexes, ...options.markerUnitIndexes]);
|
|
1641
|
-
return {
|
|
1642
|
-
relation,
|
|
1643
|
-
insertBeforeUnitIndex: reportSourceUnitIndexes[0] ?? predicateUnitIndex,
|
|
1644
|
-
suppressUnitIndexes,
|
|
1645
|
-
sourceUnitIndexes: reportSourceUnitIndexes,
|
|
1646
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1647
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((unitIndex) => (options.units[unitIndex]?.jpIndices ?? []))),
|
|
1648
|
-
renderPlan,
|
|
1649
|
-
};
|
|
1650
|
-
}
|
|
1651
|
-
function projectNegativeConditionalObligationPlan(plan, tokens, conditionalIdx) {
|
|
1652
|
-
const tail = plan.realization.root.tail;
|
|
1653
|
-
if (tail.kind !== "auxLayer")
|
|
1654
|
-
return null;
|
|
1655
|
-
const conditionalOpIdx = tail.ops.findIndex((op) => op.kind === "connective" && op.source.tokenIndices.includes(conditionalIdx));
|
|
1656
|
-
if (conditionalOpIdx < 0)
|
|
1657
|
-
return null;
|
|
1658
|
-
let negationOpIdx = -1;
|
|
1659
|
-
for (let index = conditionalOpIdx - 1; index >= 0; index -= 1) {
|
|
1660
|
-
if (tail.ops[index]?.kind === "negation") {
|
|
1661
|
-
negationOpIdx = index;
|
|
1662
|
-
break;
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
if (negationOpIdx < 0)
|
|
1666
|
-
return null;
|
|
1667
|
-
const conditionalOp = tail.ops[conditionalOpIdx];
|
|
1668
|
-
const negationOp = tail.ops[negationOpIdx];
|
|
1669
|
-
const sourceIndices = uniqueSorted([...negationOp.source.tokenIndices, conditionalIdx]);
|
|
1670
|
-
const obligation = createIdiomOp({
|
|
1671
|
-
idiom: "obligation",
|
|
1672
|
-
variant: tokens[conditionalIdx]?.surface === "ば" ? "standard_nakereba" : "colloquial_naito_elided",
|
|
1673
|
-
polarity: "affirmative",
|
|
1674
|
-
polite: false,
|
|
1675
|
-
past: false,
|
|
1676
|
-
source: {
|
|
1677
|
-
tokens: sourceIndices.flatMap((index) => tokens[index] === undefined ? [] : [tokens[index]]),
|
|
1678
|
-
tokenIndices: sourceIndices,
|
|
1679
|
-
},
|
|
1680
|
-
});
|
|
1681
|
-
const ops = tail.ops.filter((_, index) => index !== negationOpIdx && index !== conditionalOpIdx);
|
|
1682
|
-
ops.splice(Math.min(negationOpIdx, ops.length), 0, obligation);
|
|
1683
|
-
return {
|
|
1684
|
-
...plan,
|
|
1685
|
-
realization: {
|
|
1686
|
-
...plan.realization,
|
|
1687
|
-
root: {
|
|
1688
|
-
...plan.realization.root,
|
|
1689
|
-
tail: { ...tail, ops },
|
|
1690
|
-
},
|
|
1691
|
-
},
|
|
1692
|
-
};
|
|
1693
|
-
}
|
|
1694
|
-
function buildPredicateBoundTameQuoteStructuredRenderOperation(options) {
|
|
1695
|
-
const relation = options.relation;
|
|
1696
|
-
const quote = relation.quote;
|
|
1697
|
-
if (quote === undefined || quote.slotKind !== "quoted_content") {
|
|
1698
|
-
return null;
|
|
1699
|
-
}
|
|
1700
|
-
const tameIdx = previousNonSpaceTokenIndex(options.tokens, quote.markerIdx);
|
|
1701
|
-
const tame = tameIdx === null ? undefined : options.tokens[tameIdx];
|
|
1702
|
-
const tameForm = tame?.dictionaryForm || tame?.surface;
|
|
1703
|
-
if (tameIdx === null ||
|
|
1704
|
-
tameIdx < quote.contentSpan.start ||
|
|
1705
|
-
tameIdx >= quote.contentSpan.endExclusive ||
|
|
1706
|
-
(tameForm !== "ため" && tameForm !== "為")) {
|
|
1707
|
-
return null;
|
|
1708
|
-
}
|
|
1709
|
-
const sourceUnitIndex = sourceUnitIndexesWithPredicateBoundTame(options.units, options.sourceUnitIndexes, tameIdx)[0] ?? null;
|
|
1710
|
-
const sourceUnit = sourceUnitIndex === null ? undefined : options.units[sourceUnitIndex];
|
|
1711
|
-
if (sourceUnitIndex === null || sourceUnit === undefined || sourceUnit.unitType === UnitType.SYMBOL || sourceUnit.renderPlan === null) {
|
|
1712
|
-
return null;
|
|
1713
|
-
}
|
|
1714
|
-
const sourcePlan = projectUnitPredicateConnectivePlan(sourceUnit, predicateBoundTameQuoteConnective(sourceUnit, options.tokens, tameIdx, tame?.surface ?? "ため", options.lookups)) ?? sourceUnit.renderPlan;
|
|
1715
|
-
const quotedPlan = attachParticleRenderPlan(sourcePlan, "이라고/라고");
|
|
1716
|
-
if (quotedPlan === null) {
|
|
1717
|
-
return null;
|
|
1718
|
-
}
|
|
1719
|
-
const suppressUnitIndexes = uniqueSorted([sourceUnitIndex, ...options.markerUnitIndexes])
|
|
1720
|
-
.filter((candidateIndex) => options.units[candidateIndex]?.unitType !== UnitType.SYMBOL);
|
|
1721
|
-
return {
|
|
1722
|
-
relation,
|
|
1723
|
-
insertBeforeUnitIndex: sourceUnitIndex,
|
|
1724
|
-
suppressUnitIndexes,
|
|
1725
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
1726
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1727
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
1728
|
-
renderPlan: quotedPlan,
|
|
1729
|
-
};
|
|
1730
|
-
}
|
|
1731
|
-
function sourceUnitIndexesWithPredicateBoundTame(units, sourceUnitIndexes, tameIdx) {
|
|
1732
|
-
return sourceUnitIndexes.filter((unitIndex) => {
|
|
1733
|
-
const unit = units[unitIndex];
|
|
1734
|
-
return unit !== undefined &&
|
|
1735
|
-
unit.renderPlan?.kind === "headTailChain" &&
|
|
1736
|
-
unit.jpIndices.includes(tameIdx);
|
|
1737
|
-
});
|
|
1738
|
-
}
|
|
1739
|
-
function sourceUnitIndexesWithToken(units, sourceUnitIndexes, tokenIdx) {
|
|
1740
|
-
return sourceUnitIndexes.filter((unitIndex) => units[unitIndex]?.jpIndices.includes(tokenIdx) === true);
|
|
1741
|
-
}
|
|
1742
|
-
function projectUnitWithoutQuoteMarkerConnectivePlan(unit, quoteMarkerSource, allowSeparatedMarker = false, registryNormalizedRoot = null) {
|
|
1743
|
-
const plan = unit.renderPlan;
|
|
1744
|
-
if (!isPredicateHeadTailChainRenderPlan(plan) ||
|
|
1745
|
-
plan.realization.root.tail.kind !== "auxLayer" ||
|
|
1746
|
-
quoteMarkerSource === null ||
|
|
1747
|
-
(registryNormalizedRoot !== null && registryNormalizedRoot.tail.kind !== "auxLayer")) {
|
|
1748
|
-
return null;
|
|
1749
|
-
}
|
|
1750
|
-
const layer = plan.realization.root.tail;
|
|
1751
|
-
const ownsQuoteMarker = layer.ops.some((op) => op.kind === "connective" && opSourceCoveredBy(op.source, quoteMarkerSource));
|
|
1752
|
-
if (!ownsQuoteMarker && !allowSeparatedMarker) {
|
|
1753
|
-
return null;
|
|
1754
|
-
}
|
|
1755
|
-
const normalizedLayer = registryNormalizedRoot?.tail.kind === "auxLayer"
|
|
1756
|
-
? registryNormalizedRoot.tail
|
|
1757
|
-
: null;
|
|
1758
|
-
const projectedOps = (normalizedLayer?.ops ?? layer.ops.filter((op) => !(op.kind === "connective" && opSourceCoveredBy(op.source, quoteMarkerSource)))).map((op) => (op.kind === "connective" && op.connective === "conditional" && op.surface === "ば"
|
|
1759
|
-
? { ...op, conditionalFlavor: "plain" }
|
|
1760
|
-
: op));
|
|
1761
|
-
const projectedLayer = {
|
|
1762
|
-
...(normalizedLayer ?? layer),
|
|
1763
|
-
ops: projectedOps,
|
|
1764
|
-
terminal: null,
|
|
1765
|
-
};
|
|
1766
|
-
const projectedRoot = {
|
|
1767
|
-
...(registryNormalizedRoot ?? plan.realization.root),
|
|
1768
|
-
tail: projectedLayer,
|
|
1769
|
-
};
|
|
1770
|
-
const lastConnective = [...projectedOps].reverse().find((op) => op.kind === "connective") ?? null;
|
|
1771
|
-
const projectedBoundary = lastConnective === null
|
|
1772
|
-
? { kind: "terminal" }
|
|
1773
|
-
: connectiveBoundaryForProjection(plan, { connective: lastConnective.connective, surface: lastConnective.surface }, lastConnective.source);
|
|
1774
|
-
const { headTailCandidate: _headTailCandidate, headTailSourceCandidate: _headTailSourceCandidate, ...planWithoutOriginalSourceCandidate } = plan;
|
|
1775
|
-
const { partial: _partial, ...realizationWithoutPartial } = plan.realization;
|
|
1776
|
-
return {
|
|
1777
|
-
...planWithoutOriginalSourceCandidate,
|
|
1778
|
-
clauseRole: { ...plan.clauseRole, outgoingBoundary: projectedBoundary },
|
|
1779
|
-
realization: {
|
|
1780
|
-
...realizationWithoutPartial,
|
|
1781
|
-
root: projectedRoot,
|
|
1782
|
-
warnings: resolvedStructuralProjectionWarnings(plan.realization.warnings),
|
|
1783
|
-
},
|
|
1784
|
-
};
|
|
1785
|
-
}
|
|
1786
|
-
function predicateBoundTameQuoteConnective(unit, tokens, tameIdx, surface, lookups) {
|
|
1787
|
-
const plan = unit.renderPlan;
|
|
1788
|
-
return {
|
|
1789
|
-
connective: plan?.kind === "headTailChain" &&
|
|
1790
|
-
plan.realization.kind === "predicate" &&
|
|
1791
|
-
tailPredicateHostPrefersTameReason({
|
|
1792
|
-
root: plan.realization.root,
|
|
1793
|
-
tokens,
|
|
1794
|
-
tameIndex: tameIdx,
|
|
1795
|
-
lookups,
|
|
1796
|
-
})
|
|
1797
|
-
? "tame_reason"
|
|
1798
|
-
: "tame_purpose",
|
|
1799
|
-
surface,
|
|
1800
|
-
};
|
|
1801
|
-
}
|
|
1802
|
-
function buildPunctuatedAttributiveStructuredRenderOperation(options) {
|
|
1803
|
-
if (options.relation.nominalExemplification !== undefined) {
|
|
1804
|
-
return buildNominalExemplificationAttributiveRenderOperation({
|
|
1805
|
-
...options,
|
|
1806
|
-
exemplification: options.relation.nominalExemplification,
|
|
1807
|
-
});
|
|
1808
|
-
}
|
|
1809
|
-
const unitIndex = sourcePredicateUnitIndexForRelation(options.units, options.relation, options.sourceUnitIndexes);
|
|
1810
|
-
if (unitIndex === null) {
|
|
1811
|
-
return null;
|
|
1812
|
-
}
|
|
1813
|
-
const unit = options.units[unitIndex];
|
|
1814
|
-
if (unit === undefined || unit.unitType === UnitType.SYMBOL) {
|
|
1815
|
-
return null;
|
|
1816
|
-
}
|
|
1817
|
-
const projectedPlan = projectUnitAttributivePlan(unit, targetHeadToken(options.tokens, options.relation), {
|
|
1818
|
-
tokens: options.tokens,
|
|
1819
|
-
lookups: options.lookups,
|
|
1820
|
-
});
|
|
1821
|
-
if (projectedPlan === null) {
|
|
1822
|
-
return null;
|
|
1823
|
-
}
|
|
1824
|
-
return {
|
|
1825
|
-
relation: options.relation,
|
|
1826
|
-
insertBeforeUnitIndex: unitIndex,
|
|
1827
|
-
suppressUnitIndexes: [unitIndex],
|
|
1828
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
1829
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1830
|
-
projectionTokenIndexes: [...unit.jpIndices],
|
|
1831
|
-
renderPlan: projectedPlan,
|
|
1832
|
-
};
|
|
1833
|
-
}
|
|
1834
|
-
function buildNominalExemplificationAttributiveRenderOperation(options) {
|
|
1835
|
-
const exemplification = options.exemplification;
|
|
1836
|
-
const hostUnitIndex = sourcePredicateUnitIndexForRelation(options.units, options.relation, options.sourceUnitIndexes);
|
|
1837
|
-
if (hostUnitIndex === null) {
|
|
1838
|
-
return null;
|
|
1839
|
-
}
|
|
1840
|
-
const absorbedStart = exemplification.exemplificationMarkerSpan?.start ?? exemplification.quoteMarkerSpan.start;
|
|
1841
|
-
const carrierUnitIndexes = uniqueSorted([hostUnitIndex, ...options.markerUnitIndexes])
|
|
1842
|
-
.filter((unitIndex) => options.units[unitIndex]?.unitType !== UnitType.SYMBOL);
|
|
1843
|
-
if (carrierUnitIndexes.some((unitIndex) => options.units[unitIndex]?.jpIndices.every((jpIndex) => absorbedStart <= jpIndex) !== true)) {
|
|
1844
|
-
return null;
|
|
1845
|
-
}
|
|
1846
|
-
return {
|
|
1847
|
-
relation: options.relation,
|
|
1848
|
-
insertBeforeUnitIndex: carrierUnitIndexes[0] ?? hostUnitIndex,
|
|
1849
|
-
suppressUnitIndexes: carrierUnitIndexes,
|
|
1850
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
1851
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1852
|
-
projectionTokenIndexes: uniqueSorted(carrierUnitIndexes.flatMap((unitIndex) => options.units[unitIndex]?.jpIndices ?? [])),
|
|
1853
|
-
renderPlan: {
|
|
1854
|
-
kind: "fixedText",
|
|
1855
|
-
text: exemplification.exemplificationMarkerSpan === null ? "같은" : "등의",
|
|
1856
|
-
koreanPos: 구,
|
|
1857
|
-
},
|
|
1858
|
-
};
|
|
1859
|
-
}
|
|
1860
|
-
function buildNominalConcessionStructuredRenderOperation(options) {
|
|
1861
|
-
const sourcePredicateIdx = relationSourcePredicateIdx(options.relation);
|
|
1862
|
-
if (sourcePredicateIdx !== null) {
|
|
1863
|
-
return null;
|
|
1864
|
-
}
|
|
1865
|
-
const projectedUnitIndexes = options.sourceSpanUnitIndexes;
|
|
1866
|
-
const sourcePlan = composeRelationSourceUnitPlans(options.tokens, options.units, projectedUnitIndexes);
|
|
1867
|
-
if (sourcePlan === null) {
|
|
1868
|
-
return null;
|
|
1869
|
-
}
|
|
1870
|
-
const sourceUnitIndex = projectedUnitIndexes[0] ?? null;
|
|
1871
|
-
if (sourceUnitIndex === null) {
|
|
1872
|
-
return null;
|
|
1873
|
-
}
|
|
1874
|
-
const suppressUnitIndexes = uniqueSorted([...projectedUnitIndexes, ...options.markerUnitIndexes]);
|
|
1875
|
-
const edgeAttachment = projectionEdgeAttachment(options.units, suppressUnitIndexes);
|
|
1876
|
-
return {
|
|
1877
|
-
relation: options.relation,
|
|
1878
|
-
insertBeforeUnitIndex: sourceUnitIndex,
|
|
1879
|
-
suppressUnitIndexes,
|
|
1880
|
-
...edgeAttachment,
|
|
1881
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
1882
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
1883
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
1884
|
-
renderPlan: {
|
|
1885
|
-
kind: "nominalConnectiveScope",
|
|
1886
|
-
payload: {
|
|
1887
|
-
content: sourcePlan,
|
|
1888
|
-
connectiveKind: "concession",
|
|
1889
|
-
koreanPos: 구,
|
|
1890
|
-
},
|
|
1891
|
-
},
|
|
1892
|
-
};
|
|
1893
|
-
}
|
|
1894
|
-
function composeRelationSourceUnitPlans(tokens, units, unitIndexes, replacements) {
|
|
1895
|
-
const parts = relationSourceUnitSequenceParts(tokens, units, unitIndexes, replacements);
|
|
1896
|
-
return parts === null ? null : structuralRelationSequencePlan(parts.map((entry) => entry.part));
|
|
1897
|
-
}
|
|
1898
|
-
export function relationSourceUnitSequenceParts(tokens, units, unitIndexes, replacements) {
|
|
1899
|
-
const parts = [];
|
|
1900
|
-
let previousUnit;
|
|
1901
|
-
for (const unitIndex of unitIndexes) {
|
|
1902
|
-
const unit = units[unitIndex];
|
|
1903
|
-
if (unit === undefined) {
|
|
1904
|
-
continue;
|
|
1905
|
-
}
|
|
1906
|
-
const unitPlan = replacements?.get(unitIndex) ?? relationSourceUnitPlan(tokens, unit);
|
|
1907
|
-
if (unitPlan === null && unit.allomorphKey !== null) {
|
|
1908
|
-
const host = particleHostPhraseInParts(parts);
|
|
1909
|
-
const previousPlan = host?.plan ?? null;
|
|
1910
|
-
const particle = particleKeyFromAllomorph(unit.allomorphKey);
|
|
1911
|
-
const possessiveContraction = particle === "의" && previousPlan !== null
|
|
1912
|
-
? contractPossessivePronounPlan(previousPlan)
|
|
1913
|
-
: null;
|
|
1914
|
-
if (possessiveContraction !== null && host !== null) {
|
|
1915
|
-
parts.splice(host.fromIndex, parts.length - host.fromIndex, {
|
|
1916
|
-
part: possessiveContraction,
|
|
1917
|
-
unit: host.unit,
|
|
1918
|
-
sourceSpan: combineRelationSourceSpans(host.sourceSpan, unit.sourceSpan)
|
|
1919
|
-
});
|
|
1920
|
-
previousUnit = unit;
|
|
1921
|
-
continue;
|
|
1922
|
-
}
|
|
1923
|
-
const attached = previousPlan === null
|
|
1924
|
-
? null
|
|
1925
|
-
: attachAllomorphParticlePlan(previousPlan, unit.allomorphKey, unit.register, {
|
|
1926
|
-
sourceSpan: unit.sourceSpan,
|
|
1927
|
-
unit
|
|
1928
|
-
});
|
|
1929
|
-
if (attached === null || host === null) {
|
|
1930
|
-
return null;
|
|
1931
|
-
}
|
|
1932
|
-
parts.splice(host.fromIndex, parts.length - host.fromIndex, {
|
|
1933
|
-
part: attached,
|
|
1934
|
-
unit: host.unit,
|
|
1935
|
-
sourceSpan: host.sourceSpan
|
|
1936
|
-
});
|
|
1937
|
-
previousUnit = unit;
|
|
1938
|
-
continue;
|
|
1939
|
-
}
|
|
1940
|
-
if (unitPlan === null) {
|
|
1941
|
-
return null;
|
|
1942
|
-
}
|
|
1943
|
-
if (parts.length > 0) {
|
|
1944
|
-
const separator = !unit.attachLeft && previousUnit?.attachRight !== true ? " " : "";
|
|
1945
|
-
if (separator.length > 0) {
|
|
1946
|
-
parts.push({
|
|
1947
|
-
part: { kind: "structuralText", text: separator, koreanPos: 구 },
|
|
1948
|
-
unit: null,
|
|
1949
|
-
sourceSpan: null
|
|
1950
|
-
});
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
parts.push({ part: unitPlan, unit, sourceSpan: unit.sourceSpan });
|
|
1954
|
-
previousUnit = unit;
|
|
1955
|
-
}
|
|
1956
|
-
return parts;
|
|
1957
|
-
}
|
|
1958
|
-
function lastSequenceRenderPlan(parts) {
|
|
1959
|
-
const last = parts[parts.length - 1];
|
|
1960
|
-
return last === undefined || last.kind === "structuralText" ? null : last;
|
|
1961
|
-
}
|
|
1962
|
-
function particleHostPhraseInParts(parts) {
|
|
1963
|
-
let index = parts.length - 1;
|
|
1964
|
-
while (index >= 0 && parts[index]?.part.kind === "structuralText") {
|
|
1965
|
-
index -= 1;
|
|
1966
|
-
}
|
|
1967
|
-
const anchor = parts[index];
|
|
1968
|
-
if (index < 0 || anchor === undefined || anchor.part.kind === "structuralText") {
|
|
1969
|
-
return null;
|
|
1970
|
-
}
|
|
1971
|
-
if (index === parts.length - 1) {
|
|
1972
|
-
return { plan: anchor.part, fromIndex: index, unit: anchor.unit, sourceSpan: anchor.sourceSpan };
|
|
1973
|
-
}
|
|
1974
|
-
const group = parts.slice(index);
|
|
1975
|
-
const grouped = structuralRelationSequencePlan(group.map((entry) => entry.part));
|
|
1976
|
-
return grouped === null
|
|
1977
|
-
? null
|
|
1978
|
-
: {
|
|
1979
|
-
plan: grouped,
|
|
1980
|
-
fromIndex: index,
|
|
1981
|
-
unit: anchor.unit,
|
|
1982
|
-
sourceSpan: group.reduce((span, entry) => combineRelationSourceSpans(span, entry.sourceSpan), null)
|
|
1983
|
-
};
|
|
1984
|
-
}
|
|
1985
|
-
function combineRelationSourceSpans(left, right) {
|
|
1986
|
-
if (left === null) {
|
|
1987
|
-
return right;
|
|
1988
|
-
}
|
|
1989
|
-
if (right === null) {
|
|
1990
|
-
return left;
|
|
1991
|
-
}
|
|
1992
|
-
return {
|
|
1993
|
-
startOrdinal: Math.min(left.startOrdinal, right.startOrdinal),
|
|
1994
|
-
endOrdinal: Math.max(left.endOrdinal, right.endOrdinal)
|
|
1995
|
-
};
|
|
1996
|
-
}
|
|
1997
|
-
function structuralRelationSequencePlan(parts) {
|
|
1998
|
-
if (parts.length === 0) {
|
|
1999
|
-
return null;
|
|
2000
|
-
}
|
|
2001
|
-
if (parts.length === 1) {
|
|
2002
|
-
const only = parts[0];
|
|
2003
|
-
return only === undefined || only.kind === "structuralText"
|
|
2004
|
-
? null
|
|
2005
|
-
: only;
|
|
2006
|
-
}
|
|
2007
|
-
return {
|
|
2008
|
-
kind: "structuralRelationSequence",
|
|
2009
|
-
parts,
|
|
2010
|
-
koreanPos: 구,
|
|
2011
|
-
};
|
|
2012
|
-
}
|
|
2013
|
-
function relationSourceUnitPlan(tokens, unit) {
|
|
2014
|
-
if (unit.renderPlan !== null) {
|
|
2015
|
-
return unit.renderPlan;
|
|
2016
|
-
}
|
|
2017
|
-
if (unit.unitType === UnitType.SYMBOL) {
|
|
2018
|
-
const tokenIndexes = uniqueSorted(unit.jpIndices);
|
|
2019
|
-
const text = tokenIndexes
|
|
2020
|
-
.flatMap((index) => tokens[index] === undefined ? [] : [tokens[index].surface])
|
|
2021
|
-
.join("");
|
|
2022
|
-
const first = tokenIndexes[0];
|
|
2023
|
-
const last = tokenIndexes.at(-1);
|
|
2024
|
-
return text.length === 0 || first === undefined || last === undefined
|
|
2025
|
-
? null
|
|
2026
|
-
: {
|
|
2027
|
-
kind: "structuralText",
|
|
2028
|
-
text,
|
|
2029
|
-
koreanPos: 기호,
|
|
2030
|
-
sourceSpan: sourceSpanForStructuralTokenSpan(tokens, {
|
|
2031
|
-
start: first,
|
|
2032
|
-
endExclusive: last + 1,
|
|
2033
|
-
}),
|
|
2034
|
-
};
|
|
2035
|
-
}
|
|
2036
|
-
return null;
|
|
2037
|
-
}
|
|
2038
|
-
function attachAllomorphParticlePlan(content, allomorphKey, register, source) {
|
|
2039
|
-
const particle = particleKeyFromAllomorph(allomorphKey);
|
|
2040
|
-
if (particle === null) {
|
|
2041
|
-
return null;
|
|
2042
|
-
}
|
|
2043
|
-
return attachParticleRenderPlan(content, particle, {
|
|
2044
|
-
register,
|
|
2045
|
-
...(source === undefined ? {} : { source })
|
|
2046
|
-
});
|
|
2047
|
-
}
|
|
2048
|
-
function buildPurposeModifierStructuredRenderOperation(options) {
|
|
2049
|
-
for (let index = options.sourceUnitIndexes.length - 1; index >= 0; index -= 1) {
|
|
2050
|
-
const unitIndex = options.sourceUnitIndexes[index];
|
|
2051
|
-
const unit = unitIndex === undefined ? undefined : options.units[unitIndex];
|
|
2052
|
-
if (unitIndex === undefined || unit === undefined || unit.unitType === UnitType.SYMBOL) {
|
|
2053
|
-
continue;
|
|
2054
|
-
}
|
|
2055
|
-
const projectedPlan = projectUnitPurposeAttributivePlan(unit);
|
|
2056
|
-
if (projectedPlan === null) {
|
|
2057
|
-
continue;
|
|
2058
|
-
}
|
|
2059
|
-
const suppressUnitIndexes = uniqueSorted([unitIndex, ...options.markerUnitIndexes])
|
|
2060
|
-
.filter((candidateIndex) => options.units[candidateIndex]?.unitType !== UnitType.SYMBOL);
|
|
2061
|
-
return {
|
|
2062
|
-
relation: options.relation,
|
|
2063
|
-
insertBeforeUnitIndex: unitIndex,
|
|
2064
|
-
suppressUnitIndexes,
|
|
2065
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
2066
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
2067
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
2068
|
-
renderPlan: projectedPlan,
|
|
2069
|
-
};
|
|
2070
|
-
}
|
|
2071
|
-
return null;
|
|
2072
|
-
}
|
|
2073
|
-
function buildCorrelativeDegreeStructuredRenderOperation(options) {
|
|
2074
|
-
const degreeMarker = options.relation.markerSpans.find((span) => span.role === "degree_marker") ?? null;
|
|
2075
|
-
if (degreeMarker === null) {
|
|
2076
|
-
return null;
|
|
2077
|
-
}
|
|
2078
|
-
const candidateUnitIndexes = uniqueSorted([...options.sourceUnitIndexes, ...options.markerUnitIndexes]);
|
|
2079
|
-
const degreeUnitIndex = candidateUnitIndexes.find((unitIndex) => {
|
|
2080
|
-
const unit = options.units[unitIndex];
|
|
2081
|
-
return unit !== undefined && unit.jpIndices.some((jpIndex) => (degreeMarker.start <= jpIndex && jpIndex < degreeMarker.endExclusive));
|
|
2082
|
-
}) ?? null;
|
|
2083
|
-
const degreeUnit = degreeUnitIndex === null ? undefined : options.units[degreeUnitIndex];
|
|
2084
|
-
if (degreeUnitIndex === null || degreeUnit === undefined || degreeUnit.unitType === UnitType.SYMBOL) {
|
|
2085
|
-
return null;
|
|
2086
|
-
}
|
|
2087
|
-
const projectedPlan = projectUnitHeadTailConnectivePlan(degreeUnit, { connective: "predicate_projection_correlative_degree", surface: degreeMarker.surface }, opSourceForMarkerSpans(options.tokens, [degreeMarker]));
|
|
2088
|
-
if (projectedPlan === null) {
|
|
2089
|
-
return null;
|
|
2090
|
-
}
|
|
2091
|
-
return {
|
|
2092
|
-
relation: options.relation,
|
|
2093
|
-
insertBeforeUnitIndex: degreeUnitIndex,
|
|
2094
|
-
suppressUnitIndexes: [degreeUnitIndex],
|
|
2095
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
2096
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
2097
|
-
projectionTokenIndexes: [...degreeUnit.jpIndices],
|
|
2098
|
-
renderPlan: projectedPlan,
|
|
2099
|
-
};
|
|
2100
|
-
}
|
|
2101
|
-
function buildKaParallelStructuredRenderOperation(options) {
|
|
2102
|
-
const payload = options.relation.kaParallel;
|
|
2103
|
-
const minimumItemCount = options.relation.kind === "toka_parallel_listing" ? 1 : 2;
|
|
2104
|
-
if (payload === undefined || payload.itemAnchors.length < minimumItemCount) {
|
|
2105
|
-
return null;
|
|
2106
|
-
}
|
|
2107
|
-
const explicitTerminalPunctuation = payload.terminalPunctuation;
|
|
2108
|
-
const matrixQuestionItems = payload.matrixQuestionItems;
|
|
2109
|
-
const yieldsLastItemToTerminalOwner = payload.terminalOwnerBoundary !== undefined;
|
|
2110
|
-
const projectedItems = yieldsLastItemToTerminalOwner
|
|
2111
|
-
? payload.itemAnchors.slice(0, -1)
|
|
2112
|
-
: payload.itemAnchors;
|
|
2113
|
-
if (projectedItems.length === 0)
|
|
2114
|
-
return null;
|
|
2115
|
-
if (relationWindowHasExternalBoundarySymbol(options.tokens, options.units, options.relation.source.span.start, yieldsLastItemToTerminalOwner
|
|
2116
|
-
? projectedItems.at(-1).markerSpan.endExclusive
|
|
2117
|
-
: payload.itemAnchors.at(-1)?.markerSpan.start ?? options.relation.source.span.endExclusive))
|
|
2118
|
-
return null;
|
|
2119
|
-
const itemPlans = [];
|
|
2120
|
-
for (const [itemIndex, item] of projectedItems.entries()) {
|
|
2121
|
-
const isLastItem = !yieldsLastItemToTerminalOwner && itemIndex === projectedItems.length - 1;
|
|
2122
|
-
const plan = kaParallelItemPlan(options.tokens, options.units, item, options.relation.kind, isLastItem, payload.closure, yieldsLastItemToTerminalOwner ? false : matrixQuestionItems);
|
|
2123
|
-
if (plan === null) {
|
|
2124
|
-
return null;
|
|
2125
|
-
}
|
|
2126
|
-
itemPlans.push(plan);
|
|
2127
|
-
}
|
|
2128
|
-
const trailingSuffix = yieldsLastItemToTerminalOwner
|
|
2129
|
-
? {
|
|
2130
|
-
suffix: payload.separatorSpans.length > 0 ? "," : null,
|
|
2131
|
-
suffixUnitIndexes: payload.separatorSpans.flatMap((span) => unitIndexesInSpan(options.units, span)),
|
|
2132
|
-
}
|
|
2133
|
-
: kaParallelTrailingSuffixPlan(options.tokens, options.units, options.sourceUnitIndexes, options.relation.source.span.endExclusive, options.lookups, payload.closure);
|
|
2134
|
-
const projectedSourceSpan = yieldsLastItemToTerminalOwner
|
|
2135
|
-
? {
|
|
2136
|
-
start: projectedItems[0].source.span.start,
|
|
2137
|
-
endExclusive: projectedItems.at(-1).markerSpan.endExclusive,
|
|
2138
|
-
}
|
|
2139
|
-
: options.relation.source.span;
|
|
2140
|
-
const relationSourceUnitIndexes = yieldsLastItemToTerminalOwner
|
|
2141
|
-
? unitIndexesInSpan(options.units, projectedSourceSpan)
|
|
2142
|
-
: options.sourceUnitIndexes;
|
|
2143
|
-
const relationMarkerUnitIndexes = yieldsLastItemToTerminalOwner
|
|
2144
|
-
? projectedItems.flatMap((item) => unitIndexesInSpan(options.units, item.markerSpan))
|
|
2145
|
-
: options.markerUnitIndexes;
|
|
2146
|
-
const internalSymbolUnitIndexes = unitIndexesInSpan(options.units, options.relation.source.span)
|
|
2147
|
-
.filter((unitIndex) => options.units[unitIndex]?.unitType === UnitType.SYMBOL &&
|
|
2148
|
-
options.units[unitIndex].jpIndices.some((jpIndex) => jpIndex >= projectedSourceSpan.start && jpIndex < projectedSourceSpan.endExclusive));
|
|
2149
|
-
const ownedSourceUnitIndexes = uniqueSorted([
|
|
2150
|
-
...relationSourceUnitIndexes,
|
|
2151
|
-
...internalSymbolUnitIndexes,
|
|
2152
|
-
]);
|
|
2153
|
-
const suppressUnitIndexes = uniqueSorted([
|
|
2154
|
-
...ownedSourceUnitIndexes,
|
|
2155
|
-
...relationMarkerUnitIndexes,
|
|
2156
|
-
...trailingSuffix.suffixUnitIndexes,
|
|
2157
|
-
]);
|
|
2158
|
-
const insertBeforeUnitIndex = suppressUnitIndexes[0] ?? options.sourceUnitIndexes[0] ?? null;
|
|
2159
|
-
if (insertBeforeUnitIndex === null) {
|
|
2160
|
-
return null;
|
|
2161
|
-
}
|
|
2162
|
-
const terminalOwnerPlanReplacements = payload.terminalOwnerBoundary === "matrix_terminal_question"
|
|
2163
|
-
? kaParallelTerminalOwnerPlanReplacement(options.units, payload.itemAnchors.at(-1))
|
|
2164
|
-
: [];
|
|
2165
|
-
return {
|
|
2166
|
-
relation: options.relation,
|
|
2167
|
-
insertBeforeUnitIndex,
|
|
2168
|
-
suppressUnitIndexes,
|
|
2169
|
-
sourceUnitIndexes: ownedSourceUnitIndexes,
|
|
2170
|
-
targetUnitIndexes: yieldsLastItemToTerminalOwner ? [] : options.targetUnitIndexes,
|
|
2171
|
-
unitRenderPlanReplacements: terminalOwnerPlanReplacements,
|
|
2172
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
2173
|
-
renderPlan: {
|
|
2174
|
-
kind: "kaParallel",
|
|
2175
|
-
relationKind: options.relation.kind === "ka_parallel_choice" ? "choice" : "question_content",
|
|
2176
|
-
itemPlans,
|
|
2177
|
-
itemSourceSpans: projectedItems.map((item) => sourceSpanForStructuralTokenSpan(options.tokens, item.source.span)),
|
|
2178
|
-
markerSourceSpans: projectedItems.map((item) => sourceSpanForStructuralTokenSpan(options.tokens, item.markerSpan)),
|
|
2179
|
-
separator: payload.separatorSpans.length > 0 ? "comma" : "space",
|
|
2180
|
-
terminalPunctuation: yieldsLastItemToTerminalOwner ? null : explicitTerminalPunctuation,
|
|
2181
|
-
terminalPunctuationRun: yieldsLastItemToTerminalOwner ? [] : payload.terminalPunctuationRun,
|
|
2182
|
-
...(trailingSuffix.suffix === null ? {} : { suffix: trailingSuffix.suffix }),
|
|
2183
|
-
koreanPos: 구,
|
|
2184
|
-
},
|
|
2185
|
-
};
|
|
2186
|
-
}
|
|
2187
|
-
function kaParallelTerminalOwnerPlanReplacement(units, item) {
|
|
2188
|
-
const unitIndexes = unitIndexesInSpan(units, item.source.span);
|
|
2189
|
-
const predicateUnitIndex = parallelPredicateUnitIndex(units, unitIndexes, item.predicateIdx);
|
|
2190
|
-
if (predicateUnitIndex === null)
|
|
2191
|
-
return [];
|
|
2192
|
-
const plan = units[predicateUnitIndex]?.renderPlan;
|
|
2193
|
-
if (plan === undefined || plan === null)
|
|
2194
|
-
return [];
|
|
2195
|
-
return [{ unitIndex: predicateUnitIndex, renderPlan: markQuestionContentTerminalPlan(plan) }];
|
|
2196
|
-
}
|
|
2197
|
-
function buildEmbeddedQuestionAttributiveQuoteStructuredRenderOperation(options) {
|
|
2198
|
-
const payload = options.relation.embeddedQuestionAttributiveQuote;
|
|
2199
|
-
if (payload === undefined)
|
|
2200
|
-
return null;
|
|
2201
|
-
const itemPlan = kaParallelItemPlan(options.tokens, options.units, payload.item, options.relation.kind, true, payload.closure, false);
|
|
2202
|
-
if (itemPlan === null)
|
|
2203
|
-
return null;
|
|
2204
|
-
const suffixUnitIndexes = unitIndexesInSpan(options.units, payload.closure.markerSpan);
|
|
2205
|
-
if (suffixUnitIndexes.length === 0)
|
|
2206
|
-
return null;
|
|
2207
|
-
const sourceUnitIndexSet = new Set(options.sourceUnitIndexes);
|
|
2208
|
-
const closureEscapesMarkerSpan = suffixUnitIndexes.some((unitIndex) => {
|
|
2209
|
-
if (sourceUnitIndexSet.has(unitIndex))
|
|
2210
|
-
return false;
|
|
2211
|
-
const unit = options.units[unitIndex];
|
|
2212
|
-
return unit === undefined || !unitFullyCoveredBySpans(unit, [payload.closure.markerSpan]);
|
|
2213
|
-
});
|
|
2214
|
-
if (closureEscapesMarkerSpan)
|
|
2215
|
-
return null;
|
|
2216
|
-
const particleUnitIndexes = payload.closure.particleSpan === undefined
|
|
2217
|
-
? []
|
|
2218
|
-
: unitIndexesInSpan(options.units, payload.closure.particleSpan);
|
|
2219
|
-
const suffix = payload.closure.realization === "light_koto"
|
|
2220
|
-
? " 하는"
|
|
2221
|
-
: payload.closure.realization === "pronominal_no" ? "라는 것" : "라는";
|
|
2222
|
-
const sequencePlan = structuralRelationSequencePlan([
|
|
2223
|
-
itemPlan,
|
|
2224
|
-
{
|
|
2225
|
-
kind: "structuralText",
|
|
2226
|
-
text: suffix,
|
|
2227
|
-
koreanPos: 구,
|
|
2228
|
-
sourceSpan: sourceSpanForStructuralTokenSpan(options.tokens, payload.closure.markerSpan),
|
|
2229
|
-
},
|
|
2230
|
-
]);
|
|
2231
|
-
if (sequencePlan === null)
|
|
2232
|
-
return null;
|
|
2233
|
-
const trailingParticle = particleUnitIndexes
|
|
2234
|
-
.map((unitIndex) => options.units[unitIndex]?.allomorphKey ?? null)
|
|
2235
|
-
.map((key) => key === null ? null : particleKeyFromAllomorph(key))
|
|
2236
|
-
.find((key) => key !== null) ?? null;
|
|
2237
|
-
const renderPlan = payload.closure.realization === "pronominal_no" && trailingParticle !== null
|
|
2238
|
-
? attachParticleRenderPlan(sequencePlan, trailingParticle)
|
|
2239
|
-
: sequencePlan;
|
|
2240
|
-
if (renderPlan === null)
|
|
2241
|
-
return null;
|
|
2242
|
-
const suppressUnitIndexes = uniqueSorted([
|
|
2243
|
-
...options.sourceUnitIndexes,
|
|
2244
|
-
...options.markerUnitIndexes,
|
|
2245
|
-
...suffixUnitIndexes,
|
|
2246
|
-
...particleUnitIndexes,
|
|
2247
|
-
]).filter((unitIndex) => options.units[unitIndex]?.unitType !== UnitType.SYMBOL);
|
|
2248
|
-
const insertBeforeUnitIndex = suppressUnitIndexes[0] ?? null;
|
|
2249
|
-
if (insertBeforeUnitIndex === null)
|
|
2250
|
-
return null;
|
|
2251
|
-
return {
|
|
2252
|
-
relation: options.relation,
|
|
2253
|
-
insertBeforeUnitIndex,
|
|
2254
|
-
suppressUnitIndexes,
|
|
2255
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
2256
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
2257
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((unitIndex) => (options.units[unitIndex]?.jpIndices ?? []))),
|
|
2258
|
-
renderPlan,
|
|
2259
|
-
};
|
|
2260
|
-
}
|
|
2261
|
-
function relationWindowHasExternalBoundarySymbol(tokens, units, start, endExclusive) {
|
|
2262
|
-
return units.some((unit) => unit.unitType === UnitType.SYMBOL &&
|
|
2263
|
-
unit.jpIndices.some((jpIndex) => {
|
|
2264
|
-
if (jpIndex < start || jpIndex >= endExclusive)
|
|
2265
|
-
return false;
|
|
2266
|
-
const token = tokens[jpIndex];
|
|
2267
|
-
return token !== undefined &&
|
|
2268
|
-
!isClauseOpeningPunctuationToken(token) &&
|
|
2269
|
-
!isClauseEvidenceTransparentPunctuation(token);
|
|
2270
|
-
}));
|
|
2271
|
-
}
|
|
2272
|
-
function buildNariParallelStructuredRenderOperation(options) {
|
|
2273
|
-
const payload = options.relation.nariParallel;
|
|
2274
|
-
if (payload === undefined || payload.itemAnchors.length < 2) {
|
|
2275
|
-
return null;
|
|
2276
|
-
}
|
|
2277
|
-
const itemPlans = [];
|
|
2278
|
-
for (const item of payload.itemAnchors) {
|
|
2279
|
-
if (nariItemSpanContainsTransparentPunctuation(options.tokens, item.source.span)) {
|
|
2280
|
-
return null;
|
|
2281
|
-
}
|
|
2282
|
-
const plan = nariParallelItemPlan(options.tokens, options.units, item, item.itemKind);
|
|
2283
|
-
if (plan === null) {
|
|
2284
|
-
return null;
|
|
2285
|
-
}
|
|
2286
|
-
itemPlans.push(plan);
|
|
2287
|
-
}
|
|
2288
|
-
const trailingParticle = nariParallelTrailingParticleKey(options.units, payload.trailingParticleSpan ?? null);
|
|
2289
|
-
const consumeTrailing = payload.trailingParticleSpan !== null &&
|
|
2290
|
-
payload.trailingParticleSpan !== undefined && trailingParticle !== null;
|
|
2291
|
-
const unconsumedTrailingUnitIndexes = consumeTrailing || payload.trailingParticleSpan === null || payload.trailingParticleSpan === undefined
|
|
2292
|
-
? []
|
|
2293
|
-
: unitIndexesInSpan(options.units, payload.trailingParticleSpan);
|
|
2294
|
-
const suppressUnitIndexes = uniqueSorted([...options.sourceUnitIndexes, ...options.markerUnitIndexes])
|
|
2295
|
-
.filter((unitIndex) => !unconsumedTrailingUnitIndexes.includes(unitIndex));
|
|
2296
|
-
const insertBeforeUnitIndex = suppressUnitIndexes[0] ?? options.sourceUnitIndexes[0] ?? null;
|
|
2297
|
-
if (insertBeforeUnitIndex === null) {
|
|
2298
|
-
return null;
|
|
2299
|
-
}
|
|
2300
|
-
return {
|
|
2301
|
-
relation: options.relation,
|
|
2302
|
-
insertBeforeUnitIndex,
|
|
2303
|
-
suppressUnitIndexes,
|
|
2304
|
-
sourceUnitIndexes: options.sourceUnitIndexes,
|
|
2305
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
2306
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
2307
|
-
renderPlan: {
|
|
2308
|
-
kind: "nariParallel",
|
|
2309
|
-
itemKind: payload.itemKind,
|
|
2310
|
-
itemKinds: payload.itemAnchors.map((item) => item.itemKind),
|
|
2311
|
-
itemPlans,
|
|
2312
|
-
itemSourceSpans: payload.itemAnchors.map((item) => sourceSpanForStructuralTokenSpan(options.tokens, item.source.span)),
|
|
2313
|
-
markerSourceSpans: payload.markerSpans.map((span) => sourceSpanForStructuralTokenSpan(options.tokens, span)),
|
|
2314
|
-
separator: payload.separatorSpans.length > 0 ? "comma" : "space",
|
|
2315
|
-
...(consumeTrailing && trailingParticle !== null ? { trailingParticle } : {}),
|
|
2316
|
-
koreanPos: 구,
|
|
2317
|
-
},
|
|
2318
|
-
};
|
|
2319
|
-
}
|
|
2320
|
-
function buildTokaNominalListingStructuredRenderOperation(options) {
|
|
2321
|
-
const payload = options.relation.tokaNominalListing;
|
|
2322
|
-
if (payload === undefined || payload.itemAnchors.length < 2) {
|
|
2323
|
-
return null;
|
|
2324
|
-
}
|
|
2325
|
-
const itemPlans = [];
|
|
2326
|
-
const relationCoreSpans = [
|
|
2327
|
-
...payload.itemAnchors.map((item) => item.span),
|
|
2328
|
-
...options.relation.markerSpans,
|
|
2329
|
-
...payload.separatorSpans,
|
|
2330
|
-
];
|
|
2331
|
-
if (tokaNominalListingHasUnownedSourceGap(options.tokens, relationCoreSpans)) {
|
|
2332
|
-
return null;
|
|
2333
|
-
}
|
|
2334
|
-
const itemUnitIndexesForSuppression = [];
|
|
2335
|
-
for (const item of payload.itemAnchors) {
|
|
2336
|
-
if (nariItemSpanContainsTransparentPunctuation(options.tokens, item.span)) {
|
|
2337
|
-
return null;
|
|
2338
|
-
}
|
|
2339
|
-
const itemUnitIndexes = unitIndexesInSpan(options.units, item.span);
|
|
2340
|
-
if (itemUnitIndexes.some((unitIndex) => {
|
|
2341
|
-
const unit = options.units[unitIndex];
|
|
2342
|
-
return unit === undefined || !unitFullyCoveredBySpans(unit, [item.span]);
|
|
2343
|
-
})) {
|
|
2344
|
-
return null;
|
|
2345
|
-
}
|
|
2346
|
-
const itemPlan = composeRelationSourceUnitPlans(options.tokens, options.units, itemUnitIndexes);
|
|
2347
|
-
if (itemPlan === null) {
|
|
2348
|
-
return null;
|
|
2349
|
-
}
|
|
2350
|
-
itemUnitIndexesForSuppression.push(...itemUnitIndexes);
|
|
2351
|
-
itemPlans.push(itemPlan);
|
|
2352
|
-
}
|
|
2353
|
-
const trailingParticle = payload.closure === "closed"
|
|
2354
|
-
? nariParallelTrailingParticleKey(options.units, payload.trailingParticleSpan)
|
|
2355
|
-
: null;
|
|
2356
|
-
const consumeTrailing = payload.closure === "closed" &&
|
|
2357
|
-
payload.trailingParticleSpan !== null && trailingParticle !== null;
|
|
2358
|
-
const unconsumedTrailingUnitIndexes = !consumeTrailing && payload.trailingParticleSpan !== null
|
|
2359
|
-
? unitIndexesInSpan(options.units, payload.trailingParticleSpan)
|
|
2360
|
-
: [];
|
|
2361
|
-
const suppressUnitIndexes = uniqueSorted([
|
|
2362
|
-
...options.sourceUnitIndexes,
|
|
2363
|
-
...options.markerUnitIndexes,
|
|
2364
|
-
...itemUnitIndexesForSuppression,
|
|
2365
|
-
]).filter((unitIndex) => !unconsumedTrailingUnitIndexes.includes(unitIndex));
|
|
2366
|
-
const suppressibleSpans = [
|
|
2367
|
-
...payload.itemAnchors.map((item) => item.span),
|
|
2368
|
-
...options.relation.markerSpans,
|
|
2369
|
-
...payload.separatorSpans,
|
|
2370
|
-
...(consumeTrailing && payload.trailingParticleSpan !== null
|
|
2371
|
-
? [payload.trailingParticleSpan]
|
|
2372
|
-
: []),
|
|
2373
|
-
];
|
|
2374
|
-
if (suppressUnitIndexes.some((unitIndex) => {
|
|
2375
|
-
const unit = options.units[unitIndex];
|
|
2376
|
-
return unit === undefined || !unitFullyCoveredBySpans(unit, suppressibleSpans);
|
|
2377
|
-
})) {
|
|
2378
|
-
return null;
|
|
2379
|
-
}
|
|
2380
|
-
const insertBeforeUnitIndex = suppressUnitIndexes[0] ?? options.sourceUnitIndexes[0] ?? null;
|
|
2381
|
-
if (insertBeforeUnitIndex === null) {
|
|
2382
|
-
return null;
|
|
2383
|
-
}
|
|
2384
|
-
return {
|
|
2385
|
-
relation: consumeTrailing || payload.trailingParticleSpan === null
|
|
2386
|
-
? options.relation
|
|
2387
|
-
: tokaNominalListingRelationWithoutTrailingParticle(options.relation),
|
|
2388
|
-
insertBeforeUnitIndex,
|
|
2389
|
-
suppressUnitIndexes,
|
|
2390
|
-
sourceUnitIndexes: suppressUnitIndexes,
|
|
2391
|
-
targetUnitIndexes: options.targetUnitIndexes,
|
|
2392
|
-
projectionTokenIndexes: uniqueSorted(suppressUnitIndexes.flatMap((candidateIndex) => (options.units[candidateIndex]?.jpIndices ?? []))),
|
|
2393
|
-
...(consumeTrailing && payload.trailingParticleSpan !== null
|
|
2394
|
-
? { projectionHeadTokenIndex: payload.trailingParticleSpan.start }
|
|
2395
|
-
: {}),
|
|
2396
|
-
renderPlan: {
|
|
2397
|
-
kind: "nariParallel",
|
|
2398
|
-
itemKind: "nominal",
|
|
2399
|
-
itemPlans,
|
|
2400
|
-
itemSourceSpans: payload.itemAnchors.map((item) => sourceSpanForStructuralTokenSpan(options.tokens, item.span)),
|
|
2401
|
-
markerSourceSpans: options.relation.markerSpans.map((span) => sourceSpanForStructuralTokenSpan(options.tokens, span)),
|
|
2402
|
-
separator: "space",
|
|
2403
|
-
itemSeparatorTexts: payload.itemAnchors.slice(0, -1).map((_, index) => {
|
|
2404
|
-
const markerEnd = options.relation.markerSpans[index]?.endExclusive ?? 0;
|
|
2405
|
-
const nextItemStart = payload.itemAnchors[index + 1]?.span.start ?? markerEnd;
|
|
2406
|
-
const separatorSpans = payload.separatorSpans.filter((span) => span.start >= markerEnd && span.endExclusive <= nextItemStart);
|
|
2407
|
-
return separatorSpans.length === 0
|
|
2408
|
-
? " "
|
|
2409
|
-
: separatorSpans.map((span) => span.surface).join("");
|
|
2410
|
-
}),
|
|
2411
|
-
itemSeparatorSourceSpans: payload.itemAnchors.slice(0, -1).map((_, index) => {
|
|
2412
|
-
const markerEnd = options.relation.markerSpans[index]?.endExclusive ?? 0;
|
|
2413
|
-
const nextItemStart = payload.itemAnchors[index + 1]?.span.start ?? markerEnd;
|
|
2414
|
-
const separatorSpans = payload.separatorSpans.filter((span) => span.start >= markerEnd && span.endExclusive <= nextItemStart);
|
|
2415
|
-
const firstSeparator = separatorSpans[0];
|
|
2416
|
-
const lastSeparator = separatorSpans.at(-1);
|
|
2417
|
-
return firstSeparator === undefined || lastSeparator === undefined
|
|
2418
|
-
? null
|
|
2419
|
-
: sourceSpanForStructuralTokenSpan(options.tokens, {
|
|
2420
|
-
start: firstSeparator.start,
|
|
2421
|
-
endExclusive: lastSeparator.endExclusive,
|
|
2422
|
-
});
|
|
2423
|
-
}),
|
|
2424
|
-
...(consumeTrailing && trailingParticle !== null && payload.trailingParticleSpan !== null
|
|
2425
|
-
? {
|
|
2426
|
-
trailingParticle,
|
|
2427
|
-
trailingParticleSourceSpan: sourceSpanForStructuralTokenSpan(options.tokens, payload.trailingParticleSpan),
|
|
2428
|
-
}
|
|
2429
|
-
: {}),
|
|
2430
|
-
nominalListingStyle: "toka",
|
|
2431
|
-
nominalListingClosure: payload.closure,
|
|
2432
|
-
koreanPos: 구,
|
|
2433
|
-
},
|
|
2434
|
-
};
|
|
2435
|
-
}
|
|
2436
|
-
function tokaNominalListingHasUnownedSourceGap(tokens, spans) {
|
|
2437
|
-
const indexes = uniqueSorted(spans.flatMap((span) => {
|
|
2438
|
-
const values = [];
|
|
2439
|
-
for (let index = span.start; index < span.endExclusive; index += 1) {
|
|
2440
|
-
values.push(index);
|
|
2441
|
-
}
|
|
2442
|
-
return values;
|
|
2443
|
-
}));
|
|
2444
|
-
for (let position = 1; position < indexes.length; position += 1) {
|
|
2445
|
-
const previous = tokens[indexes[position - 1]];
|
|
2446
|
-
const current = tokens[indexes[position]];
|
|
2447
|
-
const previousSpan = previous?.sourceSpan;
|
|
2448
|
-
const currentSpan = current?.sourceSpan;
|
|
2449
|
-
if (previousSpan !== undefined &&
|
|
2450
|
-
previousSpan !== null &&
|
|
2451
|
-
currentSpan !== undefined &&
|
|
2452
|
-
currentSpan !== null &&
|
|
2453
|
-
previousSpan.endOrdinal < currentSpan.startOrdinal) {
|
|
2454
|
-
return true;
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
return false;
|
|
2458
|
-
}
|
|
2459
|
-
function tokaNominalListingRelationWithoutTrailingParticle(relation) {
|
|
2460
|
-
const payload = relation.tokaNominalListing;
|
|
2461
|
-
if (payload === undefined || payload.trailingParticleSpan === null) {
|
|
2462
|
-
return relation;
|
|
2463
|
-
}
|
|
2464
|
-
const sourceEnd = Math.max(...payload.itemAnchors.map((item) => item.span.endExclusive), ...relation.markerSpans.map((span) => span.endExclusive));
|
|
2465
|
-
return {
|
|
2466
|
-
...relation,
|
|
2467
|
-
source: {
|
|
2468
|
-
...relation.source,
|
|
2469
|
-
span: { ...relation.source.span, endExclusive: sourceEnd },
|
|
2470
|
-
},
|
|
2471
|
-
...(relation.candidateSuppressibleTokenSpans === undefined ? {} : {
|
|
2472
|
-
candidateSuppressibleTokenSpans: relation.candidateSuppressibleTokenSpans.filter((span) => span.reason !== "relation_trailing_particle"),
|
|
2473
|
-
}),
|
|
2474
|
-
tokaNominalListing: {
|
|
2475
|
-
...payload,
|
|
2476
|
-
trailingParticleSpan: null,
|
|
2477
|
-
},
|
|
2478
|
-
};
|
|
2479
|
-
}
|
|
2480
|
-
function nariParallelItemPlan(tokens, units, item, itemKind) {
|
|
2481
|
-
const unitIndexes = unitIndexesInSpan(units, item.source.span);
|
|
2482
|
-
if (unitIndexes.length === 0) {
|
|
2483
|
-
return null;
|
|
2484
|
-
}
|
|
2485
|
-
if (itemKind === "nominal") {
|
|
2486
|
-
return composeRelationSourceUnitPlans(tokens, units, unitIndexes);
|
|
2487
|
-
}
|
|
2488
|
-
const predicateUnitIndex = parallelPredicateUnitIndex(units, unitIndexes, item.predicateIdx);
|
|
2489
|
-
if (predicateUnitIndex === null) {
|
|
2490
|
-
return null;
|
|
2491
|
-
}
|
|
2492
|
-
const predicateUnit = units[predicateUnitIndex];
|
|
2493
|
-
if (predicateUnit === undefined) {
|
|
2494
|
-
return null;
|
|
2495
|
-
}
|
|
2496
|
-
const projected = nariParallelPredicateProjectionPlan(predicateUnit.renderPlan);
|
|
2497
|
-
if (projected === null) {
|
|
2498
|
-
return null;
|
|
2499
|
-
}
|
|
2500
|
-
const extraUnitIndexes = unitIndexes.filter((unitIndex) => unitIndex !== predicateUnitIndex && units[unitIndex]?.unitType !== UnitType.SYMBOL);
|
|
2501
|
-
if (extraUnitIndexes.length === 0) {
|
|
2502
|
-
return projected;
|
|
2503
|
-
}
|
|
2504
|
-
if (extraUnitIndexes.some((unitIndex) => unitIndex > predicateUnitIndex)) {
|
|
2505
|
-
return null;
|
|
2506
|
-
}
|
|
2507
|
-
return composeRelationSourceUnitPlans(tokens, units, unitIndexes, new Map([[predicateUnitIndex, projected]]));
|
|
2508
|
-
}
|
|
2509
|
-
function nariParallelPredicateProjectionPlan(plan) {
|
|
2510
|
-
if (plan?.kind === "lemma") {
|
|
2511
|
-
if ((plan.koreanPos !== 동사 && plan.koreanPos !== 형용사) ||
|
|
2512
|
-
plan.prefix !== undefined ||
|
|
2513
|
-
plan.suffix !== undefined ||
|
|
2514
|
-
(plan.connective !== undefined && plan.connective !== null) ||
|
|
2515
|
-
(plan.sfp !== undefined && plan.sfp !== null)) {
|
|
2516
|
-
return null;
|
|
2517
|
-
}
|
|
2518
|
-
return {
|
|
2519
|
-
...plan,
|
|
2520
|
-
connective: "든",
|
|
2521
|
-
sfp: null,
|
|
2522
|
-
};
|
|
2523
|
-
}
|
|
2524
|
-
if (plan?.kind !== "headTailChain" || plan.realization.kind !== "predicate" || plan.realization.root.tail.kind !== "auxLayer") {
|
|
2525
|
-
return null;
|
|
2526
|
-
}
|
|
2527
|
-
const layer = plan.realization.root.tail;
|
|
2528
|
-
if (layer.ops.length !== 0 || layer.terminal !== null || plan.realization.root.sfp !== null) {
|
|
2529
|
-
return null;
|
|
2530
|
-
}
|
|
2531
|
-
const stem = layer.stem;
|
|
2532
|
-
if (stem.kind !== "verb" && stem.kind !== "adj") {
|
|
2533
|
-
return null;
|
|
2534
|
-
}
|
|
2535
|
-
return {
|
|
2536
|
-
kind: "lemma",
|
|
2537
|
-
entry: plan.realization.entry ?? null,
|
|
2538
|
-
koreanLemma: stem.lemma,
|
|
2539
|
-
koreanPos: stem.kind === "verb" ? 동사 : 형용사,
|
|
2540
|
-
irregular: stem.irregular,
|
|
2541
|
-
auxTokens: [],
|
|
2542
|
-
connective: "든",
|
|
2543
|
-
voice: "active",
|
|
2544
|
-
};
|
|
2545
|
-
}
|
|
2546
|
-
function nariItemSpanContainsTransparentPunctuation(tokens, span) {
|
|
2547
|
-
for (let index = span.start; index < span.endExclusive; index += 1) {
|
|
2548
|
-
const token = tokens[index];
|
|
2549
|
-
if (token !== undefined && isClauseEvidenceTransparentPunctuation(token)) {
|
|
2550
|
-
return true;
|
|
2551
|
-
}
|
|
2552
|
-
}
|
|
2553
|
-
return false;
|
|
2554
|
-
}
|
|
2555
|
-
function nariParallelTrailingParticleKey(units, span) {
|
|
2556
|
-
if (span === null) {
|
|
2557
|
-
return null;
|
|
2558
|
-
}
|
|
2559
|
-
for (const unitIndex of unitIndexesInSpan(units, span)) {
|
|
2560
|
-
const key = units[unitIndex]?.allomorphKey;
|
|
2561
|
-
if (key === undefined || key === null) {
|
|
2562
|
-
continue;
|
|
2563
|
-
}
|
|
2564
|
-
const particle = particleKeyFromAllomorph(key);
|
|
2565
|
-
if (particle !== null) {
|
|
2566
|
-
return particle;
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
return null;
|
|
2570
|
-
}
|
|
2571
|
-
function kaParallelTrailingSuffixPlan(tokens, units, sourceUnitIndexes, sourceEndExclusive, lookups, closure) {
|
|
2572
|
-
const cursor = new TokenCursor(tokens, sourceEndExclusive, tokens.length, sourceEndExclusive);
|
|
2573
|
-
const externalSuffix = kaParallelExternalDakeCopulaSuffixPlan(cursor, units, lookups);
|
|
2574
|
-
if (externalSuffix !== null) {
|
|
2575
|
-
return externalSuffix;
|
|
2576
|
-
}
|
|
2577
|
-
const embeddedQuestionQuote = kaParallelEmbeddedQuestionQuoteSuffix(units, closure);
|
|
2578
|
-
if (embeddedQuestionQuote !== null) {
|
|
2579
|
-
return embeddedQuestionQuote;
|
|
2580
|
-
}
|
|
2581
|
-
for (const unitIndex of sourceUnitIndexes) {
|
|
2582
|
-
const unit = units[unitIndex];
|
|
2583
|
-
const plan = unit?.renderPlan;
|
|
2584
|
-
if (unit === undefined ||
|
|
2585
|
-
plan?.kind !== "predicateScopeCarrier" ||
|
|
2586
|
-
plan.suffix === undefined ||
|
|
2587
|
-
!unit.jpIndices.some((jpIndex) => jpIndex >= sourceEndExclusive)) {
|
|
2588
|
-
continue;
|
|
2589
|
-
}
|
|
2590
|
-
return { suffix: plan.suffix, suffixUnitIndexes: [unitIndex] };
|
|
2591
|
-
}
|
|
2592
|
-
return { suffix: null, suffixUnitIndexes: [] };
|
|
2593
|
-
}
|
|
2594
|
-
function kaParallelEmbeddedQuestionQuoteSuffix(units, closure) {
|
|
2595
|
-
if (closure.kind !== "attributive_quote") {
|
|
2596
|
-
return null;
|
|
2597
|
-
}
|
|
2598
|
-
const suffixUnitIndexes = unitIndexesInSpan(units, {
|
|
2599
|
-
start: closure.markerSpan.start,
|
|
2600
|
-
endExclusive: closure.markerSpan.endExclusive
|
|
2601
|
-
});
|
|
2602
|
-
return suffixUnitIndexes.length === 0
|
|
2603
|
-
? null
|
|
2604
|
-
: {
|
|
2605
|
-
suffix: closure.realization === "light_koto"
|
|
2606
|
-
? " 하는"
|
|
2607
|
-
: closure.realization === "pronominal_no" ? "라는 것" : "라는",
|
|
2608
|
-
suffixUnitIndexes
|
|
2609
|
-
};
|
|
2610
|
-
}
|
|
2611
|
-
function kaParallelExternalDakeCopulaSuffixPlan(cursor, units, lookups) {
|
|
2612
|
-
const { tokens, pos: sourceEndExclusive } = cursor;
|
|
2613
|
-
const dakeIndex = nextNonSpaceTokenIndex(cursor);
|
|
2614
|
-
const dake = dakeIndex === null ? undefined : tokens[dakeIndex];
|
|
2615
|
-
if (dakeIndex === null || dake?.surface !== "だけ") {
|
|
2616
|
-
return null;
|
|
2617
|
-
}
|
|
2618
|
-
const copulaTail = matchCopulaTailWithOptionalConditional(cursor.fork(dakeIndex + 1, cursor.end, dakeIndex + 1), { skipLeadingSpace: true });
|
|
2619
|
-
if (copulaTail === null || (copulaTail.auxTokens.length === 0 && copulaTail.connective === null)) {
|
|
2620
|
-
return null;
|
|
2621
|
-
}
|
|
2622
|
-
let endExclusive = dakeIndex + 1 + copulaTail.consumed;
|
|
2623
|
-
let connective = copulaTail.connective;
|
|
2624
|
-
const tameReasonConsumed = kaParallelTameReasonTail(cursor.fork(endExclusive), sourceEndExclusive - 1, lookups);
|
|
2625
|
-
if (tameReasonConsumed !== null) {
|
|
2626
|
-
connective = "기 때문에";
|
|
2627
|
-
endExclusive += tameReasonConsumed;
|
|
2628
|
-
}
|
|
2629
|
-
else if (!kaParallelSuffixCanEndAt(cursor.fork(endExclusive))) {
|
|
2630
|
-
return null;
|
|
2631
|
-
}
|
|
2632
|
-
const suffixUnitIndexes = unitIndexesInSpan(units, {
|
|
2633
|
-
start: dakeIndex,
|
|
2634
|
-
endExclusive,
|
|
2635
|
-
});
|
|
2636
|
-
if (suffixUnitIndexes.length === 0) {
|
|
2637
|
-
return null;
|
|
2638
|
-
}
|
|
2639
|
-
return {
|
|
2640
|
-
suffix: {
|
|
2641
|
-
kind: "lemma",
|
|
2642
|
-
entry: null,
|
|
2643
|
-
koreanLemma: "뿐",
|
|
2644
|
-
koreanPos: 명사,
|
|
2645
|
-
irregular: null,
|
|
2646
|
-
auxTokens: copulaTail.auxTokens,
|
|
2647
|
-
formalOverride: true,
|
|
2648
|
-
...(connective === null ? {} : { connective }),
|
|
2649
|
-
},
|
|
2650
|
-
suffixUnitIndexes,
|
|
2651
|
-
};
|
|
2652
|
-
}
|
|
2653
|
-
function kaParallelTameReasonTail(cursor, contentIdx, lookups) {
|
|
2654
|
-
const headIndex = nextNonSpaceTokenIndex(cursor);
|
|
2655
|
-
const headToken = headIndex === null ? null : cursor.tokens[headIndex] ?? null;
|
|
2656
|
-
if (!isTameReasonHeadContext(headToken, cursor.tokens, contentIdx, lookups)) {
|
|
2657
|
-
return null;
|
|
2658
|
-
}
|
|
2659
|
-
if (headIndex === null) {
|
|
2660
|
-
return null;
|
|
2661
|
-
}
|
|
2662
|
-
return headIndex - cursor.pos + 1;
|
|
2663
|
-
}
|
|
2664
|
-
function kaParallelSuffixCanEndAt(cursor) {
|
|
2665
|
-
const index = nextNonSpaceTokenIndex(cursor);
|
|
2666
|
-
if (index === null) {
|
|
2667
|
-
return true;
|
|
2668
|
-
}
|
|
2669
|
-
const token = cursor.tokens[index];
|
|
2670
|
-
if (token === undefined) {
|
|
2671
|
-
return false;
|
|
2672
|
-
}
|
|
2673
|
-
const pos0 = token.pos & POS0;
|
|
2674
|
-
return pos0 === 補助記号 || pos0 === 記号;
|
|
2675
|
-
}
|
|
2676
|
-
function nextNonSpaceTokenIndex(cursor) {
|
|
2677
|
-
const c = cursor.fork();
|
|
2678
|
-
return c.pos < c.end ? c.pos : null;
|
|
2679
|
-
}
|
|
2680
|
-
function previousNonSpaceTokenIndex(tokens, start) {
|
|
2681
|
-
for (let index = Math.min(start - 1, tokens.length - 1); index >= 0; index -= 1) {
|
|
2682
|
-
const token = tokens[index];
|
|
2683
|
-
if (token === undefined) {
|
|
2684
|
-
continue;
|
|
2685
|
-
}
|
|
2686
|
-
return index;
|
|
2687
|
-
}
|
|
2688
|
-
return null;
|
|
2689
|
-
}
|
|
2690
|
-
function kaParallelItemPlan(tokens, units, item, relationKind, isLast, closure, matrixQuestionItems) {
|
|
2691
|
-
const unitIndexes = unitIndexesInSpan(units, item.source.span);
|
|
2692
|
-
if (unitIndexes.length === 0) {
|
|
2693
|
-
return null;
|
|
2694
|
-
}
|
|
2695
|
-
if (relationKind === "toka_parallel_listing") {
|
|
2696
|
-
return tokaParallelListingItemPlan(tokens, units, unitIndexes, item);
|
|
2697
|
-
}
|
|
2698
|
-
if (relationKind === "ka_parallel_choice") {
|
|
2699
|
-
const replacements = new Map();
|
|
2700
|
-
for (const unitIndex of unitIndexes) {
|
|
2701
|
-
const unit = units[unitIndex];
|
|
2702
|
-
if (unit === undefined) {
|
|
2703
|
-
continue;
|
|
2704
|
-
}
|
|
2705
|
-
const projected = projectUnitWithoutKaSfpPlan(unit, item.markerSpan, tokens);
|
|
2706
|
-
if (projected !== null) {
|
|
2707
|
-
replacements.set(unitIndex, projected);
|
|
2708
|
-
}
|
|
2709
|
-
}
|
|
2710
|
-
return composeRelationSourceUnitPlans(tokens, units, unitIndexes, replacements);
|
|
2711
|
-
}
|
|
2712
|
-
const negativeAlternative = kaParallelNegativeAlternativePlan(item);
|
|
2713
|
-
if (negativeAlternative !== null) {
|
|
2714
|
-
return negativeAlternative;
|
|
2715
|
-
}
|
|
2716
|
-
const predicateUnitIndex = parallelPredicateUnitIndex(units, unitIndexes, item.predicateIdx);
|
|
2717
|
-
if (predicateUnitIndex === null) {
|
|
2718
|
-
if (!matrixQuestionItems) {
|
|
2719
|
-
return composeRelationSourceUnitPlans(tokens, units, unitIndexes);
|
|
2720
|
-
}
|
|
2721
|
-
const replacements = new Map();
|
|
2722
|
-
for (const unitIndex of unitIndexes) {
|
|
2723
|
-
const plan = units[unitIndex]?.renderPlan;
|
|
2724
|
-
if (plan === undefined || plan === null)
|
|
2725
|
-
continue;
|
|
2726
|
-
const projected = markQuestionContentTerminalPlan(plan);
|
|
2727
|
-
if (projected !== plan)
|
|
2728
|
-
replacements.set(unitIndex, projected);
|
|
2729
|
-
}
|
|
2730
|
-
return composeRelationSourceUnitPlans(tokens, units, unitIndexes, replacements);
|
|
2731
|
-
}
|
|
2732
|
-
const predicateUnit = units[predicateUnitIndex];
|
|
2733
|
-
if (predicateUnit === undefined) {
|
|
2734
|
-
return null;
|
|
2735
|
-
}
|
|
2736
|
-
if (isLast && closure.kind === "terminal_fragment" && isNominalizedConjectureMatrixQuestionPlan(predicateUnit.renderPlan)) {
|
|
2737
|
-
return composeRelationSourceUnitPlans(tokens, units, unitIndexes);
|
|
2738
|
-
}
|
|
2739
|
-
const projectedPredicateBase = projectSimpleNegativeHeadTailQuestionContentPlan(predicateUnit.renderPlan) ??
|
|
2740
|
-
projectUnitHeadTailConnectivePlan(predicateUnit, { connective: "question_content", surface: item.markerSpan.surface }, opSourceForMarkerSpans(tokens, [item.markerSpan]), true, closure.kind === "attributive_quote"
|
|
2741
|
-
? opSourceForMarkerSpans(tokens, [item.markerSpan, closure.markerSpan])
|
|
2742
|
-
: null) ??
|
|
2743
|
-
projectLemmaQuestionContentPlan(predicateUnit.renderPlan) ??
|
|
2744
|
-
projectConjugatedLemmaQuestionContentPlan(predicateUnit.renderPlan) ??
|
|
2745
|
-
projectPredicateScopeCarrierQuestionContentPlan(predicateUnit.renderPlan);
|
|
2746
|
-
if (projectedPredicateBase === null) {
|
|
2747
|
-
return null;
|
|
2748
|
-
}
|
|
2749
|
-
const projectedPredicate = matrixQuestionItems
|
|
2750
|
-
? markQuestionContentTerminalPlan(projectedPredicateBase)
|
|
2751
|
-
: markStructuralKaParallelQuestionContentPlan(projectedPredicateBase);
|
|
2752
|
-
return composeRelationSourceUnitPlans(tokens, units, unitIndexes, new Map([[predicateUnitIndex, projectedPredicate]]));
|
|
2753
|
-
}
|
|
2754
|
-
function tokaParallelListingItemPlan(tokens, units, unitIndexes, item) {
|
|
2755
|
-
const replacements = new Map();
|
|
2756
|
-
const ownerUnitIndex = parallelPredicateUnitIndex(units, unitIndexes, item.predicateIdx);
|
|
2757
|
-
const plan = ownerUnitIndex === null ? null : units[ownerUnitIndex]?.renderPlan ?? null;
|
|
2758
|
-
if (ownerUnitIndex !== null && plan !== null) {
|
|
2759
|
-
const copulaIdx = previousNonSpaceTokenIndex(tokens, item.markerSpan.start);
|
|
2760
|
-
const copula = copulaIdx === null ? undefined : tokens[copulaIdx];
|
|
2761
|
-
const basePlan = plan.kind === "lemma"
|
|
2762
|
-
? {
|
|
2763
|
-
...plan,
|
|
2764
|
-
auxTokens: copula === undefined
|
|
2765
|
-
? plan.auxTokens
|
|
2766
|
-
: plan.auxTokens.filter((token) => !sourceTokensOverlap(token, copula)),
|
|
2767
|
-
sfp: null,
|
|
2768
|
-
terminalSfp: null,
|
|
2769
|
-
}
|
|
2770
|
-
: plan;
|
|
2771
|
-
const exemplified = item.predicateCategory === "predicate"
|
|
2772
|
-
? projectTokaPredicateListingPlan(basePlan, opSourceForMarkerSpans(tokens, [item.markerSpan]))
|
|
2773
|
-
: attachParticleRenderPlan(basePlan, "이라든가/라든가");
|
|
2774
|
-
if (exemplified === null) {
|
|
2775
|
-
return null;
|
|
2776
|
-
}
|
|
2777
|
-
replacements.set(ownerUnitIndex, exemplified);
|
|
2778
|
-
}
|
|
2779
|
-
return composeRelationSourceUnitPlans(tokens, units, unitIndexes, replacements);
|
|
2780
|
-
}
|
|
2781
|
-
function projectTokaPredicateListingPlan(plan, source) {
|
|
2782
|
-
if (plan.kind === "lemma") {
|
|
2783
|
-
const rule = CONNECTIVE_RENDER_MAP.get("とか");
|
|
2784
|
-
if (rule === undefined || (plan.koreanPos !== 동사 && plan.koreanPos !== 형용사)) {
|
|
2785
|
-
return null;
|
|
2786
|
-
}
|
|
2787
|
-
return {
|
|
2788
|
-
...plan,
|
|
2789
|
-
connective: plan.koreanPos === 형용사 ? rule.adjEnding ?? rule.korean : rule.korean,
|
|
2790
|
-
...(rule.suffixText === undefined ? {} : { suffix: `${plan.suffix ?? ""}${rule.suffixText}` }),
|
|
2791
|
-
sfp: null,
|
|
2792
|
-
terminalSfp: null,
|
|
2793
|
-
};
|
|
2794
|
-
}
|
|
2795
|
-
if (!isPredicateHeadTailChainRenderPlan(plan) || source === null) {
|
|
2796
|
-
return null;
|
|
2797
|
-
}
|
|
2798
|
-
return projectHeadTailConnectivePlan(plan, { connective: "exemplification", surface: "とか" }, source);
|
|
2799
|
-
}
|
|
2800
|
-
function markQuestionContentTerminalPlan(plan) {
|
|
2801
|
-
if (!isPredicateHeadTailChainRenderPlan(plan) || plan.realization.root.tail.kind !== "auxLayer") {
|
|
2802
|
-
return plan;
|
|
2803
|
-
}
|
|
2804
|
-
const layer = plan.realization.root.tail;
|
|
2805
|
-
const ops = layer.ops.map((op) => op.kind === "connective" && op.connective === "question_content"
|
|
2806
|
-
? markQuestionContentTerminalOp(op)
|
|
2807
|
-
: op);
|
|
2808
|
-
if (ops.every((op, index) => op === layer.ops[index]))
|
|
2809
|
-
return plan;
|
|
2810
|
-
return {
|
|
2811
|
-
...plan,
|
|
2812
|
-
realization: {
|
|
2813
|
-
...plan.realization,
|
|
2814
|
-
root: {
|
|
2815
|
-
...plan.realization.root,
|
|
2816
|
-
tail: { ...layer, ops }
|
|
2817
|
-
}
|
|
2818
|
-
}
|
|
2819
|
-
};
|
|
2820
|
-
}
|
|
2821
|
-
function markStructuralKaParallelQuestionContentPlan(plan) {
|
|
2822
|
-
if (!isPredicateHeadTailChainRenderPlan(plan) || plan.realization.root.tail.kind !== "auxLayer") {
|
|
2823
|
-
return plan;
|
|
2824
|
-
}
|
|
2825
|
-
const layer = plan.realization.root.tail;
|
|
2826
|
-
const ops = layer.ops.map((op) => op.kind === "connective" && op.connective === "question_content"
|
|
2827
|
-
? markStructuralKaParallelQuestionContentOp(op)
|
|
2828
|
-
: op);
|
|
2829
|
-
return {
|
|
2830
|
-
...plan,
|
|
2831
|
-
realization: {
|
|
2832
|
-
...plan.realization,
|
|
2833
|
-
root: {
|
|
2834
|
-
...plan.realization.root,
|
|
2835
|
-
tail: { ...layer, ops }
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
};
|
|
2839
|
-
}
|
|
2840
|
-
export function markQuestionContentTerminalOp(op) {
|
|
2841
|
-
return { ...op, questionContentRole: "terminal" };
|
|
2842
|
-
}
|
|
2843
|
-
export function markStructuralKaParallelQuestionContentOp(op) {
|
|
2844
|
-
return {
|
|
2845
|
-
...op,
|
|
2846
|
-
questionContentRole: op.questionContentRole ?? "embedded",
|
|
2847
|
-
ownedByStructuralKaParallel: true
|
|
2848
|
-
};
|
|
2849
|
-
}
|
|
2850
|
-
function kaParallelNegativeAlternativePlan(item) {
|
|
2851
|
-
if (item.itemKind !== "negative_alternative") {
|
|
2852
|
-
return null;
|
|
2853
|
-
}
|
|
2854
|
-
return {
|
|
2855
|
-
kind: "kaParallelNegativeAlternative",
|
|
2856
|
-
koreanPos: 구,
|
|
2857
|
-
};
|
|
2858
|
-
}
|
|
2859
|
-
function projectUnitWithoutKaSfpPlan(unit, markerSpan, tokens) {
|
|
2860
|
-
const plan = unit.renderPlan;
|
|
2861
|
-
if (!isPredicateHeadTailChainRenderPlan(plan)) {
|
|
2862
|
-
return null;
|
|
2863
|
-
}
|
|
2864
|
-
const sfp = plan.realization.root.sfp;
|
|
2865
|
-
const markerSource = opSourceForMarkerSpans(tokens, [{
|
|
2866
|
-
start: markerSpan.start,
|
|
2867
|
-
endExclusive: markerSpan.endExclusive,
|
|
2868
|
-
surface: "",
|
|
2869
|
-
role: "ka_parallel_marker",
|
|
2870
|
-
}]);
|
|
2871
|
-
if (markerSource === null || sfp?.effect !== "ka" || !opSourceCoveredBy(sfp.source, markerSource)) {
|
|
2872
|
-
return null;
|
|
2873
|
-
}
|
|
2874
|
-
const projectedRoot = {
|
|
2875
|
-
...plan.realization.root,
|
|
2876
|
-
sfp: null,
|
|
2877
|
-
};
|
|
2878
|
-
const { headTailCandidate: _headTailCandidate, headTailSourceCandidate: _headTailSourceCandidate, ...planWithoutOriginalSourceCandidate } = plan;
|
|
2879
|
-
return {
|
|
2880
|
-
...planWithoutOriginalSourceCandidate,
|
|
2881
|
-
realization: { ...plan.realization, root: projectedRoot },
|
|
2882
|
-
clauseRole: { ...plan.clauseRole, outgoingBoundary: { kind: "terminal" } },
|
|
2883
|
-
};
|
|
2884
|
-
}
|
|
2885
|
-
function lastRealizedUnitIndexAfter(units, unitIndexes, anchorPos) {
|
|
2886
|
-
for (let index = unitIndexes.length - 1; index >= anchorPos; index -= 1) {
|
|
2887
|
-
const unitIndex = unitIndexes[index];
|
|
2888
|
-
if (unitIndex === undefined) {
|
|
2889
|
-
continue;
|
|
2890
|
-
}
|
|
2891
|
-
const unit = units[unitIndex];
|
|
2892
|
-
if (unit !== undefined && unit.unitType !== UnitType.SYMBOL && unit.renderPlan !== null) {
|
|
2893
|
-
return unitIndex;
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
return null;
|
|
2897
|
-
}
|
|
2898
|
-
function isNominalHeadUnit(unit) {
|
|
2899
|
-
const pos0 = (unit?.jpHead.pos ?? 0) & POS0;
|
|
2900
|
-
return pos0 === 名詞 || pos0 === 代名詞;
|
|
2901
|
-
}
|
|
2902
|
-
function parallelPredicateUnitIndex(units, unitIndexes, predicateIdx) {
|
|
2903
|
-
if (predicateIdx !== null) {
|
|
2904
|
-
const anchorPos = unitIndexes.findIndex((unitIndex) => units[unitIndex]?.jpIndices.includes(predicateIdx) === true);
|
|
2905
|
-
if (anchorPos >= 0) {
|
|
2906
|
-
const closingUnitIndex = lastRealizedUnitIndexAfter(units, unitIndexes, anchorPos);
|
|
2907
|
-
if (closingUnitIndex !== null && isNominalHeadUnit(units[closingUnitIndex])) {
|
|
2908
|
-
return closingUnitIndex;
|
|
2909
|
-
}
|
|
2910
|
-
const anchorUnitIndex = unitIndexes[anchorPos];
|
|
2911
|
-
if (anchorUnitIndex !== undefined) {
|
|
2912
|
-
return anchorUnitIndex;
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
for (let index = unitIndexes.length - 1; index >= 0; index -= 1) {
|
|
2917
|
-
const unitIndex = unitIndexes[index];
|
|
2918
|
-
if (unitIndex === undefined) {
|
|
2919
|
-
continue;
|
|
2920
|
-
}
|
|
2921
|
-
const unit = units[unitIndex];
|
|
2922
|
-
if (unit !== undefined && unit.unitType !== UnitType.SYMBOL && unit.renderPlan !== null) {
|
|
2923
|
-
return unitIndex;
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
|
-
return null;
|
|
2927
|
-
}
|
|
2928
|
-
function projectLemmaQuestionContentPlan(plan) {
|
|
2929
|
-
if (plan?.kind !== "lemma") {
|
|
2930
|
-
return null;
|
|
2931
|
-
}
|
|
2932
|
-
if (plan.koreanPos !== 동사 && plan.koreanPos !== 형용사 && plan.koreanPos !== 명사 && plan.koreanPos !== 대명사) {
|
|
2933
|
-
return null;
|
|
2934
|
-
}
|
|
2935
|
-
return {
|
|
2936
|
-
...plan,
|
|
2937
|
-
connective: "는지",
|
|
2938
|
-
sfp: null,
|
|
2939
|
-
};
|
|
2940
|
-
}
|
|
2941
|
-
function projectConjugatedLemmaQuestionContentPlan(plan) {
|
|
2942
|
-
if (plan?.kind !== "conjugatedLemma") {
|
|
2943
|
-
return null;
|
|
2944
|
-
}
|
|
2945
|
-
if (!("koreanLemma" in plan) || !("ending" in plan) || plan.koreanPos !== 동사 && plan.koreanPos !== 형용사) {
|
|
2946
|
-
return null;
|
|
2947
|
-
}
|
|
2948
|
-
return {
|
|
2949
|
-
...plan,
|
|
2950
|
-
ending: plan.koreanPos === 형용사 ? "ㄴ/은지" : "는지",
|
|
2951
|
-
};
|
|
2952
|
-
}
|
|
2953
|
-
function projectPredicateScopeCarrierQuestionContentPlan(plan) {
|
|
2954
|
-
if (plan?.kind !== "predicateScopeCarrier") {
|
|
2955
|
-
return null;
|
|
2956
|
-
}
|
|
2957
|
-
if (plan.projection.kind === "direct" && predicateHeadTailPlanHasQuestionContent(plan.projection.base)) {
|
|
2958
|
-
return projectSimpleNegativeHeadTailQuestionContentPlan(plan.projection.base) ?? plan.projection.base;
|
|
2959
|
-
}
|
|
2960
|
-
return projectLemmaQuestionContentPlan(plan.projection.base);
|
|
2961
|
-
}
|
|
2962
|
-
function predicateHeadTailPlanHasQuestionContent(plan) {
|
|
2963
|
-
if (plan === null) {
|
|
2964
|
-
return false;
|
|
2965
|
-
}
|
|
2966
|
-
if (plan.kind !== "headTailChain" || plan.realization.kind !== "predicate" || plan.realization.root.tail.kind !== "auxLayer") {
|
|
2967
|
-
return false;
|
|
2968
|
-
}
|
|
2969
|
-
return plan.realization.root.tail.ops.some((op) => (op.kind === "connective" &&
|
|
2970
|
-
(op.connective === "question_content" || op.connective === "question_content_alternative")));
|
|
2971
|
-
}
|
|
2972
|
-
function projectSimpleNegativeHeadTailQuestionContentPlan(plan) {
|
|
2973
|
-
if (!predicateHeadTailPlanHasQuestionContent(plan)) {
|
|
2974
|
-
return null;
|
|
2975
|
-
}
|
|
2976
|
-
if (plan.realization.root.tail.kind !== "auxLayer" || plan.realization.root.tail.terminal !== null || plan.realization.root.sfp !== null) {
|
|
2977
|
-
return null;
|
|
2978
|
-
}
|
|
2979
|
-
const layer = plan.realization.root.tail;
|
|
2980
|
-
if (layer.ops.length !== 2) {
|
|
2981
|
-
return null;
|
|
2982
|
-
}
|
|
2983
|
-
const [negative, connective] = layer.ops;
|
|
2984
|
-
if (negative?.kind !== "negation" ||
|
|
2985
|
-
connective?.kind !== "connective" ||
|
|
2986
|
-
(connective.connective !== "question_content" && connective.connective !== "question_content_alternative")) {
|
|
2987
|
-
return null;
|
|
2988
|
-
}
|
|
2989
|
-
const stem = committedPredicateStemView(layer.stem);
|
|
2990
|
-
if (stem === null) {
|
|
2991
|
-
return null;
|
|
2992
|
-
}
|
|
2993
|
-
if (stem.category === "adjectival_predicate") {
|
|
2994
|
-
return {
|
|
2995
|
-
kind: "lemma",
|
|
2996
|
-
entry: plan.realization.entry ?? null,
|
|
2997
|
-
koreanLemma: "않다",
|
|
2998
|
-
koreanPos: 형용사,
|
|
2999
|
-
irregular: null,
|
|
3000
|
-
prefix: `${conjugate(stem.lemma, asIrregular(stem.irregular), "지")} `,
|
|
3001
|
-
auxTokens: [],
|
|
3002
|
-
connective: "ㄴ/은지",
|
|
3003
|
-
voice: "active",
|
|
3004
|
-
};
|
|
3005
|
-
}
|
|
3006
|
-
return {
|
|
3007
|
-
kind: "lemma",
|
|
3008
|
-
entry: plan.realization.entry ?? null,
|
|
3009
|
-
koreanLemma: stem.lemma,
|
|
3010
|
-
koreanPos: 동사,
|
|
3011
|
-
irregular: stem.irregular,
|
|
3012
|
-
auxTokens: negative.source.tokens,
|
|
3013
|
-
connective: "는지",
|
|
3014
|
-
voice: "active",
|
|
3015
|
-
};
|
|
3016
|
-
}
|
|
3017
|
-
function committedPredicateStemView(stem) {
|
|
3018
|
-
if (stem.kind === "verb") {
|
|
3019
|
-
return { category: "verbal_predicate", lemma: stem.lemma, irregular: stem.irregular };
|
|
3020
|
-
}
|
|
3021
|
-
if (stem.kind === "adj") {
|
|
3022
|
-
return { category: "adjectival_predicate", lemma: stem.lemma, irregular: stem.irregular };
|
|
3023
|
-
}
|
|
3024
|
-
if (stem.kind !== "candidateSet" ||
|
|
3025
|
-
stem.committedSense === undefined) {
|
|
3026
|
-
return null;
|
|
3027
|
-
}
|
|
3028
|
-
const category = committedCandidateSetPredicateCategory(stem);
|
|
3029
|
-
if (category === null) {
|
|
3030
|
-
return null;
|
|
3031
|
-
}
|
|
3032
|
-
const candidate = stem.candidates.find((item) => stemCandidateIdentitiesEqual(stemCandidateIdentity(item), stem.committedSense));
|
|
3033
|
-
return candidate === undefined
|
|
3034
|
-
? null
|
|
3035
|
-
: {
|
|
3036
|
-
category,
|
|
3037
|
-
lemma: candidate.lemma,
|
|
3038
|
-
irregular: candidate.irregular
|
|
3039
|
-
};
|
|
3040
|
-
}
|
|
3041
|
-
function committedCandidateSetPredicateCategory(stem) {
|
|
3042
|
-
const category = stem.committedSenseRealization?.category;
|
|
3043
|
-
if (category !== undefined) {
|
|
3044
|
-
return category === "verbal_predicate" || category === "adjectival_predicate"
|
|
3045
|
-
? category
|
|
3046
|
-
: null;
|
|
3047
|
-
}
|
|
3048
|
-
switch (stem.sourcePredicateShape) {
|
|
3049
|
-
case "verb":
|
|
3050
|
-
case "sahen_verbalization":
|
|
3051
|
-
return "verbal_predicate";
|
|
3052
|
-
case "i_adjective":
|
|
3053
|
-
case "na_adjective":
|
|
3054
|
-
return "adjectival_predicate";
|
|
3055
|
-
case "nominal":
|
|
3056
|
-
case "particle_phrase":
|
|
3057
|
-
case "lexical_adverb":
|
|
3058
|
-
case undefined:
|
|
3059
|
-
return null;
|
|
3060
|
-
}
|
|
3061
|
-
return null;
|
|
3062
|
-
}
|
|
3063
|
-
function sourcePredicateHeadTailUnitIndexForRelation(units, relation, sourceUnitIndexes) {
|
|
3064
|
-
const predicateIdx = relationSourcePredicateIdx(relation);
|
|
3065
|
-
if (predicateIdx === null) {
|
|
3066
|
-
return null;
|
|
3067
|
-
}
|
|
3068
|
-
return sourceUnitIndexes.find((unitIndex) => {
|
|
3069
|
-
const unit = units[unitIndex];
|
|
3070
|
-
return unit?.jpIndices.includes(predicateIdx) === true && unit.renderPlan?.kind === "headTailChain";
|
|
3071
|
-
}) ?? null;
|
|
3072
|
-
}
|
|
3073
|
-
function sourcePredicateUnitIndexForRelation(units, relation, sourceUnitIndexes) {
|
|
3074
|
-
const predicateIdx = relationSourcePredicateIdx(relation);
|
|
3075
|
-
if (predicateIdx === null) {
|
|
3076
|
-
return null;
|
|
3077
|
-
}
|
|
3078
|
-
return sourceUnitIndexes.find((unitIndex) => units[unitIndex]?.jpIndices.includes(predicateIdx) === true) ?? null;
|
|
3079
|
-
}
|
|
3080
|
-
function relationSourcePredicateIdx(relation) {
|
|
3081
|
-
return relation.source.kind === "predicate"
|
|
3082
|
-
? relation.source.predicateIdx
|
|
3083
|
-
: relation.source.kind === "clause"
|
|
3084
|
-
? relation.source.predicateIdx
|
|
3085
|
-
: null;
|
|
3086
|
-
}
|
|
3087
|
-
function sourcePredicateProjectionCandidateUnitIndexes(units, relation, sourceUnitIndexes, markerUnitIndexes) {
|
|
3088
|
-
if (relation.kind === "concession" && relationSourcePredicateIdx(relation) === null) {
|
|
3089
|
-
return sourceUnitIndexes.filter((unitIndex) => markerUnitIndexes.includes(unitIndex)).reverse();
|
|
3090
|
-
}
|
|
3091
|
-
const anchoredUnitIndex = sourcePredicateHeadTailUnitIndexForRelation(units, relation, sourceUnitIndexes);
|
|
3092
|
-
return anchoredUnitIndex === null
|
|
3093
|
-
? [...sourceUnitIndexes].reverse()
|
|
3094
|
-
: [anchoredUnitIndex];
|
|
3095
|
-
}
|
|
3096
|
-
function sourcePredicateConnectiveProjection(relation) {
|
|
3097
|
-
switch (relation.kind) {
|
|
3098
|
-
case "simultaneous_progression":
|
|
3099
|
-
case "te_attendant_simultaneous":
|
|
3100
|
-
return { connective: "simultaneous", surface: "ながら" };
|
|
3101
|
-
case "listing_example":
|
|
3102
|
-
return { connective: "exemplification", surface: "たり" };
|
|
3103
|
-
case "tari_listing_coordination":
|
|
3104
|
-
return { connective: "alternative", surface: "たり" };
|
|
3105
|
-
case "purpose_clause_coordination":
|
|
3106
|
-
return { connective: "tame_purpose", surface: purposeClauseCoordinationSurface(relation) };
|
|
3107
|
-
case "immediate_sequence":
|
|
3108
|
-
return { connective: "sequence_immediate", surface: relation.markerSpans[0]?.surface ?? "なり" };
|
|
3109
|
-
case "stative_hold_sequence":
|
|
3110
|
-
return { connective: "stative_hold", surface: "なり" };
|
|
3111
|
-
case "concession":
|
|
3112
|
-
return { connective: "concession", surface: concessionProjectionSurface(relation) };
|
|
3113
|
-
default:
|
|
3114
|
-
return null;
|
|
3115
|
-
}
|
|
3116
|
-
}
|
|
3117
|
-
function purposeClauseCoordinationSurface(relation) {
|
|
3118
|
-
return relation.purposeClauseCoordination?.purposeMarkerSpan.surface ?? "ため";
|
|
3119
|
-
}
|
|
3120
|
-
function concessionProjectionSurface(relation) {
|
|
3121
|
-
const surface = relation.markerSpans[0]?.surface ?? "にもかかわらず";
|
|
3122
|
-
return surface.endsWith("にもかかわらず") ? "にもかかわらず" : surface;
|
|
3123
|
-
}
|
|
3124
402
|
function projectRelationForSharedUnitIr(options) {
|
|
3125
403
|
const projected = options.projectRelation({
|
|
3126
404
|
relation: options.relation,
|
|
@@ -3202,14 +480,6 @@ function applyRenderOperations(tokens, units, operations) {
|
|
|
3202
480
|
}
|
|
3203
481
|
return output;
|
|
3204
482
|
}
|
|
3205
|
-
function projectionEdgeAttachment(units, projectedUnitIndexes) {
|
|
3206
|
-
const first = units[projectedUnitIndexes[0] ?? -1];
|
|
3207
|
-
const last = units[projectedUnitIndexes[projectedUnitIndexes.length - 1] ?? -1];
|
|
3208
|
-
return {
|
|
3209
|
-
...(first?.attachLeft === true ? { attachLeft: true } : {}),
|
|
3210
|
-
...(last?.attachRight === true ? { attachRight: true } : {}),
|
|
3211
|
-
};
|
|
3212
|
-
}
|
|
3213
483
|
function makeRelationProjectionUnit(tokens, operation) {
|
|
3214
484
|
const tokenIndexes = operation.projectionTokenIndexes;
|
|
3215
485
|
const firstTokenIndex = operation.projectionHeadTokenIndex ??
|
|
@@ -3238,309 +508,6 @@ function makeRelationProjectionUnit(tokens, operation) {
|
|
|
3238
508
|
provenanceReason: `relation:${operation.relation.kind}`,
|
|
3239
509
|
});
|
|
3240
510
|
}
|
|
3241
|
-
function sourceSpanForStructuralTokenSpan(tokens, span) {
|
|
3242
|
-
const indexes = [];
|
|
3243
|
-
for (let index = Math.max(0, span.start); index < Math.min(tokens.length, span.endExclusive); index += 1) {
|
|
3244
|
-
indexes.push(index);
|
|
3245
|
-
}
|
|
3246
|
-
return sourceSpanForTokenIndexes(tokens, indexes);
|
|
3247
|
-
}
|
|
3248
|
-
function unitIndexesInSpan(units, span) {
|
|
3249
|
-
const indexes = [];
|
|
3250
|
-
for (const [unitIndex, unit] of units.entries()) {
|
|
3251
|
-
if (unit.jpIndices.some((jpIndex) => span.start <= jpIndex && jpIndex < span.endExclusive)) {
|
|
3252
|
-
indexes.push(unitIndex);
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
return indexes;
|
|
3256
|
-
}
|
|
3257
|
-
function unitFullyCoveredBySpans(unit, spans) {
|
|
3258
|
-
return unit.jpIndices.length > 0 && unit.jpIndices.every((jpIndex) => (spans.some((span) => span.start <= jpIndex && jpIndex < span.endExclusive)));
|
|
3259
|
-
}
|
|
3260
511
|
function relationSourceStart(_graph, relation) {
|
|
3261
512
|
return relation.source.span.start;
|
|
3262
513
|
}
|
|
3263
|
-
function uniqueSorted(values) {
|
|
3264
|
-
return [...new Set(values)].sort((left, right) => left - right);
|
|
3265
|
-
}
|
|
3266
|
-
function projectUnitHeadTailConnectivePlan(unit, connective, sourceOverride = null, suppressNodaOwnedByRelation = false, quoteOwnerSource = null) {
|
|
3267
|
-
const plan = unit.renderPlan;
|
|
3268
|
-
if (!isPredicateHeadTailChainRenderPlan(plan)) {
|
|
3269
|
-
return null;
|
|
3270
|
-
}
|
|
3271
|
-
return projectHeadTailConnectivePlan(plan, connective, sourceOverride, suppressNodaOwnedByRelation, quoteOwnerSource);
|
|
3272
|
-
}
|
|
3273
|
-
function projectHeadTailConnectivePlan(plan, connective, sourceOverride = null, suppressNodaOwnedByRelation = false, quoteOwnerSource = null, connectiveProjection = "replace_last") {
|
|
3274
|
-
if (plan.realization.root.tail.kind !== "auxLayer")
|
|
3275
|
-
return null;
|
|
3276
|
-
const layer = plan.realization.root.tail;
|
|
3277
|
-
const source = sourceOverride ?? [...layer.ops].reverse().find((op) => op.kind === "connective")?.source ?? layer.stem.source;
|
|
3278
|
-
const suppressQuestionSfp = shouldProjectQuestionSfp(plan.realization.root, connective, source);
|
|
3279
|
-
const suppressNominalizedQuestionSfp = suppressQuestionSfp && isNominalizedQuestionSurface(connective.surface);
|
|
3280
|
-
const baseOps = layer.ops.filter((op) => {
|
|
3281
|
-
if (quoteOwnerSource !== null &&
|
|
3282
|
-
op.kind === "predicateQuoteCarrier" &&
|
|
3283
|
-
opSourceCoveredBy(op.source, quoteOwnerSource)) {
|
|
3284
|
-
return false;
|
|
3285
|
-
}
|
|
3286
|
-
return !(suppressNominalizedQuestionSfp || suppressNodaOwnedByRelation) || !(op.kind === "modal" &&
|
|
3287
|
-
op.modal === "noda" &&
|
|
3288
|
-
(suppressNodaOwnedByRelation || opSourceCoveredBy(op.source, source)));
|
|
3289
|
-
});
|
|
3290
|
-
const replacement = buildStructuralProjectionConnectiveOp(source, connective);
|
|
3291
|
-
const projectedOps = connectiveProjection === "append"
|
|
3292
|
-
? [...baseOps, replacement]
|
|
3293
|
-
: replaceLastConnectiveOp(baseOps, replacement);
|
|
3294
|
-
const projectedLayer = {
|
|
3295
|
-
...layer,
|
|
3296
|
-
ops: projectedOps,
|
|
3297
|
-
terminal: null,
|
|
3298
|
-
};
|
|
3299
|
-
const projectedRoot = {
|
|
3300
|
-
...plan.realization.root,
|
|
3301
|
-
tail: projectedLayer,
|
|
3302
|
-
...(suppressQuestionSfp ? { sfp: null } : {}),
|
|
3303
|
-
};
|
|
3304
|
-
const projectedBoundary = connectiveBoundaryForProjection(plan, connective, source);
|
|
3305
|
-
const { headTailCandidate: _headTailCandidate, headTailSourceCandidate: _headTailSourceCandidate, ...planWithoutOriginalSourceCandidate } = plan;
|
|
3306
|
-
const { partial: _partial, ...realizationWithoutPartial } = plan.realization;
|
|
3307
|
-
const projectedPlan = {
|
|
3308
|
-
...planWithoutOriginalSourceCandidate,
|
|
3309
|
-
clauseRole: { ...plan.clauseRole, outgoingBoundary: projectedBoundary },
|
|
3310
|
-
realization: {
|
|
3311
|
-
...realizationWithoutPartial,
|
|
3312
|
-
root: projectedRoot,
|
|
3313
|
-
warnings: resolvedStructuralProjectionWarnings(plan.realization.warnings),
|
|
3314
|
-
},
|
|
3315
|
-
};
|
|
3316
|
-
return projectedPlan;
|
|
3317
|
-
}
|
|
3318
|
-
function resolvedStructuralProjectionWarnings(warnings) {
|
|
3319
|
-
return warnings.filter((warning) => warning.type !== "partial_tail_suffix_unresolved" &&
|
|
3320
|
-
warning.type !== "tail_boundary_attachment_weak");
|
|
3321
|
-
}
|
|
3322
|
-
function projectUnitPredicateConnectivePlan(unit, connective, sourceOverride = null) {
|
|
3323
|
-
return projectUnitHeadTailConnectivePlan(unit, connective, sourceOverride) ??
|
|
3324
|
-
projectUnitLemmaConnectivePlan(unit, connective);
|
|
3325
|
-
}
|
|
3326
|
-
export function buildStructuralProjectionConnectiveOp(source, projection) {
|
|
3327
|
-
return createConnectiveOp({
|
|
3328
|
-
connective: projection.connective,
|
|
3329
|
-
surface: projection.surface,
|
|
3330
|
-
source,
|
|
3331
|
-
...(projection.quotativeMood === undefined ? {} : { quotativeMood: projection.quotativeMood })
|
|
3332
|
-
});
|
|
3333
|
-
}
|
|
3334
|
-
function projectUnitLemmaConnectivePlan(unit, connective) {
|
|
3335
|
-
const plan = unit.renderPlan;
|
|
3336
|
-
if (plan?.kind !== "lemma") {
|
|
3337
|
-
return null;
|
|
3338
|
-
}
|
|
3339
|
-
if (connective.connective === "stative_hold") {
|
|
3340
|
-
return projectUnitLemmaStativeHoldPlan(plan);
|
|
3341
|
-
}
|
|
3342
|
-
if (connective.connective !== "sequence_immediate") {
|
|
3343
|
-
return null;
|
|
3344
|
-
}
|
|
3345
|
-
if (plan.koreanPos !== 동사 && plan.koreanPos !== 형용사) {
|
|
3346
|
-
return null;
|
|
3347
|
-
}
|
|
3348
|
-
if (plan.sfp !== undefined && plan.sfp !== null) {
|
|
3349
|
-
return null;
|
|
3350
|
-
}
|
|
3351
|
-
if (plan.suffix !== undefined) {
|
|
3352
|
-
return null;
|
|
3353
|
-
}
|
|
3354
|
-
return {
|
|
3355
|
-
...plan,
|
|
3356
|
-
connective: "자",
|
|
3357
|
-
suffix: "마자",
|
|
3358
|
-
sfp: null,
|
|
3359
|
-
};
|
|
3360
|
-
}
|
|
3361
|
-
function projectUnitLemmaStativeHoldPlan(plan) {
|
|
3362
|
-
if (plan.koreanPos !== 동사) {
|
|
3363
|
-
return null;
|
|
3364
|
-
}
|
|
3365
|
-
if (plan.sfp !== undefined && plan.sfp !== null) {
|
|
3366
|
-
return null;
|
|
3367
|
-
}
|
|
3368
|
-
if (plan.suffix !== undefined || (plan.negationChainDepth ?? 0) !== 0) {
|
|
3369
|
-
return null;
|
|
3370
|
-
}
|
|
3371
|
-
if (plan.auxTokens.length === 0 || !plan.auxTokens.every((token) => (token.pos & POS4) === 助動詞_タ)) {
|
|
3372
|
-
return null;
|
|
3373
|
-
}
|
|
3374
|
-
return {
|
|
3375
|
-
...plan,
|
|
3376
|
-
auxTokens: [],
|
|
3377
|
-
connective: "ㄴ/은",
|
|
3378
|
-
suffix: " 채",
|
|
3379
|
-
sfp: null,
|
|
3380
|
-
};
|
|
3381
|
-
}
|
|
3382
|
-
function shouldProjectQuestionSfp(root, connective, source) {
|
|
3383
|
-
if (connective.connective !== "question_content" || root.sfp === null) {
|
|
3384
|
-
return false;
|
|
3385
|
-
}
|
|
3386
|
-
if (root.sfp.effect === "ka") {
|
|
3387
|
-
return opSourceCoveredBy(root.sfp.source, source);
|
|
3388
|
-
}
|
|
3389
|
-
if (root.sfp.effect === "kana") {
|
|
3390
|
-
return opSourceOverlaps(root.sfp.source, source);
|
|
3391
|
-
}
|
|
3392
|
-
return false;
|
|
3393
|
-
}
|
|
3394
|
-
function opSourceOverlaps(candidate, other) {
|
|
3395
|
-
const otherIndices = new Set(other.tokenIndices);
|
|
3396
|
-
return candidate.tokenIndices.some((tokenIndex) => otherIndices.has(tokenIndex));
|
|
3397
|
-
}
|
|
3398
|
-
function isNominalizedQuestionSurface(surface) {
|
|
3399
|
-
return surface.includes("の") || surface.includes("ん");
|
|
3400
|
-
}
|
|
3401
|
-
function opSourceCoveredBy(candidate, covering) {
|
|
3402
|
-
const coveringIndices = new Set(covering.tokenIndices);
|
|
3403
|
-
return candidate.tokenIndices.length > 0 && candidate.tokenIndices.every((tokenIndex) => coveringIndices.has(tokenIndex));
|
|
3404
|
-
}
|
|
3405
|
-
function connectiveBoundaryForProjection(plan, connective, source) {
|
|
3406
|
-
const sortedIndices = [...source.tokenIndices].sort((left, right) => left - right);
|
|
3407
|
-
const start = sortedIndices[0] ?? plan.clauseRole.tokenSpan.end;
|
|
3408
|
-
const end = sortedIndices[sortedIndices.length - 1] ?? start;
|
|
3409
|
-
return {
|
|
3410
|
-
kind: "接続助詞",
|
|
3411
|
-
connectiveKind: connective.connective,
|
|
3412
|
-
surface: connective.surface,
|
|
3413
|
-
tokenIdx: end,
|
|
3414
|
-
tokenSpan: { start, end },
|
|
3415
|
-
};
|
|
3416
|
-
}
|
|
3417
|
-
function projectUnitAttributivePlan(unit, headNounToken, options) {
|
|
3418
|
-
const plan = unit.renderPlan;
|
|
3419
|
-
if (plan === null) {
|
|
3420
|
-
return null;
|
|
3421
|
-
}
|
|
3422
|
-
if (plan.kind === "attributive") {
|
|
3423
|
-
return plan;
|
|
3424
|
-
}
|
|
3425
|
-
if (plan.kind === "lemma") {
|
|
3426
|
-
return projectLemmaAttributivePlan(plan, unit, headNounToken, options);
|
|
3427
|
-
}
|
|
3428
|
-
if (isPredicateHeadTailChainRenderPlan(plan)) {
|
|
3429
|
-
return projectPredicateHeadTailAttributivePlan(plan);
|
|
3430
|
-
}
|
|
3431
|
-
return null;
|
|
3432
|
-
}
|
|
3433
|
-
function projectLemmaAttributivePlan(plan, unit, headNounToken, options) {
|
|
3434
|
-
if (plan.prefix !== undefined && typeof plan.prefix !== "string") {
|
|
3435
|
-
return null;
|
|
3436
|
-
}
|
|
3437
|
-
const plainVerbEnding = plainVerbAttributiveEndingForProjection(plan, unit, headNounToken, options);
|
|
3438
|
-
return {
|
|
3439
|
-
kind: "attributive",
|
|
3440
|
-
koreanLemma: plan.koreanLemma,
|
|
3441
|
-
irregular: plan.irregular,
|
|
3442
|
-
koreanPos: plan.koreanPos,
|
|
3443
|
-
auxTokens: plan.auxTokens,
|
|
3444
|
-
contentToken: unit.jpHead,
|
|
3445
|
-
...(plan.prefix === undefined ? {} : { prefix: plan.prefix }),
|
|
3446
|
-
...(plan.sahenNoun === undefined ? {} : { sahenNoun: plan.sahenNoun }),
|
|
3447
|
-
...(headNounToken === null ? {} : { headNounToken }),
|
|
3448
|
-
...(plainVerbEnding === null ? {} : { plainVerbEnding }),
|
|
3449
|
-
...(plan.voice === undefined ? {} : { voice: plan.voice }),
|
|
3450
|
-
...(plan.passiveClass === undefined ? {} : { passiveClass: plan.passiveClass }),
|
|
3451
|
-
...(isRenyouLemmaProjectionHost(unit.jpHead) ? { tailLemmaMode: true } : {}),
|
|
3452
|
-
...(plan.teIruContractToPast === undefined ? {} : { teIruContractToPast: plan.teIruContractToPast }),
|
|
3453
|
-
};
|
|
3454
|
-
}
|
|
3455
|
-
function isRenyouLemmaProjectionHost(token) {
|
|
3456
|
-
return (token.pos & (POS0 | POS5A)) === (動詞 | 連用形_);
|
|
3457
|
-
}
|
|
3458
|
-
function plainVerbAttributiveEndingForProjection(plan, unit, headNounToken, options) {
|
|
3459
|
-
if (plan.koreanPos !== 동사 || plan.auxTokens.length !== 0) {
|
|
3460
|
-
return null;
|
|
3461
|
-
}
|
|
3462
|
-
const contentIdx = unit.jpIndices[0] ?? null;
|
|
3463
|
-
if (contentIdx === null) {
|
|
3464
|
-
return null;
|
|
3465
|
-
}
|
|
3466
|
-
return selectPlainVerbAttributiveEnding(plan.koreanLemma, unit.jpHead, headNounToken, {
|
|
3467
|
-
tokens: options.tokens,
|
|
3468
|
-
contentIdx,
|
|
3469
|
-
lookups: options.lookups,
|
|
3470
|
-
});
|
|
3471
|
-
}
|
|
3472
|
-
export function projectPredicateHeadTailAttributivePlan(plan) {
|
|
3473
|
-
if (plan.realization.root.tail.kind !== "auxLayer") {
|
|
3474
|
-
return null;
|
|
3475
|
-
}
|
|
3476
|
-
if (plan.realization.root.tail.ops.some((op) => op.kind === "connective")) {
|
|
3477
|
-
return null;
|
|
3478
|
-
}
|
|
3479
|
-
if (plan.realization.root.tail.terminal === "attributive") {
|
|
3480
|
-
return plan;
|
|
3481
|
-
}
|
|
3482
|
-
const sfp = plan.realization.root.sfp;
|
|
3483
|
-
const projectedRoot = {
|
|
3484
|
-
...plan.realization.root,
|
|
3485
|
-
...(sfp !== null && sfp.source.tokenIndices.length === 0 ? { sfp: null } : {}),
|
|
3486
|
-
tail: {
|
|
3487
|
-
...plan.realization.root.tail,
|
|
3488
|
-
terminal: "attributive",
|
|
3489
|
-
},
|
|
3490
|
-
};
|
|
3491
|
-
const { headTailCandidate: _headTailCandidate, headTailSourceCandidate: _headTailSourceCandidate, ...planWithoutOriginalSourceCandidate } = plan;
|
|
3492
|
-
return {
|
|
3493
|
-
...planWithoutOriginalSourceCandidate,
|
|
3494
|
-
realization: { ...plan.realization, root: projectedRoot },
|
|
3495
|
-
};
|
|
3496
|
-
}
|
|
3497
|
-
function targetHeadToken(tokens, relation) {
|
|
3498
|
-
if (relation.target?.kind !== "noun_phrase") {
|
|
3499
|
-
return null;
|
|
3500
|
-
}
|
|
3501
|
-
const headIdx = relation.target.headIdx;
|
|
3502
|
-
if (headIdx === null) {
|
|
3503
|
-
return null;
|
|
3504
|
-
}
|
|
3505
|
-
return tokens[headIdx] ?? null;
|
|
3506
|
-
}
|
|
3507
|
-
function opSourceForMarkerSpans(tokens, markerSpans) {
|
|
3508
|
-
const tokenIndices = uniqueSorted(markerSpans.flatMap((span) => {
|
|
3509
|
-
const indexes = [];
|
|
3510
|
-
for (let idx = span.start; idx < span.endExclusive; idx += 1) {
|
|
3511
|
-
indexes.push(idx);
|
|
3512
|
-
}
|
|
3513
|
-
return indexes;
|
|
3514
|
-
}));
|
|
3515
|
-
if (tokenIndices.length === 0) {
|
|
3516
|
-
return null;
|
|
3517
|
-
}
|
|
3518
|
-
const sourceTokens = tokenIndices.map((index) => tokens[index]);
|
|
3519
|
-
if (sourceTokens.some((token) => token === undefined)) {
|
|
3520
|
-
return null;
|
|
3521
|
-
}
|
|
3522
|
-
return {
|
|
3523
|
-
tokens: sourceTokens,
|
|
3524
|
-
tokenIndices,
|
|
3525
|
-
};
|
|
3526
|
-
}
|
|
3527
|
-
function replaceLastConnectiveOp(ops, replacement) {
|
|
3528
|
-
const projected = [...ops];
|
|
3529
|
-
for (let index = projected.length - 1; index >= 0; index -= 1) {
|
|
3530
|
-
if (projected[index]?.kind === "connective") {
|
|
3531
|
-
projected[index] = replacement;
|
|
3532
|
-
return projected;
|
|
3533
|
-
}
|
|
3534
|
-
}
|
|
3535
|
-
return [...projected, replacement];
|
|
3536
|
-
}
|
|
3537
|
-
function projectUnitPurposeAttributivePlan(unit) {
|
|
3538
|
-
const plan = unit.renderPlan;
|
|
3539
|
-
if (!isNominalHeadTailChainRenderPlan(plan)) {
|
|
3540
|
-
return null;
|
|
3541
|
-
}
|
|
3542
|
-
return {
|
|
3543
|
-
...plan,
|
|
3544
|
-
realization: { ...plan.realization, projection: { kind: "purpose_attributive" } }
|
|
3545
|
-
};
|
|
3546
|
-
}
|