better plurals with ee endings

This commit is contained in:
lingdocs 2021-11-01 17:55:07 -04:00
parent 4cd88baa68
commit 4d4135abc9
4 changed files with 53 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@ -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<T.PsString> = [
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<T.PluralInflectionSet> {
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 };
}