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", "name": "@lingdocs/pashto-inflector",
"version": "1.3.7", "version": "1.3.8",
"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

@ -987,13 +987,13 @@ export function endsWith(
return (ps: T.PsString) => endsWith(ending, ps, matchAccent); return (ps: T.PsString) => endsWith(ending, ps, matchAccent);
} }
if (Array.isArray(ending)) { 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)) { 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)) { 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 f = removeFVarients(ps.f).replace(/'/g, "");
const fEnd = "f" in ending 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"}, in: {"ts":1527823093,"i":13207,"p":"نبي","f":"nabee","g":"nabee","e":"prophet","c":"n. m. anim.","app":"انبیا","apf":"ambiyáa"},
out: { out: {
plural: {
masc: [
[{ p: "نبیان", f: "nabiyáan" }],
[{ p: "نبیانو", f: "nabiyáano" }],
],
},
arabicPlural: { arabicPlural: {
masc: [ masc: [
[{ p: "انبیا", f: "ambiyáa" }], [{ p: "انبیا", f: "ambiyáa" }],
@ -1003,6 +1009,12 @@ const nouns: Array<{
i: 5503, i: 5503,
}, },
out: { out: {
plural: {
fem: [
[{ p: "دوستیانې", f: "dostiyáane" }, { p: "دوستیګانې", f: "dosteegáane" }],
[{ p: "دوستیانو", f: "dostiyáano" }, { p: "دوستیګانو", f: "dosteegáano" }],
],
},
inflections: { inflections: {
fem: [ fem: [
[{p: "دوستي", f: "dostee"}], [{p: "دوستي", f: "dostee"}],

View File

@ -480,6 +480,24 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections
fem: addSecondInf(concatPsString(base, { p: "انې", f: "áane" })), 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> { function addAnimN3UnisexPluralSuffix(): T.UnisexSet<T.PluralInflectionSet> {
const b = removeAccents(w); const b = removeAccents(w);
const base = { const base = {
@ -547,17 +565,16 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections
if (shortSquish && !anim) { if (shortSquish && !anim) {
return { arabicPlural, plural: { masc: addMascPluralSuffix(anim, shortSquish) }}; return { arabicPlural, plural: { masc: addMascPluralSuffix(anim, shortSquish) }};
} }
// TODO: Does the amount of syllables matter for this? if (endsWith([{ p: "ی", f: "éy" }, { p: "ي" }], w, true)) {
if (endsWith({ p: "ی", f: "éy" }, w, true) && w.c?.includes("anim.")) {
return { arabicPlural, plural: addAnimN3UnisexPluralSuffix() }; return { arabicPlural, plural: addAnimN3UnisexPluralSuffix() };
} }
// usually shortSquish nouns would never have arabicPlurals -- so we don't have to worry about catching // usually shortSquish nouns would never have arabicPlurals -- so we don't have to worry about catching
// arabic plurals for the animat ones, right? // arabic plurals for the animat ones, right?
} }
if ( if (
type === "masc noun" && type === "masc noun" &&
(shortSquish || ((endsInConsonant(w) || endsInShwa(w)) && (!w.infap))) && (shortSquish || ((endsInConsonant(w) || endsInShwa(w)) && (!w.infap))) &&
(w.p.slice(-3) !== "توب") (w.p.slice(-3) !== "توب")
) { ) {
return { return {
arabicPlural, 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 // TODO: What about endings in long ee / animate at inanimate
if (type === "fem noun" && endsInAaOrOo(w) && (!w.infap)) { if (type === "fem noun" && endsInAaOrOo(w) && (!w.infap)) {
return { 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) { if (arabicPlural) {
return { arabicPlural, plural: pashtoPlural }; return { arabicPlural, plural: pashtoPlural };
} }