From 28f79729a4960cc0086595f6332113081e15387b Mon Sep 17 00:00:00 2001 From: adueck Date: Fri, 1 Sep 2023 12:47:15 +0400 Subject: [PATCH] bug fix --- package-lock.json | 4 +- package.json | 2 +- src/components/package-lock.json | 4 +- src/components/package.json | 2 +- src/lib/package.json | 2 +- .../src/new-verb-engine/render-verb.test.ts | 39 +++++++++++++++++++ src/lib/src/new-verb-engine/render-verb.ts | 22 +++++++++++ src/lib/src/parsing/parse-vp.ts | 2 + 8 files changed, 70 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 44acb00..7b90f8b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pashto-inflector", - "version": "6.0.7", + "version": "6.0.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pashto-inflector", - "version": "6.0.7", + "version": "6.0.8", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index aca1526..b698a9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pashto-inflector", - "version": "6.0.7", + "version": "6.0.8", "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/components/package-lock.json b/src/components/package-lock.json index 5edb3a3..739bd9b 100644 --- a/src/components/package-lock.json +++ b/src/components/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lingdocs/ps-react", - "version": "6.0.7", + "version": "6.0.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lingdocs/ps-react", - "version": "6.0.7", + "version": "6.0.8", "license": "MIT", "dependencies": { "@formkit/auto-animate": "^1.0.0-beta.3", diff --git a/src/components/package.json b/src/components/package.json index 47a8888..42ec31e 100644 --- a/src/components/package.json +++ b/src/components/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/ps-react", - "version": "6.0.7", + "version": "6.0.8", "description": "Pashto inflector library module with React components", "main": "dist/components/library.js", "module": "dist/components/library.js", diff --git a/src/lib/package.json b/src/lib/package.json index d7365c7..071988c 100644 --- a/src/lib/package.json +++ b/src/lib/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/inflect", - "version": "6.0.7", + "version": "6.0.8", "description": "Pashto inflector library", "main": "dist/index.js", "types": "dist/lib/library.d.ts", diff --git a/src/lib/src/new-verb-engine/render-verb.test.ts b/src/lib/src/new-verb-engine/render-verb.test.ts index e3ec282..fdd4064 100644 --- a/src/lib/src/new-verb-engine/render-verb.test.ts +++ b/src/lib/src/new-verb-engine/render-verb.test.ts @@ -80,6 +80,7 @@ const kedulDyn = vEntry({ separationAtP: 1, separationAtF: 2, }); +const ahkeestul = wordQuery("اخیستل", "verb"); const wahul = wordQuery("وهل", "verb"); const achawul = wordQuery("اچول", "verb"); const ganul = wordQuery("ګڼل", "verb"); @@ -290,6 +291,44 @@ const tests: { ], }, }, + { + input: { + verb: ahkeestul, + tense: "perfectivePast", + subject: T.Person.FirstSingMale, + object: T.Person.ThirdSingMale, + voice: "active", + negative: false, + }, + output: { + hasBa: false, + vbs: [ + [{ type: "PH", ps: { p: "وا", f: "wáa" } }], + [ + { + type: "VB", + ps: { + long: [{ p: "خیستلو", f: "kheestulo" }], + short: [ + { p: "خیست", f: "kheest" }, + { + p: "خیسته", + f: "kheestu", + }, + ], + }, + person: T.Person.ThirdSingMale, + info: { + type: "verb", + aspect: "perfective", + base: "root", + verb: ahkeestul, + }, + }, + ], + ], + }, + }, ], }, { diff --git a/src/lib/src/new-verb-engine/render-verb.ts b/src/lib/src/new-verb-engine/render-verb.ts index 05308ef..7cf8739 100644 --- a/src/lib/src/new-verb-engine/render-verb.ts +++ b/src/lib/src/new-verb-engine/render-verb.ts @@ -377,6 +377,8 @@ function ensure3rdPast( if (verb.entry.tppp && verb.entry.tppf) { const tpps = splitPsByVarients( makePsString(verb.entry.tppp, verb.entry.tppf) + ).map((ps) => + !verb.entry.sepOo && aspect === "perfective" ? takeOffAaStart(ps) : ps ); if (verb.entry.p === "وړل" && aspect === "perfective") { return [ @@ -445,3 +447,23 @@ function removeAbility( ): T.VerbTense | T.ImperativeTense { return tense.replace("Modal", "") as T.VerbTense | T.ImperativeTense; } + +function takeOffAaStart(ps: T.PsString): T.PsString { + if (!["ا", "آ"].includes(ps.p[0])) { + return ps; + } + // TODO handle more than just the starting aa + if (["aa", "áa"].includes(ps.f.slice(0, 2))) { + return { + p: ps.p.slice(1), + f: ps.f.slice(2), + }; + } + if (["a", "á"].includes(ps.f[0])) { + return { + p: ps.p.slice(1), + f: ps.f.slice(1), + }; + } + return ps; +} diff --git a/src/lib/src/parsing/parse-vp.ts b/src/lib/src/parsing/parse-vp.ts index cb2a7c8..cee0c1b 100644 --- a/src/lib/src/parsing/parse-vp.ts +++ b/src/lib/src/parsing/parse-vp.ts @@ -30,6 +30,8 @@ import { LookupFunction } from "./lookup"; // learn to use jq to edit selected json in vim ?? COOOL // TODO: test grammatically transitive stuff +// test bo ba ye dzee +// test raaba ye wree export function parseVP( tokens: Readonly,