From 31c5b3b4e80f3f1c692100099cb6e6eed020cb3a Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Sat, 16 Oct 2021 12:41:41 -0400 Subject: [PATCH] =?UTF-8?q?fix=20potential=20edge=20case=20with=20=D9=88?= =?UTF-8?q?=20w=20consonant=20endings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/lib/pashto-inflector.ts | 4 +++- src/lib/verb-conjugation.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b188b4e..da5cc78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "1.2.3", + "version": "1.2.4", "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/pashto-inflector.ts b/src/lib/pashto-inflector.ts index 0d5c365..a32a6d2 100644 --- a/src/lib/pashto-inflector.ts +++ b/src/lib/pashto-inflector.ts @@ -92,6 +92,7 @@ function handleUnisexWord(word: T.DictionaryEntryNoFVars): T.InflectorOutput { pashtoConsonants.includes(pEnd) || word.p.slice(-2) === "وی" || word.p.slice(-2) === "ای" || + word.f.slice(-1) === "w" || (word.p.slice(-1) === "ه" && word.f.slice(-1) === "h") ) { return { inflections: inflectConsonantEndingUnisex(word.p, word.f), ...plurals }; @@ -150,7 +151,8 @@ function handleFemNoun(word: T.DictionaryEntryNoFVars): T.InflectorOutput { if (word.p.slice(-1) === "ح" && endingInSingleARegex.test(word.f)) { return { inflections: inflectRegularAWithHimPEnding(word.p, word.f), ...plurals }; } - if (pashtoConsonants.includes(pEnd) && !animate) { + // TODO: better reusable function to check if something ends with a consonant + if ((pashtoConsonants.includes(pEnd) || word.f.slice(-1) === "w") && !animate) { return { inflections: inflectRegularInanMissingAFem(word.p, word.f), ...plurals }; } if (pEnd === "ي" && (!animate)) { diff --git a/src/lib/verb-conjugation.ts b/src/lib/verb-conjugation.ts index a795b25..4cb269d 100644 --- a/src/lib/verb-conjugation.ts +++ b/src/lib/verb-conjugation.ts @@ -622,7 +622,7 @@ function ensureShort3rdPersMascSing( const form = info.idiosyncraticThirdMascSing[aspect]; // if it ends in a consonant, the special form will also have another // variation ending with a ه - u - const endsInAConsonant = pashtoConsonants.includes(form.p.slice(-1)); + const endsInAConsonant = (pashtoConsonants.includes(form.p.slice(-1)) || form.f.slice(-1) === "w"); const replacement: T.ArrayOneOrMore = endsInAConsonant ? [form, concatPsString(form, { p: "ه", f: "u" })] : [form];