ability to show passive roots and stems
This commit is contained in:
parent
9a466456f6
commit
af5b24eb18
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/pashto-inflector",
|
"name": "@lingdocs/pashto-inflector",
|
||||||
"version": "2.6.6",
|
"version": "2.6.7",
|
||||||
"author": "lingdocs.com",
|
"author": "lingdocs.com",
|
||||||
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
|
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
|
||||||
"homepage": "https://verbs.lingdocs.com",
|
"homepage": "https://verbs.lingdocs.com",
|
||||||
|
|
|
@ -41,7 +41,7 @@ const title: CSSProperties = {
|
||||||
|
|
||||||
export function RootsAndStems({ textOptions, info, hidePastParticiple, highlighted }: {
|
export function RootsAndStems({ textOptions, info, hidePastParticiple, highlighted }: {
|
||||||
textOptions: T.TextOptions,
|
textOptions: T.TextOptions,
|
||||||
info: T.NonComboVerbInfo,
|
info: T.NonComboVerbInfo | T.PassiveRootsStems,
|
||||||
hidePastParticiple?: boolean,
|
hidePastParticiple?: boolean,
|
||||||
highlighted?: T.RootsOrStemsToHighlight,
|
highlighted?: T.RootsOrStemsToHighlight,
|
||||||
}) {
|
}) {
|
||||||
|
@ -62,7 +62,7 @@ export function RootsAndStems({ textOptions, info, hidePastParticiple, highlight
|
||||||
{showPersInf && <PersonInfsPicker
|
{showPersInf && <PersonInfsPicker
|
||||||
persInf={persInf}
|
persInf={persInf}
|
||||||
handleChange={(p) => setPersInf(p)}
|
handleChange={(p) => setPersInf(p)}
|
||||||
transitivity={info.transitivity}
|
transitivity={"transitivity" in info ? info.transitivity : "intransitive"}
|
||||||
/>}
|
/>}
|
||||||
<div className="verb-info" style={{
|
<div className="verb-info" style={{
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as T from "../../types";
|
import * as T from "../../types";
|
||||||
import ButtonSelect from "../ButtonSelect";
|
import ButtonSelect from "../ButtonSelect";
|
||||||
import { RootsAndStems } from "../verb-info/VerbInfo";
|
import { RootsAndStems } from "../verb-info/VerbInfo";
|
||||||
import { getVerbInfo } from "../../lib/verb-info";
|
import { getPassiveRootsAndStems, getVerbInfo } from "../../lib/verb-info";
|
||||||
import Hider from "../Hider";
|
import Hider from "../Hider";
|
||||||
import useStickyState from "../../lib/useStickyState";
|
import useStickyState from "../../lib/useStickyState";
|
||||||
import CompoundDisplay from "./CompoundDisplay";
|
import CompoundDisplay from "./CompoundDisplay";
|
||||||
|
@ -50,6 +50,7 @@ function VerbPicker(props: {
|
||||||
payload,
|
payload,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const passiveRootsAndStems = (info && props.vps.verb.voice === "passive") ? getPassiveRootsAndStems(info) : undefined;
|
||||||
return <div className="mb-3">
|
return <div className="mb-3">
|
||||||
{info && <CompoundDisplay
|
{info && <CompoundDisplay
|
||||||
info={info}
|
info={info}
|
||||||
|
@ -65,7 +66,7 @@ function VerbPicker(props: {
|
||||||
>
|
>
|
||||||
<RootsAndStems
|
<RootsAndStems
|
||||||
textOptions={props.opts}
|
textOptions={props.opts}
|
||||||
info={info}
|
info={passiveRootsAndStems ? passiveRootsAndStems : info}
|
||||||
/>
|
/>
|
||||||
</Hider>
|
</Hider>
|
||||||
</div>}
|
</div>}
|
||||||
|
|
|
@ -54,11 +54,11 @@ export function pickPersInf<T>(s: T.OptionalPersonInflections<T>, persInf: T.Per
|
||||||
// return s;
|
// return s;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
export function hasPersInfs(info: T.NonComboVerbInfo): boolean {
|
export function hasPersInfs(info: T.NonComboVerbInfo | T.PassiveRootsStems): boolean {
|
||||||
return (
|
return (
|
||||||
"mascSing" in info.root.perfective ||
|
"mascSing" in info.root.perfective ||
|
||||||
"mascSing" in info.stem.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
|
"mascSing" in info.participle.past
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {
|
||||||
ensureShortWurShwaShift,
|
ensureShortWurShwaShift,
|
||||||
choosePersInf,
|
choosePersInf,
|
||||||
isUnisexSet,
|
isUnisexSet,
|
||||||
|
getLong,
|
||||||
} from "./p-text-helpers";
|
} from "./p-text-helpers";
|
||||||
import {
|
import {
|
||||||
makePsString,
|
makePsString,
|
||||||
|
@ -135,7 +136,6 @@ export function getVerbInfo(
|
||||||
const yulEnding = yulEndingInfinitive(infinitive);
|
const yulEnding = yulEndingInfinitive(infinitive);
|
||||||
const participle = getParticiple(entry, stem, infinitive, transitivity, comp);
|
const participle = getParticiple(entry, stem, infinitive, transitivity, comp);
|
||||||
const idiosyncraticThirdMascSing = getIdiosyncraticThirdMascSing(entry);
|
const idiosyncraticThirdMascSing = getIdiosyncraticThirdMascSing(entry);
|
||||||
|
|
||||||
const baseInfo: T.VerbInfoBase = {
|
const baseInfo: T.VerbInfoBase = {
|
||||||
entry: {
|
entry: {
|
||||||
// TODO: cleanup the type safety with the DictionaryNoFVars messing things up etc
|
// TODO: cleanup the type safety with the DictionaryNoFVars messing things up etc
|
||||||
|
@ -964,3 +964,70 @@ function makeDynamicPerfectiveSplit(comp: T.PsString, auxSplit: T.SplitInfo): T.
|
||||||
auxSplit[1],
|
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),
|
||||||
|
}
|
||||||
|
}
|
|
@ -169,6 +169,14 @@ export type VerbInfoBase = {
|
||||||
idiosyncraticThirdMascSing?: ShortThirdPersFormSet;
|
idiosyncraticThirdMascSing?: ShortThirdPersFormSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PassiveRootsStems = {
|
||||||
|
stem: VerbStemSet,
|
||||||
|
root: VerbRootSet,
|
||||||
|
participle: {
|
||||||
|
past: FullForm<PsString>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
export type SimpleVerbInfo = VerbInfoBase & {
|
export type SimpleVerbInfo = VerbInfoBase & {
|
||||||
type: "simple";
|
type: "simple";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue