From 9a10fc1559df27b56e6471ce8016170614c322df Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Tue, 31 May 2022 17:32:22 -0500 Subject: [PATCH] hacky way to include the perfective split in the intransitive forms --- package.json | 2 +- src/lib/verb-info.ts | 65 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8ddd945..eec3131 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.6.9", + "version": "2.7.0", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", diff --git a/src/lib/verb-info.ts b/src/lib/verb-info.ts index 4a208fe..e9ba20a 100644 --- a/src/lib/verb-info.ts +++ b/src/lib/verb-info.ts @@ -968,25 +968,82 @@ function makeDynamicPerfectiveSplit(comp: T.PsString, auxSplit: T.SplitInfo): T. export function getPassiveRootsAndStems(info: T.NonComboVerbInfo): T.PassiveRootsStems | undefined { if (info.transitivity !== "transitive") return undefined; return { - stem: getPassiveStem(info.root), - root: getPassiveRoot(info.root), + stem: getPassiveStem(info.root, info.root.perfectiveSplit), + root: getPassiveRoot(info.root, info.root.perfectiveSplit), participle: { past: getPassivePastParticiple(info.root.imperfective), }, }; } -function getPassiveStem(root: T.VerbRootSet): T.VerbStemSet { +function getPassiveStem(root: T.VerbRootSet, splitInfo: T.SplitInfo | undefined): T.VerbStemSet { return { perfective: getPassiveStemAspect(root.perfective, "perfective"), imperfective: getPassiveStemAspect(root.imperfective, "imperfective"), + ...splitInfo ? { + perfectiveSplit: getPassiveStemPerfectiveSplit(root.perfective, splitInfo), + } : {}, }; } -function getPassiveRoot(root: T.VerbRootSet): T.VerbRootSet { +function getPassiveStemPerfectiveSplit(stem: T.OptionalPersonInflections>, splitInfo: T.SplitInfo): T.SplitInfo { + const si = "long" in splitInfo ? splitInfo.long : splitInfo; + if ("mascSing" in si) { + if (!("mascSing" in stem)) throw new Error("persInflections doesn't match perfective split"); + return { + "mascSing": getPassiveStemPerfectiveSplit(stem.mascSing, si.mascSing) as [T.PsString, T.PsString], + "mascPlur": getPassiveStemPerfectiveSplit(stem.mascPlur, si.mascPlur) as [T.PsString, T.PsString], + "femSing": getPassiveStemPerfectiveSplit(stem.femSing, si.femSing) as [T.PsString, T.PsString], + "femPlur": getPassiveStemPerfectiveSplit(stem.femPlur, si.femPlur) as [T.PsString, T.PsString], + } + } + return [ + si[0], + // @ts-ignore + concatPsString(si[1], " ", stativeAux.intransitive.info.stem.perfective), + ]; +} + +function getPassiveRootPerfectiveSplit(root: T.OptionalPersonInflections>, splitInfo: T.SplitInfo): T.SplitInfo { + const si = "long" in splitInfo ? splitInfo.long : splitInfo; + // if ("long" in splitInfo) { + // return { + // // @ts-ignore + // short: getPassiveRootPerfectiveSplit(root, splitInfo.long, "short"), + // // @ts-ignore + // long: getPassiveRootPerfectiveSplit(root, splitInfo.long, "long"), + // }; + // } + if ("mascSing" in si) { + if (!("mascSing" in root)) throw new Error("persInflections doesn't match perfective split"); + return { + "mascSing": getPassiveRootPerfectiveSplit(root.mascSing, si.mascSing) as [T.PsString, T.PsString], + "mascPlur": getPassiveRootPerfectiveSplit(root.mascPlur, si.mascPlur) as [T.PsString, T.PsString], + "femSing": getPassiveRootPerfectiveSplit(root.femSing, si.femSing) as [T.PsString, T.PsString], + "femPlur": getPassiveRootPerfectiveSplit(root.femPlur, si.femPlur) as [T.PsString, T.PsString], + }; + } + return { + short: [ + si[0], + // @ts-ignore + concatPsString(si[1], " ", stativeAux.intransitive.info.root.perfective.short), + ], + long: [ + si[0], + // @ts-ignore + concatPsString(si[1], " ", stativeAux.intransitive.info.root.perfective.long), + ], + }; +} + +function getPassiveRoot(root: T.VerbRootSet, splitInfo: T.SplitInfo | undefined): T.VerbRootSet { return { perfective: getPassiveRootAspect(root.perfective, "perfective"), imperfective: getPassiveRootAspect(root.imperfective, "imperfective"), + ...splitInfo ? { + perfectiveSplit: getPassiveRootPerfectiveSplit(root.perfective, splitInfo), + } : {}, }; }