fix blankouts - hopefully

This commit is contained in:
lingdocs 2022-06-13 22:11:14 -04:00
parent 02551291ba
commit 68484962dc
2 changed files with 14 additions and 9 deletions

View File

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

View File

@ -29,13 +29,13 @@ import { getAPsFromBlocks, getPredicateSelectionFromBlocks, getRenderedObjectSel
// TODO: GET BLANKING WORKING! // TODO: GET BLANKING WORKING!
// const blank: T.PsString = { const blank: T.PsString = {
// p: "______", p: "______",
// f: "______", f: "______",
// }; };
type BlankoutOptions = { equative?: boolean, ba?: boolean, kidsSection?: boolean }; 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<T.PsString[]>, e?: string [] }; export function compileVP(VP: T.VPRendered, form: T.FormVersion): { ps: T.SingleOrLengthOpts<T.PsString[]>, e?: string [] };
export function compileVP(VP: T.VPRendered, form: T.FormVersion, combineLengths: true): { ps: T.PsString[], 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, omitSubject ? blocks.filter(b => b.type !== "subjectSelection") : blocks,
kids, 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 first = pieces[0];
const rest = pieces.slice(1); 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) { if (!rest.length) {
return firstPs; return firstPs;
} }