From ee109b2669b4226bd679b6d1fa26006fbc9483a1 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Wed, 7 Jul 2021 14:27:04 +0300 Subject: [PATCH] more on english verb conjugation --- package.json | 2 +- src/lib/misc-helpers.test.ts | 4 ++++ src/lib/misc-helpers.ts | 12 +++++++++--- src/lib/verb-conjugation.ts | 3 +++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 896b367..57281f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "0.6.2", + "version": "0.6.3", "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/misc-helpers.test.ts b/src/lib/misc-helpers.test.ts index 5ec04d1..b3a98e5 100644 --- a/src/lib/misc-helpers.test.ts +++ b/src/lib/misc-helpers.test.ts @@ -14,7 +14,11 @@ test("parseEc should work", () => { expect(parseEc("walk")).toEqual(["walk", "walks", "walking", "walked", "walked"]); expect(parseEc("scare")).toEqual(["scare", "scares", "scaring", "scared", "scared"]); expect(parseEc("study")).toEqual(["study","studies","studying","studied","studied"]); + expect(parseEc("cry")).toEqual(["cry", "cries", "crying", "cried", "cried"]); + expect(parseEc("die")).toEqual(["die", "dies", "dying", "died", "died"]); expect(parseEc("play")).toEqual(["play","plays","playing","played","played"]); + // if there are only four items the perfect will be the same as the simple past + expect(parseEc("think,thinks,thinking,thought")).toEqual(["think","thinks","thinking","thought","thought"]); expect(parseEc("sew,sews,sewing,sewed,sown")).toEqual(["sew", "sews", "sewing", "sewed", "sown"]); expect(parseEc(" sew, sews,sewing ,sewed, sown")).toEqual(["sew", "sews", "sewing", "sewed", "sown"]); }); \ No newline at end of file diff --git a/src/lib/misc-helpers.ts b/src/lib/misc-helpers.ts index b432757..fd03123 100644 --- a/src/lib/misc-helpers.ts +++ b/src/lib/misc-helpers.ts @@ -223,15 +223,21 @@ export function parseEc(ec: string): T.EnglishVerbConjugationEc { const b = s.slice(0, -1); return [`${s}`, `${b}ies`, `${s}ing`, `${b}ied`, `${b}ied`]; } + if (s.slice(-2) === "ie" && !isVowel(s.slice(-3)[0])) { + const b = s.slice(0, -2); + return [`${s}`, `${s}s`, `${b}ying`, `${s}d`, `${s}d`]; + } const b = (s.slice(-1) === "e") ? s.slice(0, -1) : s; return [`${s}`, `${s}s`, `${b}ing`, `${b}ed`, `${b}ed`]; } const items = ec.split(",").map(x => x.trim()); - return (items.length !== 5) - ? makeRegularConjugations(items[0]) - : [items[0], items[1], items[2], items[3], items[4]]; + return (items.length === 4) + ? [items[0], items[1], items[2], items[3], items[3]] + : (items.length === 5) + ? [items[0], items[1], items[2], items[3], items[4]] + : makeRegularConjugations(items[0]); } // not being used diff --git a/src/lib/verb-conjugation.ts b/src/lib/verb-conjugation.ts index 4a977e0..27d791c 100644 --- a/src/lib/verb-conjugation.ts +++ b/src/lib/verb-conjugation.ts @@ -54,6 +54,9 @@ const getAayTail = (type: T.AayTail): T.PsString => ( ); export function conjugateVerb(entry: T.DictionaryEntry, aayTailType: T.AayTail, complement?: T.DictionaryEntry, verbInfo?: T.NonComboVerbInfo): T.VerbOutput { + if (!(entry.c && entry.c.slice(0, 2) === "v.")) { + throw new Error("not a verb"); + }; const irregularConj = checkForIrregularConjugation(entry); if (irregularConj) { return irregularConj;