From af5b24eb184b651fc57247fd1585b1ff792e1b12 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 30 May 2022 14:07:58 -0500 Subject: [PATCH] ability to show passive roots and stems --- package.json | 2 +- src/components/verb-info/VerbInfo.tsx | 4 +- src/components/vp-explorer/VerbPicker.tsx | 5 +- src/lib/misc-helpers.ts | 4 +- src/lib/verb-info.ts | 69 ++++++++++++++++++++++- src/types.ts | 8 +++ 6 files changed, 84 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 84ccc31..8141d8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.6.6", + "version": "2.6.7", "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/components/verb-info/VerbInfo.tsx b/src/components/verb-info/VerbInfo.tsx index e924df7..f559520 100644 --- a/src/components/verb-info/VerbInfo.tsx +++ b/src/components/verb-info/VerbInfo.tsx @@ -41,7 +41,7 @@ const title: CSSProperties = { export function RootsAndStems({ textOptions, info, hidePastParticiple, highlighted }: { textOptions: T.TextOptions, - info: T.NonComboVerbInfo, + info: T.NonComboVerbInfo | T.PassiveRootsStems, hidePastParticiple?: boolean, highlighted?: T.RootsOrStemsToHighlight, }) { @@ -62,7 +62,7 @@ export function RootsAndStems({ textOptions, info, hidePastParticiple, highlight {showPersInf && setPersInf(p)} - transitivity={info.transitivity} + transitivity={"transitivity" in info ? info.transitivity : "intransitive"} />}
{info &&
} diff --git a/src/lib/misc-helpers.ts b/src/lib/misc-helpers.ts index 80b863c..24aca22 100644 --- a/src/lib/misc-helpers.ts +++ b/src/lib/misc-helpers.ts @@ -54,11 +54,11 @@ export function pickPersInf(s: T.OptionalPersonInflections, persInf: T.Per // return s; // } -export function hasPersInfs(info: T.NonComboVerbInfo): boolean { +export function hasPersInfs(info: T.NonComboVerbInfo | T.PassiveRootsStems): boolean { return ( "mascSing" in info.root.perfective || "mascSing" in info.stem.perfective || - "mascSing" in info.participle.present || + ("present" in info.participle && "mascSing" in info.participle.present) || "mascSing" in info.participle.past ); } diff --git a/src/lib/verb-info.ts b/src/lib/verb-info.ts index 42a3d66..4a208fe 100644 --- a/src/lib/verb-info.ts +++ b/src/lib/verb-info.ts @@ -20,6 +20,7 @@ import { ensureShortWurShwaShift, choosePersInf, isUnisexSet, + getLong, } from "./p-text-helpers"; import { makePsString, @@ -135,7 +136,6 @@ export function getVerbInfo( const yulEnding = yulEndingInfinitive(infinitive); const participle = getParticiple(entry, stem, infinitive, transitivity, comp); const idiosyncraticThirdMascSing = getIdiosyncraticThirdMascSing(entry); - const baseInfo: T.VerbInfoBase = { entry: { // TODO: cleanup the type safety with the DictionaryNoFVars messing things up etc @@ -963,4 +963,71 @@ function makeDynamicPerfectiveSplit(comp: T.PsString, auxSplit: T.SplitInfo): T. concatPsString(comp, " ", auxSplit[0]), auxSplit[1], ]; +} + +export function getPassiveRootsAndStems(info: T.NonComboVerbInfo): T.PassiveRootsStems | undefined { + if (info.transitivity !== "transitive") return undefined; + return { + stem: getPassiveStem(info.root), + root: getPassiveRoot(info.root), + participle: { + past: getPassivePastParticiple(info.root.imperfective), + }, + }; +} + +function getPassiveStem(root: T.VerbRootSet): T.VerbStemSet { + return { + perfective: getPassiveStemAspect(root.perfective, "perfective"), + imperfective: getPassiveStemAspect(root.imperfective, "imperfective"), + }; +} + +function getPassiveRoot(root: T.VerbRootSet): T.VerbRootSet { + return { + perfective: getPassiveRootAspect(root.perfective, "perfective"), + imperfective: getPassiveRootAspect(root.imperfective, "imperfective"), + }; +} + +function getPassivePastParticiple(root: T.OptionalPersonInflections>): T.OptionalPersonInflections> { + if ("mascSing" in root) { + return { + "mascSing": getPassivePastParticiple(root.mascSing) as T.LengthOptions, + "mascPlur": getPassivePastParticiple(root.mascPlur) as T.LengthOptions, + "femSing": getPassivePastParticiple(root.femPlur) as T.LengthOptions, + "femPlur": getPassivePastParticiple(root.femPlur) as T.LengthOptions, + }; + } + // @ts-ignore + return concatPsString(getLong(root), " ", stativeAux.intransitive.info.participle.past) as T.PsString; +} + +function getPassiveStemAspect(root: T.FullForm, aspect: T.Aspect): T.FullForm { + if ("mascSing" in root) { + return { + "mascSing": getPassiveStemAspect(root.mascSing, aspect) as T.PsString, + "mascPlur": getPassiveStemAspect(root.mascPlur, aspect) as T.PsString, + "femSing": getPassiveStemAspect(root.femPlur, aspect) as T.PsString, + "femPlur": getPassiveStemAspect(root.femPlur, aspect) as T.PsString, + }; + } + return concatPsString(getLong(root), " ", stativeAux.intransitive.info.stem[aspect]); +} + +function getPassiveRootAspect(root: T.OptionalPersonInflections>, aspect: T.Aspect): T.OptionalPersonInflections> { + if ("mascSing" in root) { + return { + "mascSing": getPassiveRootAspect(root.mascSing, aspect) as T.LengthOptions, + "mascPlur": getPassiveRootAspect(root.mascPlur, aspect) as T.LengthOptions, + "femPlur": getPassiveRootAspect(root.femPlur, aspect) as T.LengthOptions, + "femSing": getPassiveRootAspect(root.femPlur, aspect) as T.LengthOptions, + }; + } + return { + // @ts-ignore + long: concatPsString(root.long, " ", stativeAux.intransitive.info.root[aspect].long), + // @ts-ignore + short: concatPsString(root.long, " ", stativeAux.intransitive.info.root[aspect].short), + } } \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 38fb3bc..e9037d8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -169,6 +169,14 @@ export type VerbInfoBase = { idiosyncraticThirdMascSing?: ShortThirdPersFormSet; } +export type PassiveRootsStems = { + stem: VerbStemSet, + root: VerbRootSet, + participle: { + past: FullForm, + }, +} + export type SimpleVerbInfo = VerbInfoBase & { type: "simple"; }