From 36078c243329b69b88db254f6e3dc526c01f832b Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Tue, 14 Jun 2022 20:44:07 -0400 Subject: [PATCH] fixed kids blanking thing --- package.json | 2 +- src/lib/phrase-building/compile.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 716fc8d..d985ea3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.9.6", + "version": "2.9.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/lib/phrase-building/compile.ts b/src/lib/phrase-building/compile.ts index 18a6330..7af63e6 100644 --- a/src/lib/phrase-building/compile.ts +++ b/src/lib/phrase-building/compile.ts @@ -263,7 +263,6 @@ function arrangeVerbWNegative(head: T.PsString | undefined, restRaw: T.PsString[ export function compileEP(EP: T.EPRendered): { ps: T.SingleOrLengthOpts, e?: string[] }; export function compileEP(EP: T.EPRendered, combineLengths: true, blankOut?: BlankoutOptions): { ps: T.PsString[], e?: string[] }; export function compileEP(EP: T.EPRendered, combineLengths?: boolean, blankOut?: BlankoutOptions): { ps: T.SingleOrLengthOpts, e?: string[] } { - console.log("blankout options passed", blankOut); const psResult = compileEPPs(EP.blocks, EP.kids, EP.omitSubject, blankOut); return { ps: combineLengths ? flattenLengths(psResult) : psResult, @@ -283,21 +282,22 @@ function compileEPPs(blocks: T.Block[], kids: T.Kid[], omitSubject: boolean, bla const blocksWKids = putKidsInKidsSection( omitSubject ? blocks.filter(b => b.type !== "subjectSelection") : blocks, kids, + !!blankOut?.kidsSection ); + // BIG TODO: If the kid's section is blank and there are no kids - add a blank for the kids section! return removeDuplicates(combineIntoText(blocksWKids, subjectPerson, blankOut)); } -function combineIntoText(pieces: (T.Block | T.Kid)[], subjectPerson: T.Person, blankOut?: BlankoutOptions): T.PsString[] { - console.log("in text combining blankout", blankOut); +function combineIntoText(pieces: (T.Block | T.Kid | T.PsString)[], subjectPerson: T.Person, blankOut?: BlankoutOptions): T.PsString[] { const first = pieces[0]; const rest = pieces.slice(1); - const firstPs = (blankOut?.equative && first.type === "equative") + const firstPs = ("p" in first) + ? [first] + : (blankOut?.equative && first.type === "equative") ? [blank] - : ((blankOut?.ba || blankOut?.kidsSection) && first.type === "ba") - // TODO: properly handle blanking out whole kids section + : ((blankOut?.ba) && first.type === "ba") ? [kidsBlank] : getPsFromPiece(first, subjectPerson); - console.log({ first, firstPs }); if (!rest.length) { return firstPs; } @@ -346,12 +346,12 @@ function getEnglishAPs(blocks: (T.Rendered | T.Rende }, ""); } -function putKidsInKidsSection(blocks: T.Block[], kids: T.Kid[]): (T.Block | T.Kid)[] { +function putKidsInKidsSection(blocks: T.Block[], kids: T.Kid[], enforceKidsSectionBlankout: boolean): (T.Block | T.Kid | T.PsString)[] { const first = blocks[0]; const rest = blocks.slice(1); return [ first, - ...kids, + ...enforceKidsSectionBlankout ? [kidsBlank] : kids, ...rest, ]; }