more work on parser and fixed some verb conjugation bugs
This commit is contained in:
parent
035e59ae19
commit
f59e3c6550
Binary file not shown.
Before Width: | Height: | Size: 146 KiB After Width: | Height: | Size: 149 KiB |
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "pashto-inflector",
|
||||
"version": "6.0.6",
|
||||
"version": "6.0.7",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pashto-inflector",
|
||||
"version": "6.0.6",
|
||||
"version": "6.0.7",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "pashto-inflector",
|
||||
"version": "6.0.6",
|
||||
"version": "6.0.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",
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@lingdocs/ps-react",
|
||||
"version": "6.0.6",
|
||||
"version": "6.0.7",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lingdocs/ps-react",
|
||||
"version": "6.0.6",
|
||||
"version": "6.0.7",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@formkit/auto-animate": "^1.0.0-beta.3",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lingdocs/ps-react",
|
||||
"version": "6.0.6",
|
||||
"version": "6.0.7",
|
||||
"description": "Pashto inflector library module with React components",
|
||||
"main": "dist/components/library.js",
|
||||
"module": "dist/components/library.js",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lingdocs/inflect",
|
||||
"version": "6.0.6",
|
||||
"version": "6.0.7",
|
||||
"description": "Pashto inflector library",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/lib/library.d.ts",
|
||||
|
|
|
@ -97,6 +97,9 @@ const sturayKawul = wordQuery("ستړی کول", "verb");
|
|||
const raawrul = wordQuery("راوړل", "verb");
|
||||
const ooPh: T.PH = { type: "PH", ps: { p: "و", f: "óo" } };
|
||||
|
||||
// TODO: test all cases of یوړ یوړه یووړ یووړه
|
||||
// and then parsing of all those!!
|
||||
|
||||
const tests: {
|
||||
label: string;
|
||||
cases: {
|
||||
|
@ -1115,6 +1118,7 @@ test("special endings", () => {
|
|||
{ p: "خوت", f: "khot" },
|
||||
// // TODO: is this even right?
|
||||
// { p: "خوته", f: "khotu" },
|
||||
// { p: "خته", f: "khatu" }, ???
|
||||
// { p: "خوتو", f: "khoto" },
|
||||
],
|
||||
},
|
||||
|
@ -1142,8 +1146,7 @@ test("special endings", () => {
|
|||
short: [
|
||||
{ p: "لید", f: "léed" },
|
||||
// // TODO: is this even right?
|
||||
// { p: "خوته", f: "khotu" },
|
||||
// { p: "خوتو", f: "khoto" },
|
||||
{ p: "لیده", f: "leedú" },
|
||||
],
|
||||
},
|
||||
person: 4,
|
||||
|
@ -1167,7 +1170,10 @@ test("special endings", () => {
|
|||
type: "VB",
|
||||
ps: {
|
||||
long: [{ p: "وړلو", f: "wRulo" }],
|
||||
short: [{ p: "ووړ", f: "woR" }],
|
||||
short: [
|
||||
{ p: "ووړ", f: "woR" },
|
||||
{ p: "وړه", f: "wRu" },
|
||||
],
|
||||
},
|
||||
person: 4,
|
||||
info: {
|
||||
|
@ -1180,6 +1186,32 @@ test("special endings", () => {
|
|||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
verb: raawrul,
|
||||
tense: "imperfectivePast",
|
||||
result: [
|
||||
[],
|
||||
[
|
||||
{
|
||||
type: "VB",
|
||||
ps: {
|
||||
long: [{ p: "راوړلو", f: "raawRúlo" }],
|
||||
short: [
|
||||
{ p: "راووړ", f: "raawóR" },
|
||||
{ p: "راوړه", f: "raawRú" },
|
||||
],
|
||||
},
|
||||
person: 4,
|
||||
info: {
|
||||
type: "verb",
|
||||
aspect: "imperfective",
|
||||
base: "root",
|
||||
verb: raawrul,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
// verbs ending in a dental ت or د
|
||||
{
|
||||
verb: rasedul,
|
||||
|
|
|
@ -8,7 +8,9 @@ import {
|
|||
import { applySingleOrLengthOpts, fmapSingleOrLengthOpts } from "../fp-ps";
|
||||
import {
|
||||
concatPsString,
|
||||
endsInConsonant,
|
||||
getLength,
|
||||
lastVowelNotAorO,
|
||||
splitPsByVarients,
|
||||
} from "../p-text-helpers";
|
||||
import {
|
||||
|
@ -116,7 +118,8 @@ const formulas: Record<
|
|||
},
|
||||
};
|
||||
|
||||
// TODO: dynamic and stative compounds
|
||||
// TODO: is وخوته masc ok ??
|
||||
// TODO: what to do with khatu, khot, khotu - bi-directional
|
||||
export function renderVerb({
|
||||
verb,
|
||||
tense,
|
||||
|
@ -375,17 +378,40 @@ function ensure3rdPast(
|
|||
const tpps = splitPsByVarients(
|
||||
makePsString(verb.entry.tppp, verb.entry.tppf)
|
||||
);
|
||||
return tpps.map(({ p, f }) => {
|
||||
const tip = removeAccents(
|
||||
verb.entry.separationAtP !== undefined
|
||||
if (verb.entry.p === "وړل" && aspect === "perfective") {
|
||||
return [
|
||||
{ p: "ړ", f: "R" },
|
||||
{ p: "ړ", f: "Ru" },
|
||||
{ p: "وړ", f: "wuR" },
|
||||
{ p: "وړه", f: "wRu" },
|
||||
];
|
||||
}
|
||||
return tpps
|
||||
.flatMap(({ p, f }) => {
|
||||
if (p.endsWith("ووړ")) {
|
||||
return [
|
||||
{ p, f },
|
||||
{ p: p.slice(0, -2) + "ړه", f: f.slice(0, -2) + "Ru" },
|
||||
];
|
||||
}
|
||||
return [{ p, f }];
|
||||
})
|
||||
.map(({ p, f }) =>
|
||||
verb.entry.separationAtP !== undefined && aspect === "perfective"
|
||||
? makePsString(
|
||||
p.slice(verb.entry.separationAtP),
|
||||
f.slice(verb.entry.separationAtF)
|
||||
)
|
||||
: makePsString(p, f)
|
||||
)
|
||||
.flatMap((ps) =>
|
||||
endsInConsonant(ps) && lastVowelNotAorO(ps.f)
|
||||
? [ps, concatPsString(ps, { p: "ه", f: "u" })]
|
||||
: [ps]
|
||||
)
|
||||
.map((ps) =>
|
||||
aspect === "imperfective" ? accentOnNFromEnd(ps, 0) : removeAccents(ps)
|
||||
);
|
||||
return aspect === "imperfective" ? accentOnNFromEnd(tip, 0) : tip;
|
||||
});
|
||||
// if it ends in a consonant, the special form will also have another
|
||||
// variation ending with a ه - u
|
||||
// const endsInAConsonant = (pashtoConsonants.includes(tip.p.slice(-1)) || tip.f.slice(-1) === "w");
|
||||
|
|
|
@ -1250,3 +1250,13 @@ export function lastVowelNotA(g: string): boolean {
|
|||
}
|
||||
return matches[matches.length - 1] !== "a";
|
||||
}
|
||||
|
||||
export function lastVowelNotAorO(g: string): boolean {
|
||||
const matches = g.match(/ee|aa|i|u|o|oo|U|e|a/g);
|
||||
if (!matches) {
|
||||
return true;
|
||||
}
|
||||
return (
|
||||
matches[matches.length - 1] !== "a" && matches[matches.length - 1] !== "o"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
} from "../p-text-helpers";
|
||||
import { negativeParticle } from "../grammar-units";
|
||||
import * as grammarUnits from "../grammar-units";
|
||||
import { removeDuplicates } from "./vp-tools";
|
||||
import { ensureNoHangingR, removeDuplicates } from "./vp-tools";
|
||||
import { getEnglishFromRendered, getPashtoFromRendered } from "./np-tools";
|
||||
import { completeEPSelection, renderEP } from "./render-ep";
|
||||
import { completeVPSelection } from "./vp-tools";
|
||||
|
@ -391,7 +391,7 @@ function putKidsInKidsSection(
|
|||
return [
|
||||
first,
|
||||
...(enforceKidsSectionBlankout ? [kidsBlank] : kids),
|
||||
...rest,
|
||||
...ensureNoHangingR(rest),
|
||||
];
|
||||
}
|
||||
return blocksWVars.map(insert);
|
||||
|
|
|
@ -20,6 +20,8 @@ import { accentOnNFromEnd } from "../accent-helpers";
|
|||
|
||||
// like زما د ښځو لیدل
|
||||
// my seeing women...
|
||||
// seeing my women...
|
||||
// the women seeing me...
|
||||
|
||||
export function renderNPSelection(
|
||||
NP: T.NPSelection,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as T from "../../../types";
|
||||
import { mapVerbRenderedOutput } from "../fp-ps";
|
||||
import { removeAccents } from "../accent-helpers";
|
||||
import { getPersonFromNP, isPastTense } from "./vp-tools";
|
||||
import { ensureNoHangingR, getPersonFromNP, isPastTense } from "./vp-tools";
|
||||
import { isImperativeTense, isPattern4Entry } from "../type-predicates";
|
||||
import { renderVerb } from "../new-verb-engine/render-verb";
|
||||
import { renderEnglishVPBase } from "./english-vp-rendering";
|
||||
|
@ -21,6 +21,9 @@ import {
|
|||
import { renderComplementSelection } from "./render-complement";
|
||||
import { statVerb } from "../new-verb-engine/roots-and-stems";
|
||||
|
||||
// TODO: Issue with yo me R -- both in rendering (what to do - یوړ مې)
|
||||
// and in parsing!
|
||||
|
||||
export function renderVP(VP: T.VPSelectionComplete): T.VPRendered {
|
||||
const subject = getSubjectSelection(VP.blocks).selection;
|
||||
const object = getObjectSelection(VP.blocks).selection;
|
||||
|
@ -172,25 +175,6 @@ export function insertNegative(
|
|||
}
|
||||
}
|
||||
|
||||
function ensureNoHangingR(b: T.Block[]): T.Block[] {
|
||||
return b.map((x) =>
|
||||
x.block.type === "VB" &&
|
||||
"short" in x.block.ps &&
|
||||
x.block.ps.short.find((x) => x.p === "ړ")
|
||||
? {
|
||||
...x,
|
||||
block: {
|
||||
...x.block,
|
||||
ps: {
|
||||
...x.block.ps,
|
||||
short: x.block.ps.short.filter((ps) => ps.p !== "ړ"),
|
||||
},
|
||||
},
|
||||
}
|
||||
: x
|
||||
);
|
||||
}
|
||||
|
||||
function swapEndingBlocks<X>(arr: X[], n: number = 1): X[] {
|
||||
return [
|
||||
...arr.slice(0, arr.length - (n + 1)),
|
||||
|
|
|
@ -361,3 +361,22 @@ export function ensure2ndPersSubjPronounAndNoConflict(
|
|||
}
|
||||
throw new Error("error ensuring compatible VPSelection for imperative verb");
|
||||
}
|
||||
|
||||
export function ensureNoHangingR(b: T.Block[]): T.Block[] {
|
||||
return b.map((x) =>
|
||||
x.block.type === "VB" &&
|
||||
"short" in x.block.ps &&
|
||||
x.block.ps.short.find((x) => x.p === "ړ")
|
||||
? {
|
||||
...x,
|
||||
block: {
|
||||
...x.block,
|
||||
ps: {
|
||||
...x.block.ps,
|
||||
short: x.block.ps.short.filter((ps) => ps.p !== "ړ"),
|
||||
},
|
||||
},
|
||||
}
|
||||
: x
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue