neg perfective split problem

This commit is contained in:
lingdocs 2022-06-29 09:01:33 -05:00
parent 23c9c95692
commit 102232f559
3 changed files with 32 additions and 4 deletions

View File

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

@ -25,6 +25,15 @@ export function getSubjectSelection(blocks: T.EPSBlock[] | T.EPSBlockComplete[]
return b.block; 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<T.SubjectSelectionComplete> { export function getSubjectSelectionFromBlocks(blocks: T.Block[][]): T.Rendered<T.SubjectSelectionComplete> {
const b = blocks[0].find(f => f.block.type === "subjectSelection"); const b = blocks[0].find(f => f.block.type === "subjectSelection");
if (!b || b.block.type !== "subjectSelection") { if (!b || b.block.type !== "subjectSelection") {

View File

@ -26,7 +26,7 @@ import {
import { renderEnglishVPBase } from "./english-vp-rendering"; import { renderEnglishVPBase } from "./english-vp-rendering";
import { personGender } from "../../lib/misc-helpers"; import { personGender } from "../../lib/misc-helpers";
import { renderNPSelection } from "./render-np"; 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 { renderAPSelection } from "./render-ap";
import { findPossesivesToShrink, orderKids, getMiniPronounPs } from "./render-common"; import { findPossesivesToShrink, orderKids, getMiniPronounPs } from "./render-common";
@ -237,7 +237,8 @@ function insertNegative(blocks: T.Block[], negative: boolean, imperative: boolea
}), }),
...blocksA.slice(-1), ...blocksA.slice(-1),
]; ];
if (hasNonStandardPerfectiveSplit(blocks)) { const nonStandardPerfectiveSplit = hasNonStandardPerfectiveSplit(blocks);
if (nonStandardPerfectiveSplit) {
return [ return [
basic, basic,
[ [
@ -247,8 +248,26 @@ function insertNegative(blocks: T.Block[], negative: boolean, imperative: boolea
...blocksA.slice(-1), // last (verb) ...blocksA.slice(-1), // last (verb)
], ],
]; ];
} };
if (hasLeapFroggable(blocks)) { 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 [ return [
[ [
...blocksA.slice(0, blocks.length - 2), ...blocksA.slice(0, blocks.length - 2),