This commit is contained in:
lingdocs 2021-07-05 18:39:20 +03:00
parent fe55a02f96
commit 4a0cd55830
3 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "0.5.7", "version": "0.5.8",
"author": "lingdocs.com", "author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com", "homepage": "https://verbs.lingdocs.com",

View File

@ -14,6 +14,7 @@ test("parseEc should work", () => {
expect(parseEc("walk")).toEqual(["walk", "walks", "walking", "walked", "walked"]); expect(parseEc("walk")).toEqual(["walk", "walks", "walking", "walked", "walked"]);
expect(parseEc("scare")).toEqual(["scare", "scares", "scaring", "scared", "scared"]); expect(parseEc("scare")).toEqual(["scare", "scares", "scaring", "scared", "scared"]);
expect(parseEc("study")).toEqual(["study","studies","studying","studied","studied"]); expect(parseEc("study")).toEqual(["study","studies","studying","studied","studied"]);
expect(parseEc("play")).toEqual(["play","plays","playing","played","played"]);
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"]);
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"]);
}); });

View File

@ -215,8 +215,11 @@ export function isNounAdjOrVerb(entry: T.DictionaryEntry): "nounAdj" | "verb" |
* @returns * @returns
*/ */
export function parseEc(ec: string): T.EnglishVerbConjugationEc { export function parseEc(ec: string): T.EnglishVerbConjugationEc {
function isVowel(s: string): boolean {
return ["a", "e", "i", "o", "u"].includes(s);
}
function makeRegularConjugations(s: string): T.EnglishVerbConjugationEc { function makeRegularConjugations(s: string): T.EnglishVerbConjugationEc {
if (s.slice(-1) === "y") { if ((s.slice(-1) === "y") && !isVowel(s.slice(-2)[0])) {
const b = s.slice(0, -1); const b = s.slice(0, -1);
return [`${s}`, `${b}ies`, `${s}ing`, `${b}ied`, `${b}ied`]; return [`${s}`, `${b}ies`, `${s}ing`, `${b}ied`, `${b}ied`];
} }