From 898042131cfc9c3e13abcfcee6bede777a5fcbb0 Mon Sep 17 00:00:00 2001 From: adueck Date: Sat, 18 Jan 2025 16:29:01 -0500 Subject: [PATCH] fix bundled plural issue --- package-lock.json | 4 ++-- package.json | 2 +- src/components/package.json | 2 +- src/lib/package.json | 2 +- src/lib/src/nouns-plural.ts | 22 ++++++++++++---------- src/lib/src/pashto-inflector.test.ts | 3 --- src/lib/src/type-predicates.ts | 6 ++++-- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 09fe086..3902de0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pashto-inflector-website", - "version": "7.7.8", + "version": "7.7.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pashto-inflector-website", - "version": "7.7.8", + "version": "7.7.9", "dependencies": { "@fortawesome/fontawesome-free": "^5.15.2", "bootstrap": "4.6.1", diff --git a/package.json b/package.json index 099fdaa..f2c6e44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pashto-inflector-website", - "version": "7.7.8", + "version": "7.7.9", "type": "module", "scripts": { "patch": "npm version patch --no-git-tag-version && cd src/lib && npm version patch --no-git-tag-version && cd ../components && npm version patch --no-git-tag-version", diff --git a/src/components/package.json b/src/components/package.json index 5a94108..405dcc9 100644 --- a/src/components/package.json +++ b/src/components/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/ps-react", - "version": "7.7.8", + "version": "7.7.9", "description": "Pashto inflector library module with React components", "main": "dist/components/library-cjs.js", "module": "dist/components/library.js", diff --git a/src/lib/package.json b/src/lib/package.json index 8260894..782dfba 100644 --- a/src/lib/package.json +++ b/src/lib/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/inflect", - "version": "7.7.8", + "version": "7.7.9", "description": "Pashto inflector library", "main": "dist/lib/library.cjs", "module": "dist/lib/library.js", diff --git a/src/lib/src/nouns-plural.ts b/src/lib/src/nouns-plural.ts index aed31ba..4da3a14 100644 --- a/src/lib/src/nouns-plural.ts +++ b/src/lib/src/nouns-plural.ts @@ -15,6 +15,7 @@ import { removeAccents, } from "./accent-helpers"; import * as T from "../../types"; +import { isMascNounEntry, isPattern1Entry } from "./type-predicates"; function makePashtoPlural( word: T.DictionaryEntryNoFVars @@ -35,19 +36,20 @@ function makePashtoPlural( } function makeBundledPlural( - word: T.DictionaryEntryNoFVars + word: T.DictionaryEntry ): T.PluralInflections | undefined { - if (!endsInConsonant(word) || !word.c?.includes("n.")) { + if (isMascNounEntry(word) && isPattern1Entry(word) && endsInConsonant(word)) { + const w = makePsString(word.p, word.f); + const base = countSyllables(w) === 1 ? accentOnNFromEnd(w, 0) : w; + return { + masc: [ + [concatPsString(base, { p: "ه", f: "a" })], + [concatPsString(base, { p: "و", f: "o" })], + ], + }; + } else { return undefined; } - const w = makePsString(word.p, word.f); - const base = countSyllables(w) === 1 ? accentOnNFromEnd(w, 0) : w; - return { - masc: [ - [concatPsString(base, { p: "ه", f: "a" })], - [concatPsString(base, { p: "و", f: "o" })], - ], - }; } function makeArabicPlural( diff --git a/src/lib/src/pashto-inflector.test.ts b/src/lib/src/pashto-inflector.test.ts index 0e55a30..4d30d7d 100644 --- a/src/lib/src/pashto-inflector.test.ts +++ b/src/lib/src/pashto-inflector.test.ts @@ -957,9 +957,6 @@ const nouns: { plural: { masc: [[{ p: "غرونه", f: "ghróona" }], [{ p: "غرونو", f: "ghróono" }]], }, - bundledPlural: { - masc: [[{ p: "غره", f: "ghára" }], [{ p: "غرو", f: "gháro" }]], - }, }, }, // should NOT do the oona plural with the squish nouns, when thay're animate diff --git a/src/lib/src/type-predicates.ts b/src/lib/src/type-predicates.ts index fc88c43..279293b 100644 --- a/src/lib/src/type-predicates.ts +++ b/src/lib/src/type-predicates.ts @@ -29,7 +29,9 @@ export function isKawulVerb(e: T.VerbEntry | T.VerbDictionaryEntry): boolean { return ["کول", "راکول", "درکول", "ورکول"].includes(entry.p); } -export function isNounEntry(e: T.Entry | T.DictionaryEntry): e is T.NounEntry { +export function isNounEntry( + e: T.Entry | T.DictionaryEntry | T.DictionaryEntryNoFVars +): e is T.NounEntry { if ("entry" in e) return false; return !!(e.c && (e.c.includes("n. m.") || e.c.includes("n. f."))); } @@ -116,7 +118,7 @@ export function isVerbEntry( } export function isMascNounEntry( - e: T.InflectableEntry | T.DictionaryEntry + e: T.InflectableEntry | T.DictionaryEntry | T.DictionaryEntryNoFVars ): e is T.MascNounEntry { return !!e.c && e.c.includes("n. m."); }