fixed some complement issues
This commit is contained in:
parent
584a3646fe
commit
76349ceaab
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lingdocs/pashto-inflector",
|
||||
"version": "3.4.7",
|
||||
"version": "3.4.8",
|
||||
"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",
|
||||
|
|
|
@ -34,7 +34,7 @@ function Examples(props: ({
|
|||
const examples = "children" in props ? props.children : props.ex;
|
||||
const Example = ({ children: text }: { children: PsStringWSub }) => (
|
||||
<div className={props.lineHeight !== undefined ? `mb-${props.lineHeight}` : `mt-1 mb-3`}>
|
||||
<div dir="rtl">
|
||||
<div>
|
||||
<Pashto opts={props.opts}>{text}</Pashto>
|
||||
</div>
|
||||
<div>
|
||||
|
|
|
@ -138,7 +138,7 @@ function ModalVerbBlock({ opts, v, script }: {
|
|||
</>
|
||||
</Border>
|
||||
<div>Verb</div>
|
||||
<EnglishBelow>Modal</EnglishBelow>
|
||||
<EnglishBelow>Ability</EnglishBelow>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,11 @@ function getPsFromPiece(piece: T.Block | T.Kid, subjectPerson: T.Person): T.PsSt
|
|||
}
|
||||
if (piece.block.type === "modalVerbBlock") {
|
||||
// getLong is just for type safety - we will have split up the length options earlier in compileVPPs
|
||||
return getLong(piece.block.ps);
|
||||
const verbPs = getLong(piece.block.ps);
|
||||
if (piece.block.complementWelded) {
|
||||
return combineComplementWVerbPs(piece.block.complementWelded, verbPs);
|
||||
}
|
||||
return verbPs;
|
||||
}
|
||||
if (piece.block.type === "modalVerbKedulPart") {
|
||||
// just using the short one for now - it will only be short anyways
|
||||
|
|
|
@ -436,7 +436,9 @@ function renderVerbSelection(vs: T.VerbSelectionComplete, person: T.Person, comp
|
|||
type: "verb",
|
||||
block: {
|
||||
...vs,
|
||||
ps: rest,
|
||||
ps: (!perfective && renderedComplement && vs.verb.entry.p.includes(" "))
|
||||
? removeComplement(rest, renderedComplement)
|
||||
: rest,
|
||||
person,
|
||||
hasBa,
|
||||
complementWelded: ((!perfective && renderedComplement) && (
|
||||
|
@ -464,13 +466,42 @@ function renderVerbSelection(vs: T.VerbSelectionComplete, person: T.Person, comp
|
|||
: [],
|
||||
...splitUpIfModal(vrb),
|
||||
] as VerbBlocks;
|
||||
const perfectStuff = isPerfectTense(vrb.block.tense) ? getPerfectStuff(rest, vrb) : undefined;
|
||||
const perfectStuff = isPerfectTense(vrb.block.tense) ? getPerfectStuff(vrb) : undefined;
|
||||
return {
|
||||
verbBlocks: perfectStuff ? perfectStuff : verbBlocks,
|
||||
hasBa,
|
||||
};
|
||||
}
|
||||
|
||||
function removeComplement(ps: T.SingleOrLengthOpts<T.PsString[]>, complement: T.Rendered<T.ComplementSelection | T.UnselectedComplementSelection>): T.SingleOrLengthOpts<T.PsString[]> {
|
||||
if ("long" in ps) {
|
||||
return {
|
||||
long: removeComplement(ps.long, complement) as T.PsString[],
|
||||
short: removeComplement(ps.short, complement) as T.PsString[],
|
||||
...ps.mini ? {
|
||||
mini: removeComplement(ps.mini, complement) as T.PsString[],
|
||||
} : {},
|
||||
};
|
||||
}
|
||||
const c = complement.selection.type === "adjective"
|
||||
? complement.selection.ps
|
||||
: complement.selection.type === "loc. adv."
|
||||
? complement.selection.ps
|
||||
: complement.selection.type === "sandwich"
|
||||
? complement.selection.inside.selection.ps
|
||||
: complement.selection.type === "noun"
|
||||
? complement.selection.ps
|
||||
: complement.selection.ps;
|
||||
// TODO: this is brutal
|
||||
const removed = ps.map(p => (
|
||||
c.reduce((acc, v) => ({
|
||||
p: acc.p.replace(`${v.p} `, ""),
|
||||
f: acc.f.replace(`${v.f} `, ""),
|
||||
}), p)
|
||||
));
|
||||
return removed;
|
||||
}
|
||||
|
||||
function createComplementRetroactively(complement: T.DictionaryEntry | undefined, person: T.Person | undefined): T.ComplementSelection {
|
||||
// This is a bit of a hack to work with the current verb conjugation system.
|
||||
if (!complement) {
|
||||
|
@ -534,8 +565,8 @@ function splitUpIfModal(v: T.VerbRenderedBlock): [T.VerbRenderedBlock] | [T.Moda
|
|||
];
|
||||
}
|
||||
|
||||
function getPerfectStuff(v: T.SingleOrLengthOpts<T.PsString[]>, vrb: T.VerbRenderedBlock): [T.PerfectParticipleBlock, T.PerfectEquativeBlock] {
|
||||
const [p, eq] = splitOffLeapfrogWordFull(v);
|
||||
function getPerfectStuff(vrb: T.VerbRenderedBlock): [T.PerfectParticipleBlock, T.PerfectEquativeBlock] {
|
||||
const [p, eq] = splitOffLeapfrogWordFull(vrb.block.ps);
|
||||
return [
|
||||
{
|
||||
type: "perfectParticipleBlock",
|
||||
|
|
Loading…
Reference in New Issue