From 4a2b46e05e1f28bf8c82a6362bc77119d2238028 Mon Sep 17 00:00:00 2001 From: adueck Date: Mon, 26 Sep 2022 16:20:29 +0400 Subject: [PATCH] proper inflection in charts for stative compounds --- package.json | 2 +- src/lib/accent-helpers.ts | 10 +++ src/lib/irregular-conjugations.ts | 104 +++++++++++++++--------------- src/lib/verb-conjugation.ts | 19 +++--- 4 files changed, 74 insertions(+), 61 deletions(-) diff --git a/package.json b/package.json index c3b620b..5ccb0e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "4.0.3", + "version": "4.0.4", "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/accent-helpers.ts b/src/lib/accent-helpers.ts index 47961f6..df3de22 100644 --- a/src/lib/accent-helpers.ts +++ b/src/lib/accent-helpers.ts @@ -142,6 +142,16 @@ export function removeAccents(s: T.PsString | string | T.PsString[]): T.PsString }); } +export function removeAccentsFromInflections(inf: T.UnisexInflections): T.UnisexInflections { + function removeFromSide(inf: T.InflectionSet): T.InflectionSet { + return inf.map(removeAccents) as T.ArrayFixed, 3>; + } + return { + masc: removeFromSide(inf.masc), + fem: removeFromSide(inf.fem), + }; +} + /** * Determines if a string has any accents on it * diff --git a/src/lib/irregular-conjugations.ts b/src/lib/irregular-conjugations.ts index b267cf7..7968cf3 100644 --- a/src/lib/irregular-conjugations.ts +++ b/src/lib/irregular-conjugations.ts @@ -1050,7 +1050,7 @@ const kawulHypothetical: T.VerbForm = { export const kawulStat: T.VerbConjugation = { info: { entry: { - entry: {"ts":1579015359582,"i":10579,"p":"کول","f":"kawul","g":"kawul","e":"to make ____ ____ (as in \"He's making me angry.\")","c":"v. trans. irreg.","ssp":"کړ","ssf":"kR","prp":"کړل","prf":"kRul","pprtp":"کړی","pprtf":"kúRey","noOo":true,"ec":"make,makes,making,made,made","ep":"_____"} as T.VerbDictionaryEntry, + entry: {"ts":1579015359582,"i":10579,"p":"کول","f":"kawúl","g":"kawúl","e":"to make ____ ____ (as in \"He's making me angry.\")","c":"v. trans. irreg.","ssp":"کړ","ssf":"kR","prp":"کړل","prf":"kRul","pprtp":"کړی","pprtf":"kúRey","noOo":true,"ec":"make,makes,making,made,made","ep":"_____"} as T.VerbDictionaryEntry, }, transitivity: "transitive", type: "simple", @@ -1084,20 +1084,20 @@ export const kawulStat: T.VerbConjugation = { }, imperfective: { nonImperative: [ - [[{p: "کوم", f: "kawum"}], [{p: "کوو", f: "kawoo"}]], - [[{p: "کوم", f: "kawum"}], [{p: "کوو", f: "kawoo"}]], - [[{p: "کوې", f: "kawe"}], [{p: "کوئ", f: "kaweyy"}]], - [[{p: "کوې", f: "kawe"}], [{p: "کوئ", f: "kaweyy"}]], - [[{p: "کوي", f: "kawee"}], [{p: "کوي", f: "kawee"}]], - [[{p: "کوي", f: "kawee"}], [{p: "کوي", f: "kawee"}]], + [[{p: "کوم", f: "kawúm"}], [{p: "کوو", f: "kawóo"}]], + [[{p: "کوم", f: "kawúm"}], [{p: "کوو", f: "kawóo"}]], + [[{p: "کوې", f: "kawé"}], [{p: "کوئ", f: "kawéyy"}]], + [[{p: "کوې", f: "kawé"}], [{p: "کوئ", f: "kawéyy"}]], + [[{p: "کوي", f: "kawée"}], [{p: "کوي", f: "kawée"}]], + [[{p: "کوي", f: "kawée"}], [{p: "کوي", f: "kawée"}]], ], future: [ - [[{p: "به کوم", f: "ba kawum"}], [{p: "به کوو", f: "ba kawoo"}]], - [[{p: "به کوم", f: "ba kawum"}], [{p: "به کوو", f: "ba kawoo"}]], - [[{p: "به کوې", f: "ba kawe"}], [{p: "به کوئ", f: "ba kaweyy"}]], - [[{p: "به کوې", f: "ba kawe"}], [{p: "به کوئ", f: "ba kaweyy"}]], - [[{p: "به کوي", f: "ba kawee"}], [{p: "به کوي", f: "ba kawee"}]], - [[{p: "به کوي", f: "ba kawee"}], [{p: "به کوي", f: "ba kawee"}]], + [[{p: "به کوم", f: "ba kawúm"}], [{p: "به کوو", f: "ba kawóo"}]], + [[{p: "به کوم", f: "ba kawúm"}], [{p: "به کوو", f: "ba kawóo"}]], + [[{p: "به کوې", f: "ba kawé"}], [{p: "به کوئ", f: "ba kawéyy"}]], + [[{p: "به کوې", f: "ba kawé"}], [{p: "به کوئ", f: "ba kawéyy"}]], + [[{p: "به کوي", f: "ba kawée"}], [{p: "به کوي", f: "ba kawée"}]], + [[{p: "به کوي", f: "ba kawée"}], [{p: "به کوي", f: "ba kawée"}]], ], imperative: [ [[{ p: "کوه", f: "kawá" }], [{ p: "کوئ", f: "kawéyy" }]], @@ -1105,38 +1105,38 @@ export const kawulStat: T.VerbConjugation = { ], past: { short: [ - [[{p: "کوم", f: "kawum"}], [{p: "کوو", f: "kawoo"}]], - [[{p: "کوم", f: "kawum"}], [{p: "کوو", f: "kawoo"}]], - [[{p: "کوې", f: "kawe"}], [{p: "کوئ", f: "kaweyy"}]], - [[{p: "کوې", f: "kawe"}], [{p: "کوئ", f: "kaweyy"}]], - [[{p: "کاوه", f: "kaawu"}], [{p: "کول", f: "kawul"}]], - [[{p: "کوه", f: "kawa"}], [{p: "کوې", f: "kawe"}]], + [[{p: "کوم", f: "kawúm"}], [{p: "کوو", f: "kawóo"}]], + [[{p: "کوم", f: "kawúm"}], [{p: "کوو", f: "kawóo"}]], + [[{p: "کوې", f: "kawé"}], [{p: "کوئ", f: "kawéyy"}]], + [[{p: "کوې", f: "kawé"}], [{p: "کوئ", f: "kawéyy"}]], + [[{p: "کاوه", f: "kaawú"}], [{p: "کول", f: "kawúl"}]], + [[{p: "کوه", f: "kawá"}], [{p: "کوې", f: "kawé"}]], ], long: [ - [[{p: "کولم", f: "kawulum"}], [{p: "کولو", f: "kawuloo"}]], - [[{p: "کولم", f: "kawulum"}], [{p: "کولو", f: "kawuloo"}]], - [[{p: "کولې", f: "kawule"}], [{p: "کولئ", f: "kawuleyy"}]], - [[{p: "کولې", f: "kawule"}], [{p: "کولئ", f: "kawuleyy"}]], - [[{p: "کوله", f: "kawulu"}, {p: "کولو", f: "kawulo"}], [{p: "کول", f: "kawul"}]], - [[{p: "کوله", f: "kawula"}], [{p: "کولې", f: "kawule"}]], + [[{p: "کولم", f: "kawúlum"}], [{p: "کولو", f: "kawúloo"}]], + [[{p: "کولم", f: "kawúlum"}], [{p: "کولو", f: "kawúloo"}]], + [[{p: "کولې", f: "kawúle"}], [{p: "کولئ", f: "kawúleyy"}]], + [[{p: "کولې", f: "kawúle"}], [{p: "کولئ", f: "kawúleyy"}]], + [[{p: "کوله", f: "kawúlu"}, {p: "کولو", f: "kawúlo"}], [{p: "کول", f: "kawúl"}]], + [[{p: "کوله", f: "kawúla"}], [{p: "کولې", f: "kawúle"}]], ], }, habitualPast: { short: [ - [[{p: "به کوم", f: "ba kawum"}], [{p: "به کوو", f: "ba kawoo"}]], - [[{p: "به کوم", f: "ba kawum"}], [{p: "به کوو", f: "ba kawoo"}]], - [[{p: "به کوې", f: "ba kawe"}], [{p: "به کوئ", f: "ba kaweyy"}]], - [[{p: "به کوې", f: "ba kawe"}], [{p: "به کوئ", f: "ba kaweyy"}]], - [[{p: "به کاوه", f: "ba kaawu"}], [{p: "به کول", f: "ba kawul"}]], - [[{p: "به کوه", f: "ba kawa"}], [{p: "به کوې", f: "ba kawe"}]], + [[{p: "به کوم", f: "ba kawúm"}], [{p: "به کوو", f: "ba kawóo"}]], + [[{p: "به کوم", f: "ba kawúm"}], [{p: "به کوو", f: "ba kawóo"}]], + [[{p: "به کوې", f: "ba kawé"}], [{p: "به کوئ", f: "ba kawéyy"}]], + [[{p: "به کوې", f: "ba kawé"}], [{p: "به کوئ", f: "ba kawéyy"}]], + [[{p: "به کاوه", f: "ba kaawú"}], [{p: "به کول", f: "ba kawúl"}]], + [[{p: "به کوه", f: "ba kawá"}], [{p: "به کوې", f: "ba kawé"}]], ], long: [ - [[{p: "به کولم", f: "ba kawulum"}], [{p: "به کولو", f: "ba kawuloo"}]], - [[{p: "به کولم", f: "ba kawulum"}], [{p: "به کولو", f: "ba kawuloo"}]], - [[{p: "به کولې", f: "ba kawule"}], [{p: "به کولئ", f: "ba kawuleyy"}]], - [[{p: "به کولې", f: "ba kawule"}], [{p: "به کولئ", f: "ba kawuleyy"}]], - [[{p: "به کوله", f: "ba kawulu"}, {p: "به کولو", f: "ba kawulo"}], [{p: "به کول", f: "ba kawul"}]], - [[{p: "به کوله", f: "ba kawula"}], [{p: "به کولې", f: "ba kawule"}]], + [[{p: "به کولم", f: "ba kawúlum"}], [{p: "به کولو", f: "ba kawúloo"}]], + [[{p: "به کولم", f: "ba kawúlum"}], [{p: "به کولو", f: "ba kawúloo"}]], + [[{p: "به کولې", f: "ba kawúle"}], [{p: "به کولئ", f: "ba kawúleyy"}]], + [[{p: "به کولې", f: "ba kawúle"}], [{p: "به کولئ", f: "ba kawúleyy"}]], + [[{p: "به کوله", f: "ba kawúlu"}, {p: "به کولو", f: "ba kawúlo"}], [{p: "به کول", f: "ba kawúl"}]], + [[{p: "به کوله", f: "ba kawúla"}], [{p: "به کولې", f: "ba kawúle"}]], ], }, modal: kawulImperfectiveModal, @@ -1519,7 +1519,7 @@ export const kawulStat: T.VerbConjugation = { export const kawulDyn: T.VerbConjugation = { info: { entry: { - entry: {"ts":1527812752,"i":10578,"p":"کول","f":"kawul","g":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true,"ec":"do,does,doing,did,done"} as T.VerbDictionaryEntry, + entry: {"ts":1527812752,"i":10578,"p":"کول","f":"kawúl","g":"kawúl","e":"to do (an action or activity)","c":"v. trans. irreg.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true,"ec":"do,does,doing,did,done"} as T.VerbDictionaryEntry, }, transitivity: "transitive", type: "simple", @@ -1587,16 +1587,16 @@ export const kawulDyn: T.VerbConjugation = { [[{p: "کوم", f: "kawum"}], [{p: "کوو", f: "kawoo"}]], [[{p: "کوې", f: "kawe"}], [{p: "کوئ", f: "kaweyy"}]], [[{p: "کوې", f: "kawe"}], [{p: "کوئ", f: "kaweyy"}]], - [[{p: "کاوه", f: "kaawu"}], [{p: "کول", f: "kawul"}]], + [[{p: "کاوه", f: "kaawu"}], [{p: "کول", f: "kawúl"}]], [[{p: "کوه", f: "kawa"}], [{p: "کوې", f: "kawe"}]], ], long: [ - [[{p: "کولم", f: "kawulum"}], [{p: "کولو", f: "kawuloo"}]], - [[{p: "کولم", f: "kawulum"}], [{p: "کولو", f: "kawuloo"}]], - [[{p: "کولې", f: "kawule"}], [{p: "کولئ", f: "kawuleyy"}]], - [[{p: "کولې", f: "kawule"}], [{p: "کولئ", f: "kawuleyy"}]], - [[{p: "کوله", f: "kawulu"}, {p: "کولو", f: "kawulo"}], [{p: "کول", f: "kawul"}]], - [[{p: "کوله", f: "kawula"}], [{p: "کولې", f: "kawule"}]], + [[{p: "کولم", f: "kawúlum"}], [{p: "کولو", f: "kawúloo"}]], + [[{p: "کولم", f: "kawúlum"}], [{p: "کولو", f: "kawúloo"}]], + [[{p: "کولې", f: "kawúle"}], [{p: "کولئ", f: "kawúleyy"}]], + [[{p: "کولې", f: "kawúle"}], [{p: "کولئ", f: "kawúleyy"}]], + [[{p: "کوله", f: "kawúlu"}, {p: "کولو", f: "kawúlo"}], [{p: "کول", f: "kawúl"}]], + [[{p: "کوله", f: "kawúla"}], [{p: "کولې", f: "kawúle"}]], ], }, habitualPast: { @@ -1605,16 +1605,16 @@ export const kawulDyn: T.VerbConjugation = { [[{p: "به کوم", f: "ba kawum"}], [{p: "به کوو", f: "ba kawoo"}]], [[{p: "به کوې", f: "ba kawe"}], [{p: "به کوئ", f: "ba kaweyy"}]], [[{p: "به کوې", f: "ba kawe"}], [{p: "به کوئ", f: "ba kaweyy"}]], - [[{p: "به کاوه", f: "ba kaawu"}], [{p: "به کول", f: "ba kawul"}]], + [[{p: "به کاوه", f: "ba kaawu"}], [{p: "به کول", f: "ba kawúl"}]], [[{p: "به کوه", f: "ba kawa"}], [{p: "به کوې", f: "ba kawe"}]], ], long: [ - [[{p: "به کولم", f: "ba kawulum"}], [{p: "به کولو", f: "ba kawuloo"}]], - [[{p: "به کولم", f: "ba kawulum"}], [{p: "به کولو", f: "ba kawuloo"}]], - [[{p: "به کولې", f: "ba kawule"}], [{p: "به کولئ", f: "ba kawuleyy"}]], - [[{p: "به کولې", f: "ba kawule"}], [{p: "به کولئ", f: "ba kawuleyy"}]], - [[{p: "به کوله", f: "ba kawulu"}, {p: "به کولو", f: "ba kawulo"}], [{p: "به کول", f: "ba kawul"}]], - [[{p: "به کوله", f: "ba kawula"}], [{p: "به کولې", f: "ba kawule"}]], + [[{p: "به کولم", f: "ba kawúlum"}], [{p: "به کولو", f: "ba kawúloo"}]], + [[{p: "به کولم", f: "ba kawúlum"}], [{p: "به کولو", f: "ba kawúloo"}]], + [[{p: "به کولې", f: "ba kawúle"}], [{p: "به کولئ", f: "ba kawúleyy"}]], + [[{p: "به کولې", f: "ba kawúle"}], [{p: "به کولئ", f: "ba kawúleyy"}]], + [[{p: "به کوله", f: "ba kawúlu"}, {p: "به کولو", f: "ba kawúlo"}], [{p: "به کول", f: "ba kawúl"}]], + [[{p: "به کوله", f: "ba kawúla"}], [{p: "به کولې", f: "ba kawúle"}]], ], }, modal: kawulImperfectiveModal, diff --git a/src/lib/verb-conjugation.ts b/src/lib/verb-conjugation.ts index bda13ad..bc8cbdf 100644 --- a/src/lib/verb-conjugation.ts +++ b/src/lib/verb-conjugation.ts @@ -32,7 +32,7 @@ import { inflectYey, } from "./pashto-inflector"; import { - accentOnNFromEnd, removeAccents, + accentOnNFromEnd, removeAccents, removeAccentsFromInflections, } from "./accent-helpers"; import { pashtoConsonants } from "./pashto-consonants"; import { @@ -288,17 +288,20 @@ function makeJoinedModalContent(info: T.NonComboVerbInfo, aspectIn: T.Aspect): T function makeStativeCompoundSeperatedAspectContent(info: T.StativeCompoundVerbInfo, aspect: T.Aspect): T.AspectContent { const transitivity = getTransitivity(info); - const presentComplement = (transitivity === "transitive" && complementInflects(info.complement)) - ? unisexInfToObjectMatrix(info.complement) // transitive verb requires an object matrix for the complex - : info.complement; // intransitive verb doesn't require that because the complement matches the subject + const complement: T.UnisexInflections = aspect === "imperfective" + ? removeAccentsFromInflections(info.complement) + : info.complement; + const presentComplement = (transitivity === "transitive" && complementInflects(complement)) + ? unisexInfToObjectMatrix(complement) // transitive verb requires an object matrix for the complex + : complement; // intransitive verb doesn't require that because the complement matches the subject function makeTransitiveStativeModalContent() { const aux = stativeAux[transitivity][aspect].modal; const nonImperative = addToForm([presentComplement, " "], aux.nonImperative); const future = addToForm([baParticle, " "], nonImperative); - const past = addToForm([info.complement, " "], aux.past); + const past = addToForm([complement, " "], aux.past); const habitualPast = addToForm([baParticle, " "], past); - const hypotheticalPast = addToForm([info.complement, " "], aux.hypotheticalPast); + const hypotheticalPast = addToForm([complement, " "], aux.hypotheticalPast); return { nonImperative, future, @@ -316,7 +319,7 @@ function makeStativeCompoundSeperatedAspectContent(info: T.StativeCompoundVerbIn ); const future = addToForm([baParticle, " "], nonImperative); const imperative = addToForm([presentComplement, " "], aux.imperative); - const past = addToForm([info.complement, " "], aux.past); + const past = addToForm([complement, " "], aux.past); const habitualPast = addToForm([baParticle, " "], past); return { nonImperative, @@ -403,7 +406,7 @@ function makePerfectContent(info: T.NonComboVerbInfo): T.PerfectContent { const pastPart: (" " | T.SingleOrLengthOpts | T.SingleOrLengthOpts)[] = (info.type === "stative compound") // for stative compounds - ? [info.complement, " ", stativeAux[transitivity].participle.past] + ? [removeAccentsFromInflections(info.complement), " ", stativeAux[transitivity].participle.past] // for regular compounds : [inflectYey(noPersInfs(info.participle.past))]