diff --git a/package-lock.json b/package-lock.json index 92cf82c..c2e8227 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pashto-inflector", - "version": "5.2.1", + "version": "5.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pashto-inflector", - "version": "5.2.1", + "version": "5.3.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index de546e3..1dd1b28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pashto-inflector", - "version": "5.2.1", + "version": "5.3.0", "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/components/package.json b/src/components/package.json index 2911ac4..1b65ee7 100644 --- a/src/components/package.json +++ b/src/components/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/ps-react", - "version": "5.2.1", + "version": "5.3.0", "description": "Pashto inflector library module with React components", "main": "dist/components/library.js", "module": "dist/components/library.js", diff --git a/src/lib/package.json b/src/lib/package.json index a16ed5f..a33d529 100644 --- a/src/lib/package.json +++ b/src/lib/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/inflect", - "version": "5.2.1", + "version": "5.3.0", "description": "Pashto inflector library", "main": "dist/index.js", "types": "dist/lib/library.d.ts", diff --git a/src/lib/src/pashto-inflector.test.ts b/src/lib/src/pashto-inflector.test.ts index ae81c2f..43ec6ac 100644 --- a/src/lib/src/pashto-inflector.test.ts +++ b/src/lib/src/pashto-inflector.test.ts @@ -14,10 +14,10 @@ import { } from "./pashto-inflector"; import * as T from "../../types"; -const adjectives: Array<{ +const adjectives: { in: T.DictionaryEntry, out: T.InflectorOutput, -}> = [ +}[] = [ // irregular adj. { in: { @@ -334,10 +334,10 @@ const adjectives: Array<{ }, ]; -const nouns: Array<{ +const nouns: { in: T.DictionaryEntry, out: T.InflectorOutput, -}> = [ +}[] = [ // ## UNISEX // Unisex noun irregular { @@ -453,6 +453,12 @@ const nouns: Array<{ [{p: "چرګانو", f: "churgáano"}], ], }, + bundledPlural: { + masc: [ + [{ p: "چرګه", f: "chúrga" }], + [{ p: "چرګو", f: "chúrgo" }], + ], + }, }, }, // with #3 pattern anim unisex @@ -603,6 +609,12 @@ const nouns: Array<{ [{ 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 they're animate @@ -726,6 +738,12 @@ const nouns: Array<{ [{ p: "کتابونو", f: "kitaabóono" }], ], }, + bundledPlural: { + masc: [ + [{ p: "کتابه", f: "kitaaba" }], + [{ p: "کتابو", f: "kitaabo" }], + ], + }, }, }, { @@ -737,6 +755,12 @@ const nouns: Array<{ [{ p: "غاښونو", f: "ghaaxóono" }], ], }, + bundledPlural: { + masc: [ + [{ p: "غاښه", f: "gháaxa" }], + [{ p: "غاښو", f: "gháaxo" }], + ], + }, }, }, { @@ -770,6 +794,12 @@ const nouns: Array<{ [{ p: "لوونو", f: "lawóono" }], ], }, + bundledPlural: { + masc: [ + [{ p: "لوه", f: "láwa" }], + [{ p: "لوو", f: "láwo" }], + ], + } }, }, // ## FEMININE @@ -908,6 +938,12 @@ const nouns: Array<{ [{ p: "تبلیغونو", f: "tableeghóono" }], ], }, + bundledPlural: { + masc: [ + [{ p: "تبلیغه", f: "tableegha" }], + [{ p: "تبلیغو", f: "tableegho" }], + ], + }, arabicPlural: { masc: [ [{ p: "تبلیغات", f: "tableegháat" }], @@ -972,6 +1008,12 @@ const nouns: Array<{ [{ p: "حالونو", f: "haalóono" }], ], }, + bundledPlural: { + masc: [ + [{ p: "حاله", f: "háala" }], + [{ p: "حالو", f: "háalo" }], + ], + }, arabicPlural: { masc: [ [{ p: "احوال", f: "ahwáal" }], diff --git a/src/lib/src/pashto-inflector.ts b/src/lib/src/pashto-inflector.ts index f9ce400..3caaecb 100644 --- a/src/lib/src/pashto-inflector.ts +++ b/src/lib/src/pashto-inflector.ts @@ -23,12 +23,15 @@ import { import { makePsString, removeFVarients } from "./accent-and-ps-utils"; import { accentFSylsOnNFromEnd, + accentOnNFromEnd, + countSyllables, hasAccents, removeAccents, splitUpSyllables, } from "./accent-helpers"; import * as T from "../../types"; import { splitFIntoPhonemes } from "./phonetics-to-diacritics"; +import { isNounEntry } from "./type-predicates"; const endingInSingleARegex = /[^a]'?’?[aá]'?’?$/; const endingInHeyOrAynRegex = /[^ا][هع]$/; @@ -420,6 +423,22 @@ function makePashtoPlural(word: T.DictionaryEntryNoFVars): T.PluralInflections | return undefined; } +function makeBundledPlural(word: T.DictionaryEntryNoFVars): T.PluralInflections | undefined { + if (!endsInConsonant(word) || !word.c?.includes("n.")) { + 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(word: T.DictionaryEntryNoFVars): T.PluralInflections | undefined { if (!(word.apf && word.app)) return undefined; const w = makePsString(word.app, word.apf); @@ -438,7 +457,7 @@ function makeArabicPlural(word: T.DictionaryEntryNoFVars): T.PluralInflections | return { masc: value }; } -function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections } | { arabicPlural: T.PluralInflections } | undefined { +function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections, bundledPlural?: T.PluralInflections } | { arabicPlural: T.PluralInflections, bundledPlural?: T.PluralInflections } | undefined { function addSecondInf(plur: T.ArrayOneOrMore | T.PsString): T.PluralInflectionSet { if (!Array.isArray(plur)) { return addSecondInf([plur]); @@ -457,6 +476,7 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections } const arabicPlural = makeArabicPlural(w); const pashtoPlural = makePashtoPlural(w); + const bundledPlural = makeBundledPlural(w); 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}`); @@ -559,7 +579,7 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections if (type === "unisex noun") { // 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() }; + return { arabicPlural, bundledPlural, plural: addAnimUnisexPluralSuffix() }; } if (shortSquish && !anim) { return { arabicPlural, plural: { masc: addMascPluralSuffix(anim, shortSquish) }}; @@ -577,6 +597,7 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections ) { return { arabicPlural, + bundledPlural, plural: { masc: addMascPluralSuffix(anim, shortSquish), }, @@ -620,7 +641,7 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections }; } if (arabicPlural) { - return { arabicPlural, plural: pashtoPlural }; + return { arabicPlural, plural: pashtoPlural, bundledPlural }; } return undefined; } diff --git a/src/types.ts b/src/types.ts index 1454bf4..fa609db 100644 --- a/src/types.ts +++ b/src/types.ts @@ -378,10 +378,12 @@ export type PluralInflections = GenderedSet; export type InflectorOutput = { arabicPlural: PluralInflections, plural?: PluralInflections, + bundledPlural?: PluralInflections, inflections?: Inflections, } | { plural: PluralInflections, arabicPlural?: PluralInflections, + bundledPlural?: PluralInflections, inflections?: Inflections, } | { inflections: Inflections, @@ -436,7 +438,7 @@ export type Wrapper = T & { __brand: "wrapped" }; export type ArrayOneOrMore = { 0: T -} & Array +} & T[]; export type RootsOrStemsToHighlight = ("imperfective root" | "perfective root" | "imperfective stem" | "perfective stem" | "past participle")[];