From b6d2098028ef41c1a3b44e84209762ea0f421fda Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 5 Jul 2021 14:39:52 +0300 Subject: [PATCH] bug with english in passive tense --- package.json | 2 +- src/lib/add-pronouns.ts | 14 +++++++++----- src/lib/conjugation-forms.tsx | 8 ++++---- src/types.ts | 33 ++++++++++++++++++++------------- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 19bf30b..5f04fe0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "0.5.3", + "version": "0.5.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/add-pronouns.ts b/src/lib/add-pronouns.ts index b6f4260..560106b 100644 --- a/src/lib/add-pronouns.ts +++ b/src/lib/add-pronouns.ts @@ -84,6 +84,14 @@ export default function addPronouns({ s, subject, object, info, displayForm, int } : {}, } } + function makeEnglish(englishBuilder: T.EnglishBuilder, englishConjugation: T.EnglishVerbConjugation): string[] { + const noObject = (intransitive || info.transitivity === "grammatically transitive"); + const addRest = (s: string) => ( + `${s}${noObject ? "" : ` ${engObj(object)}`}${englishConjugation.ep ? ` ${englishConjugation.ep}` : ""}` + ); + return englishBuilder(subject, englishConjugation.ec, negative) + .map(addRest); + } const firstOrSecondObjectPresent = [0,1,2,3,6,7,8,9].includes(object) && !displayForm.past; const nearPronounPossible = (p: T.Person) => [4, 5, 10, 11].includes(p); const noPronouns = @@ -126,11 +134,7 @@ export default function addPronouns({ s, subject, object, info, displayForm, int mini: miniPronoun, }; const english = (displayForm.englishBuilder && englishConjugation) - ? displayForm.englishBuilder(subject, englishConjugation.ec, negative).map(baseS => ( - (intransitive || info.transitivity === "grammatically transitive") - ? baseS - : `${baseS} ${engObj(object)}${englishConjugation.ep ? ` ${englishConjugation.ep}` : ""}` - )) + ? makeEnglish(displayForm.englishBuilder, englishConjugation) : undefined; function attachPronounsToVariation(ps: T.PsString, prns: Pronouns): T.ArrayOneOrMore { diff --git a/src/lib/conjugation-forms.tsx b/src/lib/conjugation-forms.tsx index 0f32f60..857e458 100644 --- a/src/lib/conjugation-forms.tsx +++ b/src/lib/conjugation-forms.tsx @@ -326,7 +326,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [ aspect: "imperfective", form: conj.imperfective.imperative, englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([ - `${v[0]}`, + `${n ? "Don't " : ""}${v[0]}`, ]), formula: "Imperfective Stem + Imperative Ending", explanation: "Commanding someone/people to do something repeatedly, or in general", @@ -592,7 +592,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [ sentence: true, passive: true, englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([ - `that ${engSubj(s, true)} will have been ${v[4]}`, + `that ${engSubj(s, true)} will${n ? " not" : ""} have been ${v[4]}`, ]), formula: "Infinitive + کېدل (to be) past participle inflected + Subjunctive/Habitual Equative", }, @@ -604,7 +604,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [ sentence: true, passive: true, englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([ - `${engSubj(s)} will have been ${v[4]}`, + `${engSubj(s)} will${n ? " not" : ""} have been ${v[4]}`, ]), formula: "به - ba + Infinitive + کېدل (to be) past participle inflected + Future Equative", explanation: "Talking about something that will have happened in the future, or guessing that the event will have occured presently (Passive voice) ('I will have been ____ed')", @@ -617,7 +617,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [ sentence: true, passive: true, englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([ - `${engSubj(s)} will have been ${v[4]}`, + `${engSubj(s)} will${n ? " not" : ""} have been ${v[4]}`, ]), explanation: "Affirming that an event will have taken place (Passive voice) ('I will have been ____ed')", formula: "به - ba + Infinitive + کېدل (to be) past participle inflected + Past Equative" diff --git a/src/types.ts b/src/types.ts index cba6393..70125fa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -397,13 +397,14 @@ export type EnglishVerbConjugation = { }; export type DisplayFormItem = DisplayForm | DisplayFormSubgroup | DisplayFormForSentence; +export type EnglishBuilder = (subject: Person, ec: EnglishVerbConjugationEc, neg: boolean) => string[]; export type DisplayForm = { label: string, aspect?: Aspect, form: VerbForm | ImperativeForm | ParticipleForm | SentenceForm, advanced?: boolean, - englishBuilder?: (subject: Person, ec: EnglishVerbConjugationEc, neg: boolean) => string[], + englishBuilder?: EnglishBuilder, formula: React.ReactNode, explanation: React.ReactNode, sentence?: boolean, @@ -411,20 +412,26 @@ export type DisplayForm = { past?: boolean, reorderWithNegative?: boolean, } -export type DisplayFormForSentence = { - label: string, - aspect?: Aspect, + +export type DisplayFormForSentence = Omit & { form: VerbForm, - advanced?: boolean, - englishBuilder?: (subject: Person, ec: EnglishVerbConjugationEc, neg: boolean) => string[], - formula: React.ReactNode, secondPronounNeeded?: boolean, - explanation: React.ReactNode, - sentence?: boolean, - passive?: boolean, - past?: boolean, - reorderWithNegative?: boolean, -} +} + +// { +// label: string, +// aspect?: Aspect, +// form: VerbForm, +// advanced?: boolean, +// englishBuilder?: EnglishBuilder, +// formula: React.ReactNode, +// secondPronounNeeded?: boolean, +// explanation: React.ReactNode, +// sentence?: boolean, +// passive?: boolean, +// past?: boolean, +// reorderWithNegative?: boolean, +// } export type DisplayFormSubgroup = { label: string,