From 102232f559a749df8cb6ba0ce33cb90b3e9261c9 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Wed, 29 Jun 2022 09:01:33 -0500 Subject: [PATCH] neg perfective split problem --- package.json | 2 +- src/lib/phrase-building/blocks-utils.ts | 9 +++++++++ src/lib/phrase-building/render-vp.ts | 25 ++++++++++++++++++++++--- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 48dc535..7ea2fbd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "3.1.5", + "version": "3.1.6", "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/blocks-utils.ts b/src/lib/phrase-building/blocks-utils.ts index 8c77e28..1b91d93 100644 --- a/src/lib/phrase-building/blocks-utils.ts +++ b/src/lib/phrase-building/blocks-utils.ts @@ -25,6 +25,15 @@ export function getSubjectSelection(blocks: T.EPSBlock[] | T.EPSBlockComplete[] return b.block; } +export function findPerfectiveHead(blocks: T.Block[][]): T.PerfectiveHeadBlock | undefined { + + const b = blocks[0].find(f => f.block.type === "perfectiveHead"); + if (!b || b.block.type !== "perfectiveHead") { + return undefined; + } + return b.block; +} + export function getSubjectSelectionFromBlocks(blocks: T.Block[][]): T.Rendered { const b = blocks[0].find(f => f.block.type === "subjectSelection"); if (!b || b.block.type !== "subjectSelection") { diff --git a/src/lib/phrase-building/render-vp.ts b/src/lib/phrase-building/render-vp.ts index 2f82061..692c0e9 100644 --- a/src/lib/phrase-building/render-vp.ts +++ b/src/lib/phrase-building/render-vp.ts @@ -26,7 +26,7 @@ import { import { renderEnglishVPBase } from "./english-vp-rendering"; import { personGender } from "../../lib/misc-helpers"; import { renderNPSelection } from "./render-np"; -import { getObjectSelection, getSubjectSelection, makeBlock, makeKid } from "./blocks-utils"; +import { findPerfectiveHead, getObjectSelection, getSubjectSelection, makeBlock, makeKid } from "./blocks-utils"; import { renderAPSelection } from "./render-ap"; import { findPossesivesToShrink, orderKids, getMiniPronounPs } from "./render-common"; @@ -237,7 +237,8 @@ function insertNegative(blocks: T.Block[], negative: boolean, imperative: boolea }), ...blocksA.slice(-1), ]; - if (hasNonStandardPerfectiveSplit(blocks)) { + const nonStandardPerfectiveSplit = hasNonStandardPerfectiveSplit(blocks); + if (nonStandardPerfectiveSplit) { return [ basic, [ @@ -247,8 +248,26 @@ function insertNegative(blocks: T.Block[], negative: boolean, imperative: boolea ...blocksA.slice(-1), // last (verb) ], ]; - } + }; if (hasLeapFroggable(blocks)) { + const perfectiveHead = findPerfectiveHead([blocks]); + const perfectiveHeadReg = perfectiveHead && ["و", "وا"].includes(perfectiveHead.ps.p); + if (perfectiveHead) { + return [ + [ + ...blocksA.slice(0, blocks.length - 2), + makeBlock({ type: "negative", imperative }), + ...blocksA.slice(-1), // last + ...blocksA.slice(-2, -1), // second last + ], + [ + ...blocksA.slice(0, blocks.length - 2), + makeBlock({ type: "negative", imperative }), + ...blocksA.slice(-2), + ], + ...!perfectiveHeadReg ? [basic] : [], + ]; + } return [ [ ...blocksA.slice(0, blocks.length - 2),