diff --git a/package.json b/package.json index 7f5f7da..005c799 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "1.3.7", + "version": "1.3.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/lib/p-text-helpers.ts b/src/lib/p-text-helpers.ts index cd886d0..8f114e6 100644 --- a/src/lib/p-text-helpers.ts +++ b/src/lib/p-text-helpers.ts @@ -987,13 +987,13 @@ export function endsWith( return (ps: T.PsString) => endsWith(ending, ps, matchAccent); } if (Array.isArray(ending)) { - return ending.some(e => endsWith(e, ps)); + return ending.some(e => endsWith(e, ps, matchAccent)); } if ("p" in ending && Array.isArray(ending.p)) { - return ending.p.some(e => endsWith({ p: e }, ps)); + return ending.p.some(e => endsWith({ p: e }, ps, matchAccent)); } if ("f" in ending && Array.isArray(ending.f)) { - return ending.f.some(e => endsWith({ f: e }, ps)); + return ending.f.some(e => endsWith({ f: e }, ps, matchAccent)); } const f = removeFVarients(ps.f).replace(/'/g, ""); const fEnd = "f" in ending diff --git a/src/lib/pashto-inflector.test.ts b/src/lib/pashto-inflector.test.ts index 3a8515d..d6391d1 100644 --- a/src/lib/pashto-inflector.test.ts +++ b/src/lib/pashto-inflector.test.ts @@ -815,6 +815,12 @@ const nouns: Array<{ { in: {"ts":1527823093,"i":13207,"p":"نبي","f":"nabee","g":"nabee","e":"prophet","c":"n. m. anim.","app":"انبیا","apf":"ambiyáa"}, out: { + plural: { + masc: [ + [{ p: "نبیان", f: "nabiyáan" }], + [{ p: "نبیانو", f: "nabiyáano" }], + ], + }, arabicPlural: { masc: [ [{ p: "انبیا", f: "ambiyáa" }], @@ -1003,6 +1009,12 @@ const nouns: Array<{ i: 5503, }, out: { + plural: { + fem: [ + [{ p: "دوستیانې", f: "dostiyáane" }, { p: "دوستیګانې", f: "dosteegáane" }], + [{ p: "دوستیانو", f: "dostiyáano" }, { p: "دوستیګانو", f: "dosteegáano" }], + ], + }, inflections: { fem: [ [{p: "دوستي", f: "dostee"}], diff --git a/src/lib/pashto-inflector.ts b/src/lib/pashto-inflector.ts index 94bb341..e84f53e 100644 --- a/src/lib/pashto-inflector.ts +++ b/src/lib/pashto-inflector.ts @@ -480,6 +480,24 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections fem: addSecondInf(concatPsString(base, { p: "انې", f: "áane" })), }; } + function addEePluralSuffix(gender: T.Gender): T.PluralInflectionSet { + const b = removeAccents(w); + const base = { + p: b.p.slice(0, -1), + f: b.f.slice(0, -2), + }; + const firstInf: T.ArrayOneOrMore = [ + concatPsString(base, { p: "یان", f: "iyáan" }, gender === "fem" ? { p: "ې", f: "e" } : ""), + ...gender === "fem" + ? [concatPsString(base, { p: "یګانې", f: "eegáane" })] + : [], + ]; + return [ + firstInf, + firstInf.flatMap(addOEnding), + // firstInf.map(addOEnding), + ] as T.PluralInflectionSet; + } function addAnimN3UnisexPluralSuffix(): T.UnisexSet { const b = removeAccents(w); const base = { @@ -547,17 +565,16 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections if (shortSquish && !anim) { return { arabicPlural, plural: { masc: addMascPluralSuffix(anim, shortSquish) }}; } - // TODO: Does the amount of syllables matter for this? - if (endsWith({ p: "ی", f: "éy" }, w, true) && w.c?.includes("anim.")) { + if (endsWith([{ p: "ی", f: "éy" }, { p: "ي" }], w, true)) { return { arabicPlural, plural: addAnimN3UnisexPluralSuffix() }; } // usually shortSquish nouns would never have arabicPlurals -- so we don't have to worry about catching // arabic plurals for the animat ones, right? } if ( - type === "masc noun" && - (shortSquish || ((endsInConsonant(w) || endsInShwa(w)) && (!w.infap))) && - (w.p.slice(-3) !== "توب") + type === "masc noun" && + (shortSquish || ((endsInConsonant(w) || endsInShwa(w)) && (!w.infap))) && + (w.p.slice(-3) !== "توب") ) { return { arabicPlural, @@ -579,6 +596,13 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections }, }; } + if (type === "masc noun" && endsWith({ p: "ي" }, w)) { + const masc = addEePluralSuffix("masc"); + return { + arabicPlural, + plural: { masc }, + }; + } // TODO: What about endings in long ee / animate at inanimate if (type === "fem noun" && endsInAaOrOo(w) && (!w.infap)) { return { @@ -588,6 +612,14 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections }, }; } + if (type === "fem noun" && endsWith({ p: "ي" }, w)) { + return { + arabicPlural, + plural: { + fem: addEePluralSuffix("fem"), + }, + }; + } if (arabicPlural) { return { arabicPlural, plural: pashtoPlural }; }