From 2d17daf81fb5b38d4b6d0fb381e92cbfcad0b0a8 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Fri, 22 Oct 2021 23:22:09 -0400 Subject: [PATCH] =?UTF-8?q?all=20tenses=20in=20equative=20explorer=20?= =?UTF-8?q?=F0=9F=92=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- .../equative-explorer/explorer-helpers.ts | 6 +- .../equative-explorer/explorer-selectors.tsx | 60 ++++---- .../equative-explorer/explorer-types.ts | 6 +- src/content/equatives/other-equatives.mdx | 21 +-- src/lib/equative-machine.test.ts | 136 +++++++++++++++++- src/lib/equative-machine.ts | 31 +++- src/types.d.ts | 4 +- yarn.lock | 8 +- 9 files changed, 217 insertions(+), 57 deletions(-) diff --git a/package.json b/package.json index 18e78f8..6286b3b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "dependencies": { "@fortawesome/fontawesome-free": "^5.15.4", "@lingdocs/lingdocs-main": "^0.2.0", - "@lingdocs/pashto-inflector": "^1.3.1", + "@lingdocs/pashto-inflector": "^1.3.2", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", diff --git a/src/components/equative-explorer/explorer-helpers.ts b/src/components/equative-explorer/explorer-helpers.ts index 41f11e5..f7af0eb 100644 --- a/src/components/equative-explorer/explorer-helpers.ts +++ b/src/components/equative-explorer/explorer-helpers.ts @@ -9,15 +9,15 @@ import { ParticipleInput, isParticipleInput, getEnglishParticiple, - TenseInput, } from "../../lib/equative-machine"; export function sort(arr: Readonly): T[] { return [...arr].sort((a, b) => a.p.localeCompare(b.p)); } -export function makeBlockWPronouns(e: Adjective | UnisexNoun, tense: TenseInput, length?: "short" | "long"): T.SingleOrLengthOpts { - if (tense === "past" && !length) { +export function makeBlockWPronouns(e: Adjective | UnisexNoun, tense: EquativeTense, length?: "short" | "long"): T.SingleOrLengthOpts { + // if the output's gonna have long / short forms (if it's past or wouldBe) then recursive call to make the long and short versions + if (!length && "long" in assembleEquativeOutput(equativeMachine(0, e, tense))) { return { short: makeBlockWPronouns(e, tense, "short") as T.VerbBlock, long: makeBlockWPronouns(e, tense, "long") as T.VerbBlock, diff --git a/src/components/equative-explorer/explorer-selectors.tsx b/src/components/equative-explorer/explorer-selectors.tsx index b7e8744..ef6f082 100644 --- a/src/components/equative-explorer/explorer-selectors.tsx +++ b/src/components/equative-explorer/explorer-selectors.tsx @@ -112,32 +112,34 @@ export function SubjectSelector({ state, dispatch }: { {...zIndexProps} />
- {state.subjectType !== "participle" && <> -
- null : (p) => dispatch({ type: "setSubjectGender", payload: p as T.Gender })} - /> -
-
- dispatch({ type: "setSubjectPlural", payload: p === "plural" ? true : false })} - /> -
- } +
+ null : (p) => dispatch({ type: "setSubjectGender", payload: p as T.Gender })} + /> +
+
+ dispatch({ type: "setSubjectPlural", payload: p === "plural" ? true : false })} + /> +
} @@ -208,9 +210,13 @@ export function TenseSelector({ state, dispatch }: { state: ExplorerState, dispatch: (action: ExplorerReducerAction) => void, }) { - const options = [ + const options: { value: EquativeTense, label: string }[] = [ { value: "present", label: "Present" }, + { value: "subjunctive", label: "Habitual / Subjunctive" }, { value: "past", label: "Past" }, + { value: "future", label: "Future" }, + { value: "wouldBe", label: '"Would Be"' }, + { value: "pastSubjunctive", label: "Past Subjunctive" }, ]; function onTenseSelect({ value }: any) { dispatch({ type: "setTense", payload: value }); diff --git a/src/components/equative-explorer/explorer-types.ts b/src/components/equative-explorer/explorer-types.ts index 7849543..626b6bf 100644 --- a/src/components/equative-explorer/explorer-types.ts +++ b/src/components/equative-explorer/explorer-types.ts @@ -1,11 +1,11 @@ import { Types as T } from "@lingdocs/pashto-inflector"; -import { ParticipleInput, TenseInput } from "../../lib/equative-machine"; +import { ParticipleInput } from "../../lib/equative-machine"; export type PredicateType = keyof PredicatesSelected; export type SubjectType = "noun" | "pronouns" | "participle" | "unisexNoun"; export type ExplorerState = { - tense: TenseInput, + tense: EquativeTense, length: "short" | "long", subjectType: SubjectType, subjectsSelected: SubjectSelected, @@ -39,7 +39,7 @@ export type ExplorerReducerAction = { } | { type: "setSubjectGender", payload: T.Gender, } | { - type: "setTense", payload: TenseInput, + type: "setTense", payload: EquativeTense, } | { type: "setLength", payload: "short" | "long", }; \ No newline at end of file diff --git a/src/content/equatives/other-equatives.mdx b/src/content/equatives/other-equatives.mdx index 83b900b..986e68e 100644 --- a/src/content/equatives/other-equatives.mdx +++ b/src/content/equatives/other-equatives.mdx @@ -28,7 +28,7 @@ import EquativeFormChoice from "../../components/EquativeFormChoice"; import Formula from "../../components/formula/Formula"; import Link from "../../components/Link"; -## Future / Presumptive Equative +## Future Equative This is used for: @@ -161,12 +161,13 @@ It is usually used in the short form. }, ])} -## Affirmative Equative +## "Would be" Equative This is used: -1. To affirm or to make a strong assumption that something will have been something. ("I'll have been ...") -2. To say what would have happened if a hypothetical condition were true. ("If ..., I'd be ...") +1. To talk about something being something repeatedly in the past +2. To say something would have been something +1. To affirm or to make a strong assumption that something will have been something Like the past equative that it's based on, it's usually used with the short form. @@ -212,23 +213,23 @@ Like the past equative that it's based on, it's {psmd([ { - p: "ډوډۍ **به** تیاره **وه**.", - f: "DoDúy **ba** tayáara **wa**.", - e: "The food **will have been** ready.", + p: "زه به هر سهار هلته وم", + f: "zu ba hăr saháar halta wum", + e: "I would be there every morning", }, { p: "ته **به** خبر **وې**", f: "tu **ba** khabúr **we**.", - e: "Youwill have known.", + e: "You would have known.", }, { p: "که خوب مې نه وای کړی، زه **به** ستړی **وم**.", f: "ku khob me nu waay kúRey, zu **ba** stúRey **wum**.", - e: "If I hadn't slept, I **would have been** tired.", + e: "If I hadn't slept, I **would be been** tired.", }, ])} -## Conterfactual / Past Subjunctive / Wish Equative +## Past Subjunctive This is used to talk about something being hypothetically something, or to wish that something were something. ("If I was ...", "If only I was ..."). It is also used for prayers and blessings in some dialects. diff --git a/src/lib/equative-machine.test.ts b/src/lib/equative-machine.test.ts index 9995c19..a9a51aa 100644 --- a/src/lib/equative-machine.test.ts +++ b/src/lib/equative-machine.test.ts @@ -5,7 +5,6 @@ import { PredicateInput, ParticipleInput, assembleEquativeOutput, - TenseInput, } from "./equative-machine"; import { Types as T, @@ -46,7 +45,7 @@ const abilities: { in: { subject: SubjectInput, predicate: PredicateInput, - tense: TenseInput, + tense: EquativeTense, }, out: EquativeMachineOutput, }[], @@ -62,6 +61,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "زه", f: "zu", e: "I (m.)" }], predicate: [{ p: "ستړی", f: "stúRey", e: "tired" }], equative: [{ p: "یم", f: "yum", e: "am" }], @@ -74,6 +74,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "تاسو", f: "táaso", e: "You (f. pl.)" }, { p: "تاسې", f: "táase", e: "You (f. pl.)"}], predicate: [{ p: "ستړې", f: "stúRe", e: "tired" }], equative: [{ p: "یئ", f: "yeyy", e: "are" }], @@ -87,6 +88,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "هغه", f: "haghá", e: "She/it (f.)" }], predicate: [{ p: "خفه", f: "khufa", e: "sad" }], equative: [{ p: "ده", f: "da", e: "is" }], @@ -104,6 +106,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "زه", f: "zu", e: "I (f.)" }], predicate: [{ p: "افغانۍ", f: "afghaanúy", e: "(a/the) Afghan" }], equative: [{ p: "یم", f: "yum", e: "am" }], @@ -116,6 +119,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "مونږ", f: "moonG", e: "We (f. pl.)" }, { p: "موږ", f: "mooG", e: "We (f. pl.)" }], predicate: [ { p: "افغانیانې", f: "afghaaniyáane", e: "(the) Afghans" }, @@ -131,6 +135,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "مونږ", f: "moonG", e: "We (f. pl.)" }, { p: "موږ", f: "mooG", e: "We (f. pl.)" }], predicate: [{ p: "انسانانې", f: "insaanáane", e: "(the) humans" }, { p: "انسانې", f: "insaane", e: "(the) humans" }], equative: [{ p: "یو", f: "yoo", e: "are" }], @@ -143,6 +148,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "ته", f: "tu", e: "You (f.)" }], predicate: [{ p: "انسانه", f: "insaana", e: "(a/the) human" }], equative: [{ p: "یې", f: "ye", e: "are" }], @@ -163,6 +169,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "کتاب", f: "kitáab", e: "(A/The) book" }], predicate: [{ p: "زوړ", f: "zoR", e: "old" }], equative: [{ p: "دی", f: "dey", e: "is" }], @@ -178,6 +185,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "کتابونه", f: "kitaabóona", e: "(The) books" }], predicate: [{ p: "زاړه", f: "zaaRu", e: "old" }], equative: [{ p: "دي", f: "dee", e: "are" }], @@ -193,6 +201,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "ښځه", f: "xúdza", e: "(A/The) woman" }], predicate: [{ p: "زړه", f: "zaRa", e: "old" }], equative: [{ p: "ده", f: "da", e: "is" }], @@ -208,6 +217,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "ښځې", f: "xúdze", e: "(The) women" }], predicate: [{ p: "زړې", f: "zaRe", e: "old" }], equative: [{ p: "دي", f: "dee", e: "are" }], @@ -224,6 +234,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "ښځې", f: "xúdze", e: "(The) women" }], predicate: [{ p: "خفه", f: "khufa", e: "sad" }], equative: [{ p: "دي", f: "dee", e: "are" }], @@ -244,6 +255,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "شودې", f: "shoodé", e: "(The) milk" }], predicate: [{ p: "ښې", f: "xe", e: "good" }], equative: [{ p: "دي", f: "dee", e: "is" }], @@ -259,6 +271,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "غنم", f: "ghanúm", e: "(The) wheat" }], predicate: [{ p: "زاړه", f: "zaaRu", e: "old" }], equative: [{ p: "دي", f: "dee", e: "is" }], @@ -276,6 +289,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "خوړل", f: "khoRul", e: "eating" }], predicate: [{ p: "ښه", f: "xu", e: "good" }], equative: [{ p: "دي", f: "dee", e: "is" }], @@ -288,6 +302,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "اخیستل", f: "akheestul", e: "taking" }], predicate: [{ p: "زاړه", f: "zaaRu", e: "old" }], equative: [{ p: "دي", f: "dee", e: "is" }], @@ -300,6 +315,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "جګېدل", f: "jugedul", e: "getting up" }], predicate: [{ p: "سخت", f: "sakht", e: "hard" }], equative: [{ p: "دي", f: "dee", e: "is" }], @@ -317,6 +333,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "ته", f: "tu", e: "You (m.)" }], predicate: [{ p: "لیکل", f: "leekul", e: "writing" }], equative: [{ p: "دي", f: "dee", e: "are" }], @@ -340,6 +357,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "خوشحالي", f: "khosh`haalee", e: "(A/The) happiness" }], predicate: [{ p: "خوراک", f: "khoráak", e: "(a/the) food" }], equative: [{ p: "دی", f: "dey", e: "is" }], @@ -360,6 +378,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "وروروالی", f: "wrorwaaley", e: "(A/The) brotherhood" }], predicate: [{ p: "زغمل", f: "zghamul", e: "enduring" }], equative: [{ p: "دي", f: "dee", e: "is" }], @@ -380,6 +399,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "لیکل", f: "leekul", e: "writing" }], predicate: [{ p: "خوشحالي", f: "khosh`haalee", e: "(a/the) happiness" }], equative: [{ p: "ده", f: "da", e: "is" }], @@ -397,6 +417,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "لیکل", f: "leekul", e: "writing" }], predicate: [{ p: "پوهېدل", f: "pohedul", e: "understanding" }], equative: [{ p: "دي", f: "dee", e: "is" }], @@ -421,6 +442,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "کتابونه", f: "kitaabóona", e: "(The) books" }], predicate: [{ p: "نرسه", f: "narsa", e: "(a/the) nurse" }], equative: [{ p: "ده", f: "da", e: "are" }], @@ -442,6 +464,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [ { p: "نرسانې", f: "narsáane", e: "(The) nurses" }, { p: "نرسې", f: "narse", e: "(The) nurses" }, @@ -469,6 +492,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "نرسه", f: "narsa", e: "(A/The) nurse" }], predicate: [{ p: "کتابونه", f: "kitaabóona", e: "(the) books" }], equative: [{ p: "دي", f: "dee", e: "is" }], @@ -490,6 +514,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "نرسه", f: "narsa", e: "(A/The) nurse" }], predicate: [{ p: "غږېدل", f: "ghuGedul", e: "speaking" }], equative: [{ p: "دي", f: "dee", e: "is" }], @@ -511,6 +536,7 @@ const abilities: { tense: "present", }, out: { + ba: false, subject: [{ p: "لیکل", f: "leekul", e: "writing" }], predicate: [{ p: "نرسه", f: "narsa", e: "(a/the) nurse" }], equative: [{ p: "ده", f: "da", e: "is" }], @@ -531,6 +557,7 @@ const abilities: { tense: "past", }, out: { + ba: false, subject: [{ p: "کتاب", f: "kitáab", e: "(A/The) book" }], predicate: [{ p: "زوړ", f: "zoR", e: "old" }], equative: { @@ -541,6 +568,96 @@ const abilities: { }, ], }, + { + label: '"Would be" tense', + tests: [ + { + in: { + subject: { + entry: { "ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m." } as SingularEntry, + plural: false, + }, + predicate: {"ts":1527815451,"i":7193,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"} as Adjective, + tense: "wouldBe", + }, + out: { + ba: true, + subject: [{ p: "کتاب", f: "kitáab", e: "(A/The) book" }], + predicate: [{ p: "زوړ", f: "zoR", e: "old" }], + equative: { + short: [{ p: "و", f: "wo", e: "would be" }], + long: [{ p: "ولو", f: "wulo", e: "would be" }], + }, + }, + }, + ], + }, + { + label: "Subjunctive tense", + tests: [ + { + in: { + subject: { + entry: { "ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m." } as SingularEntry, + plural: false, + }, + predicate: {"ts":1527815451,"i":7193,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"} as Adjective, + tense: "subjunctive", + }, + out: { + ba: false, + subject: [{ p: "کتاب", f: "kitáab", e: "(A/The) book" }], + predicate: [{ p: "زوړ", f: "zoR", e: "old" }], + equative: [{ p: "وي", f: "wee", e: "is" }], + }, + }, + ], + }, + { + label: "Future tense", + tests: [ + { + in: { + subject: { + entry: { "ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m." } as SingularEntry, + plural: false, + }, + predicate: {"ts":1527815451,"i":7193,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"} as Adjective, + tense: "future", + }, + out: { + ba: true, + subject: [{ p: "کتاب", f: "kitáab", e: "(A/The) book" }], + predicate: [{ p: "زوړ", f: "zoR", e: "old" }], + equative: [{ p: "وي", f: "wee", e: "will be" }], + }, + }, + ], + }, + { + label: "Past Subjunctive Tense", + tests: [ + { + in: { + subject: { + entry: { "ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m." } as SingularEntry, + plural: false, + }, + predicate: {"ts":1527815451,"i":7193,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"} as Adjective, + tense: "pastSubjunctive", + }, + out: { + ba: false, + subject: [{ p: "کتاب", f: "kitáab", e: "(A/The) book" }], + predicate: [{ p: "زوړ", f: "zoR", e: "old" }], + equative: [ + { p: "وای", f: "waay", e: "were" }, + { p: "وی", f: "wey", e: "were" }, + ], + }, + }, + ], + }, ]; describe("equativeMachine", () => { @@ -558,6 +675,7 @@ test("assembleEquativeOutput", () => { subject: [{ p: "کتابونه", f: "kitaabóona", e: "(The) books" }], predicate: [{ p: "زاړه", f: "zaaRu", e: "old" }], equative: [{ p: "دي", f: "dee", e: "are" }], + ba: false, })).toEqual([{ p: "کتابونه زاړه دي", f: "kitaabóona zaaRu dee", e: "(The) books are old" }]); expect(assembleEquativeOutput({ subject: [{ p: "مونږ", f: "moonG", e: "We (f. pl.)" }, { p: "موږ", f: "mooG", e: "We (f. pl.)" }], @@ -566,6 +684,7 @@ test("assembleEquativeOutput", () => { { p: "افغانۍ", f: "afghaanúy", e: "(the) Afghans" }, ], equative: [{ p: "یو", f: "yoo", e: "are" }], + ba: false, })).toEqual([ { p: "مونږ افغانیانې یو", f: "moonG afghaaniyáane yoo", e: "We (f. pl.) are (the) Afghans" }, { p: "مونږ افغانۍ یو", f: "moonG afghaanúy yoo", e: "We (f. pl.) are (the) Afghans" }, @@ -579,8 +698,21 @@ test("assembleEquativeOutput", () => { short: [{ p: "و", f: "wo", e: "was" }], long: [{ p: "ولو", f: "wulo", e: "was" }], }, + ba: false, })).toEqual({ short: [{ p: "کتاب زوړ و", f: "kitáab zoR wo", e: "(A/The) book was old" }], long: [{ p: "کتاب زوړ ولو", f: "kitáab zoR wulo", e: "(A/The) book was old" }], }); + expect(assembleEquativeOutput({ + subject: [{ p: "کتاب", f: "kitáab", e: "(A/The) book" }], + predicate: [{ p: "زوړ", f: "zoR", e: "old" }], + equative: { + short: [{ p: "و", f: "wo", e: "would be" }], + long: [{ p: "ولو", f: "wulo", e: "would be" }], + }, + ba: true, + })).toEqual({ + short: [{ p: "کتاب به زوړ و", f: "kitáab ba zoR wo", e: "(A/The) book would be old" }], + long: [{ p: "کتاب به زوړ ولو", f: "kitáab ba zoR wulo", e: "(A/The) book would be old" }], + }); }); \ No newline at end of file diff --git a/src/lib/equative-machine.ts b/src/lib/equative-machine.ts index 73e293c..9ea822b 100644 --- a/src/lib/equative-machine.ts +++ b/src/lib/equative-machine.ts @@ -21,6 +21,7 @@ export type EquativeMachineOutput = { subject: T.PsString[], predicate: T.PsString[], equative: T.SingleOrLengthOpts>, + ba: boolean, }; export type NounInput = { @@ -38,9 +39,8 @@ export type PersonInput = T.Person; export type EntityInput = SubjectInput | PredicateInput; export type SubjectInput = PersonInput | NounInput | ParticipleInput | SpecifiedUnisexNounInput; export type PredicateInput = PersonInput | NounInput | Adjective | SpecifiedUnisexNounInput | UnisexNoun | ParticipleInput; -export type TenseInput = "present" | "past"; -export function equativeMachine(sub: SubjectInput, pred: PredicateInput, tense: TenseInput = "present"): EquativeMachineOutput { +export function equativeMachine(sub: SubjectInput, pred: PredicateInput, tense: EquativeTense): EquativeMachineOutput { // - english equative always agrees with subject // - pashto equative agrees with predicate, unless it's an adjective, in which case the // agreement reverts to the subject @@ -49,10 +49,12 @@ export function equativeMachine(sub: SubjectInput, pred: PredicateInput, tense: const subject = makeEntity(sub); const predicate = makeEntity(pred, subjPerson); const equative = makeEquative(subjPerson, predPerson, sub, tense); + const ba = determineBa(tense); return { subject, predicate, equative, + ba, }; } @@ -67,10 +69,11 @@ export function assembleEquativeOutput(o: EquativeMachineOutput): T.SingleOrLeng // soooo cool how this works 🤓 const equatives = o.equative; const predicates = o.predicate; + const ba = o.ba ? { p: " به", f: " ba" } : ""; const ps = o.subject.flatMap(subj => ( predicates.flatMap(pred => ( equatives.map(eq => ( - concatPsString(subj, " ", pred, " ", eq)) + concatPsString(subj, ba, " ", pred, " ", eq)) ) )) )); @@ -80,6 +83,10 @@ export function assembleEquativeOutput(o: EquativeMachineOutput): T.SingleOrLeng // LEVEL 2 FUNCTIONS +function determineBa(tense: EquativeTense): boolean { + return (tense === "future" || tense === "wouldBe"); +} + function getInputPerson(e: SubjectInput, part: "subject"): T.Person; function getInputPerson(e: PredicateInput, part: "predicate"): T.Person | undefined; function getInputPerson(e: EntityInput, part: "subject" | "predicate"): T.Person | undefined { @@ -121,7 +128,14 @@ function makeEntity(e: EntityInput, subjPerson?: T.Person): T.PsString[] { throw new Error(`invalid entity in ${subjPerson ? "predicate" : "subject"}`); } -function makeEquative(subj: T.Person, pred: T.Person, subjectInput: SubjectInput, tense: TenseInput): T.SentenceForm { +function makeEquative(subj: T.Person, pred: T.Person, subjectInput: SubjectInput, tense: EquativeTense): T.SentenceForm { + function getEngEq(row: number, col: number): string { + const t = grammarUnits.englishEquative[tense === "subjunctive" ? "present" : tense]; + return typeof t === "string" + ? t + : t[row][col]; + } + const isPluralNoun = isNounInput(subjectInput) && isPluralEntry(subjectInput.entry); // The subject's person information, for the English equative const [eeRow, eeCol] = getVerbBlockPosFromPerson( @@ -129,10 +143,15 @@ function makeEquative(subj: T.Person, pred: T.Person, subjectInput: SubjectInput ? T.Person.ThirdSingMale : subj ); + const baseTense = (tense === "future") + ? "subjunctive" + : tense === "wouldBe" + ? "past" + : tense; return addEnglish( - grammarUnits.englishEquative[tense][eeRow][eeCol], + getEngEq(eeRow, eeCol), // pashto agrees with predicate (if possible) - getPersonFromVerbForm(grammarUnits.equativeEndings[tense], pred), + getPersonFromVerbForm(grammarUnits.equativeEndings[baseTense], pred), ); } diff --git a/src/types.d.ts b/src/types.d.ts index f5fbd8f..935e2d2 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -56,4 +56,6 @@ type Words = { nouns: Noun[], adjectives: Adjective[], verbs: Verb[], -} \ No newline at end of file +} + +type EquativeTense = "present" | "subjunctive" | "past" | "future" | "wouldBe" | "pastSubjunctive"; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 57cd2c6..82dd9b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1684,10 +1684,10 @@ pbf "^3.2.1" rambda "^6.7.0" -"@lingdocs/pashto-inflector@^1.3.1": - version "1.3.1" - resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-1.3.1.tgz#09aca1e52507361d6efd5a87b7b7135704dc03a3" - integrity sha512-y8KKqvBau64zWrDP3Z7F4Zl9dxHXcB9WUyp1YRhL6jW1uqx4e92jF962p72oRkhlXGVLOXFuPFWmQqWHBVhvqw== +"@lingdocs/pashto-inflector@^1.3.2": + version "1.3.2" + resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-1.3.2.tgz#a5501d9a56c8590eee052a88ffdbe38a07594f29" + integrity sha512-crZlvjLssb+Q6kh6sAHlg4A4BerJnurSFUMz0fyYl3PlULsZyVHGvKepHYhP5AXyWt34zGiTzHTWapzIWsWtiQ== dependencies: classnames "^2.2.6" pbf "^3.2.1"