ability to show passive roots and stems

This commit is contained in:
lingdocs 2022-05-30 14:07:58 -05:00
parent 9a466456f6
commit af5b24eb18
6 changed files with 84 additions and 8 deletions

View File

@ -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",

View File

@ -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 && <PersonInfsPicker
persInf={persInf}
handleChange={(p) => setPersInf(p)}
transitivity={info.transitivity}
transitivity={"transitivity" in info ? info.transitivity : "intransitive"}
/>}
<div className="verb-info" style={{
textAlign: "center",

View File

@ -1,7 +1,7 @@
import * as T from "../../types";
import ButtonSelect from "../ButtonSelect";
import { RootsAndStems } from "../verb-info/VerbInfo";
import { getVerbInfo } from "../../lib/verb-info";
import { getPassiveRootsAndStems, getVerbInfo } from "../../lib/verb-info";
import Hider from "../Hider";
import useStickyState from "../../lib/useStickyState";
import CompoundDisplay from "./CompoundDisplay";
@ -50,6 +50,7 @@ function VerbPicker(props: {
payload,
});
}
const passiveRootsAndStems = (info && props.vps.verb.voice === "passive") ? getPassiveRootsAndStems(info) : undefined;
return <div className="mb-3">
{info && <CompoundDisplay
info={info}
@ -65,7 +66,7 @@ function VerbPicker(props: {
>
<RootsAndStems
textOptions={props.opts}
info={info}
info={passiveRootsAndStems ? passiveRootsAndStems : info}
/>
</Hider>
</div>}

View File

@ -54,11 +54,11 @@ export function pickPersInf<T>(s: T.OptionalPersonInflections<T>, 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
);
}

View File

@ -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.LengthOptions<T.PsString>>): T.OptionalPersonInflections<T.LengthOptions<T.PsString>> {
if ("mascSing" in root) {
return {
"mascSing": getPassivePastParticiple(root.mascSing) as T.LengthOptions<T.PsString>,
"mascPlur": getPassivePastParticiple(root.mascPlur) as T.LengthOptions<T.PsString>,
"femSing": getPassivePastParticiple(root.femPlur) as T.LengthOptions<T.PsString>,
"femPlur": getPassivePastParticiple(root.femPlur) as T.LengthOptions<T.PsString>,
};
}
// @ts-ignore
return concatPsString(getLong(root), " ", stativeAux.intransitive.info.participle.past) as T.PsString;
}
function getPassiveStemAspect(root: T.FullForm<T.PsString>, aspect: T.Aspect): T.FullForm<T.PsString> {
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<T.LengthOptions<T.PsString>>, aspect: T.Aspect): T.OptionalPersonInflections<T.LengthOptions<T.PsString>> {
if ("mascSing" in root) {
return {
"mascSing": getPassiveRootAspect(root.mascSing, aspect) as T.LengthOptions<T.PsString>,
"mascPlur": getPassiveRootAspect(root.mascPlur, aspect) as T.LengthOptions<T.PsString>,
"femPlur": getPassiveRootAspect(root.femPlur, aspect) as T.LengthOptions<T.PsString>,
"femSing": getPassiveRootAspect(root.femPlur, aspect) as T.LengthOptions<T.PsString>,
};
}
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),
}
}

View File

@ -169,6 +169,14 @@ export type VerbInfoBase = {
idiosyncraticThirdMascSing?: ShortThirdPersFormSet;
}
export type PassiveRootsStems = {
stem: VerbStemSet,
root: VerbRootSet,
participle: {
past: FullForm<PsString>,
},
}
export type SimpleVerbInfo = VerbInfoBase & {
type: "simple";
}