From da12c7f62b42aa02dc6f8939b6f3f8484251afc7 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Thu, 16 Sep 2021 16:41:50 -0400 Subject: [PATCH] allow variations in pashto plural --- package.json | 2 +- src/lib/pashto-inflector.test.ts | 19 +++++++++++++++++++ src/lib/pashto-inflector.ts | 9 +++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fa5174b..ea8cb6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "1.0.5", + "version": "1.0.6", "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 5fdce00..2ce1581 100644 --- a/src/lib/pashto-inflector.test.ts +++ b/src/lib/pashto-inflector.test.ts @@ -984,6 +984,25 @@ const nouns: Array<{ }, }, }, + // with variations on Pashto plural + { + in: {"ts":1527815268,"i":8475,"p":"شی","f":"shey","g":"shey","ppp":"شیان، شیونه", "ppf": "sheyáan, sheyóona","e":"thing","c":"n. m."}, + out: { + inflections: { + masc: [ + [{ p: "شی", f: "shey" }], + [{ p: "شي", f: "shee" }], + [{ p: "شیو", f: "shiyo" }, { p: "شو", f: "sho" }], + ], + }, + plural: { + masc: [ + [{ p: "شیان", f: "sheyáan" }, { p: "شیونه", f: "sheyóona" }], + [{ p: "شیانو", f: "sheyáano" }, { p: "شیونو", f: "sheyóono" }], + ], + }, + }, + }, // TODO: Plaar plaroona paaraan - wrooNa // Word with no inflections { diff --git a/src/lib/pashto-inflector.ts b/src/lib/pashto-inflector.ts index 45998c7..9b8de73 100644 --- a/src/lib/pashto-inflector.ts +++ b/src/lib/pashto-inflector.ts @@ -373,9 +373,14 @@ function inflectRegularUyFem(p: string, f: string): T.Inflections { function makePashtoPlural(word: T.DictionaryEntryNoFVars): T.PluralInflections | undefined { if (!(word.ppp && word.ppf)) return undefined; - const base = makePsString(word.ppp, word.ppf); + const base = splitPsByVarients( + makePsString(word.ppp, word.ppf) + ); function getBaseAndO(): T.PluralInflectionSet { - return [[base], addOEnding(base)]; + return [ + base, + base.flatMap(addOEnding) as T.ArrayOneOrMore, + ]; } if (word.c?.includes("n. m.")) { return { masc: getBaseAndO() };