From a303bf6032f7d6b3901486758a24dc4c4620c962 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Sun, 10 Oct 2021 01:20:39 -0400 Subject: [PATCH] better auto unisex inflection --- package.json | 2 +- src/lib/pashto-inflector.test.ts | 29 +++++++++++++++++++++++++++++ src/lib/pashto-inflector.ts | 28 +++++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9f8f061..13f30d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "1.1.6", + "version": "1.1.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", diff --git a/src/lib/pashto-inflector.test.ts b/src/lib/pashto-inflector.test.ts index b5240b0..ebefcc9 100644 --- a/src/lib/pashto-inflector.test.ts +++ b/src/lib/pashto-inflector.test.ts @@ -412,6 +412,35 @@ const nouns: Array<{ }, }, }, + // with irregular Pashto plural + // TODO: This should work with words like پلویان but not with words like ترورزامن + // { + // in: {"ts":1527820130,"i":2561,"p":"پلوی","f":"palawéy","g":"palawey","e":"adherent, supporter; the outside or further ox in a team of oxes grinding or threshing","c":"n. m. anim. unisex","ppp":"پلویان","ppf":"palawiyáan"}, + // out: { + // inflections: { + // masc: [ + // [{ p: "پلوی", f: "palawéy" }], + // [{ p: "پلوي", f: "palawée" }], + // [{ p: "پلویو", f: "palawiyo" }, { p: "پلوو", f: "palawó" }], + // ], + // fem: [ + // [{ p: "پلوۍ", f: "palawúy" }], + // [{ p: "پلوۍ", f: "palawúy" }], + // [{ p: "پلویو", f: "palawúyo" }, { p: "پلوو", f: "palawó" }], + // ], + // }, + // plural: { + // masc: [ + // [{ p: "پلویان", f: "palawiyáan" }], + // [{ p: "پلویانو", f: "palawiyáano" }], + // ], + // fem: [ + // [{ p: "پلویانې", f: "palawiyáane" }], + // [{ p: "پلویانو", f: "palawiyáano" }], + // ], + // }, + // }, + // }, // ## MASCULINE // Masculine regular ending in ی { diff --git a/src/lib/pashto-inflector.ts b/src/lib/pashto-inflector.ts index bc5e44d..1884822 100644 --- a/src/lib/pashto-inflector.ts +++ b/src/lib/pashto-inflector.ts @@ -428,10 +428,8 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections if (w.c.includes("n. m.")) return { plural: { masc: plural }}; if (w.c.includes("n. f.")) return { plural: { fem: plural }}; } - // TODO: MAKE ARABIC PLURAL HERE IF THERE IS ARABIC PLURAL const arabicPlural = makeArabicPlural(w); const pashtoPlural = makePashtoPlural(w); - if (pashtoPlural) return { plural: pashtoPlural, arabicPlural }; function addMascPluralSuffix(animate?: boolean, shortSquish?: boolean): T.PluralInflectionSet { if (shortSquish && (w.infap === undefined || w.infaf === undefined)) { throw new Error(`no irregular inflection info for ${w.p} - ${w.ts}`); @@ -463,6 +461,24 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections concatPsString(baseWOutAccents, space, { p: "ګانې", f: "gáane" }) ]); } + // TODO: This should be possible for words like پلویان but not for words like ترورزامن 🤔 + // function addFemToPashtoPlural(i: T.PluralInflections): T.UnisexSet { + // if ("fem" in i && "masc" in i) return i; + // if (!("masc" in i)) throw new Error("bad pashto plural doesn't even have masculine"); + // if (endsInConsonant(i.masc[0][0])) { + // return { + // ...i, + // fem: [ + // i.masc[0].map((x) => concatPsString(x, { p: "ې", f: "e" })) as T.ArrayOneOrMore, + // i.masc[0].map((x) => concatPsString(x, { p: "و", f: "o" })) as T.ArrayOneOrMore, + // ], + // }; + // } + // return { + // ...i, + // fem: i.masc, + // }; + // } const shortSquish = !!w.infap && !w.infap.includes("ا"); const anim = w.c?.includes("anim."); @@ -473,8 +489,14 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections : (w.c?.includes("n. f.")) ? "fem noun" : "other"; + if (pashtoPlural) return { + // TODO: add the pashto plural to words like پلویان but not to words like ترورزامن ? + plural: pashtoPlural, + arabicPlural, + }; if (type === "unisex noun") { - if (endsInConsonant(w) && (!w.infap) && anim) { + // doesn't need to be labelled anim - because it's only with animate nouns that you get the unisex - I THINK + if (endsInConsonant(w) && (!w.infap)) { return { arabicPlural, plural: addAnimUnisexPluralSuffix() }; } if (shortSquish) {