From ffcae9bdaaf600c33335d87395ca2a1db3de7452 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Tue, 31 Aug 2021 13:34:18 +0400 Subject: [PATCH] add inflection for weedu --- package.json | 2 +- src/lib/pashto-inflector.test.ts | 24 ++++++++++++++++++++++++ src/lib/pashto-inflector.ts | 25 +++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e79d90d..1f41be6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "0.9.0", + "version": "0.9.1", "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 48d152d..51b71c5 100644 --- a/src/lib/pashto-inflector.test.ts +++ b/src/lib/pashto-inflector.test.ts @@ -164,6 +164,30 @@ const adjectives: Array<{ ], }, }, + // adjective ending in u + { + in: { + ts: 1527812791, + p: "ویده", + f: "weedú", + g: "weedu", + e: "asleep", + c: "adj.", + i: 1, + }, + out: { + masc: [ + [{p: "ویده", f: "weedú"}], + [{p: "ویده", f: "weedú"}], + [{p: "ویدو", f: "weedó"}], + ], + fem: [ + [{p: "ویده", f: "weedá"}], + [{p: "ویدې", f: "weedé"}], + [{p: "ویدو", f: "weedó"}], + ], + }, + }, // adjective non-inflecting { in: { diff --git a/src/lib/pashto-inflector.ts b/src/lib/pashto-inflector.ts index 5739378..c3a8a67 100644 --- a/src/lib/pashto-inflector.ts +++ b/src/lib/pashto-inflector.ts @@ -11,7 +11,11 @@ import { concatInflections, splitDoubleWord, ensureUnisexInflections, + makePsString, } from "./p-text-helpers"; +import { + removeAccents, +} from "./accent-helpers"; import * as T from "../types"; const endingInSingleARegex = /[^a]'?’?[aá]'?’?$/; @@ -61,6 +65,9 @@ function handleUnisexWord(word: T.DictionaryEntry): T.Inflections | false { if (pEnd === "ی" && f.slice(-2) === "ey") { return inflectRegularYeyUnisex(word.p, f); } + if (pEnd === "ه" && word.g.slice(-1) === "u") { + return inflectRegularShwaEndingUnisex(word.p, f); + } if (pEnd === "ی" && f.slice(-2) === "éy") { return inflectEmphasizedYeyUnisex(word.p, f); } @@ -166,6 +173,24 @@ export function inflectRegularYeyUnisex(p: string, f: string): T.UnisexInflectio }; } +export function inflectRegularShwaEndingUnisex(pr: string, fr: string): T.UnisexInflections { + const { p, f } = removeAccents(makePsString(pr, fr)); + const baseP = p.slice(0, -1); + const baseF = f.slice(0, -1); + return { + masc: [ + [{p: `${baseP}ه`, f: `${baseF}ú`}], + [{p: `${baseP}ه`, f: `${baseF}ú`}], + [{p: `${baseP}و`, f: `${baseF}ó`}], + ], + fem: [ + [{p: `${baseP}ه`, f: `${baseF}á`}], + [{p: `${baseP}ې`, f: `${baseF}é`}], + [{p: `${baseP}و`, f: `${baseF}ó`}], + ], + }; +} + function inflectEmphasizedYeyUnisex(p: string, f: string): T.UnisexInflections { const baseP = p.slice(0, -1); const baseF = f.slice(0, -2);