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
|
@@ -0,0 +1,2013 @@
|
|
|
1
|
+
import { TokenCursor } from "../../../../token-cursor.js";
|
|
2
|
+
import { morphSurface } from "../../../../../types/token.js";
|
|
3
|
+
import { derivationForSense } from "../../../../../dictionary/derivation.js";
|
|
4
|
+
import { stemCandidateProvenanceForTranslation } from "../stem-candidate-identity.js";
|
|
5
|
+
import { buildPredicateQuoteCarrierOp } from "../matchers/predicate-quote.js";
|
|
6
|
+
import { parseTail } from "../parse-tail.js";
|
|
7
|
+
import { lineMemo } from "../../../line-memo.js";
|
|
8
|
+
import { isNaiOrNuToken, isAdverbialMannerNounHead } from "../classifiers/tokens.js";
|
|
9
|
+
import { isBekiRentaiNominalizedFrameEnd } from "../matchers/nominalizer.js";
|
|
10
|
+
import { isObligationSpanStartingAtToken } from "../matchers/obligation.js";
|
|
11
|
+
import { expandFusedDashiCopulaListingParseSlice } from "./parse-slice.js";
|
|
12
|
+
import { parseOutgoingBoundaryHint, refineRequestTerminalOutgoingBoundary } from "./boundary-hint.js";
|
|
13
|
+
import { detectSahenPredicateStart, nounCompoundSuffixRunEnd } from "./readiness.js";
|
|
14
|
+
import { tailRootHasRenyouChuushiTerminal, tailRootHasAdverbialModifierTerminal } from "../fragment-recovery.js";
|
|
15
|
+
import { tosuruResultativeMakeYieldsToAttributiveQuoteHead } from "../tosuru-construction-mode.js";
|
|
16
|
+
import { findAdverbialModifierPredicate } from "../../../../clause-layout/adverbial-predicate.js";
|
|
17
|
+
import { isClausePunctuationToken, utteranceClosedForAttributiveProjection } from "../../../../clause-layout/index.js";
|
|
18
|
+
import { nextClauseNonPunctuationIndex } from "../../../../clause-layout/navigation.js";
|
|
19
|
+
import { nextNonSpaceIndex, previousNonSpaceIndex } from "../../../../clause-layout/trivia.js";
|
|
20
|
+
import { bareAdverbialKeijoujiHostAt, isAdverbialKeijoujiMarkerHostPos } from "../../../../clause-layout/adverbial-host.js";
|
|
21
|
+
import { activeProtoLayout, activeProtoUtteranceClosureRunAt } from "../../../../clause-layout/proto-state.js";
|
|
22
|
+
import { cachedQuoteBindingForContentRoot, quoteStructuralRelationContainingContentToken, quoteStructuralRelationAt } from "../../../../structural-relation/quote.js";
|
|
23
|
+
import { relationConnectiveSpansAt, relationDiscontinuousClosureSpanAfter } from "../../connective-span-scanner.js";
|
|
24
|
+
import { PLAIN_TE_PERMISSION_ATTRIBUTIVE_HEADS } from "../../../data/semantic-helper-sets.js";
|
|
25
|
+
import { commitTail, ownClauseTailIR } from "../commit.js";
|
|
26
|
+
import { copulaContinuativeExplanatoryClosureApplies, copulaContinuativeObliqueRecoveryApplies } from "../renderers/continuative-copula.js";
|
|
27
|
+
import { renderTail } from "../render-root.js";
|
|
28
|
+
import { matchTeTailContinuationAt } from "../../postverb-tail-classifier.js";
|
|
29
|
+
import { quoteAttributiveHeadFrameForBoundary } from "../quote-attributive-head-frame.js";
|
|
30
|
+
import { DERIVATIONAL_SUFFIX_FAIL_CLOSED_PREFIX, lowerDerivationalSuffixRoot, rootHasReanchoringDerivationalSuffix } from "../derivational-suffix-lowering.js";
|
|
31
|
+
import { retrospectiveQuotativeFlavorForStemMood } from "../grammar.js";
|
|
32
|
+
import { hasHardTerminalPunctuationClass } from "../../../boundary/punctuation.js";
|
|
33
|
+
import { isKaFamilyQuestionSfpEffect, nounStemInterjectionForCandidate, sourcePredicateShapeForCapabilities, mapConjType } from "../grammar.js";
|
|
34
|
+
import { convertPunctuation } from "../../../../rendering/punctuation.js";
|
|
35
|
+
import { loadSuppletiveNegDict, roleCatNyaCount } from "../../../../../generator/aux-map.js";
|
|
36
|
+
import { hydrateAspectSemanticOps } from "../aspect-semantics.js";
|
|
37
|
+
import { hydrateBenefactivePayloads } from "../benefactive-hydration.js";
|
|
38
|
+
import { auxLayerConsumedSourceSequence, auxOpsInTailNode, chainFinalOpHostCategory, firstAuxLayer, stemSupportsProjectionCategory } from "../inspect.js";
|
|
39
|
+
import { conditionalTailConnectiveRelationForToken, dewaScopeBridgeRelationAt } from "../../../boundary/marker.js";
|
|
40
|
+
import { cachedCanonicalReformulationMarkerRelationIndex, kaOwnershipKindAt } from "../../../boundary/ka-ownership.js";
|
|
41
|
+
import { matchNodaNoKaNegativeConfirmTerminalTail } from "../../../../semantics/terminal-negative-confirm.js";
|
|
42
|
+
import { POS0, POS4, POS5A, 意志推量形_, 仮定形_, 形状詞, 形容詞0, 語幹_, 終止形_, 助動詞 as 助動詞0, 助動詞_マス, 助動詞_レル, 代名詞, 動詞, 副詞, 未然形_, 名詞, 命令形_, 連体形_, 連用形_, 부사 } from "../../../../../types/pos.js";
|
|
43
|
+
import { createConnectiveOp, createCopulaOp, markConditionalQuoteMarkerContinuationOp } from "../op-builders.js";
|
|
44
|
+
import { IU_LEXEME_FORMS } from "../../../data/quoted-reporting-sets.js";
|
|
45
|
+
import { structuralAttributiveAssemblerSuffixPayload, derivationalPredicateHeadEnd, isSoudaYotaiAdverbialModifierBoundaryEnd, shouldSuppressFormalToSuruControlForAttributiveHead, renyouCompoundPrenominalAttributiveTerminalAllowed, classifyStructuralAttributiveBoundaryPayload } from "./attributive-boundary.js";
|
|
46
|
+
import { normalizeTokaListingBoundary } from "./end-boundary-inference.js";
|
|
47
|
+
import { isZeroNiPurposeProjectionBoundaryEnd, noQuoteReportingProjectionAllowedAt, classifyAttributiveChunkBoundary, youNiCarrierRenyouChuushiSpaceTerminalAllowed, renyouChuushiClosesDetachedUtteranceAt, renyouChuushiTerminalAllowedForEnd, hasRenyouChuushiContinuationForEnd, renyouChuushiTerminalRoleAt, teOkuEvaluationReasonBoundaryAt, elidedDewaNegativeBodyAllowedAt, isPlainNominalizerParticleFrameEnd, isPlainNominalizerZeroFollowerFrameEnd, isZeroNominalizedParallelMoFrameEnd, chunkEndsWithAdnominalCopulaAttributiveHead } from "./clause-boundaries.js";
|
|
48
|
+
import { adjectiveAdverbialModifierPredicateReachable, stemTokenEndsWithNoKoto, sourceHasFormalToStateResultCarrier, sourceAdverbialSurfacePostverbKind, isKotodashiReasonScopeTail, isNegationLikeToken } from "./predicate-evidence.js";
|
|
49
|
+
import { renyouPredicateHeadLacksPredicateSense, adverbHostStartsTailChunk, isNounKamoModalPredicateStart, isNominalDirectConnectivePredicateStart, mentionedHostCarriesCanonicalReformulationMarker } from "./head-admission.js";
|
|
50
|
+
import { projectKotodakaraReasonScopeStemTranslation, normalizeTailParserStemKorean, rangeHasMonoNoConcessiveConnective, selectTailParserStemSenses, tailParserProjectionOrdinalAllocator, headHypothesisCandidateFromTranslation, candidateHasAdmittedHeadCapability, buildHeadHypothesisCarrier, headSourceCapabilityVector, tailParserStemEntry, tokenHostsInflectingPredicateAuxiliary, tokenOpensPredicateConnectiveHost, stemKindForTailParserSource, adverbialSurfaceCandidateSetCanBridge, confineNominalTargetMarkToAdjectivalSource, stemCandidateFromTranslation, sahenStemProjectionCandidates, sahenPredicateHasFollowingAgentiveAux, stemInputFromCandidate, tailParserStemKindForTranslation, stemTranslationNeedsCommitSelection, stemCandidateNeedsDeferredCommit, suppletiveBaseStemForMaterialization, detectSplitSuppletiveNegativeStem, detectContractedNegativeNStem, detectGaruSyntheticStem, detectNounPhraseHeadStem, detectRentaishiPronominalNoHeadStem, detectDemonstrativePropositionHostStem, propositionHostChainBindsWake, detectVirtualCompoundDictionaryStem, detectNominalRenyouPostverbAuxiliaryStem, detectNominalRenyouMethodYouIdiomStem, detectSahenPotentialDifficultyStem, detectDictionaryBackedLexicalSplitStem, detectContractedGodanCausativePassiveStem } from "./stem-candidates.js";
|
|
51
|
+
export async function segmentAndParseClauses(input, boundaries) {
|
|
52
|
+
const clauseSlices = [];
|
|
53
|
+
let prev = 0;
|
|
54
|
+
for (const detected of boundaries) {
|
|
55
|
+
clauseSlices.push({
|
|
56
|
+
sliceStart: prev,
|
|
57
|
+
sliceEnd: detected.splitAt,
|
|
58
|
+
outgoingBoundary: detected.boundary
|
|
59
|
+
});
|
|
60
|
+
prev = detected.splitAt;
|
|
61
|
+
}
|
|
62
|
+
clauseSlices.push({
|
|
63
|
+
sliceStart: prev,
|
|
64
|
+
sliceEnd: input.tokens.length,
|
|
65
|
+
outgoingBoundary: { kind: "terminal" }
|
|
66
|
+
});
|
|
67
|
+
const parseInfos = [];
|
|
68
|
+
const ownedOutgoingBoundaries = [];
|
|
69
|
+
const sliceStarts = [];
|
|
70
|
+
const contentRanges = [];
|
|
71
|
+
for (let i = 0; i < clauseSlices.length; i++) {
|
|
72
|
+
const cs = clauseSlices[i];
|
|
73
|
+
const clauseTokens = input.tokens.slice(cs.sliceStart, cs.sliceEnd);
|
|
74
|
+
const clauseInput = {
|
|
75
|
+
tokens: clauseTokens,
|
|
76
|
+
cursor: input.cursor.retarget(clauseTokens, 0, clauseTokens.length, cs.sliceStart),
|
|
77
|
+
dictionary: input.dictionary,
|
|
78
|
+
formal: input.formal,
|
|
79
|
+
lookups: input.lookups,
|
|
80
|
+
numeric: input.numeric,
|
|
81
|
+
...(input.numericHostReservation === undefined
|
|
82
|
+
? {}
|
|
83
|
+
: { numericHostReservation: input.numericHostReservation })
|
|
84
|
+
};
|
|
85
|
+
const subRange = findContentRange(clauseTokens);
|
|
86
|
+
if (subRange === null) {
|
|
87
|
+
return { ok: false, reason: `clause ${i} has no content tokens` };
|
|
88
|
+
}
|
|
89
|
+
const renyouTerminalRole = renyouChuushiTerminalRoleAt(input.tokens, cs.sliceStart + subRange.start, cs.sliceStart + subRange.end);
|
|
90
|
+
const parseResult = await parseSingleClause(clauseInput, subRange, cs.sliceStart, {
|
|
91
|
+
allowElidedColloquialObligation: elidedColloquialObligationContextAtBoundary(cs.outgoingBoundary),
|
|
92
|
+
allowRenyouChuushiTerminal: await renyouChuushiTerminalAllowedForEnd(input, cs.sliceStart + subRange.end),
|
|
93
|
+
...(renyouTerminalRole === null ? {} : { renyouChuushiTerminalRole: renyouTerminalRole }),
|
|
94
|
+
allowMalformedConditionalFragmentTerminal: malformedConditionalFragmentTerminalAllowed(input.tokens, cs.sliceStart + subRange.start, cs.sliceStart + subRange.end, cs.outgoingBoundary),
|
|
95
|
+
outgoingBoundary: cs.outgoingBoundary,
|
|
96
|
+
contextTokens: input.tokens,
|
|
97
|
+
contextPos: cs.sliceStart + subRange.start,
|
|
98
|
+
allowZeroNiPurposeTerminal: isZeroNiPurposeProjectionBoundaryEnd(input.cursor, cs.sliceStart + subRange.end, input.lookups)
|
|
99
|
+
});
|
|
100
|
+
if (!parseResult.ok) {
|
|
101
|
+
return { ok: false, reason: `clause ${i}: ${parseResult.reason}` };
|
|
102
|
+
}
|
|
103
|
+
const parsedLayer = firstAuxLayer(parseResult.info.root.tail);
|
|
104
|
+
const firstParsedOp = parsedLayer?.ops[0];
|
|
105
|
+
if (parsedLayer?.stem.kind === "noun" &&
|
|
106
|
+
firstParsedOp?.kind === "connective" &&
|
|
107
|
+
firstParsedOp.connective === "even_if") {
|
|
108
|
+
const markerIdx = firstParsedOp.source.tokenIndices[0];
|
|
109
|
+
const relation = markerIdx === undefined
|
|
110
|
+
? null
|
|
111
|
+
: dewaScopeBridgeRelationAt(input.tokens, markerIdx, {
|
|
112
|
+
anchorIdx: markerIdx,
|
|
113
|
+
consumers: ["tail_multi_clause"]
|
|
114
|
+
});
|
|
115
|
+
const negativeTail = relation === null
|
|
116
|
+
? undefined
|
|
117
|
+
: input.tokens[relation.span.endExclusive];
|
|
118
|
+
if (negativeTail !== undefined && isNaiOrNuToken(negativeTail)) {
|
|
119
|
+
return { ok: false, reason: `clause ${i}: bare demo concession cannot preempt a negative scope bridge tail` };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const semanticallyHydrated = hydrateClauseParseInfoBenefactive(parseResult.info, input.tokens, cs.sliceStart + parseResult.info.localPredicateIdx, input.lookups, input.numeric);
|
|
123
|
+
const hydrated = {
|
|
124
|
+
...semanticallyHydrated,
|
|
125
|
+
root: {
|
|
126
|
+
...semanticallyHydrated.root,
|
|
127
|
+
quoteBinding: cachedQuoteBindingForContentRoot(input.tokens, cs.sliceStart + parseResult.info.localPredicateIdx, cs.sliceStart + subRange.end),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
const ownedOutgoingBoundary = refineRequestTerminalOutgoingBoundary(hydrated.root, cs.outgoingBoundary);
|
|
131
|
+
const boundaryReady = quoteBoundaryReadinessBlocker(input.cursor, ownedOutgoingBoundary, hydrated.root, input.lookups);
|
|
132
|
+
if (boundaryReady !== null) {
|
|
133
|
+
return { ok: false, reason: `clause ${i}: ${boundaryReady}` };
|
|
134
|
+
}
|
|
135
|
+
const rewritten = rewriteClauseParseInfoOutgoingBoundary(hydrated, ownedOutgoingBoundary, outgoingBoundaryRewriteOptions(input.tokens, ownedOutgoingBoundary));
|
|
136
|
+
parseInfos.push(normalizeClauseParseInfoTokaOwnership(projectClauseParseInfoQuotedSfp(hydrateClauseParseInfoTerminalRoleSfp(rewritten, input.tokens, cs.sliceStart + subRange.end), ownedOutgoingBoundary), input.tokens, input.lookups, normalizeTokaListingBoundary(input.cursor, ownedOutgoingBoundary, input.lookups)));
|
|
137
|
+
ownedOutgoingBoundaries.push(ownedOutgoingBoundary);
|
|
138
|
+
sliceStarts.push(cs.sliceStart);
|
|
139
|
+
contentRanges.push({ start: subRange.start, end: subRange.end });
|
|
140
|
+
}
|
|
141
|
+
const irs = parseInfos.map((info, i) => {
|
|
142
|
+
const cs = clauseSlices[i];
|
|
143
|
+
const cr = contentRanges[i];
|
|
144
|
+
const outgoingBoundary = normalizeTokaListingBoundary(input.cursor, ownedOutgoingBoundaries[i], input.lookups);
|
|
145
|
+
return {
|
|
146
|
+
root: info.root,
|
|
147
|
+
clauseIndex: i,
|
|
148
|
+
tokenSpan: { start: cs.sliceStart, end: cs.sliceEnd - 1 },
|
|
149
|
+
contentSpan: { start: cs.sliceStart + cr.start, end: cs.sliceStart + cr.end },
|
|
150
|
+
predicateTokenIdx: sliceStarts[i] + info.localPredicateIdx,
|
|
151
|
+
outgoingBoundary
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
return { ok: true, irs, parseInfos };
|
|
155
|
+
}
|
|
156
|
+
export function adverbialModifierChunkEnd(tokens, start, lookups) {
|
|
157
|
+
const head = tokens[start];
|
|
158
|
+
if (head === undefined) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
if (adjectiveAdverbialModifierPredicateReachable(tokens, start, lookups)) {
|
|
162
|
+
return { end: start, marker: "none" };
|
|
163
|
+
}
|
|
164
|
+
const derivationalHeadEnd = derivationalPredicateHeadEnd(tokens, start);
|
|
165
|
+
if (derivationalHeadEnd === null && !isAdverbialKeijoujiMarkerHostPos(head)) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
if (bareAdverbialKeijoujiHostAt(tokens, start, lookups.ADVERBIAL_MODIFIER_BARE_KEIJOUJI_HOSTS)) {
|
|
169
|
+
return adverbialModifierPredicateReachable(tokens, start, head, lookups)
|
|
170
|
+
? { end: start, marker: "none" }
|
|
171
|
+
: null;
|
|
172
|
+
}
|
|
173
|
+
const niIdx = nextNonSpaceIndex(tokens, derivationalHeadEnd ?? nounCompoundSuffixRunEnd(tokens, start + 1), tokens.length);
|
|
174
|
+
if (niIdx === null) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const ni = tokens[niIdx];
|
|
178
|
+
if (ni === undefined ||
|
|
179
|
+
(ni.pos & (POS0 | POS5A)) !== (助動詞0 | 連用形_) ||
|
|
180
|
+
ni.dictionaryForm !== "だ" ||
|
|
181
|
+
ni.surface !== "に") {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
if (!adverbialModifierPredicateReachable(tokens, niIdx, head, lookups)) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return { end: niIdx, marker: "copula_ni" };
|
|
188
|
+
}
|
|
189
|
+
function adverbialModifierPredicateReachable(tokens, fromIdx, head, lookups) {
|
|
190
|
+
return findAdverbialModifierPredicate(tokens, fromIdx, {
|
|
191
|
+
allowLightVerbPredicate: isAdverbialMannerNounHead(head, lookups.ADVERBIAL_MODIFIER_MANNER_NOUNS),
|
|
192
|
+
deicticProPredicates: lookups.ADVERB_COPULA_DEICTIC_EXCLUSIONS
|
|
193
|
+
}) !== null;
|
|
194
|
+
}
|
|
195
|
+
function adverbialModifierTerminalAllowedAt(tokens, start, lookups) {
|
|
196
|
+
return adverbialModifierChunkEnd(tokens, start, lookups)?.marker ?? null;
|
|
197
|
+
}
|
|
198
|
+
export function parseTailChunkOnly(input, start, end, outgoingBoundary, hostRole = "clause_predicate") {
|
|
199
|
+
const key = `parseTailChunkOnly|${start}|${end}|${JSON.stringify(outgoingBoundary)}|${hostRole}`;
|
|
200
|
+
return lineMemo(input, key, () => parseTailChunkOnlyImpl(input, start, end, outgoingBoundary, hostRole), activeProtoLayout());
|
|
201
|
+
}
|
|
202
|
+
async function parseTailChunkOnlyImpl(input, start, rawEnd, outgoingBoundary, hostRole) {
|
|
203
|
+
const end = previousNonSpaceIndex(input.tokens, rawEnd + 1, start) ?? rawEnd;
|
|
204
|
+
const ownedOutgoingBoundary = normalizeTokaListingBoundary(input.cursor, outgoingBoundary, input.lookups);
|
|
205
|
+
const chunkTokens = input.tokens.slice(start, end + 1);
|
|
206
|
+
const chunkInput = {
|
|
207
|
+
tokens: chunkTokens,
|
|
208
|
+
cursor: input.cursor.retarget(chunkTokens, 0, chunkTokens.length, start),
|
|
209
|
+
dictionary: input.dictionary,
|
|
210
|
+
formal: input.formal,
|
|
211
|
+
lookups: input.lookups,
|
|
212
|
+
numeric: input.numeric,
|
|
213
|
+
...(input.synthesizeEntry === undefined ? {} : { synthesizeEntry: input.synthesizeEntry }),
|
|
214
|
+
...(input.numericHostReservation === undefined
|
|
215
|
+
? {}
|
|
216
|
+
: { numericHostReservation: input.numericHostReservation })
|
|
217
|
+
};
|
|
218
|
+
const renyouTerminalRole = renyouChuushiTerminalRoleAt(input.tokens, start, end);
|
|
219
|
+
const allowAdverbialModifierTerminal = adverbialModifierTerminalAllowedAt(input.tokens, start, input.lookups) ??
|
|
220
|
+
(isSoudaYotaiAdverbialModifierBoundaryEnd(input.tokens, end, input.lookups) ? "copula_ni" : undefined);
|
|
221
|
+
const structuralAttributiveBoundaryPayload = (ownedOutgoingBoundary.kind !== "terminal" &&
|
|
222
|
+
ownedOutgoingBoundary.connectiveKind === "predicate_projection_quote_attributive"
|
|
223
|
+
? undefined
|
|
224
|
+
: classifyStructuralAttributiveBoundaryPayload(input.tokens, start, end, end + 1, input.lookups) ?? structuralAttributiveAssemblerSuffixPayload(input.tokens, start, end + 1, input.lookups)) ?? undefined;
|
|
225
|
+
const attributiveBoundaryPayload = ownedOutgoingBoundary.kind === "terminal"
|
|
226
|
+
? structuralAttributiveBoundaryPayload
|
|
227
|
+
: ownedOutgoingBoundary.connectiveKind === "predicate_projection_quote_attributive"
|
|
228
|
+
? ownedOutgoingBoundary.attributiveBoundary
|
|
229
|
+
: ownedOutgoingBoundary.attributiveBoundary ?? structuralAttributiveBoundaryPayload;
|
|
230
|
+
const parseResult = await parseSingleClause(chunkInput, { start: 0, end: end - start }, start, {
|
|
231
|
+
allowElidedColloquialObligation: hostRole === "quoted_nominal_host"
|
|
232
|
+
? "none"
|
|
233
|
+
: elidedColloquialObligationContextAtBoundary(ownedOutgoingBoundary),
|
|
234
|
+
allowRenyouChuushiTerminal: hostRole === "nominal_head" ||
|
|
235
|
+
(await renyouChuushiTerminalAllowedForEnd(input, end)) ||
|
|
236
|
+
canLocalizeStandaloneRenyouFragment(input.tokens, start, end, outgoingBoundary) ||
|
|
237
|
+
renyouChuushiClosesDetachedUtteranceAt(input.tokens, end, outgoingBoundary, input.lookups) ||
|
|
238
|
+
youNiCarrierRenyouChuushiSpaceTerminalAllowed(input.tokens, end),
|
|
239
|
+
...(renyouTerminalRole === null ? {} : { renyouChuushiTerminalRole: renyouTerminalRole }),
|
|
240
|
+
allowMalformedConditionalFragmentTerminal: malformedConditionalFragmentTerminalAllowed(input.tokens, start, end, outgoingBoundary),
|
|
241
|
+
allowPlainNominalizerTerminal: isPlainNominalizerParticleFrameEnd(input.tokens, end, input.lookups) ||
|
|
242
|
+
isPlainNominalizerZeroFollowerFrameEnd(input.tokens, end, input.lookups),
|
|
243
|
+
...(() => {
|
|
244
|
+
const elidedDewaNegativeBody = elidedDewaNegativeBodyAllowedAt(input.tokens, end, ownedOutgoingBoundary);
|
|
245
|
+
return elidedDewaNegativeBody === null ? {} : { allowElidedDewaNegativeBody: elidedDewaNegativeBody };
|
|
246
|
+
})(),
|
|
247
|
+
allowElidedNominalizerTerminal: isZeroNominalizedParallelMoFrameEnd(input.tokens, end) ||
|
|
248
|
+
isBekiRentaiNominalizedFrameEnd(input.tokens, end, input.lookups),
|
|
249
|
+
allowZeroNiPurposeTerminal: isZeroNiPurposeProjectionBoundaryEnd(input.cursor, end, input.lookups),
|
|
250
|
+
allowAdnominalCopulaTerminal: chunkEndsWithAdnominalCopulaAttributiveHead(input.tokens, start, end, input.lookups),
|
|
251
|
+
allowRenyouCompoundPrenominalTerminal: renyouCompoundPrenominalAttributiveTerminalAllowed(end) &&
|
|
252
|
+
!(await renyouPredicateHeadLacksPredicateSense(input, start)),
|
|
253
|
+
allowExplicitAdnominalNoTerminal: attributiveBoundaryPayload?.explicitAdnominalMarker !== undefined,
|
|
254
|
+
...(allowAdverbialModifierTerminal === undefined ? {} : { allowAdverbialModifierTerminal }),
|
|
255
|
+
allowNoQuoteReportingProjection: noQuoteReportingProjectionAllowedAt(input.tokens, start, input.lookups),
|
|
256
|
+
outgoingBoundary: ownedOutgoingBoundary,
|
|
257
|
+
...(attributiveBoundaryPayload === undefined ? {} : { attributiveBoundaryPayload }),
|
|
258
|
+
contextTokens: input.tokens,
|
|
259
|
+
contextPos: start,
|
|
260
|
+
suppressFormalToSuruControl: shouldSuppressFormalToSuruControlForAttributiveHead(input.tokens, start, end, input.lookups),
|
|
261
|
+
...(hostRole === "quoted_nominal_host" ? { quotedNominalHost: true } : {})
|
|
262
|
+
});
|
|
263
|
+
if (!parseResult.ok)
|
|
264
|
+
return parseResult;
|
|
265
|
+
const predicateTokenIdx = start + parseResult.info.localPredicateIdx;
|
|
266
|
+
const hydratedInfo = hydrateClauseParseInfoBenefactive(parseResult.info, input.tokens, predicateTokenIdx, input.lookups, input.numeric);
|
|
267
|
+
const refinedOutgoingBoundary = refineRequestTerminalOutgoingBoundary(hydratedInfo.root, ownedOutgoingBoundary);
|
|
268
|
+
const rewrittenInfo = normalizeClauseParseInfoTokaOwnership(projectClauseParseInfoQuotedSfp(hydrateClauseParseInfoTerminalRoleSfp(rewriteClauseParseInfoPunctuatedAttributive(rewriteClauseParseInfoOutgoingBoundary(hydratedInfo, refinedOutgoingBoundary, outgoingBoundaryRewriteOptions(input.tokens, refinedOutgoingBoundary)), input.tokens, start, end, input.lookups), input.tokens, end), refinedOutgoingBoundary), input.tokens, input.lookups, refinedOutgoingBoundary);
|
|
269
|
+
const info = hydrateConditionalQuoteMarkerContinuation(materializeQuestionQuoteAttributiveCarrier(rewrittenInfo, attributiveBoundaryPayload), input.cursor, input.lookups);
|
|
270
|
+
const boundaryReady = quoteBoundaryReadinessBlocker(input.cursor, refinedOutgoingBoundary, info.root, input.lookups);
|
|
271
|
+
if (boundaryReady !== null) {
|
|
272
|
+
return {
|
|
273
|
+
ok: false,
|
|
274
|
+
reason: boundaryReady,
|
|
275
|
+
...(info.root.headHypothesis === undefined ? {} : { headHypothesis: info.root.headHypothesis })
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
ok: true,
|
|
280
|
+
root: info.root,
|
|
281
|
+
info,
|
|
282
|
+
predicateTokenIdx,
|
|
283
|
+
outgoingBoundary: refinedOutgoingBoundary
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function materializeQuestionQuoteAttributiveCarrier(info, attributiveBoundary) {
|
|
287
|
+
if (attributiveBoundary === undefined ||
|
|
288
|
+
attributiveBoundary.head.dictionaryForm !== "こと" ||
|
|
289
|
+
info.root.tail.kind !== "auxLayer" ||
|
|
290
|
+
info.root.tail.stem.stemMood !== "volitional") {
|
|
291
|
+
return info;
|
|
292
|
+
}
|
|
293
|
+
const ops = info.root.tail.ops;
|
|
294
|
+
const connective = ops.at(-1);
|
|
295
|
+
if (connective?.kind !== "connective" ||
|
|
296
|
+
connective.connective !== "question_quotative" ||
|
|
297
|
+
connective.allomorph !== "tte") {
|
|
298
|
+
return info;
|
|
299
|
+
}
|
|
300
|
+
const carrier = buildPredicateQuoteCarrierOp(connective.source, "question_toiu", connective.surface);
|
|
301
|
+
return {
|
|
302
|
+
...info,
|
|
303
|
+
root: {
|
|
304
|
+
...info.root,
|
|
305
|
+
tail: {
|
|
306
|
+
...info.root.tail,
|
|
307
|
+
ops: [...ops.slice(0, -1), carrier],
|
|
308
|
+
terminal: "attributive",
|
|
309
|
+
terminalPayload: attributiveBoundary
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function hydrateConditionalQuoteMarkerContinuation(info, cursor, lookups) {
|
|
315
|
+
if (info.root.tail.kind !== "auxLayer") {
|
|
316
|
+
return info;
|
|
317
|
+
}
|
|
318
|
+
let changed = false;
|
|
319
|
+
const ops = info.root.tail.ops.map((op) => {
|
|
320
|
+
if (op.kind !== "connective" || op.connective !== "conditional") {
|
|
321
|
+
return op;
|
|
322
|
+
}
|
|
323
|
+
const sourceEnd = op.source.tokenIndices.length === 0
|
|
324
|
+
? null
|
|
325
|
+
: Math.max(...op.source.tokenIndices);
|
|
326
|
+
if (sourceEnd === null) {
|
|
327
|
+
return op;
|
|
328
|
+
}
|
|
329
|
+
const relation = quoteStructuralRelationContainingContentToken(cursor, sourceEnd, lookups);
|
|
330
|
+
if (relation === undefined || relation.quote.markerIdx <= sourceEnd) {
|
|
331
|
+
return op;
|
|
332
|
+
}
|
|
333
|
+
changed = true;
|
|
334
|
+
return markConditionalQuoteMarkerContinuationOp(op);
|
|
335
|
+
});
|
|
336
|
+
return changed
|
|
337
|
+
? { ...info, root: { ...info.root, tail: { ...info.root.tail, ops } } }
|
|
338
|
+
: info;
|
|
339
|
+
}
|
|
340
|
+
function normalizeClauseParseInfoTokaOwnership(info, tokens, lookups, outgoingBoundary) {
|
|
341
|
+
const tokaListingBoundaryMarkerIdx = outgoingBoundary.kind !== "terminal" &&
|
|
342
|
+
(outgoingBoundary.connectiveKind === "conditional" ||
|
|
343
|
+
(outgoingBoundary.connectiveKind === "exemplification" && outgoingBoundary.surface === "とか"))
|
|
344
|
+
? outgoingBoundary.tokenSpan.start
|
|
345
|
+
: null;
|
|
346
|
+
const normalizeLayer = (layer) => {
|
|
347
|
+
const ops = [];
|
|
348
|
+
let changed = false;
|
|
349
|
+
for (let index = 0; index < layer.ops.length; index += 1) {
|
|
350
|
+
const op = layer.ops[index];
|
|
351
|
+
const next = layer.ops[index + 1];
|
|
352
|
+
if (op.kind === "connective" && op.connective === "listing" &&
|
|
353
|
+
next?.kind === "connective" &&
|
|
354
|
+
(next.connective === "exemplification"
|
|
355
|
+
? next.source.tokenIndices[0] !== undefined &&
|
|
356
|
+
op.source.tokenIndices.at(-1) !== undefined &&
|
|
357
|
+
next.source.tokenIndices[0] === op.source.tokenIndices.at(-1) + 1
|
|
358
|
+
: next.connective === "conditional" && next.surface === "と" &&
|
|
359
|
+
listingDeclaredClosureCoversOp(tokens, op, next))) {
|
|
360
|
+
ops.push({
|
|
361
|
+
...op,
|
|
362
|
+
source: {
|
|
363
|
+
tokens: [...op.source.tokens, ...next.source.tokens],
|
|
364
|
+
tokenIndices: [...op.source.tokenIndices, ...next.source.tokenIndices],
|
|
365
|
+
},
|
|
366
|
+
});
|
|
367
|
+
index += 1;
|
|
368
|
+
changed = true;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (op.kind === "connective" && op.connective === "conditional" &&
|
|
372
|
+
op.surface === "と" && next === undefined && tokaListingBoundaryMarkerIdx !== null) {
|
|
373
|
+
const toIdx = op.source.tokenIndices.at(-1);
|
|
374
|
+
const kaIdx = toIdx === undefined
|
|
375
|
+
? null
|
|
376
|
+
: nextNonSpaceIndex(tokens, toIdx + 1, tokens.length);
|
|
377
|
+
if (toIdx === tokaListingBoundaryMarkerIdx && kaIdx !== null &&
|
|
378
|
+
kaOwnershipKindAt(tokens, kaIdx, lookups) === "toka_listing") {
|
|
379
|
+
ops.push({ ...op, connective: "exemplification", surface: "とか" });
|
|
380
|
+
changed = true;
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (op.kind === "connective" && op.connective === "quotative" && next?.kind === "connective" && next.connective === "question_content") {
|
|
385
|
+
const kaIdx = next.source.tokenIndices.at(-1);
|
|
386
|
+
if (kaIdx !== undefined && kaOwnershipKindAt(tokens, kaIdx, lookups) === "toka_listing") {
|
|
387
|
+
ops.push(tokaExemplificationOp(op, next));
|
|
388
|
+
index += 1;
|
|
389
|
+
changed = true;
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (op.kind === "connective" && op.connective === "quotative" && next?.kind === "predicateQuoteCarrier" && next.style === "question_toiu") {
|
|
394
|
+
const kaOffset = next.source.tokens.findIndex((token) => morphSurface(token) === "か");
|
|
395
|
+
const kaIdx = kaOffset < 0 ? undefined : next.source.tokenIndices[kaOffset];
|
|
396
|
+
if (kaIdx !== undefined && kaOwnershipKindAt(tokens, kaIdx, lookups) === "toka_listing") {
|
|
397
|
+
const kaSource = { tokens: [next.source.tokens[kaOffset]], tokenIndices: [kaIdx] };
|
|
398
|
+
ops.push(tokaExemplificationOp(op, createConnectiveOp({ connective: "question_content", surface: "か", source: kaSource })));
|
|
399
|
+
ops.push({
|
|
400
|
+
...next,
|
|
401
|
+
style: "compact_toiu",
|
|
402
|
+
surface: "という",
|
|
403
|
+
source: {
|
|
404
|
+
tokens: next.source.tokens.filter((_, sourceIndex) => sourceIndex !== kaOffset),
|
|
405
|
+
tokenIndices: next.source.tokenIndices.filter((_, sourceIndex) => sourceIndex !== kaOffset),
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
index += 1;
|
|
409
|
+
changed = true;
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
ops.push(op);
|
|
414
|
+
}
|
|
415
|
+
return changed ? { ...layer, ops } : layer;
|
|
416
|
+
};
|
|
417
|
+
const normalizeTail = (tail) => {
|
|
418
|
+
if (tail.kind === "auxLayer")
|
|
419
|
+
return normalizeLayer(tail);
|
|
420
|
+
const inner = normalizeLayer(tail.inner);
|
|
421
|
+
const outer = normalizeTail(tail.outer);
|
|
422
|
+
return inner === tail.inner && outer === tail.outer ? tail : { ...tail, inner, outer };
|
|
423
|
+
};
|
|
424
|
+
const tail = normalizeTail(info.root.tail);
|
|
425
|
+
return tail === info.root.tail ? info : { ...info, root: { ...info.root, tail } };
|
|
426
|
+
}
|
|
427
|
+
function listingDeclaredClosureCoversOp(tokens, listing, closureOp) {
|
|
428
|
+
const markerStart = listing.source.tokenIndices[0];
|
|
429
|
+
const markerEnd = listing.source.tokenIndices.at(-1);
|
|
430
|
+
const closureStart = closureOp.source.tokenIndices[0];
|
|
431
|
+
const closureEnd = closureOp.source.tokenIndices.at(-1);
|
|
432
|
+
if (markerStart === undefined || markerEnd === undefined ||
|
|
433
|
+
closureStart === undefined || closureEnd === undefined ||
|
|
434
|
+
closureEnd < markerEnd) {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
const scopeEnd = closureEnd + 1;
|
|
438
|
+
const cursor = new TokenCursor(tokens, markerStart, scopeEnd, markerStart);
|
|
439
|
+
for (const match of relationConnectiveSpansAt(cursor)) {
|
|
440
|
+
if (match.endExclusive !== markerEnd + 1) {
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
const closure = relationDiscontinuousClosureSpanAfter(cursor.fork(match.endExclusive, scopeEnd, match.endExclusive), match);
|
|
444
|
+
if (closure !== null && closure.start === closureStart && closure.endExclusive === scopeEnd) {
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
function tokaExemplificationOp(quotative, ka) {
|
|
451
|
+
return createConnectiveOp({
|
|
452
|
+
connective: "exemplification",
|
|
453
|
+
surface: `${quotative.surface}${ka.surface}`,
|
|
454
|
+
source: {
|
|
455
|
+
tokens: [...quotative.source.tokens, ...ka.source.tokens],
|
|
456
|
+
tokenIndices: [...quotative.source.tokenIndices, ...ka.source.tokenIndices],
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
function canLocalizeStandaloneRenyouFragment(tokens, start, end, outgoingBoundary) {
|
|
461
|
+
return canLocalizeStandaloneTailFragment(tokens, start, end, outgoingBoundary);
|
|
462
|
+
}
|
|
463
|
+
function malformedConditionalFragmentTerminalAllowed(tokens, start, end, outgoingBoundary) {
|
|
464
|
+
const conditional = conditionalTailConnectiveRelationForToken(tokens[end], end, {
|
|
465
|
+
consumers: ["tail_multi_clause"]
|
|
466
|
+
});
|
|
467
|
+
return conditional !== null ||
|
|
468
|
+
canLocalizeStandaloneTailFragment(tokens, start, end, outgoingBoundary);
|
|
469
|
+
}
|
|
470
|
+
export function elidedColloquialObligationContextAtBoundary(boundary) {
|
|
471
|
+
if (boundary.kind === "terminal") {
|
|
472
|
+
return "terminal";
|
|
473
|
+
}
|
|
474
|
+
return (boundary.quoteBoundary !== undefined && boundary.connectiveKind === "quotative") ||
|
|
475
|
+
boundary.connectiveKind === "exemplification"
|
|
476
|
+
? "quote_content_terminal"
|
|
477
|
+
: "none";
|
|
478
|
+
}
|
|
479
|
+
function canLocalizeStandaloneTailFragment(tokens, start, end, outgoingBoundary) {
|
|
480
|
+
if (outgoingBoundary.kind !== "terminal" || end < start) {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
const next = tokens[end + 1];
|
|
484
|
+
return next === undefined || isClausePunctuationToken(next);
|
|
485
|
+
}
|
|
486
|
+
export function standaloneRenyouFragmentWarningsForParsedChunk(tokens, start, end, root, outgoingBoundary, lookups) {
|
|
487
|
+
if (!tailRootHasRenyouChuushiTerminal(root) ||
|
|
488
|
+
!canLocalizeStandaloneRenyouFragment(tokens, start, end, outgoingBoundary) ||
|
|
489
|
+
hasRenyouChuushiContinuationForEnd(tokens, end, lookups) ||
|
|
490
|
+
renyouChuushiClosesDetachedUtteranceAt(tokens, end, outgoingBoundary, lookups)) {
|
|
491
|
+
return [];
|
|
492
|
+
}
|
|
493
|
+
if (root.tail.kind === "auxLayer" &&
|
|
494
|
+
root.sfp !== null &&
|
|
495
|
+
(root.sfp.effect !== null ||
|
|
496
|
+
copulaContinuativeExplanatoryClosureApplies(root.tail, root.sfp, lookups) ||
|
|
497
|
+
copulaContinuativeObliqueRecoveryApplies(root.tail, root.sfp, lookups))) {
|
|
498
|
+
return [];
|
|
499
|
+
}
|
|
500
|
+
return [{
|
|
501
|
+
type: "out_of_subset_default",
|
|
502
|
+
severity: "warning",
|
|
503
|
+
opKind: "terminal_renyou_fragment",
|
|
504
|
+
span: { start, end },
|
|
505
|
+
message: "Terminal 連用 fragment rendered as a connective fragment instead of falling back to legacy tail."
|
|
506
|
+
}];
|
|
507
|
+
}
|
|
508
|
+
export function missingConditionalMarkerWarningsForRoot(root) {
|
|
509
|
+
if (root.tail.kind !== "auxLayer") {
|
|
510
|
+
return [];
|
|
511
|
+
}
|
|
512
|
+
return root.tail.ops
|
|
513
|
+
.filter((op) => op.kind === "connective" && op.recovery === "missing_conditional_marker")
|
|
514
|
+
.map((op) => {
|
|
515
|
+
const start = op.source.tokenIndices[0] ?? 0;
|
|
516
|
+
const end = op.source.tokenIndices[op.source.tokenIndices.length - 1] ?? start;
|
|
517
|
+
return {
|
|
518
|
+
type: "out_of_subset_default",
|
|
519
|
+
severity: "warning",
|
|
520
|
+
opKind: "malformed_conditional_fragment",
|
|
521
|
+
span: { start, end },
|
|
522
|
+
message: "Malformed 仮定形 fragment recovered as a conditional connective with an omitted ば marker."
|
|
523
|
+
};
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
export function renderParsedChunk(input, start, end, info, outgoingBoundary) {
|
|
527
|
+
const predicateTokenIdx = start + info.localPredicateIdx;
|
|
528
|
+
const peer = {
|
|
529
|
+
root: info.root,
|
|
530
|
+
clauseIndex: 0,
|
|
531
|
+
tokenSpan: { start, end },
|
|
532
|
+
contentSpan: { start, end },
|
|
533
|
+
predicateTokenIdx,
|
|
534
|
+
outgoingBoundary
|
|
535
|
+
};
|
|
536
|
+
const result = commitAndRenderSingleClause(info, {
|
|
537
|
+
clauseIndex: 0,
|
|
538
|
+
predicateTokenIdx: peer.predicateTokenIdx,
|
|
539
|
+
peerClauses: [peer],
|
|
540
|
+
ownClause: peer,
|
|
541
|
+
tokens: input.tokens,
|
|
542
|
+
lookups: input.lookups,
|
|
543
|
+
numeric: input.numeric
|
|
544
|
+
});
|
|
545
|
+
return result;
|
|
546
|
+
}
|
|
547
|
+
function hydrateClauseParseInfoBenefactive(info, tokens, predicateTokenIdx, lookups, numeric) {
|
|
548
|
+
const benefactiveRoot = hydrateBenefactivePayloads(info.root, { tokens, predicateTokenIdx, lookups, layout: undefined });
|
|
549
|
+
const root = hydrateAspectSemanticPayloads(benefactiveRoot, tokens, predicateTokenIdx, lookups, numeric);
|
|
550
|
+
return root === info.root ? info : { ...info, root };
|
|
551
|
+
}
|
|
552
|
+
function rewriteClauseParseInfoOutgoingBoundary(info, outgoingBoundary, options = {}) {
|
|
553
|
+
const root = rewriteRootOutgoingBoundaryConnective(info.root, outgoingBoundary, options);
|
|
554
|
+
return root === info.root ? info : { ...info, root };
|
|
555
|
+
}
|
|
556
|
+
function projectClauseParseInfoQuotedSfp(info, outgoingBoundary) {
|
|
557
|
+
const sfp = info.root.sfp;
|
|
558
|
+
if (sfp === null ||
|
|
559
|
+
outgoingBoundary.kind === "terminal" ||
|
|
560
|
+
outgoingBoundary.connectiveKind !== "quotative" ||
|
|
561
|
+
sfp.quoteProjection !== undefined)
|
|
562
|
+
return info;
|
|
563
|
+
const quoteProjection = sfp.effect === "na_prohib"
|
|
564
|
+
? "prohibitive"
|
|
565
|
+
: sfp.effect === "na_excl" ||
|
|
566
|
+
sfp.effect === "na_soft_imperative" ||
|
|
567
|
+
sfp.effect === "kana" ||
|
|
568
|
+
sfp.effect === "kke" ||
|
|
569
|
+
isKaFamilyQuestionSfpEffect(sfp.effect) ||
|
|
570
|
+
sfp.effect === "quotative_command"
|
|
571
|
+
? "terminal_mood"
|
|
572
|
+
: null;
|
|
573
|
+
if (quoteProjection === null)
|
|
574
|
+
return info;
|
|
575
|
+
const focusParticle = quoteProjection === "terminal_mood"
|
|
576
|
+
? outgoingBoundary.quoteBoundary?.focusParticle
|
|
577
|
+
: undefined;
|
|
578
|
+
return {
|
|
579
|
+
...info,
|
|
580
|
+
root: {
|
|
581
|
+
...info.root,
|
|
582
|
+
sfp: {
|
|
583
|
+
...sfp,
|
|
584
|
+
quoteProjection,
|
|
585
|
+
...(focusParticle === undefined ? {} : { quoteFocusParticle: focusParticle }),
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function outgoingBoundaryRewriteOptions(tokens, outgoingBoundary) {
|
|
591
|
+
if (outgoingBoundary.kind !== "terminal" &&
|
|
592
|
+
outgoingBoundary.connectiveKind === "te_form" &&
|
|
593
|
+
teOkuEvaluationReasonBoundaryAt(tokens, outgoingBoundary.tokenIdx)) {
|
|
594
|
+
return { teFormRole: "reason" };
|
|
595
|
+
}
|
|
596
|
+
return {};
|
|
597
|
+
}
|
|
598
|
+
function rewriteClauseParseInfoPunctuatedAttributive(info, tokens, startIdx, contentEndIdx, lookups) {
|
|
599
|
+
const boundary = classifyAttributiveChunkBoundary(tokens, startIdx, contentEndIdx, lookups);
|
|
600
|
+
if (boundary === null) {
|
|
601
|
+
return info;
|
|
602
|
+
}
|
|
603
|
+
if (tailRootHasClauseBoundaryOp(info.root)) {
|
|
604
|
+
return info;
|
|
605
|
+
}
|
|
606
|
+
if (tailRootHasRenyouChuushiTerminal(info.root)) {
|
|
607
|
+
return info;
|
|
608
|
+
}
|
|
609
|
+
if (tailRootHasAdverbialModifierTerminal(info.root)) {
|
|
610
|
+
return info;
|
|
611
|
+
}
|
|
612
|
+
if (attributiveRewriteRestsOnClosedUtterance(info.root, contentEndIdx, lookups)) {
|
|
613
|
+
return info;
|
|
614
|
+
}
|
|
615
|
+
const root = markTailRootAttributiveTerminal(info.root, boundary.payload);
|
|
616
|
+
return root === info.root ? info : { ...info, root };
|
|
617
|
+
}
|
|
618
|
+
export function attributiveRewriteRestsOnClosedUtterance(root, fallbackCloseIdx, lookups) {
|
|
619
|
+
return utteranceClosedForAttributiveProjection(activeProtoUtteranceClosureRunAt(tailRootUtteranceCloseIndex(root, fallbackCloseIdx)), root.sfp?.effect, lookups.SFP_UTTERANCE_CLOSING_EFFECTS);
|
|
620
|
+
}
|
|
621
|
+
function tailRootUtteranceCloseIndex(root, fallbackCloseIdx) {
|
|
622
|
+
const layer = firstAuxLayer(root.tail);
|
|
623
|
+
if (layer === null) {
|
|
624
|
+
return fallbackCloseIdx;
|
|
625
|
+
}
|
|
626
|
+
const consumed = auxLayerConsumedSourceSequence(layer, root.sfp ?? null);
|
|
627
|
+
const last = consumed[consumed.length - 1];
|
|
628
|
+
return last === undefined ? fallbackCloseIdx : Math.max(fallbackCloseIdx, last[0] + 1);
|
|
629
|
+
}
|
|
630
|
+
function tailRootHasClauseBoundaryOp(root) {
|
|
631
|
+
return root.tail.kind === "auxLayer" && root.tail.ops.some((op) => op.kind === "connective" ||
|
|
632
|
+
(op.kind === "copula" && op.variant === "conditional_nara"));
|
|
633
|
+
}
|
|
634
|
+
export function stripTrailingConnectiveForAttributiveHost(root) {
|
|
635
|
+
if (root.tail.kind !== "auxLayer")
|
|
636
|
+
return root;
|
|
637
|
+
const ops = root.tail.ops;
|
|
638
|
+
if (ops.length === 0 || ops[ops.length - 1]?.kind !== "connective")
|
|
639
|
+
return root;
|
|
640
|
+
return {
|
|
641
|
+
...root,
|
|
642
|
+
tail: { ...root.tail, ops: ops.slice(0, -1) }
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
export function markTailRootAttributiveTerminal(root, payload) {
|
|
646
|
+
if (root.tail.kind !== "auxLayer") {
|
|
647
|
+
return root;
|
|
648
|
+
}
|
|
649
|
+
const ops = normalizeTosuruModeForAttributivePayload(root.tail.ops, payload);
|
|
650
|
+
if (root.tail.terminal === "attributive") {
|
|
651
|
+
if (payload === undefined && ops === root.tail.ops) {
|
|
652
|
+
return root;
|
|
653
|
+
}
|
|
654
|
+
return {
|
|
655
|
+
...root,
|
|
656
|
+
tail: {
|
|
657
|
+
...root.tail,
|
|
658
|
+
ops,
|
|
659
|
+
...(payload === undefined ? {} : { terminalPayload: payload })
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
return {
|
|
664
|
+
...root,
|
|
665
|
+
tail: {
|
|
666
|
+
...root.tail,
|
|
667
|
+
ops,
|
|
668
|
+
terminal: "attributive",
|
|
669
|
+
...(payload === undefined ? {} : { terminalPayload: payload })
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
function normalizeTosuruModeForAttributivePayload(ops, payload) {
|
|
674
|
+
const follower = payload?.source.tokens[0];
|
|
675
|
+
if (follower === undefined) {
|
|
676
|
+
return ops;
|
|
677
|
+
}
|
|
678
|
+
let changed = false;
|
|
679
|
+
const normalized = ops.map((op) => {
|
|
680
|
+
if (op.kind !== "predicateQuoteCarrier" ||
|
|
681
|
+
op.style !== "suru_attributive" ||
|
|
682
|
+
op.tosuruMode !== "resultative_make") {
|
|
683
|
+
return op;
|
|
684
|
+
}
|
|
685
|
+
const carrier = op.source.tokens.at(-1);
|
|
686
|
+
if (carrier === undefined || !tosuruResultativeMakeYieldsToAttributiveQuoteHead(carrier, follower)) {
|
|
687
|
+
return op;
|
|
688
|
+
}
|
|
689
|
+
changed = true;
|
|
690
|
+
return { ...op, tosuruMode: "quote" };
|
|
691
|
+
});
|
|
692
|
+
return changed ? normalized : ops;
|
|
693
|
+
}
|
|
694
|
+
function hydrateClauseParseInfoTerminalRoleSfp(info, tokens, contentEndIdx) {
|
|
695
|
+
const root = hydrateTerminalRoleSfp(info.root, tokens, contentEndIdx);
|
|
696
|
+
return root === info.root ? info : { ...info, root };
|
|
697
|
+
}
|
|
698
|
+
function hydrateTerminalRoleSfp(root, tokens, contentEndIdx) {
|
|
699
|
+
if (root.sfp !== null) {
|
|
700
|
+
const markerIdx = root.sfp.source.tokenIndices.at(-1);
|
|
701
|
+
const punctuationIdx = markerIdx === undefined
|
|
702
|
+
? null
|
|
703
|
+
: nextNonSpaceIndex(tokens, markerIdx + 1, tokens.length);
|
|
704
|
+
let runIdx = punctuationIdx;
|
|
705
|
+
let emphaticQuestion = false;
|
|
706
|
+
while (isKaFamilyQuestionSfpEffect(root.sfp.effect) &&
|
|
707
|
+
root.sfp.emphaticQuestion !== true &&
|
|
708
|
+
runIdx !== null) {
|
|
709
|
+
if (hasHardTerminalPunctuationClass(tokens[runIdx], runIdx, ["exclamation"], ["tail_render"])) {
|
|
710
|
+
emphaticQuestion = true;
|
|
711
|
+
}
|
|
712
|
+
if (!hasHardTerminalPunctuationClass(tokens[runIdx], runIdx, ["question", "exclamation", "japanese_period", "ascii_period", "ellipsis"], ["tail_render"])) {
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
runIdx = nextNonSpaceIndex(tokens, runIdx + 1, tokens.length);
|
|
716
|
+
}
|
|
717
|
+
return emphaticQuestion
|
|
718
|
+
? { ...root, sfp: { ...root.sfp, emphaticQuestion: true } }
|
|
719
|
+
: root;
|
|
720
|
+
}
|
|
721
|
+
const question = terminalQuestionPunctuationSfpNodeAt(root, tokens, contentEndIdx);
|
|
722
|
+
if (question !== null) {
|
|
723
|
+
return { ...root, sfp: question };
|
|
724
|
+
}
|
|
725
|
+
const sfp = terminalRoleSfpNodeAt(tokens, contentEndIdx);
|
|
726
|
+
if (sfp === null) {
|
|
727
|
+
return root;
|
|
728
|
+
}
|
|
729
|
+
return { ...root, sfp };
|
|
730
|
+
}
|
|
731
|
+
function terminalQuestionPunctuationSfpNodeAt(root, tokens, contentEndIdx) {
|
|
732
|
+
if (!tailRootHasNoHeadNegativeScopeBridge(root)) {
|
|
733
|
+
return null;
|
|
734
|
+
}
|
|
735
|
+
const tokenIdx = nextNonSpaceIndex(tokens, contentEndIdx + 1) ?? contentEndIdx + 1;
|
|
736
|
+
const terminal = matchNodaNoKaNegativeConfirmTerminalTail(tokens, tokenIdx, tokens.length, {
|
|
737
|
+
consumers: ["tail_multi_clause"]
|
|
738
|
+
});
|
|
739
|
+
if (terminal === null || terminal.contentEndExclusive !== tokenIdx) {
|
|
740
|
+
return null;
|
|
741
|
+
}
|
|
742
|
+
const token = tokens[terminal.questionIdx];
|
|
743
|
+
if (token === undefined) {
|
|
744
|
+
return null;
|
|
745
|
+
}
|
|
746
|
+
return {
|
|
747
|
+
effect: "neg_confirm_q",
|
|
748
|
+
surface: token.surface,
|
|
749
|
+
consumed: 0,
|
|
750
|
+
repeatCount: 1,
|
|
751
|
+
source: { tokens: [token], tokenIndices: [terminal.questionIdx] }
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
function tailRootHasNoHeadNegativeScopeBridge(root) {
|
|
755
|
+
if (root.tail.kind !== "auxLayer") {
|
|
756
|
+
return false;
|
|
757
|
+
}
|
|
758
|
+
const last = root.tail.ops.at(-1);
|
|
759
|
+
const bridge = last?.kind === "modal" && last.modal === "noda"
|
|
760
|
+
? root.tail.ops.at(-2)
|
|
761
|
+
: last;
|
|
762
|
+
return bridge?.kind === "scopeBridge" &&
|
|
763
|
+
bridge.head === "no" &&
|
|
764
|
+
bridge.polarity === "negative" &&
|
|
765
|
+
bridge.chainDepth === 1;
|
|
766
|
+
}
|
|
767
|
+
function terminalRoleSfpNodeAt(tokens, contentEndIdx) {
|
|
768
|
+
const trailing = tokens[contentEndIdx];
|
|
769
|
+
const after = terminalRoleSfpFromToken(trailing, contentEndIdx, "after");
|
|
770
|
+
if (after !== null) {
|
|
771
|
+
return after;
|
|
772
|
+
}
|
|
773
|
+
const next = tokens[contentEndIdx + 1];
|
|
774
|
+
return terminalRoleSfpFromToken(next, contentEndIdx + 1, "before");
|
|
775
|
+
}
|
|
776
|
+
function terminalRoleSfpFromToken(token, tokenIdx, side) {
|
|
777
|
+
if (token === undefined || tokenIdx < 0) {
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
const marker = side === "before" ? token.terminalRoleSfpBefore : token.terminalRoleSfpAfter;
|
|
781
|
+
if (marker === undefined) {
|
|
782
|
+
return null;
|
|
783
|
+
}
|
|
784
|
+
const countFromMarker = roleCatNyaCount(marker);
|
|
785
|
+
if (countFromMarker <= 0) {
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
788
|
+
const explicitCount = side === "before" ? token.terminalRoleSfpBeforeCount : token.terminalRoleSfpAfterCount;
|
|
789
|
+
return {
|
|
790
|
+
effect: "role_cat_nya",
|
|
791
|
+
surface: marker,
|
|
792
|
+
consumed: 0,
|
|
793
|
+
repeatCount: explicitCount ?? countFromMarker,
|
|
794
|
+
source: { tokens: [token], tokenIndices: [tokenIdx] }
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
function quoteBoundaryReadinessBlocker(cursor, outgoingBoundary, root, lookups) {
|
|
798
|
+
const tokens = cursor.tokens;
|
|
799
|
+
if (outgoingBoundary.kind === "terminal" || outgoingBoundary.connectiveKind !== "quotative") {
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
const relation = quoteStructuralRelationAt(cursor.fork(outgoingBoundary.tokenIdx, tokens.length, outgoingBoundary.tokenIdx), lookups);
|
|
803
|
+
if (relation === undefined ||
|
|
804
|
+
!IU_LEXEME_FORMS.has(relation.quote.hostMatch.hostForm) ||
|
|
805
|
+
!isPassiveQuoteHost(tokens, relation.quote.hostMatch.hostIdx) ||
|
|
806
|
+
!tailRootHasBareReceiveDesireQuoteContent(root, outgoingBoundary.tokenIdx)) {
|
|
807
|
+
return null;
|
|
808
|
+
}
|
|
809
|
+
return "passive 言われる + receive-desire quote request is not yet represented in TailRoot";
|
|
810
|
+
}
|
|
811
|
+
function isPassiveQuoteHost(tokens, hostIdx) {
|
|
812
|
+
const next = tokens[hostIdx + 1];
|
|
813
|
+
return next !== undefined &&
|
|
814
|
+
(next.pos & POS4) === 助動詞_レル;
|
|
815
|
+
}
|
|
816
|
+
function tailRootHasBareReceiveDesireQuoteContent(root, boundaryTokenIdx) {
|
|
817
|
+
if (root.tail.kind !== "auxLayer") {
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
820
|
+
const connectiveIdx = root.tail.ops.findIndex((op) => op.kind === "connective" && op.source.tokenIndices.includes(boundaryTokenIdx));
|
|
821
|
+
const ops = connectiveIdx >= 0 ? root.tail.ops.slice(0, connectiveIdx) : root.tail.ops;
|
|
822
|
+
const desireIdx = ops.findIndex((op) => op.kind === "desire");
|
|
823
|
+
if (desireIdx < 0) {
|
|
824
|
+
return false;
|
|
825
|
+
}
|
|
826
|
+
const hasReceiveBenefactive = ops.some((op) => op.kind === "aspect" &&
|
|
827
|
+
(op.aspect === "te_morau" ||
|
|
828
|
+
op.aspect === "te_itadaku" ||
|
|
829
|
+
op.aspect === "te_moraeru" ||
|
|
830
|
+
op.aspect === "te_itadakeru"));
|
|
831
|
+
if (!hasReceiveBenefactive) {
|
|
832
|
+
return false;
|
|
833
|
+
}
|
|
834
|
+
return !ops.slice(desireIdx + 1).some((op) => op.kind === "negation" ||
|
|
835
|
+
op.kind === "tense" ||
|
|
836
|
+
op.kind === "conjecture" ||
|
|
837
|
+
op.kind === "modal" ||
|
|
838
|
+
chainFinalOpHostCategory(op) !== undefined);
|
|
839
|
+
}
|
|
840
|
+
export function rewriteRootOutgoingBoundaryConnective(root, outgoingBoundary, options = {}) {
|
|
841
|
+
if (outgoingBoundary.kind === "terminal") {
|
|
842
|
+
return root;
|
|
843
|
+
}
|
|
844
|
+
const layer = firstAuxLayer(root.tail);
|
|
845
|
+
const refinedOutgoingBoundary = outgoingBoundary.retrospectiveQuotativeFlavor === undefined
|
|
846
|
+
? outgoingBoundary
|
|
847
|
+
: {
|
|
848
|
+
...outgoingBoundary,
|
|
849
|
+
retrospectiveQuotativeFlavor: retrospectiveQuotativeFlavorForStemMood(outgoingBoundary.retrospectiveQuotativeFlavor, layer?.stem.stemMood)
|
|
850
|
+
};
|
|
851
|
+
const tail = rewriteTailNodeOutgoingBoundaryConnective(root.tail, refinedOutgoingBoundary, options);
|
|
852
|
+
return tail === root.tail ? root : { ...root, tail };
|
|
853
|
+
}
|
|
854
|
+
function rewriteTailNodeOutgoingBoundaryConnective(tail, outgoingBoundary, options) {
|
|
855
|
+
if (tail.kind === "connective") {
|
|
856
|
+
const inner = rewriteAuxLayerOutgoingBoundaryConnective(tail.inner, outgoingBoundary, options);
|
|
857
|
+
const outer = rewriteTailNodeOutgoingBoundaryConnective(tail.outer, outgoingBoundary, options);
|
|
858
|
+
const selfNeedsRewrite = tail.source.tokenIndices.includes(outgoingBoundary.tokenIdx) &&
|
|
859
|
+
!connectiveSurfaceSpecializesOutgoingBoundary(tail.surface, outgoingBoundary.surface) &&
|
|
860
|
+
(tail.connective !== outgoingBoundary.connectiveKind ||
|
|
861
|
+
tail.surface !== outgoingBoundary.surface ||
|
|
862
|
+
!quoteBoundaryPayloadEquals(tail.quoteBoundary, outgoingBoundary.quoteBoundary));
|
|
863
|
+
if (inner === tail.inner && outer === tail.outer && !selfNeedsRewrite) {
|
|
864
|
+
return tail;
|
|
865
|
+
}
|
|
866
|
+
return {
|
|
867
|
+
...tail,
|
|
868
|
+
inner,
|
|
869
|
+
outer,
|
|
870
|
+
...(selfNeedsRewrite
|
|
871
|
+
? {
|
|
872
|
+
connective: outgoingBoundary.connectiveKind,
|
|
873
|
+
surface: outgoingBoundary.surface,
|
|
874
|
+
...(outgoingBoundary.quoteBoundary === undefined
|
|
875
|
+
? {}
|
|
876
|
+
: { quoteBoundary: outgoingBoundary.quoteBoundary })
|
|
877
|
+
}
|
|
878
|
+
: {})
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
return rewriteAuxLayerOutgoingBoundaryConnective(tail, outgoingBoundary, options);
|
|
882
|
+
}
|
|
883
|
+
function rewriteAuxLayerOutgoingBoundaryConnective(layer, outgoingBoundary, options) {
|
|
884
|
+
const ops = layer.ops.map((op) => {
|
|
885
|
+
const teFormRole = outgoingBoundaryTeFormRole(outgoingBoundary, options);
|
|
886
|
+
if (op.kind !== "connective" ||
|
|
887
|
+
!op.source.tokenIndices.includes(outgoingBoundary.tokenIdx) ||
|
|
888
|
+
connectiveSurfaceSpecializesOutgoingBoundary(op.surface, outgoingBoundary.surface) ||
|
|
889
|
+
(op.connective === outgoingBoundary.connectiveKind &&
|
|
890
|
+
op.surface === outgoingBoundary.surface &&
|
|
891
|
+
(outgoingBoundary.quotativeMood === undefined ||
|
|
892
|
+
op.quotativeMood === outgoingBoundary.quotativeMood) &&
|
|
893
|
+
op.retrospectiveQuotativeFlavor === outgoingBoundary.retrospectiveQuotativeFlavor &&
|
|
894
|
+
quoteBoundaryPayloadEquals(op.quoteBoundary, outgoingBoundary.quoteBoundary) &&
|
|
895
|
+
(teFormRole === undefined || op.teFormRole === teFormRole))) {
|
|
896
|
+
return op;
|
|
897
|
+
}
|
|
898
|
+
return {
|
|
899
|
+
...op,
|
|
900
|
+
connective: outgoingBoundary.connectiveKind,
|
|
901
|
+
surface: outgoingBoundary.surface,
|
|
902
|
+
...(outgoingBoundary.boundNominalReasonMonoNoun === undefined
|
|
903
|
+
? {}
|
|
904
|
+
: { boundNominalReasonMonoNoun: outgoingBoundary.boundNominalReasonMonoNoun }),
|
|
905
|
+
...(outgoingBoundary.quotativeMood === undefined
|
|
906
|
+
? {}
|
|
907
|
+
: { quotativeMood: outgoingBoundary.quotativeMood }),
|
|
908
|
+
...(outgoingBoundary.retrospectiveQuotativeFlavor === undefined
|
|
909
|
+
? {}
|
|
910
|
+
: { retrospectiveQuotativeFlavor: outgoingBoundary.retrospectiveQuotativeFlavor }),
|
|
911
|
+
...(teFormRole === undefined ? {} : { teFormRole }),
|
|
912
|
+
...(outgoingBoundary.quoteBoundary === undefined
|
|
913
|
+
? {}
|
|
914
|
+
: { quoteBoundary: outgoingBoundary.quoteBoundary })
|
|
915
|
+
};
|
|
916
|
+
});
|
|
917
|
+
return { ...layer, ops };
|
|
918
|
+
}
|
|
919
|
+
function outgoingBoundaryTeFormRole(outgoingBoundary, options) {
|
|
920
|
+
return outgoingBoundary.connectiveKind === "te_form" ? options.teFormRole : undefined;
|
|
921
|
+
}
|
|
922
|
+
function connectiveSurfaceSpecializesOutgoingBoundary(surface, boundarySurface) {
|
|
923
|
+
return ((surface === "でありながら" && boundarySurface === "ながら") ||
|
|
924
|
+
(surface === "ことから" && boundarySurface === "から") ||
|
|
925
|
+
(surface.startsWith("ということから") && boundarySurface === "から") ||
|
|
926
|
+
(surface.startsWith("ってことから") && boundarySurface === "から") ||
|
|
927
|
+
(surface.includes("こともあって") && boundarySurface === "て") ||
|
|
928
|
+
(surface.includes("ことも手伝って") && boundarySurface === "て") ||
|
|
929
|
+
((surface === "ために" || surface === "為に") && boundarySurface === "に") ||
|
|
930
|
+
(surface === "__renyou_mo" && boundarySurface === "も"));
|
|
931
|
+
}
|
|
932
|
+
function quoteBoundaryPayloadEquals(left, right) {
|
|
933
|
+
if (left === undefined && right === undefined)
|
|
934
|
+
return true;
|
|
935
|
+
if (left === undefined || right === undefined)
|
|
936
|
+
return false;
|
|
937
|
+
return left.koreanClauseForm === right.koreanClauseForm &&
|
|
938
|
+
left.requestTailKind === right.requestTailKind &&
|
|
939
|
+
left.focusParticle === right.focusParticle &&
|
|
940
|
+
left.nominalRoleParticle === right.nominalRoleParticle &&
|
|
941
|
+
left.reportingPassiveRoleLabel === right.reportingPassiveRoleLabel &&
|
|
942
|
+
left.adjectivalDistributionContent === right.adjectivalDistributionContent;
|
|
943
|
+
}
|
|
944
|
+
function hydrateAspectSemanticPayloads(root, tokens, predicateTokenIdx, lookups, numeric) {
|
|
945
|
+
const tail = hydrateAspectSemanticTailNode(root.tail, tokens, predicateTokenIdx, lookups, numeric);
|
|
946
|
+
return tail === root.tail ? root : { ...root, tail };
|
|
947
|
+
}
|
|
948
|
+
function hydrateAspectSemanticTailNode(node, tokens, predicateTokenIdx, lookups, numeric) {
|
|
949
|
+
if (node.kind === "connective") {
|
|
950
|
+
const inner = hydrateAspectSemanticAuxLayer(node.inner, tokens, predicateTokenIdx, lookups, numeric);
|
|
951
|
+
const outer = hydrateAspectSemanticTailNode(node.outer, tokens, predicateTokenIdx, lookups, numeric);
|
|
952
|
+
return inner === node.inner && outer === node.outer ? node : { ...node, inner, outer };
|
|
953
|
+
}
|
|
954
|
+
return hydrateAspectSemanticAuxLayer(node, tokens, predicateTokenIdx, lookups, numeric);
|
|
955
|
+
}
|
|
956
|
+
function hydrateAspectSemanticAuxLayer(layer, tokens, predicateTokenIdx, lookups, numeric) {
|
|
957
|
+
const hydrated = hydrateAspectSemanticOps({
|
|
958
|
+
ops: layer.ops,
|
|
959
|
+
stem: layer.stem,
|
|
960
|
+
headEntry: null,
|
|
961
|
+
tokens,
|
|
962
|
+
predicateTokenIdx,
|
|
963
|
+
lookups,
|
|
964
|
+
numeric
|
|
965
|
+
});
|
|
966
|
+
return hydrated === null ? layer : { ...layer, stem: hydrated.stem, ops: hydrated.ops };
|
|
967
|
+
}
|
|
968
|
+
async function parseSingleClause(input, range, baseOffset, options = {}) {
|
|
969
|
+
const originalStemToken = input.tokens[range.start];
|
|
970
|
+
if (originalStemToken === undefined) {
|
|
971
|
+
return { ok: false, reason: "stem token undefined" };
|
|
972
|
+
}
|
|
973
|
+
const request = { input, range, baseOffset, options };
|
|
974
|
+
const stems = await detectClauseStemVariants(request, originalStemToken);
|
|
975
|
+
const head = await resolveClauseStemHead(request, stems);
|
|
976
|
+
if ("ok" in head) {
|
|
977
|
+
return head;
|
|
978
|
+
}
|
|
979
|
+
const { stemKind, entry } = head;
|
|
980
|
+
const senseContext = clauseStemSenseContext(request, stems);
|
|
981
|
+
const { contextTokens, contextPos } = senseContext;
|
|
982
|
+
const hypothesisSource = clauseHeadHypothesisSource(request, stems, head);
|
|
983
|
+
const { initialHeadHypothesisSource, headHypothesisCapabilities } = hypothesisSource;
|
|
984
|
+
const senses = selectTailParserStemSenses(entry, contextTokens, contextPos, stemKind, input, {
|
|
985
|
+
adverbialModifierContext: options.allowAdverbialModifierTerminal !== undefined
|
|
986
|
+
});
|
|
987
|
+
if (senses === null || senses.length === 0) {
|
|
988
|
+
return {
|
|
989
|
+
ok: false,
|
|
990
|
+
reason: "dictionary entry has no senses",
|
|
991
|
+
headHypothesis: buildHeadHypothesisCarrier({
|
|
992
|
+
sourceStemKind: stemKind,
|
|
993
|
+
admittedStemKind: stemKind,
|
|
994
|
+
source: initialHeadHypothesisSource,
|
|
995
|
+
sourceCapabilities: headHypothesisCapabilities,
|
|
996
|
+
originalCandidateCount: 0,
|
|
997
|
+
candidates: []
|
|
998
|
+
})
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
const preserved = preserveClauseStemSenseCandidates(request, stems, head, hypothesisSource, senses);
|
|
1002
|
+
if ("ok" in preserved) {
|
|
1003
|
+
return preserved;
|
|
1004
|
+
}
|
|
1005
|
+
const intake = admitClauseStemIntake(request, head, hypothesisSource, preserved, senses);
|
|
1006
|
+
if ("ok" in intake) {
|
|
1007
|
+
return intake;
|
|
1008
|
+
}
|
|
1009
|
+
const { intakeHeadHypothesis } = intake;
|
|
1010
|
+
const stemBuild = buildClauseStemInput(request, stems, head, hypothesisSource, preserved, senses);
|
|
1011
|
+
const slice = buildClauseParseSlice(request, stems, head, stemBuild);
|
|
1012
|
+
for (const t of senses) {
|
|
1013
|
+
if (t.koreanHonorific !== undefined) {
|
|
1014
|
+
return {
|
|
1015
|
+
ok: false,
|
|
1016
|
+
reason: "translation has honorific lemma frame — out of subset",
|
|
1017
|
+
headHypothesis: intakeHeadHypothesis
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
const anchors = buildClauseStemSourceAnchors(request, stems, head, stemBuild, slice);
|
|
1022
|
+
const { headHypothesis, parsed } = parseClauseTail(request, head, hypothesisSource, preserved, intake, stemBuild, slice, anchors, senseContext, senses);
|
|
1023
|
+
if (!parsed.ok) {
|
|
1024
|
+
return {
|
|
1025
|
+
ok: false,
|
|
1026
|
+
reason: `parser: ${parsed.reason}`,
|
|
1027
|
+
headHypothesis
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
const { virtualCompoundStem } = stems;
|
|
1031
|
+
if (virtualCompoundStem?.propositionHost === true && !propositionHostChainBindsWake(parsed.root)) {
|
|
1032
|
+
return {
|
|
1033
|
+
ok: false,
|
|
1034
|
+
reason: "demonstrative proposition host requires a wake operator binding わけ",
|
|
1035
|
+
headHypothesis
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
const fullContextTokens = options.contextTokens ?? input.tokens;
|
|
1039
|
+
const unlicensedRejection = rejectUnlicensedParsedClause(request, parsed, headHypothesis, fullContextTokens);
|
|
1040
|
+
if (unlicensedRejection !== null) {
|
|
1041
|
+
return unlicensedRejection;
|
|
1042
|
+
}
|
|
1043
|
+
return finishParsedClause(request, stems, senseContext, slice, anchors, parsed, headHypothesis, fullContextTokens);
|
|
1044
|
+
}
|
|
1045
|
+
async function detectClauseStemVariants(request, originalStemToken) {
|
|
1046
|
+
const { input, range, baseOffset, options } = request;
|
|
1047
|
+
const garuCompoundStem = await detectGaruSyntheticStem(input, range, baseOffset);
|
|
1048
|
+
const virtualCompoundStem = garuCompoundStem ??
|
|
1049
|
+
detectDemonstrativePropositionHostStem(input, range, baseOffset) ??
|
|
1050
|
+
await detectRentaishiPronominalNoHeadStem(input, range, baseOffset) ??
|
|
1051
|
+
await detectNounPhraseHeadStem(input, range, baseOffset, options.outgoingBoundary, options.contextTokens) ??
|
|
1052
|
+
await detectVirtualCompoundDictionaryStem(input, range, baseOffset) ??
|
|
1053
|
+
await detectSahenPotentialDifficultyStem(input, range, baseOffset) ??
|
|
1054
|
+
await detectNominalRenyouPostverbAuxiliaryStem(input, range, baseOffset) ??
|
|
1055
|
+
await detectNominalRenyouMethodYouIdiomStem(input, range, baseOffset) ??
|
|
1056
|
+
await detectDictionaryBackedLexicalSplitStem(input, range, baseOffset);
|
|
1057
|
+
const contractedCausativePassiveStem = virtualCompoundStem === null
|
|
1058
|
+
? await detectContractedGodanCausativePassiveStem(input, range)
|
|
1059
|
+
: null;
|
|
1060
|
+
const contractedNegativeNStem = virtualCompoundStem === null && contractedCausativePassiveStem === null
|
|
1061
|
+
? detectContractedNegativeNStem(input.tokens, range.start, baseOffset)
|
|
1062
|
+
: null;
|
|
1063
|
+
const splitSuppletiveStem = virtualCompoundStem === null && contractedCausativePassiveStem === null && contractedNegativeNStem === null
|
|
1064
|
+
? detectSplitSuppletiveNegativeStem(input.tokens, range.start, baseOffset)
|
|
1065
|
+
: null;
|
|
1066
|
+
return { originalStemToken, virtualCompoundStem, contractedCausativePassiveStem, contractedNegativeNStem, splitSuppletiveStem };
|
|
1067
|
+
}
|
|
1068
|
+
async function resolveClauseStemHead(request, stems) {
|
|
1069
|
+
const { input, range, options } = request;
|
|
1070
|
+
const { originalStemToken, virtualCompoundStem, contractedCausativePassiveStem, contractedNegativeNStem, splitSuppletiveStem } = stems;
|
|
1071
|
+
const stemToken = virtualCompoundStem?.virtualToken ??
|
|
1072
|
+
contractedCausativePassiveStem?.virtualToken ??
|
|
1073
|
+
contractedNegativeNStem?.virtualToken ??
|
|
1074
|
+
splitSuppletiveStem?.virtualToken ??
|
|
1075
|
+
originalStemToken;
|
|
1076
|
+
const stemPos0 = stemToken.pos & POS0;
|
|
1077
|
+
const stemSourceHost = {
|
|
1078
|
+
cursor: new TokenCursor(options.contextTokens ?? input.tokens, 0, (options.contextTokens ?? input.tokens).length, options.contextPos ?? range.start),
|
|
1079
|
+
start: options.contextPos ?? range.start
|
|
1080
|
+
};
|
|
1081
|
+
if (stemPos0 !== 動詞 &&
|
|
1082
|
+
stemPos0 !== 形容詞0 &&
|
|
1083
|
+
stemPos0 !== 形状詞 &&
|
|
1084
|
+
stemPos0 !== 名詞 &&
|
|
1085
|
+
stemPos0 !== 代名詞 &&
|
|
1086
|
+
virtualCompoundStem?.propositionHost !== true &&
|
|
1087
|
+
!(stemPos0 === 副詞 && adverbHostStartsTailChunk(input.tokens, range.start, input.numeric, input.lookups, stemSourceHost))) {
|
|
1088
|
+
return { ok: false, reason: "stem pos[0] not in subset (動詞/形容詞/形状詞/名詞/代名詞/조건부 副詞 — adverbHostStartsTailChunk)" };
|
|
1089
|
+
}
|
|
1090
|
+
const rawEntry = virtualCompoundStem?.entry ??
|
|
1091
|
+
contractedCausativePassiveStem?.entry ??
|
|
1092
|
+
await input.dictionary.lookupTokenRelaxed(stemToken) ??
|
|
1093
|
+
await input.synthesizeEntry?.(stemToken, { nextToken: input.tokens[range.start + 1] ?? null });
|
|
1094
|
+
if (rawEntry === undefined) {
|
|
1095
|
+
return { ok: false, reason: "no dictionary entry for stem" };
|
|
1096
|
+
}
|
|
1097
|
+
const stemKind = virtualCompoundStem?.propositionHost === true
|
|
1098
|
+
? "adj"
|
|
1099
|
+
: stemKindForTailParserSource(input.tokens, range.start, stemPos0, input.numeric, input.lookups, stemSourceHost);
|
|
1100
|
+
const sahenStartCandidate = stemKind === "noun" || stemKind === "verb"
|
|
1101
|
+
? detectSahenPredicateStart(input.tokens, range.start, {
|
|
1102
|
+
tokens: options.contextTokens ?? input.tokens,
|
|
1103
|
+
idx: options.contextPos ?? range.start
|
|
1104
|
+
})
|
|
1105
|
+
: null;
|
|
1106
|
+
const sahenStart = sahenStartCandidate !== null &&
|
|
1107
|
+
(sahenStartCandidate.hostKind === "nominal") === (stemKind === "noun")
|
|
1108
|
+
? sahenStartCandidate
|
|
1109
|
+
: null;
|
|
1110
|
+
const sahenSliceOffset = sahenStart !== null ? 1 : 0;
|
|
1111
|
+
const stemConsumedTokens = virtualCompoundStem?.consumed ?? 1;
|
|
1112
|
+
const followingAuxIndex = range.start + stemConsumedTokens;
|
|
1113
|
+
const inflectingAuxHost = contractedCausativePassiveStem !== null ||
|
|
1114
|
+
contractedNegativeNStem !== null ||
|
|
1115
|
+
splitSuppletiveStem !== null ||
|
|
1116
|
+
(followingAuxIndex <= range.end &&
|
|
1117
|
+
tokenHostsInflectingPredicateAuxiliary(input.tokens[followingAuxIndex]));
|
|
1118
|
+
const nominalTargetPredicateContext = inflectingAuxHost ||
|
|
1119
|
+
(followingAuxIndex <= range.end &&
|
|
1120
|
+
tokenOpensPredicateConnectiveHost(input.tokens[followingAuxIndex]));
|
|
1121
|
+
const entry = await tailParserStemEntry(input.dictionary, stemToken, rawEntry, stemKind, inflectingAuxHost, nominalTargetPredicateContext);
|
|
1122
|
+
return { stemToken, stemPos0, stemKind, sahenSliceOffset, entry };
|
|
1123
|
+
}
|
|
1124
|
+
function clauseStemSenseContext(request, stems) {
|
|
1125
|
+
const { input, range, options } = request;
|
|
1126
|
+
const { virtualCompoundStem, contractedCausativePassiveStem, contractedNegativeNStem, splitSuppletiveStem } = stems;
|
|
1127
|
+
const baseContextTokens = options.contextTokens ?? input.tokens;
|
|
1128
|
+
const baseContextPos = options.contextPos ?? range.start;
|
|
1129
|
+
const contextTokens = virtualCompoundStem !== null
|
|
1130
|
+
? [
|
|
1131
|
+
...baseContextTokens.slice(0, baseContextPos),
|
|
1132
|
+
virtualCompoundStem.virtualToken,
|
|
1133
|
+
...baseContextTokens.slice(baseContextPos + virtualCompoundStem.consumed)
|
|
1134
|
+
]
|
|
1135
|
+
: contractedCausativePassiveStem !== null
|
|
1136
|
+
? [
|
|
1137
|
+
...baseContextTokens.slice(0, baseContextPos),
|
|
1138
|
+
contractedCausativePassiveStem.virtualToken,
|
|
1139
|
+
contractedCausativePassiveStem.causativeToken,
|
|
1140
|
+
...baseContextTokens.slice(baseContextPos + 1)
|
|
1141
|
+
]
|
|
1142
|
+
: contractedNegativeNStem !== null
|
|
1143
|
+
? [
|
|
1144
|
+
...baseContextTokens.slice(0, baseContextPos),
|
|
1145
|
+
contractedNegativeNStem.virtualToken,
|
|
1146
|
+
contractedNegativeNStem.negativeToken,
|
|
1147
|
+
...baseContextTokens.slice(baseContextPos + 1)
|
|
1148
|
+
]
|
|
1149
|
+
: splitSuppletiveStem === null
|
|
1150
|
+
? baseContextTokens
|
|
1151
|
+
: input.tokens;
|
|
1152
|
+
const contextPos = virtualCompoundStem !== null
|
|
1153
|
+
? baseContextPos
|
|
1154
|
+
: contractedCausativePassiveStem !== null
|
|
1155
|
+
? baseContextPos
|
|
1156
|
+
: contractedNegativeNStem !== null
|
|
1157
|
+
? baseContextPos
|
|
1158
|
+
: splitSuppletiveStem === null
|
|
1159
|
+
? baseContextPos
|
|
1160
|
+
: range.start;
|
|
1161
|
+
return { baseContextTokens, baseContextPos, contextTokens, contextPos };
|
|
1162
|
+
}
|
|
1163
|
+
function clauseHeadHypothesisSource(request, stems, head) {
|
|
1164
|
+
const { range, baseOffset } = request;
|
|
1165
|
+
const { virtualCompoundStem } = stems;
|
|
1166
|
+
const { stemToken, sahenSliceOffset } = head;
|
|
1167
|
+
const initialHeadHypothesisSource = {
|
|
1168
|
+
tokens: [stemToken],
|
|
1169
|
+
tokenIndices: [baseOffset + range.start]
|
|
1170
|
+
};
|
|
1171
|
+
const initialHeadHypothesisCapabilities = headSourceCapabilityVector(stemToken);
|
|
1172
|
+
const sourceUsesSahenProjection = sahenSliceOffset === 1 || virtualCompoundStem?.sahenHydration === true;
|
|
1173
|
+
const headHypothesisCapabilities = !sourceUsesSahenProjection || initialHeadHypothesisCapabilities.sahenVerbalizationCapable
|
|
1174
|
+
? initialHeadHypothesisCapabilities
|
|
1175
|
+
: { ...initialHeadHypothesisCapabilities, sahenVerbalizationCapable: true };
|
|
1176
|
+
const sourcePredicateShape = sourcePredicateShapeForCapabilities(headHypothesisCapabilities, sourceUsesSahenProjection);
|
|
1177
|
+
return { initialHeadHypothesisSource, headHypothesisCapabilities, sourceUsesSahenProjection, sourcePredicateShape };
|
|
1178
|
+
}
|
|
1179
|
+
function preserveClauseStemSenseCandidates(request, stems, head, hypothesisSource, senses) {
|
|
1180
|
+
const { input, range, options } = request;
|
|
1181
|
+
const { virtualCompoundStem } = stems;
|
|
1182
|
+
const { stemToken, stemKind, sahenSliceOffset, entry } = head;
|
|
1183
|
+
const { initialHeadHypothesisSource, headHypothesisCapabilities, sourceUsesSahenProjection } = hypothesisSource;
|
|
1184
|
+
const adverbialSurfacePostverbKind = sourceAdverbialSurfacePostverbKind(input.tokens, range.start);
|
|
1185
|
+
const adverbialSurfaceBridgeActive = adverbialSurfacePostverbKind !== null &&
|
|
1186
|
+
adverbialSurfaceCandidateSetCanBridge(senses, adverbialSurfacePostverbKind);
|
|
1187
|
+
const tailSenses = [];
|
|
1188
|
+
const allowInternalObjectMarkerPrefix = virtualCompoundStem !== null ||
|
|
1189
|
+
rangeHasMonoNoConcessiveConnective(input.cursor, range) ||
|
|
1190
|
+
(options.outgoingBoundary?.kind !== "terminal" &&
|
|
1191
|
+
options.outgoingBoundary?.connectiveKind === "concession" &&
|
|
1192
|
+
options.outgoingBoundary.surface === "ものの");
|
|
1193
|
+
const incompatibleTranslationReasons = [];
|
|
1194
|
+
const headHypothesisCandidates = [];
|
|
1195
|
+
const conjForVerb = stemKind === "verb"
|
|
1196
|
+
? mapConjType(entry.conjugationType ?? 0)
|
|
1197
|
+
: undefined;
|
|
1198
|
+
const usesSahenProjection = sourceUsesSahenProjection;
|
|
1199
|
+
const sahenProjectionSourceSurface = usesSahenProjection
|
|
1200
|
+
? input.tokens[range.start]?.dictionaryForm ?? input.tokens[range.start]?.surface ?? ""
|
|
1201
|
+
: "";
|
|
1202
|
+
const sahenProjectionOptions = usesSahenProjection
|
|
1203
|
+
? {
|
|
1204
|
+
followingAgentiveAux: sahenPredicateHasFollowingAgentiveAux(input.tokens, range.start + sahenSliceOffset, input.lookups)
|
|
1205
|
+
}
|
|
1206
|
+
: {};
|
|
1207
|
+
const allocateHeadProjectionOrdinal = tailParserProjectionOrdinalAllocator(senses, entry);
|
|
1208
|
+
for (const [candidateIndex, t] of senses.entries()) {
|
|
1209
|
+
const candidateStemKind = tailParserStemKindForTranslation(t, stemKind);
|
|
1210
|
+
const projectedTranslationBase = t;
|
|
1211
|
+
const projectedTranslation = projectKotodakaraReasonScopeStemTranslation(projectedTranslationBase, stemToken, input.tokens, range.start, stemKind);
|
|
1212
|
+
const normalizedStem = normalizeTailParserStemKorean(projectedTranslation.korean, candidateStemKind, {
|
|
1213
|
+
allowInternalObjectMarkerPrefix,
|
|
1214
|
+
allowLexicalNegativePrefix: projectedTranslation.dropFirstNegativeAux === true
|
|
1215
|
+
});
|
|
1216
|
+
const projectedPreservedCandidate = stemCandidateFromTranslation(projectedTranslation, stemKind, conjForVerb, { entry });
|
|
1217
|
+
if (normalizedStem === null) {
|
|
1218
|
+
const reason = `multi-word lemma '${projectedTranslation.korean}' — out of subset`;
|
|
1219
|
+
incompatibleTranslationReasons.push(reason);
|
|
1220
|
+
headHypothesisCandidates.push(headHypothesisCandidateFromTranslation(projectedTranslation, candidateIndex, {
|
|
1221
|
+
sourceStemKind: stemKind,
|
|
1222
|
+
sourceCapabilities: headHypothesisCapabilities,
|
|
1223
|
+
status: "dropped",
|
|
1224
|
+
stage: "lemma_normalization",
|
|
1225
|
+
projectedStemKind: candidateStemKind,
|
|
1226
|
+
preservedCandidate: projectedPreservedCandidate,
|
|
1227
|
+
reason
|
|
1228
|
+
}));
|
|
1229
|
+
continue;
|
|
1230
|
+
}
|
|
1231
|
+
const admittedTranslation = {
|
|
1232
|
+
...projectedTranslation,
|
|
1233
|
+
korean: normalizedStem.korean,
|
|
1234
|
+
...(normalizedStem.koreanPrefix === undefined
|
|
1235
|
+
? {}
|
|
1236
|
+
: { koreanPrefix: `${projectedTranslation.koreanPrefix ?? ""}${normalizedStem.koreanPrefix}` })
|
|
1237
|
+
};
|
|
1238
|
+
tailSenses.push(admittedTranslation);
|
|
1239
|
+
if (usesSahenProjection) {
|
|
1240
|
+
for (const projection of sahenStemProjectionCandidates(admittedTranslation, sahenProjectionSourceSurface, input.lookups, () => allocateHeadProjectionOrdinal(stemCandidateProvenanceForTranslation(admittedTranslation, derivationForSense(admittedTranslation, entry))), sahenProjectionOptions)) {
|
|
1241
|
+
const preservedCandidate = stemCandidateFromTranslation(admittedTranslation, "noun", undefined, { ...projection, entry });
|
|
1242
|
+
headHypothesisCandidates.push(headHypothesisCandidateFromTranslation(admittedTranslation, headHypothesisCandidates.length, {
|
|
1243
|
+
sourceStemKind: stemKind,
|
|
1244
|
+
sourceCapabilities: headHypothesisCapabilities,
|
|
1245
|
+
status: "admitted",
|
|
1246
|
+
stage: "lemma_normalization",
|
|
1247
|
+
lemma: preservedCandidate.lemma,
|
|
1248
|
+
projectedStemKind: projection.stemKind ?? tailParserStemKindForTranslation(admittedTranslation, stemKind),
|
|
1249
|
+
preservedCandidate,
|
|
1250
|
+
adverbialModifierContext: options.allowAdverbialModifierTerminal !== undefined,
|
|
1251
|
+
adverbialSurfaceBridgeContext: adverbialSurfacePostverbKind !== null,
|
|
1252
|
+
adverbialSurfaceBridgeAllowed: adverbialSurfaceBridgeActive
|
|
1253
|
+
}));
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
else {
|
|
1257
|
+
headHypothesisCandidates.push(headHypothesisCandidateFromTranslation(projectedTranslation, candidateIndex, {
|
|
1258
|
+
sourceStemKind: stemKind,
|
|
1259
|
+
sourceCapabilities: headHypothesisCapabilities,
|
|
1260
|
+
status: "admitted",
|
|
1261
|
+
stage: "lemma_normalization",
|
|
1262
|
+
lemma: normalizedStem.korean,
|
|
1263
|
+
projectedStemKind: candidateStemKind,
|
|
1264
|
+
preservedCandidate: stemCandidateFromTranslation(admittedTranslation, stemKind, conjForVerb, { entry }),
|
|
1265
|
+
adverbialModifierContext: options.allowAdverbialModifierTerminal !== undefined,
|
|
1266
|
+
adverbialSurfaceBridgeContext: adverbialSurfacePostverbKind !== null,
|
|
1267
|
+
adverbialSurfaceBridgeAllowed: adverbialSurfaceBridgeActive
|
|
1268
|
+
}));
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
if (tailSenses.length === 0) {
|
|
1272
|
+
return {
|
|
1273
|
+
ok: false,
|
|
1274
|
+
reason: incompatibleTranslationReasons[0] ?? "no compatible tail-parser stem senses",
|
|
1275
|
+
headHypothesis: buildHeadHypothesisCarrier({
|
|
1276
|
+
sourceStemKind: stemKind,
|
|
1277
|
+
admittedStemKind: stemKind,
|
|
1278
|
+
source: initialHeadHypothesisSource,
|
|
1279
|
+
sourceCapabilities: headHypothesisCapabilities,
|
|
1280
|
+
originalCandidateCount: senses.length,
|
|
1281
|
+
candidates: headHypothesisCandidates
|
|
1282
|
+
})
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
return { tailSenses, headHypothesisCandidates, conjForVerb, usesSahenProjection, adverbialSurfaceBridgeActive };
|
|
1286
|
+
}
|
|
1287
|
+
function admitClauseStemIntake(request, head, hypothesisSource, preserved, senses) {
|
|
1288
|
+
const { input, range } = request;
|
|
1289
|
+
const { stemToken, stemPos0, stemKind } = head;
|
|
1290
|
+
const { initialHeadHypothesisSource, headHypothesisCapabilities } = hypothesisSource;
|
|
1291
|
+
const { headHypothesisCandidates } = preserved;
|
|
1292
|
+
const currentWinnerIndex = headHypothesisCandidates.find((candidate) => candidate.status === "admitted")?.index;
|
|
1293
|
+
const intakeHeadHypothesis = buildHeadHypothesisCarrier({
|
|
1294
|
+
sourceStemKind: stemKind,
|
|
1295
|
+
admittedStemKind: stemKind,
|
|
1296
|
+
source: initialHeadHypothesisSource,
|
|
1297
|
+
sourceCapabilities: headHypothesisCapabilities,
|
|
1298
|
+
originalCandidateCount: senses.length,
|
|
1299
|
+
candidates: headHypothesisCandidates,
|
|
1300
|
+
...(currentWinnerIndex === undefined ? {} : { currentWinnerIndex })
|
|
1301
|
+
});
|
|
1302
|
+
if (!headHypothesisCandidates.some(candidateHasAdmittedHeadCapability)) {
|
|
1303
|
+
return {
|
|
1304
|
+
ok: false,
|
|
1305
|
+
reason: "admitted dictionary candidates expose no carrier head capability",
|
|
1306
|
+
headHypothesis: intakeHeadHypothesis
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
if (stemKind !== "noun" &&
|
|
1310
|
+
stemPos0 !== 形状詞 &&
|
|
1311
|
+
stemPos0 !== 副詞 &&
|
|
1312
|
+
!sourceHasFormalToStateResultCarrier(input.tokens, range.start)) {
|
|
1313
|
+
const stemPos5A = stemToken.pos & POS5A;
|
|
1314
|
+
if (stemPos5A !== 0 && !isStemFormInSubset(stemPos5A, input.tokens, range.start)) {
|
|
1315
|
+
return {
|
|
1316
|
+
ok: false,
|
|
1317
|
+
reason: `stem form '${stemPos5A}' — out of subset`,
|
|
1318
|
+
headHypothesis: intakeHeadHypothesis
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
return { currentWinnerIndex, intakeHeadHypothesis };
|
|
1323
|
+
}
|
|
1324
|
+
function buildClauseStemInput(request, stems, head, hypothesisSource, preserved, senses) {
|
|
1325
|
+
const { input, range, options } = request;
|
|
1326
|
+
const { virtualCompoundStem, splitSuppletiveStem } = stems;
|
|
1327
|
+
const { stemKind, sahenSliceOffset, entry } = head;
|
|
1328
|
+
const { sourcePredicateShape } = hypothesisSource;
|
|
1329
|
+
const { tailSenses, conjForVerb, usesSahenProjection, adverbialSurfaceBridgeActive } = preserved;
|
|
1330
|
+
const trans = tailSenses[0];
|
|
1331
|
+
let stem;
|
|
1332
|
+
if (usesSahenProjection) {
|
|
1333
|
+
const sahenNounToken = input.tokens[range.start];
|
|
1334
|
+
const sahenNounSurface = sahenNounToken?.dictionaryForm ?? sahenNounToken?.surface ?? "";
|
|
1335
|
+
const allocateStemProjectionOrdinal = tailParserProjectionOrdinalAllocator(senses, entry);
|
|
1336
|
+
const candidates = tailSenses.flatMap(t => sahenStemProjectionCandidates(t, sahenNounSurface, input.lookups, () => allocateStemProjectionOrdinal(stemCandidateProvenanceForTranslation(t, derivationForSense(t, entry))), {
|
|
1337
|
+
followingAgentiveAux: sahenPredicateHasFollowingAgentiveAux(input.tokens, range.start + Math.max(1, sahenSliceOffset), input.lookups)
|
|
1338
|
+
})
|
|
1339
|
+
.map(projection => stemCandidateFromTranslation(t, "noun", undefined, { ...projection, entry })));
|
|
1340
|
+
stem = candidates.length === 1 && !stemCandidateNeedsDeferredCommit(candidates[0])
|
|
1341
|
+
? stemInputFromCandidate(candidates[0], "verb")
|
|
1342
|
+
: { kind: "candidateSet", candidates };
|
|
1343
|
+
}
|
|
1344
|
+
else if (stemKind === "noun") {
|
|
1345
|
+
const containsPredicateCandidate = tailSenses.some(t => tailParserStemKindForTranslation(t, stemKind) !== "noun");
|
|
1346
|
+
const adverbialCandidateSetContext = adverbialSurfaceBridgeActive || options.allowAdverbialModifierTerminal !== undefined;
|
|
1347
|
+
const requiresAdverbialCommitSelection = adverbialCandidateSetContext &&
|
|
1348
|
+
tailSenses.some(t => t.koreanPos === 부사);
|
|
1349
|
+
const singleCandidate = tailSenses.length === 1
|
|
1350
|
+
? stemCandidateFromTranslation(trans, "noun", undefined, { entry })
|
|
1351
|
+
: null;
|
|
1352
|
+
stem = singleCandidate !== null &&
|
|
1353
|
+
!requiresAdverbialCommitSelection &&
|
|
1354
|
+
!stemTranslationNeedsCommitSelection(trans, stemKind) &&
|
|
1355
|
+
!containsPredicateCandidate &&
|
|
1356
|
+
!stemCandidateNeedsDeferredCommit(singleCandidate)
|
|
1357
|
+
? {
|
|
1358
|
+
kind: "noun",
|
|
1359
|
+
lemma: trans.korean,
|
|
1360
|
+
...nounStemInterjectionForCandidate(singleCandidate),
|
|
1361
|
+
...(trans.koreanPrefix === undefined ? {} : { koreanPrefix: trans.koreanPrefix }),
|
|
1362
|
+
...(trans.koreanSuffix === undefined ? {} : { koreanSuffix: trans.koreanSuffix })
|
|
1363
|
+
}
|
|
1364
|
+
: {
|
|
1365
|
+
kind: "candidateSet",
|
|
1366
|
+
candidates: tailSenses.map(t => stemCandidateFromTranslation(t, "noun", undefined, { entry }))
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
else if (tailSenses.length === 1 && !stemTranslationNeedsCommitSelection(trans, stemKind)) {
|
|
1370
|
+
const singleCandidate = stemCandidateFromTranslation(trans, stemKind, conjForVerb, { entry });
|
|
1371
|
+
stem = !stemCandidateNeedsDeferredCommit(singleCandidate)
|
|
1372
|
+
? stemInputFromCandidate(singleCandidate, stemKind)
|
|
1373
|
+
: { kind: "candidateSet", candidates: [singleCandidate] };
|
|
1374
|
+
}
|
|
1375
|
+
else {
|
|
1376
|
+
stem = {
|
|
1377
|
+
kind: "candidateSet",
|
|
1378
|
+
candidates: tailSenses.map(t => stemCandidateFromTranslation(t, stemKind, conjForVerb, { entry }))
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
const suppletiveFirstNegIdx = splitSuppletiveStem?.firstNegIdx ?? (range.start + 1);
|
|
1382
|
+
const suppletiveBase = suppletiveBaseStemForMaterialization(stem, tailSenses, stemKind, conjForVerb);
|
|
1383
|
+
const suppletiveMaterialization = sahenSliceOffset === 0 && suppletiveBase !== null
|
|
1384
|
+
? materializeSuppletiveNegationStem(input.tokens, suppletiveFirstNegIdx, suppletiveBase.stem, suppletiveBase.korean, input.lookups)
|
|
1385
|
+
: null;
|
|
1386
|
+
if (suppletiveMaterialization !== null) {
|
|
1387
|
+
stem = suppletiveMaterialization.stem;
|
|
1388
|
+
}
|
|
1389
|
+
stem = confineNominalTargetMarkToAdjectivalSource({ ...stem, sourcePredicateShape }, sourcePredicateShape);
|
|
1390
|
+
if (virtualCompoundStem?.numericBase !== undefined && stem.kind === "noun") {
|
|
1391
|
+
stem = { ...stem, numericBase: virtualCompoundStem.numericBase };
|
|
1392
|
+
}
|
|
1393
|
+
if (virtualCompoundStem?.pronominalNoHeadBase !== undefined && stem.kind === "noun") {
|
|
1394
|
+
stem = { ...stem, pronominalNoHeadBase: virtualCompoundStem.pronominalNoHeadBase };
|
|
1395
|
+
}
|
|
1396
|
+
return { stem, suppletiveMaterialization };
|
|
1397
|
+
}
|
|
1398
|
+
function buildClauseParseSlice(request, stems, head, stemBuild) {
|
|
1399
|
+
const { input, range } = request;
|
|
1400
|
+
const { originalStemToken, virtualCompoundStem, contractedCausativePassiveStem, contractedNegativeNStem, splitSuppletiveStem } = stems;
|
|
1401
|
+
const { sahenSliceOffset } = head;
|
|
1402
|
+
const { suppletiveMaterialization } = stemBuild;
|
|
1403
|
+
const effectiveSliceOffset = suppletiveMaterialization?.sliceOffset ?? sahenSliceOffset;
|
|
1404
|
+
const suppletivePoliteNegative = suppletiveMaterialization?.politeNegative;
|
|
1405
|
+
const virtualTailStart = virtualCompoundStem === null
|
|
1406
|
+
? null
|
|
1407
|
+
: range.start + virtualCompoundStem.consumed;
|
|
1408
|
+
const splitTailStart = splitSuppletiveStem === null
|
|
1409
|
+
? null
|
|
1410
|
+
: splitSuppletiveStem.firstNegIdx + effectiveSliceOffset;
|
|
1411
|
+
const parseSlice = virtualCompoundStem !== null
|
|
1412
|
+
? [virtualCompoundStem.virtualToken, ...input.tokens.slice(virtualTailStart, range.end + 1)]
|
|
1413
|
+
: contractedCausativePassiveStem !== null
|
|
1414
|
+
? [
|
|
1415
|
+
contractedCausativePassiveStem.virtualToken,
|
|
1416
|
+
contractedCausativePassiveStem.causativeToken,
|
|
1417
|
+
...input.tokens.slice(range.start + 1, range.end + 1)
|
|
1418
|
+
]
|
|
1419
|
+
: contractedNegativeNStem !== null
|
|
1420
|
+
? [
|
|
1421
|
+
contractedNegativeNStem.virtualToken,
|
|
1422
|
+
contractedNegativeNStem.negativeToken,
|
|
1423
|
+
...input.tokens.slice(range.start + 1, range.end + 1)
|
|
1424
|
+
]
|
|
1425
|
+
: splitSuppletiveStem === null
|
|
1426
|
+
? suppletivePoliteNegative !== undefined
|
|
1427
|
+
? [
|
|
1428
|
+
originalStemToken,
|
|
1429
|
+
input.tokens[suppletivePoliteNegative.politeIdx],
|
|
1430
|
+
...input.tokens.slice(suppletivePoliteNegative.negIdx + 1, range.end + 1)
|
|
1431
|
+
]
|
|
1432
|
+
: input.tokens.slice(range.start + effectiveSliceOffset, range.end + 1)
|
|
1433
|
+
: [splitSuppletiveStem.virtualToken, ...input.tokens.slice(splitTailStart, range.end + 1)];
|
|
1434
|
+
return { effectiveSliceOffset, suppletivePoliteNegative, virtualTailStart, splitTailStart, parseSlice };
|
|
1435
|
+
}
|
|
1436
|
+
function buildClauseStemSourceAnchors(request, stems, head, stemBuild, slice) {
|
|
1437
|
+
const { input, range, baseOffset } = request;
|
|
1438
|
+
const { originalStemToken, virtualCompoundStem, contractedCausativePassiveStem, contractedNegativeNStem, splitSuppletiveStem } = stems;
|
|
1439
|
+
const { sahenSliceOffset } = head;
|
|
1440
|
+
const { suppletiveMaterialization } = stemBuild;
|
|
1441
|
+
const { effectiveSliceOffset, suppletivePoliteNegative, virtualTailStart, splitTailStart, parseSlice } = slice;
|
|
1442
|
+
const isSahen = sahenSliceOffset === 1;
|
|
1443
|
+
const suppletiveUsesOriginalStemToken = suppletiveMaterialization !== null && effectiveSliceOffset === 0 && splitSuppletiveStem === null;
|
|
1444
|
+
const splitStemSource = splitSuppletiveStem === null
|
|
1445
|
+
? undefined
|
|
1446
|
+
: {
|
|
1447
|
+
tokens: [
|
|
1448
|
+
...splitSuppletiveStem.stemSourceTokens,
|
|
1449
|
+
...(effectiveSliceOffset > 0 ? [input.tokens[splitSuppletiveStem.firstNegIdx]] : [])
|
|
1450
|
+
],
|
|
1451
|
+
tokenIndices: [
|
|
1452
|
+
...splitSuppletiveStem.stemSourceTokenIndices,
|
|
1453
|
+
...(effectiveSliceOffset > 0 ? [baseOffset + splitSuppletiveStem.firstNegIdx] : [])
|
|
1454
|
+
]
|
|
1455
|
+
};
|
|
1456
|
+
const contractedNegativeStemSource = contractedNegativeNStem === null
|
|
1457
|
+
? undefined
|
|
1458
|
+
: {
|
|
1459
|
+
tokens: contractedNegativeNStem.stemSourceTokens,
|
|
1460
|
+
tokenIndices: contractedNegativeNStem.stemSourceTokenIndices
|
|
1461
|
+
};
|
|
1462
|
+
const virtualCompoundStemSource = virtualCompoundStem === null
|
|
1463
|
+
? undefined
|
|
1464
|
+
: {
|
|
1465
|
+
tokens: virtualCompoundStem.stemSourceTokens,
|
|
1466
|
+
tokenIndices: virtualCompoundStem.stemSourceTokenIndices
|
|
1467
|
+
};
|
|
1468
|
+
const suppletivePoliteNegativeStemSource = suppletivePoliteNegative === undefined
|
|
1469
|
+
? undefined
|
|
1470
|
+
: {
|
|
1471
|
+
tokens: [originalStemToken, input.tokens[suppletivePoliteNegative.negIdx]],
|
|
1472
|
+
tokenIndices: [baseOffset + range.start, baseOffset + suppletivePoliteNegative.negIdx]
|
|
1473
|
+
};
|
|
1474
|
+
const virtualCompoundSourceIndexMap = virtualCompoundStem === null
|
|
1475
|
+
? undefined
|
|
1476
|
+
: [
|
|
1477
|
+
baseOffset + range.start,
|
|
1478
|
+
...input.tokens
|
|
1479
|
+
.slice(virtualTailStart, range.end + 1)
|
|
1480
|
+
.map((_, idx) => baseOffset + virtualTailStart + idx)
|
|
1481
|
+
];
|
|
1482
|
+
const contractedCausativePassiveSourceIndexMap = contractedCausativePassiveStem === null
|
|
1483
|
+
? undefined
|
|
1484
|
+
: [
|
|
1485
|
+
baseOffset + range.start,
|
|
1486
|
+
baseOffset + range.start,
|
|
1487
|
+
...input.tokens
|
|
1488
|
+
.slice(range.start + 1, range.end + 1)
|
|
1489
|
+
.map((_, idx) => baseOffset + range.start + 1 + idx)
|
|
1490
|
+
];
|
|
1491
|
+
const contractedNegativeNSourceIndexMap = contractedNegativeNStem === null
|
|
1492
|
+
? undefined
|
|
1493
|
+
: [
|
|
1494
|
+
baseOffset + range.start,
|
|
1495
|
+
baseOffset + range.start,
|
|
1496
|
+
...input.tokens
|
|
1497
|
+
.slice(range.start + 1, range.end + 1)
|
|
1498
|
+
.map((_, idx) => baseOffset + range.start + 1 + idx)
|
|
1499
|
+
];
|
|
1500
|
+
const splitSourceIndexMap = splitSuppletiveStem === null
|
|
1501
|
+
? undefined
|
|
1502
|
+
: [
|
|
1503
|
+
baseOffset + range.start,
|
|
1504
|
+
...input.tokens
|
|
1505
|
+
.slice(splitTailStart, range.end + 1)
|
|
1506
|
+
.map((_, idx) => baseOffset + splitTailStart + idx)
|
|
1507
|
+
];
|
|
1508
|
+
const suppletivePoliteNegativeSourceIndexMap = suppletivePoliteNegative === undefined
|
|
1509
|
+
? undefined
|
|
1510
|
+
: [
|
|
1511
|
+
baseOffset + range.start,
|
|
1512
|
+
baseOffset + suppletivePoliteNegative.politeIdx,
|
|
1513
|
+
...input.tokens
|
|
1514
|
+
.slice(suppletivePoliteNegative.negIdx + 1, range.end + 1)
|
|
1515
|
+
.map((_, idx) => baseOffset + suppletivePoliteNegative.negIdx + 1 + idx)
|
|
1516
|
+
];
|
|
1517
|
+
const sourceIndexMap = virtualCompoundSourceIndexMap ??
|
|
1518
|
+
contractedCausativePassiveSourceIndexMap ??
|
|
1519
|
+
contractedNegativeNSourceIndexMap ??
|
|
1520
|
+
splitSourceIndexMap ??
|
|
1521
|
+
suppletivePoliteNegativeSourceIndexMap;
|
|
1522
|
+
const parseSliceInput = expandFusedDashiCopulaListingParseSlice(parseSlice, sourceIndexMap, parseSlice.map((_, idx) => baseOffset + range.start + effectiveSliceOffset + idx));
|
|
1523
|
+
const stemSourceOverride = virtualCompoundStemSource ??
|
|
1524
|
+
contractedNegativeStemSource ??
|
|
1525
|
+
splitStemSource ??
|
|
1526
|
+
suppletivePoliteNegativeStemSource;
|
|
1527
|
+
const prependSource = virtualCompoundStem !== null
|
|
1528
|
+
? undefined
|
|
1529
|
+
: suppletiveMaterialization !== null && !suppletiveUsesOriginalStemToken && splitSuppletiveStem === null
|
|
1530
|
+
? {
|
|
1531
|
+
tokens: [originalStemToken],
|
|
1532
|
+
tokenIndices: [baseOffset + range.start]
|
|
1533
|
+
}
|
|
1534
|
+
: isSahen
|
|
1535
|
+
? {
|
|
1536
|
+
tokens: [originalStemToken],
|
|
1537
|
+
tokenIndices: [baseOffset + range.start]
|
|
1538
|
+
}
|
|
1539
|
+
: undefined;
|
|
1540
|
+
const conjugationAnchor = virtualCompoundStemSource !== undefined
|
|
1541
|
+
? virtualCompoundStemSource.tokens.length - 1
|
|
1542
|
+
: contractedNegativeStemSource !== undefined
|
|
1543
|
+
? 0
|
|
1544
|
+
: splitStemSource !== undefined
|
|
1545
|
+
? splitStemSource.tokens.length - 1
|
|
1546
|
+
: suppletivePoliteNegativeStemSource !== undefined
|
|
1547
|
+
? 0
|
|
1548
|
+
: suppletiveMaterialization !== null && !suppletiveUsesOriginalStemToken
|
|
1549
|
+
? 1
|
|
1550
|
+
: isSahen ? 1 : undefined;
|
|
1551
|
+
const semanticAnchors = virtualCompoundStemSource !== undefined
|
|
1552
|
+
? Array.from({ length: virtualCompoundStemSource.tokens.length }, (_, idx) => idx)
|
|
1553
|
+
: contractedNegativeStemSource !== undefined
|
|
1554
|
+
? [0]
|
|
1555
|
+
: splitStemSource !== undefined
|
|
1556
|
+
? Array.from({ length: splitSuppletiveStem.stemSourceTokens.length }, (_, idx) => idx)
|
|
1557
|
+
: suppletivePoliteNegativeStemSource !== undefined
|
|
1558
|
+
? [0, 1]
|
|
1559
|
+
: suppletiveMaterialization !== null && !suppletiveUsesOriginalStemToken
|
|
1560
|
+
? [0]
|
|
1561
|
+
: isSahen ? [0] : undefined;
|
|
1562
|
+
return { parseSliceInput, stemSourceOverride, prependSource, conjugationAnchor, semanticAnchors };
|
|
1563
|
+
}
|
|
1564
|
+
function parseClauseTail(request, head, hypothesisSource, preserved, intake, stemBuild, slice, anchors, senseContext, senses) {
|
|
1565
|
+
const { input, range, baseOffset, options } = request;
|
|
1566
|
+
const { stemKind } = head;
|
|
1567
|
+
const { initialHeadHypothesisSource, headHypothesisCapabilities } = hypothesisSource;
|
|
1568
|
+
const { headHypothesisCandidates, usesSahenProjection } = preserved;
|
|
1569
|
+
const { currentWinnerIndex } = intake;
|
|
1570
|
+
const { stem } = stemBuild;
|
|
1571
|
+
const { effectiveSliceOffset } = slice;
|
|
1572
|
+
const { parseSliceInput, stemSourceOverride, prependSource, conjugationAnchor, semanticAnchors } = anchors;
|
|
1573
|
+
const { baseContextTokens } = senseContext;
|
|
1574
|
+
const headHypothesis = buildHeadHypothesisCarrier({
|
|
1575
|
+
sourceStemKind: stemKind,
|
|
1576
|
+
admittedStemKind: usesSahenProjection
|
|
1577
|
+
? "verb"
|
|
1578
|
+
: stem.kind === "candidateSet"
|
|
1579
|
+
? stemKind
|
|
1580
|
+
: stem.kind,
|
|
1581
|
+
source: stemSourceOverride ?? prependSource ?? initialHeadHypothesisSource,
|
|
1582
|
+
sourceCapabilities: headHypothesisCapabilities,
|
|
1583
|
+
originalCandidateCount: senses.length,
|
|
1584
|
+
candidates: headHypothesisCandidates,
|
|
1585
|
+
...(currentWinnerIndex === undefined ? {} : { currentWinnerIndex })
|
|
1586
|
+
});
|
|
1587
|
+
const outgoingBoundaryHint = parseOutgoingBoundaryHint(options.outgoingBoundary);
|
|
1588
|
+
const quoteAttributiveHeadFrame = quoteAttributiveHeadFrameForBoundary(options.attributiveBoundaryPayload ?? outgoingBoundaryHint?.attributiveBoundary, input.lookups);
|
|
1589
|
+
const parsed = parseTail({
|
|
1590
|
+
tokens: parseSliceInput.tokens,
|
|
1591
|
+
start: 0,
|
|
1592
|
+
stem,
|
|
1593
|
+
headHypothesis,
|
|
1594
|
+
lookups: input.lookups,
|
|
1595
|
+
allowElidedColloquialObligation: options.allowElidedColloquialObligation ?? true,
|
|
1596
|
+
allowRenyouChuushiTerminal: options.allowRenyouChuushiTerminal === true,
|
|
1597
|
+
...(options.renyouChuushiTerminalRole === undefined ? {} : { renyouChuushiTerminalRole: options.renyouChuushiTerminalRole }),
|
|
1598
|
+
allowMalformedConditionalFragmentTerminal: options.allowMalformedConditionalFragmentTerminal === true,
|
|
1599
|
+
allowPlainNominalizerTerminal: options.allowPlainNominalizerTerminal === true,
|
|
1600
|
+
...(options.allowElidedDewaNegativeBody === undefined ? {} : { allowElidedDewaNegativeBody: options.allowElidedDewaNegativeBody }),
|
|
1601
|
+
allowElidedNominalizerTerminal: options.allowElidedNominalizerTerminal === true,
|
|
1602
|
+
allowZeroNiPurposeTerminal: options.allowZeroNiPurposeTerminal === true,
|
|
1603
|
+
allowAdnominalCopulaTerminal: options.allowAdnominalCopulaTerminal === true,
|
|
1604
|
+
allowRenyouCompoundPrenominalTerminal: options.allowRenyouCompoundPrenominalTerminal === true,
|
|
1605
|
+
allowExplicitAdnominalNoTerminal: options.allowExplicitAdnominalNoTerminal === true,
|
|
1606
|
+
...(options.allowAdverbialModifierTerminal === undefined ? {} : { allowAdverbialModifierTerminal: options.allowAdverbialModifierTerminal }),
|
|
1607
|
+
allowNoQuoteReportingProjection: options.allowNoQuoteReportingProjection === true,
|
|
1608
|
+
...(outgoingBoundaryHint === undefined ? {} : { outgoingBoundaryHint }),
|
|
1609
|
+
...(quoteAttributiveHeadFrame === undefined ? {} : { quoteAttributiveHeadFrame }),
|
|
1610
|
+
...(options.suppressFormalToSuruControl === true ? { suppressFormalToSuruControl: true } : {}),
|
|
1611
|
+
...(options.quotedNominalHost === true ? { quotedNominalHost: true } : {}),
|
|
1612
|
+
streamStart: baseOffset + range.start + effectiveSliceOffset,
|
|
1613
|
+
...(parseSliceInput.sourceIndexMap !== undefined ? { sourceIndexMap: parseSliceInput.sourceIndexMap } : {}),
|
|
1614
|
+
...(options.contextTokens !== undefined ? { contextTokens: options.contextTokens } : {}),
|
|
1615
|
+
...(() => {
|
|
1616
|
+
const relationIndex = cachedCanonicalReformulationMarkerRelationIndex(baseContextTokens, request.input.lookups);
|
|
1617
|
+
return relationIndex === null
|
|
1618
|
+
? {}
|
|
1619
|
+
: { canonicalReformulationMarkerRelations: relationIndex };
|
|
1620
|
+
})(),
|
|
1621
|
+
...(stemSourceOverride !== undefined ? { stemSourceOverride } : {}),
|
|
1622
|
+
...(prependSource !== undefined ? { prependSource } : {}),
|
|
1623
|
+
...(conjugationAnchor !== undefined ? { conjugationAnchor } : {}),
|
|
1624
|
+
...(semanticAnchors !== undefined ? { semanticAnchors } : {})
|
|
1625
|
+
});
|
|
1626
|
+
return { headHypothesis, parsed };
|
|
1627
|
+
}
|
|
1628
|
+
function rejectUnlicensedParsedClause(request, parsed, headHypothesis, fullContextTokens) {
|
|
1629
|
+
const { range, baseOffset } = request;
|
|
1630
|
+
const parsedLayer = firstAuxLayer(parsed.root.tail);
|
|
1631
|
+
const firstParsedOp = parsedLayer?.ops[0];
|
|
1632
|
+
if (parsedLayer?.stem.kind === "noun" &&
|
|
1633
|
+
firstParsedOp?.kind === "connective" &&
|
|
1634
|
+
firstParsedOp.connective === "even_if") {
|
|
1635
|
+
const markerIdx = firstParsedOp.source.tokenIndices[0];
|
|
1636
|
+
const relation = markerIdx === undefined
|
|
1637
|
+
? null
|
|
1638
|
+
: dewaScopeBridgeRelationAt(fullContextTokens, markerIdx, {
|
|
1639
|
+
anchorIdx: markerIdx,
|
|
1640
|
+
consumers: ["tail_multi_clause"]
|
|
1641
|
+
});
|
|
1642
|
+
const negativeTail = relation === null
|
|
1643
|
+
? undefined
|
|
1644
|
+
: fullContextTokens[relation.span.endExclusive];
|
|
1645
|
+
if (negativeTail !== undefined && isNaiOrNuToken(negativeTail)) {
|
|
1646
|
+
return {
|
|
1647
|
+
ok: false,
|
|
1648
|
+
reason: "bare demo concession cannot preempt a following negative scope bridge tail",
|
|
1649
|
+
headHypothesis
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
if (plainTePermissionAttributiveBlocked(parsed.root, fullContextTokens, baseOffset + range.end)) {
|
|
1654
|
+
return {
|
|
1655
|
+
ok: false,
|
|
1656
|
+
reason: "plain te-permission attributive head not licensed",
|
|
1657
|
+
headHypothesis
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
return null;
|
|
1661
|
+
}
|
|
1662
|
+
function finishParsedClause(request, stems, senseContext, slice, anchors, parsed, headHypothesis, fullContextTokens) {
|
|
1663
|
+
const { input, range, baseOffset } = request;
|
|
1664
|
+
const { virtualCompoundStem, splitSuppletiveStem } = stems;
|
|
1665
|
+
const { baseContextTokens, baseContextPos } = senseContext;
|
|
1666
|
+
const { effectiveSliceOffset } = slice;
|
|
1667
|
+
const { parseSliceInput } = anchors;
|
|
1668
|
+
const partialAttributiveBoundary = parsed.consumed !== parseSliceInput.tokens.length &&
|
|
1669
|
+
partialParseEndsAtAttributiveBoundaryHead(parsed.root, parsed.consumed);
|
|
1670
|
+
const partialQuoteBoundary = parsed.consumed !== parseSliceInput.tokens.length &&
|
|
1671
|
+
parsed.root.sfp !== null &&
|
|
1672
|
+
partialParseRemainderIsOwnedQuoteMarker({
|
|
1673
|
+
parsedConsumed: parsed.consumed,
|
|
1674
|
+
parseLength: parseSliceInput.tokens.length,
|
|
1675
|
+
...(parseSliceInput.sourceIndexMap === undefined ? {} : { sourceIndexMap: parseSliceInput.sourceIndexMap }),
|
|
1676
|
+
baseOffset,
|
|
1677
|
+
rangeStart: range.start,
|
|
1678
|
+
effectiveSliceOffset,
|
|
1679
|
+
contextTokens: fullContextTokens,
|
|
1680
|
+
lookups: input.lookups,
|
|
1681
|
+
});
|
|
1682
|
+
const parsedRoot = rewriteKotodashiReasonScopeRoot(materializeNominalZeroCopulaPredicate(parsed.root, input.cursor, range.start, input.numeric, input.lookups, { cursor: new TokenCursor(baseContextTokens, 0, baseContextTokens.length, baseContextPos), start: baseContextPos }), input.tokens, range.start);
|
|
1683
|
+
const derivationalLowering = lowerDerivationalSuffixRoot(parsedRoot, {
|
|
1684
|
+
quoteBinding: cachedQuoteBindingForContentRoot(fullContextTokens, baseOffset + range.start + effectiveSliceOffset, baseOffset + range.end)
|
|
1685
|
+
});
|
|
1686
|
+
if (derivationalLowering.kind === "rejected") {
|
|
1687
|
+
return {
|
|
1688
|
+
ok: false,
|
|
1689
|
+
reason: `${DERIVATIONAL_SUFFIX_FAIL_CLOSED_PREFIX}${derivationalLowering.reason}`,
|
|
1690
|
+
headHypothesis
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
if (parsed.consumed !== parseSliceInput.tokens.length && !partialAttributiveBoundary && !partialQuoteBoundary) {
|
|
1694
|
+
const derivationalPrefix = rootHasReanchoringDerivationalSuffix(parsedRoot)
|
|
1695
|
+
? DERIVATIONAL_SUFFIX_FAIL_CLOSED_PREFIX
|
|
1696
|
+
: "";
|
|
1697
|
+
return {
|
|
1698
|
+
ok: false,
|
|
1699
|
+
reason: `${derivationalPrefix}parser consumed ${parsed.consumed}/${parseSliceInput.tokens.length} content tokens — partial parse not in subset`,
|
|
1700
|
+
headHypothesis
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
const rootWithHeadHypothesis = {
|
|
1704
|
+
...(derivationalLowering.kind === "lowered" ? derivationalLowering.root : parsedRoot),
|
|
1705
|
+
headHypothesis
|
|
1706
|
+
};
|
|
1707
|
+
const leadingSurface = input.tokens.slice(0, range.start).map((t) => t.surface).join("");
|
|
1708
|
+
const trailingSurface = input.tokens.slice(range.end + 1).map((t) => t.surface).join("");
|
|
1709
|
+
const sourceConsumed = partialAttributiveBoundary || partialQuoteBoundary
|
|
1710
|
+
? sourceConsumedForParsedSlice(range.start, baseOffset, effectiveSliceOffset, parsed.consumed, parseSliceInput.sourceIndexMap)
|
|
1711
|
+
: range.end - range.start + 1;
|
|
1712
|
+
return {
|
|
1713
|
+
ok: true,
|
|
1714
|
+
info: {
|
|
1715
|
+
root: rootWithHeadHypothesis,
|
|
1716
|
+
leadingSurface,
|
|
1717
|
+
trailingSurface,
|
|
1718
|
+
formal: input.formal,
|
|
1719
|
+
sourceConsumed,
|
|
1720
|
+
localPredicateIdx: virtualCompoundStem !== null
|
|
1721
|
+
? range.start
|
|
1722
|
+
: splitSuppletiveStem === null
|
|
1723
|
+
? range.start + effectiveSliceOffset
|
|
1724
|
+
: range.start + splitSuppletiveStem.stemSourceTokens.length - 1
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
function partialParseRemainderIsOwnedQuoteMarker(options) {
|
|
1729
|
+
const firstRemainderSourceIdx = options.sourceIndexMap?.[options.parsedConsumed] ??
|
|
1730
|
+
options.baseOffset + options.rangeStart + options.effectiveSliceOffset + options.parsedConsumed;
|
|
1731
|
+
const relation = quoteStructuralRelationAt(new TokenCursor(options.contextTokens, firstRemainderSourceIdx, options.contextTokens.length, firstRemainderSourceIdx), options.lookups);
|
|
1732
|
+
if (relation === undefined || relation.quote.markerSpan.start !== firstRemainderSourceIdx)
|
|
1733
|
+
return false;
|
|
1734
|
+
const lastParsedSourceIdx = options.sourceIndexMap?.[options.parseLength - 1] ??
|
|
1735
|
+
options.baseOffset + options.rangeStart + options.effectiveSliceOffset + options.parseLength - 1;
|
|
1736
|
+
return relation.quote.markerSpan.endExclusive - 1 >= lastParsedSourceIdx;
|
|
1737
|
+
}
|
|
1738
|
+
function sourceConsumedForParsedSlice(rangeStart, baseOffset, effectiveSliceOffset, parsedConsumed, sourceIndexMap) {
|
|
1739
|
+
if (parsedConsumed <= 0) {
|
|
1740
|
+
return Math.max(1, effectiveSliceOffset);
|
|
1741
|
+
}
|
|
1742
|
+
const sourceIndex = sourceIndexMap?.[parsedConsumed - 1];
|
|
1743
|
+
if (sourceIndex === undefined) {
|
|
1744
|
+
return effectiveSliceOffset + parsedConsumed;
|
|
1745
|
+
}
|
|
1746
|
+
return Math.max(1, sourceIndex - baseOffset - rangeStart + 1);
|
|
1747
|
+
}
|
|
1748
|
+
function partialParseEndsAtAttributiveBoundaryHead(root, consumed) {
|
|
1749
|
+
if (root.tail.kind !== "auxLayer" ||
|
|
1750
|
+
root.tail.terminal !== "attributive" ||
|
|
1751
|
+
root.tail.terminalPayload?.kind !== "attributiveBoundary") {
|
|
1752
|
+
return false;
|
|
1753
|
+
}
|
|
1754
|
+
return consumed <= root.tail.terminalPayload.head.tokenIdx;
|
|
1755
|
+
}
|
|
1756
|
+
function plainTePermissionAttributiveBlocked(root, tokens, contentEndIdx) {
|
|
1757
|
+
const ops = auxOpsInTailNode(root.tail);
|
|
1758
|
+
const permissionIndex = ops.findIndex((op) => op.kind === "idiom" && op.idiom === "permission");
|
|
1759
|
+
if (permissionIndex < 0) {
|
|
1760
|
+
return false;
|
|
1761
|
+
}
|
|
1762
|
+
const permission = ops[permissionIndex];
|
|
1763
|
+
if (permission?.kind !== "idiom" || permission.idiom !== "permission") {
|
|
1764
|
+
return false;
|
|
1765
|
+
}
|
|
1766
|
+
if (ops.slice(0, permissionIndex).some((op) => op.kind === "negation")) {
|
|
1767
|
+
return false;
|
|
1768
|
+
}
|
|
1769
|
+
const sourceTokens = permission.source.tokens;
|
|
1770
|
+
const first = sourceTokens[0];
|
|
1771
|
+
if (first === undefined || (first.surface !== "て" && first.surface !== "で")) {
|
|
1772
|
+
return false;
|
|
1773
|
+
}
|
|
1774
|
+
if (sourceTokens.some((token) => token.surface === "も" || token.surface === "ても" || token.surface === "でも")) {
|
|
1775
|
+
return false;
|
|
1776
|
+
}
|
|
1777
|
+
const afterContent = contentEndIdx + 1;
|
|
1778
|
+
if (isClausePunctuationToken(tokens[afterContent])) {
|
|
1779
|
+
return false;
|
|
1780
|
+
}
|
|
1781
|
+
const headIdx = nextClauseNonPunctuationIndex(tokens, afterContent, tokens.length);
|
|
1782
|
+
const head = headIdx === null ? undefined : tokens[headIdx];
|
|
1783
|
+
if (head === undefined || ((head.pos & POS0) !== 名詞 && (head.pos & POS0) !== 代名詞)) {
|
|
1784
|
+
return false;
|
|
1785
|
+
}
|
|
1786
|
+
const headForm = head.dictionaryForm || head.surface;
|
|
1787
|
+
return !PLAIN_TE_PERMISSION_ATTRIBUTIVE_HEADS.has(headForm) &&
|
|
1788
|
+
!PLAIN_TE_PERMISSION_ATTRIBUTIVE_HEADS.has(head.surface);
|
|
1789
|
+
}
|
|
1790
|
+
function materializeNominalZeroCopulaPredicate(root, cursor, start, numeric, lookups, sourceHost) {
|
|
1791
|
+
if (root.tail.kind !== "auxLayer" ||
|
|
1792
|
+
!stemCanHostNominalZeroCopula(root.tail.stem) ||
|
|
1793
|
+
!nominalZeroCopulaPredicateNeedsMaterialization(root.tail.ops[0], cursor, start, numeric, lookups, sourceHost)) {
|
|
1794
|
+
return root;
|
|
1795
|
+
}
|
|
1796
|
+
if (quotedConcessiveCanSelectAdjectivalCandidate(root.tail.stem, root.tail.ops[0])) {
|
|
1797
|
+
return root;
|
|
1798
|
+
}
|
|
1799
|
+
const zeroCopula = createCopulaOp({
|
|
1800
|
+
source: root.tail.stem.source,
|
|
1801
|
+
variant: "basic",
|
|
1802
|
+
polarity: "affirmative",
|
|
1803
|
+
polite: false
|
|
1804
|
+
});
|
|
1805
|
+
return {
|
|
1806
|
+
...root,
|
|
1807
|
+
tail: {
|
|
1808
|
+
...root.tail,
|
|
1809
|
+
ops: [zeroCopula, ...root.tail.ops]
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
function quotedConcessiveCanSelectAdjectivalCandidate(stem, firstOp) {
|
|
1814
|
+
return stem.kind === "candidateSet" &&
|
|
1815
|
+
firstOp?.kind === "connective" &&
|
|
1816
|
+
firstOp.connective === "quoted_concessive" &&
|
|
1817
|
+
(firstOp.surface.includes("ないまでも") || firstOp.surface.includes("ぬまでも")) &&
|
|
1818
|
+
stemSupportsProjectionCategory(stem, "adjectival_predicate");
|
|
1819
|
+
}
|
|
1820
|
+
function stemCanHostNominalZeroCopula(stem) {
|
|
1821
|
+
if (stem.kind === "noun") {
|
|
1822
|
+
return true;
|
|
1823
|
+
}
|
|
1824
|
+
return stemSupportsProjectionCategory(stem, "nominal");
|
|
1825
|
+
}
|
|
1826
|
+
function nominalZeroCopulaPredicateNeedsMaterialization(firstOp, cursor, start, numeric, lookups, sourceHost) {
|
|
1827
|
+
const { tokens } = cursor;
|
|
1828
|
+
if (firstOp?.kind === "predicateQuoteCarrier" && firstOp.style !== "suru_attributive") {
|
|
1829
|
+
return true;
|
|
1830
|
+
}
|
|
1831
|
+
if (firstOp?.kind === "connective") {
|
|
1832
|
+
return firstOp.connective === "quotative" ||
|
|
1833
|
+
isNominalDirectConnectivePredicateStart(cursor, start, numeric) ||
|
|
1834
|
+
(firstOp.connective === "reformulation" &&
|
|
1835
|
+
mentionedHostCarriesCanonicalReformulationMarker(sourceHost?.cursor ?? cursor, sourceHost?.start ?? start, numeric, lookups));
|
|
1836
|
+
}
|
|
1837
|
+
if (firstOp?.kind === "modal" && firstOp.modal === "kamo") {
|
|
1838
|
+
return isNounKamoModalPredicateStart(tokens, start, lookups);
|
|
1839
|
+
}
|
|
1840
|
+
return false;
|
|
1841
|
+
}
|
|
1842
|
+
function rewriteKotodashiReasonScopeRoot(root, tokens, start) {
|
|
1843
|
+
const stemToken = tokens[start];
|
|
1844
|
+
if (stemToken === undefined ||
|
|
1845
|
+
!stemTokenEndsWithNoKoto(stemToken) ||
|
|
1846
|
+
!isKotodashiReasonScopeTail(tokens, start + 1)) {
|
|
1847
|
+
return root;
|
|
1848
|
+
}
|
|
1849
|
+
const tail = rewriteKotodashiReasonScopeTailNode(root.tail);
|
|
1850
|
+
return tail === root.tail
|
|
1851
|
+
? root
|
|
1852
|
+
: { ...root, tail };
|
|
1853
|
+
}
|
|
1854
|
+
function rewriteKotodashiReasonScopeTailNode(tail) {
|
|
1855
|
+
if (tail.kind === "connective") {
|
|
1856
|
+
const inner = rewriteKotodashiReasonScopeAuxLayer(tail.inner);
|
|
1857
|
+
const outer = rewriteKotodashiReasonScopeTailNode(tail.outer);
|
|
1858
|
+
const connective = tail.connective === "listing" && tail.surface === "し"
|
|
1859
|
+
? "reason"
|
|
1860
|
+
: tail.connective;
|
|
1861
|
+
const surface = tail.surface;
|
|
1862
|
+
if (inner === tail.inner && outer === tail.outer && connective === tail.connective && surface === tail.surface) {
|
|
1863
|
+
return tail;
|
|
1864
|
+
}
|
|
1865
|
+
return {
|
|
1866
|
+
...tail,
|
|
1867
|
+
inner,
|
|
1868
|
+
outer,
|
|
1869
|
+
connective,
|
|
1870
|
+
surface
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
return rewriteKotodashiReasonScopeAuxLayer(tail);
|
|
1874
|
+
}
|
|
1875
|
+
function rewriteKotodashiReasonScopeAuxLayer(tail) {
|
|
1876
|
+
const ops = tail.ops.map((op) => {
|
|
1877
|
+
if (op.kind === "connective" && op.connective === "listing" && op.surface === "し") {
|
|
1878
|
+
return {
|
|
1879
|
+
...op,
|
|
1880
|
+
connective: "reason",
|
|
1881
|
+
surface: "し"
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
return op;
|
|
1885
|
+
});
|
|
1886
|
+
return {
|
|
1887
|
+
...tail,
|
|
1888
|
+
ops
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
function materializeSuppletiveNegationStem(tokens, firstNegIdx, currentStem, koreanLemma, lookups) {
|
|
1892
|
+
if (currentStem.kind === "noun" || currentStem.kind === "candidateSet" || currentStem.kind === "adverb") {
|
|
1893
|
+
return null;
|
|
1894
|
+
}
|
|
1895
|
+
const politeNeg = detectPoliteNegativeSequence(tokens, firstNegIdx);
|
|
1896
|
+
const effectiveNegIdx = politeNeg?.negIdx ?? firstNegIdx;
|
|
1897
|
+
const effectiveNegToken = tokens[effectiveNegIdx];
|
|
1898
|
+
if (effectiveNegToken === undefined || !isNegationLikeToken(effectiveNegToken)) {
|
|
1899
|
+
return null;
|
|
1900
|
+
}
|
|
1901
|
+
const suppletive = loadSuppletiveNegDict().get(koreanLemma);
|
|
1902
|
+
if (suppletive === undefined) {
|
|
1903
|
+
return null;
|
|
1904
|
+
}
|
|
1905
|
+
if (matchTeTailContinuationAt(tokens, firstNegIdx, lookups)?.kind === "prohibition") {
|
|
1906
|
+
return null;
|
|
1907
|
+
}
|
|
1908
|
+
if (isObligationSpanStartingAtToken(tokens, firstNegIdx, false, { excludeLexicalBodyForms: true })) {
|
|
1909
|
+
return null;
|
|
1910
|
+
}
|
|
1911
|
+
const [lemma, irregular] = suppletive;
|
|
1912
|
+
const stemKind = lemma === "없다" ? "adj" : currentStem.kind;
|
|
1913
|
+
const stem = stemKind === "verb"
|
|
1914
|
+
? {
|
|
1915
|
+
kind: "verb",
|
|
1916
|
+
lemma,
|
|
1917
|
+
irregular,
|
|
1918
|
+
...(currentStem.kind === "verb" && currentStem.conj !== undefined ? { conj: currentStem.conj } : {}),
|
|
1919
|
+
commitment: "suppletive_negation"
|
|
1920
|
+
}
|
|
1921
|
+
: {
|
|
1922
|
+
kind: "adj",
|
|
1923
|
+
lemma,
|
|
1924
|
+
irregular,
|
|
1925
|
+
commitment: "suppletive_negation"
|
|
1926
|
+
};
|
|
1927
|
+
if (politeNeg !== null) {
|
|
1928
|
+
return { stem, sliceOffset: 0, politeNegative: politeNeg };
|
|
1929
|
+
}
|
|
1930
|
+
return { stem, sliceOffset: isContinuedSuppletiveNegationChain(tokens, firstNegIdx) ? 0 : 1 };
|
|
1931
|
+
}
|
|
1932
|
+
function detectPoliteNegativeSequence(tokens, politeIdx) {
|
|
1933
|
+
const polite = tokens[politeIdx];
|
|
1934
|
+
const neg = tokens[politeIdx + 1];
|
|
1935
|
+
if (polite === undefined || neg === undefined) {
|
|
1936
|
+
return null;
|
|
1937
|
+
}
|
|
1938
|
+
if ((polite.pos & POS4) !== 助動詞_マス) {
|
|
1939
|
+
return null;
|
|
1940
|
+
}
|
|
1941
|
+
if ((polite.pos & POS5A) !== 未然形_) {
|
|
1942
|
+
return null;
|
|
1943
|
+
}
|
|
1944
|
+
if (!isNegationLikeToken(neg)) {
|
|
1945
|
+
return null;
|
|
1946
|
+
}
|
|
1947
|
+
return { politeIdx, negIdx: politeIdx + 1 };
|
|
1948
|
+
}
|
|
1949
|
+
function isContinuedSuppletiveNegationChain(tokens, firstNegIdx) {
|
|
1950
|
+
const firstNeg = tokens[firstNegIdx];
|
|
1951
|
+
if (firstNeg === undefined || !isNegationLikeToken(firstNeg)) {
|
|
1952
|
+
return false;
|
|
1953
|
+
}
|
|
1954
|
+
const pos5A = firstNeg.pos & POS5A;
|
|
1955
|
+
if (pos5A !== 連用形_) {
|
|
1956
|
+
return false;
|
|
1957
|
+
}
|
|
1958
|
+
const next = tokens[firstNegIdx + 1];
|
|
1959
|
+
return next !== undefined && isNegationLikeToken(next);
|
|
1960
|
+
}
|
|
1961
|
+
function commitAndRenderSingleClause(info, ctx) {
|
|
1962
|
+
const committed = commitTail(info.root, ctx);
|
|
1963
|
+
let rendered;
|
|
1964
|
+
try {
|
|
1965
|
+
const outgoingBoundary = ownClauseTailIR(ctx)?.outgoingBoundary;
|
|
1966
|
+
rendered = renderTail(committed.root, outgoingBoundary === undefined
|
|
1967
|
+
? { formal: info.formal, lookups: ctx.lookups }
|
|
1968
|
+
: { formal: info.formal, outgoingBoundary, lookups: ctx.lookups });
|
|
1969
|
+
}
|
|
1970
|
+
catch (err) {
|
|
1971
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1972
|
+
return { ok: false, reason: `renderer threw: ${message}` };
|
|
1973
|
+
}
|
|
1974
|
+
if (!rendered.ok) {
|
|
1975
|
+
return { ok: false, reason: `renderer: ${rendered.reason}` };
|
|
1976
|
+
}
|
|
1977
|
+
const composed = `${info.leadingSurface}${rendered.text}${info.trailingSurface}`;
|
|
1978
|
+
const allWarnings = [
|
|
1979
|
+
...committed.warnings,
|
|
1980
|
+
...(rendered.warnings ?? []),
|
|
1981
|
+
...missingConditionalMarkerWarningsForRoot(committed.root)
|
|
1982
|
+
];
|
|
1983
|
+
return {
|
|
1984
|
+
ok: true,
|
|
1985
|
+
text: convertPunctuation(composed),
|
|
1986
|
+
polite: rendered.polite,
|
|
1987
|
+
warnings: allWarnings
|
|
1988
|
+
};
|
|
1989
|
+
}
|
|
1990
|
+
export function findContentRange(tokens) {
|
|
1991
|
+
let start = 0;
|
|
1992
|
+
while (start < tokens.length && isClausePunctuationToken(tokens[start])) {
|
|
1993
|
+
start += 1;
|
|
1994
|
+
}
|
|
1995
|
+
let end = tokens.length - 1;
|
|
1996
|
+
while (end >= start && isClausePunctuationToken(tokens[end])) {
|
|
1997
|
+
end -= 1;
|
|
1998
|
+
}
|
|
1999
|
+
if (end < start) {
|
|
2000
|
+
return null;
|
|
2001
|
+
}
|
|
2002
|
+
return { start, end };
|
|
2003
|
+
}
|
|
2004
|
+
function isStemFormInSubset(pos5, _tokens, _stemIdx) {
|
|
2005
|
+
return (pos5 === 終止形_ ||
|
|
2006
|
+
pos5 === 連体形_ ||
|
|
2007
|
+
pos5 === 連用形_ ||
|
|
2008
|
+
pos5 === 未然形_ ||
|
|
2009
|
+
pos5 === 意志推量形_ ||
|
|
2010
|
+
pos5 === 仮定形_ ||
|
|
2011
|
+
pos5 === 命令形_ ||
|
|
2012
|
+
pos5 === 語幹_);
|
|
2013
|
+
}
|