yikes fixed big bug with the length specification in the blocks when compiling

This commit is contained in:
lingdocs 2022-07-10 17:26:55 -05:00
parent 15fcb638ea
commit 511e215592
4 changed files with 35 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/pashto-inflector",
"version": "3.3.2",
"version": "3.3.4",
"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

@ -110,7 +110,7 @@ function VerbSBlock({ opts, v, script }: {
</>
</Border>
<div>{v.type === "perfectParticipleBlock" ? "Past Partic." : "Verb"}</div>
<EnglishBelow>{((v.type === "perfectParticipleBlock" ? "Past Partic." : "Verb")
<EnglishBelow>{(v.type === "perfectParticipleBlock"
? getEnglishParticipleInflection
: getEnglishPersonInfo
)(v.person, "short")}</EnglishBelow>

View File

@ -67,6 +67,17 @@ export function getVerbFromBlocks(blocks: T.Block[][]): T.VerbRenderedBlock {
return v;
}
export function getLengthyFromBlocks(blocks: T.Block[][]): T.VerbRenderedBlock | T.PerfectParticipleBlock | T.ModalVerbBlock | T.PerfectEquativeBlock | undefined {
return blocks[0].find(f => f.block.type === "verb"
||
f.block.type === "perfectParticipleBlock"
||
f.block.type === "modalVerbBlock"
||
f.block.type === "perfectEquativeBlock"
)?.block as T.VerbRenderedBlock | T.PerfectParticipleBlock | T.ModalVerbBlock | T.PerfectEquativeBlock | undefined;
}
export function getVerbAndHeadFromBlocks(blocks: T.Block[][]): { verb: T.VerbRenderedBlock, perfectiveHead: T.PerfectiveHeadBlock | undefined } {
const verb = getVerbFromBlocks(blocks);
const perfectiveHead = blocks[0].find(f => f.block.type === "perfectiveHead");
@ -296,7 +307,7 @@ export function specifyEquativeLength(blocksWVars: T.Block[][], length: "long" |
return blocksWVars.map(specify);
}
export function specifyVerbLength(blocksWVars: T.Block[][], length: "long" | "short" | "mini"): T.Block[][] {
export function specifyBlockLength(blocksWVars: T.Block[][], length: "long" | "short" | "mini"): T.Block[][] {
function specify(blocks: T.Block[]): T.Block[] {
return blocks.map((block): T.Block => {
if (block.block.type === "verb") {
@ -312,6 +323,16 @@ export function specifyVerbLength(blocksWVars: T.Block[][], length: "long" | "sh
};
return v;
}
if (block.block.type === "perfectEquativeBlock") {
const v: T.Block = {
...block,
block: {
...block.block,
ps: getLength(block.block.ps, length),
},
};
return v;
}
if (block.block.type === "perfectParticipleBlock") {
const p: T.Block = {
...block,

View File

@ -15,13 +15,14 @@ import { renderVP } from "./render-vp";
import {
getAPsFromBlocks,
getComplementFromBlocks,
getLengthyFromBlocks,
getObjectSelectionFromBlocks,
getPredicateSelectionFromBlocks,
getSubjectSelectionFromBlocks,
getVerbFromBlocks,
hasEquativeWithLengths,
specifyBlockLength,
specifyEquativeLength,
specifyVerbLength,
} from "./blocks-utils";
const blank: T.PsString = {
@ -81,13 +82,16 @@ export function compileVP(VP: T.VPRendered, form: T.FormVersion, combineLengths?
}
function compileVPPs(blocks: T.Block[][], kids: T.Kid[], form: T.FormVersion, king: "subject" | "object"): T.SingleOrLengthOpts<T.PsString[]> {
const verbBlock = getVerbFromBlocks(blocks);
if ("long" in verbBlock.block.ps) {
const lengthyBlock = getLengthyFromBlocks(blocks);
const potentialLengthy = lengthyBlock?.type === "verb"
? lengthyBlock.block.ps
: lengthyBlock?.ps;
if (potentialLengthy && "long" in potentialLengthy) {
return {
long: compileVPPs(specifyVerbLength(blocks, "long"), kids, form, king) as T.PsString[],
short: compileVPPs(specifyVerbLength(blocks, "short"), kids, form, king) as T.PsString[],
..."mini" in verbBlock.block.ps ? {
mini: compileVPPs(specifyVerbLength(blocks, "mini"), kids, form, king) as T.PsString[],
long: compileVPPs(specifyBlockLength(blocks, "long"), kids, form, king) as T.PsString[],
short: compileVPPs(specifyBlockLength(blocks, "short"), kids, form, king) as T.PsString[],
..."mini" in potentialLengthy ? {
mini: compileVPPs(specifyBlockLength(blocks, "mini"), kids, form, king) as T.PsString[],
} : {},
};
}
@ -98,7 +102,6 @@ function compileVPPs(blocks: T.Block[][], kids: T.Kid[], form: T.FormVersion, ki
kids,
false,
);
console.log({ blocksWKids });
return removeDuplicates(combineIntoText(blocksWKids, subjectPerson, {}));
}