From 68484962dc12cce87b26b6a4e6c02fb5143e9c39 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:11:14 -0400 Subject: [PATCH] fix blankouts - hopefully --- package.json | 2 +- src/lib/phrase-building/compile.ts | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 3dbca2e..fb50203 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.9.3", + "version": "2.9.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", diff --git a/src/lib/phrase-building/compile.ts b/src/lib/phrase-building/compile.ts index b4e0cdc..2a9dfac 100644 --- a/src/lib/phrase-building/compile.ts +++ b/src/lib/phrase-building/compile.ts @@ -29,13 +29,13 @@ import { getAPsFromBlocks, getPredicateSelectionFromBlocks, getRenderedObjectSel // TODO: GET BLANKING WORKING! -// const blank: T.PsString = { -// p: "______", -// f: "______", -// }; +const blank: T.PsString = { + p: "______", + f: "______", +}; type BlankoutOptions = { equative?: boolean, ba?: boolean, kidsSection?: boolean }; -// const kidsBlank = makeSegment({ p: "___", f: "___" }, ["isKid"]); +const kidsBlank: T.PsString = { p: "___", f: "___" }; export function compileVP(VP: T.VPRendered, form: T.FormVersion): { ps: T.SingleOrLengthOpts, e?: string [] }; export function compileVP(VP: T.VPRendered, form: T.FormVersion, combineLengths: true): { ps: T.PsString[], e?: string [] }; @@ -283,13 +283,18 @@ function compileEPPs(blocks: T.Block[], kids: T.Kid[], omitSubject: boolean, bla omitSubject ? blocks.filter(b => b.type !== "subjectSelection") : blocks, kids, ); - return removeDuplicates(combineIntoText(blocksWKids, subjectPerson)); + return removeDuplicates(combineIntoText(blocksWKids, subjectPerson, blankOut)); } -function combineIntoText(pieces: (T.Block | T.Kid)[], subjectPerson: T.Person): T.PsString[] { +function combineIntoText(pieces: (T.Block | T.Kid)[], subjectPerson: T.Person, blankOut?: BlankoutOptions): T.PsString[] { const first = pieces[0]; const rest = pieces.slice(1); - const firstPs = getPsFromPiece(first, subjectPerson); + const firstPs = (blankOut?.equative && first.type === "equative") + ? [blank] + : ((blankOut?.ba || blankOut?.kidsSection) && first.type === "ba") + // TODO: properly handle blanking out whole kids section + ? [kidsBlank] + : getPsFromPiece(first, subjectPerson); if (!rest.length) { return firstPs; }