fix potential edge case with و w consonant endings

This commit is contained in:
lingdocs 2021-10-16 12:41:41 -04:00
parent 7b5242d165
commit 31c5b3b4e8
3 changed files with 5 additions and 3 deletions

View File

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

@ -92,6 +92,7 @@ function handleUnisexWord(word: T.DictionaryEntryNoFVars): T.InflectorOutput {
pashtoConsonants.includes(pEnd) || pashtoConsonants.includes(pEnd) ||
word.p.slice(-2) === "وی" || word.p.slice(-2) === "وی" ||
word.p.slice(-2) === "ای" || word.p.slice(-2) === "ای" ||
word.f.slice(-1) === "w" ||
(word.p.slice(-1) === "ه" && word.f.slice(-1) === "h") (word.p.slice(-1) === "ه" && word.f.slice(-1) === "h")
) { ) {
return { inflections: inflectConsonantEndingUnisex(word.p, word.f), ...plurals }; 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)) { if (word.p.slice(-1) === "ح" && endingInSingleARegex.test(word.f)) {
return { inflections: inflectRegularAWithHimPEnding(word.p, word.f), ...plurals }; 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 }; return { inflections: inflectRegularInanMissingAFem(word.p, word.f), ...plurals };
} }
if (pEnd === "ي" && (!animate)) { if (pEnd === "ي" && (!animate)) {

View File

@ -622,7 +622,7 @@ function ensureShort3rdPersMascSing(
const form = info.idiosyncraticThirdMascSing[aspect]; const form = info.idiosyncraticThirdMascSing[aspect];
// if it ends in a consonant, the special form will also have another // if it ends in a consonant, the special form will also have another
// variation ending with a ه - u // 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<T.PsString> = endsInAConsonant const replacement: T.ArrayOneOrMore<T.PsString> = endsInAConsonant
? [form, concatPsString(form, { p: "ه", f: "u" })] ? [form, concatPsString(form, { p: "ه", f: "u" })]
: [form]; : [form];