better auto unisex inflection

This commit is contained in:
lingdocs 2021-10-10 01:20:39 -04:00
parent ddcc8011cc
commit a303bf6032
3 changed files with 55 additions and 4 deletions

View File

@ -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",

View File

@ -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 ی
{

View File

@ -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<T.PluralInflectionSet> {
// 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<T.PsString>,
// i.masc[0].map((x) => concatPsString(x, { p: "و", f: "o" })) as T.ArrayOneOrMore<T.PsString>,
// ],
// };
// }
// 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) {