From 5cae22bde7379dbec7c95eaad167eae7ec8e6548 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Wed, 22 Sep 2021 13:21:59 -0400 Subject: [PATCH] fix accent issue --- package.json | 2 +- src/lib/pashto-inflector.test.ts | 18 ++++++++++++++++++ src/lib/pashto-inflector.ts | 13 +++++++------ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index ea8cb6d..6fb7154 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "1.0.6", + "version": "1.0.7", "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 2ce1581..8a96621 100644 --- a/src/lib/pashto-inflector.test.ts +++ b/src/lib/pashto-inflector.test.ts @@ -202,6 +202,24 @@ const adjectives: Array<{ }, }, }, + // without accents + { + in: {"ts":1527812796,"i":8574,"p":"ښه","f":"xu","g":"xu","e":"good","c":"adj."}, + out: { + inflections: { + masc: [ + [{ p: "ښه", f: "xu" }], + [{ p: "ښه", f: "xu" }], + [{ p: "ښو", f: "xo" }], + ], + fem: [ + [{ p: "ښه", f: "xa" }], + [{ p: "ښې", f: "xe" }], + [{ p: "ښو", f: "xo" }], + ], + }, + }, + }, // adjective non-inflecting { in: { diff --git a/src/lib/pashto-inflector.ts b/src/lib/pashto-inflector.ts index 9b8de73..429ac96 100644 --- a/src/lib/pashto-inflector.ts +++ b/src/lib/pashto-inflector.ts @@ -203,18 +203,19 @@ 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 accented = fr.slice(-1) === "ú"; 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}ó`}], + [{p: `${baseP}ه`, f: `${baseF}${accented ? "ú" : "u"}`}], + [{p: `${baseP}ه`, f: `${baseF}${accented ? "ú" : "u"}`}], + [{p: `${baseP}و`, f: `${baseF}${accented ? "ó" : "o"}`}], ], fem: [ - [{p: `${baseP}ه`, f: `${baseF}á`}], - [{p: `${baseP}ې`, f: `${baseF}é`}], - [{p: `${baseP}و`, f: `${baseF}ó`}], + [{p: `${baseP}ه`, f: `${baseF}${accented ? "á" : "a"}`}], + [{p: `${baseP}ې`, f: `${baseF}${accented ? "é" : "e"}`}], + [{p: `${baseP}و`, f: `${baseF}${accented ? "ó" : "o"}`}], ], }; }