From 092c64f9672effe42b5099067e4e221c0c95abbe Mon Sep 17 00:00:00 2001 From: adueck Date: Tue, 11 Apr 2023 18:21:32 +0400 Subject: [PATCH] testing going on past participles --- .../{render-verb.test.ts => not-working.txt} | 0 src/lib/src/new-verb-engine/render-verb.ts | 31 +- .../new-verb-engine/roots-and-stems.test.ts | 2166 +++++++++-------- .../src/new-verb-engine/roots-and-stems.ts | 201 +- src/lib/src/new-verb-engine/rs-helpers.ts | 107 +- src/types.ts | 5 +- 6 files changed, 1354 insertions(+), 1156 deletions(-) rename src/lib/src/new-verb-engine/{render-verb.test.ts => not-working.txt} (100%) diff --git a/src/lib/src/new-verb-engine/render-verb.test.ts b/src/lib/src/new-verb-engine/not-working.txt similarity index 100% rename from src/lib/src/new-verb-engine/render-verb.test.ts rename to src/lib/src/new-verb-engine/not-working.txt diff --git a/src/lib/src/new-verb-engine/render-verb.ts b/src/lib/src/new-verb-engine/render-verb.ts index 32dce8d..d7ef221 100644 --- a/src/lib/src/new-verb-engine/render-verb.ts +++ b/src/lib/src/new-verb-engine/render-verb.ts @@ -19,7 +19,7 @@ import { isPastTense } from "../phrase-building/vp-tools"; import { makePsString, removeFVarients } from "../accent-and-ps-utils"; import { pashtoConsonants } from "../pashto-consonants"; import { getPastParticiple, getRootStem } from "./roots-and-stems"; -import { verbEndingConcat } from "./rs-helpers"; +import { getAspect, isKedul, perfectTenseToEquative, verbEndingConcat } from "./rs-helpers"; // For the chart display of the results: base the length thing on the VBE at the end, if there are other // length variations earlier in the blocks, flatten those into the variations @@ -238,32 +238,3 @@ function ensure3rdPast(rs: T.PsString[], ending: T.PsString[], verb: T.VerbEntry ...ending, ] : ending).map(e => concatPsString(rs[0], e)); } - -function getAspect(tense: T.VerbTense | T.AbilityTense): T.Aspect { - const t = tense.replace("Modal", ""); - if (["presentVerb", "imperfectiveFuture", "imperfectivePast", "habitualImperfectivePast"].includes(t)) { - return "imperfective"; - } else { - return "perfective"; - } -} - -function isKedul(v: T.VerbEntry): boolean { - return v.entry.p === "کېدل"; -} - -function perfectTenseToEquative(t: T.PerfectTense): keyof typeof equativeEndings { - return t === "presentPerfect" - ? "present" - : t === "futurePerfect" - ? "habitual" - : t === "habitualPerfect" - ? "habitual" - : t === "pastPerfect" - ? "past" - : t === "pastSubjunctivePerfect" - ? "pastSubjunctive" - : t === "wouldBePerfect" - ? "past" - : "subjunctive" -} \ No newline at end of file diff --git a/src/lib/src/new-verb-engine/roots-and-stems.test.ts b/src/lib/src/new-verb-engine/roots-and-stems.test.ts index e29fa77..299c9ff 100644 --- a/src/lib/src/new-verb-engine/roots-and-stems.test.ts +++ b/src/lib/src/new-verb-engine/roots-and-stems.test.ts @@ -1,4 +1,5 @@ import * as T from "../../../types"; +import { getPastParticiple } from "./roots-and-stems"; import { vEntry } from "./rs-helpers"; import { getAllRs } from "./rs-helpers"; @@ -23,1036 +24,1141 @@ const wurul = vEntry({"ts":1527816865,"i":14903,"p":"وړل","f":"wuRúl, oRúl, const kexodul = vEntry({"ts":1527812284,"i":11113,"p":"کېښودل","f":"kexodul","g":"kexodul","e":"to put, to put down, to set in place","r":4,"c":"v. trans.","psp":"ږد","psf":"Gd","ssp":"کېږد","ssf":"kéGd","noOo":true,"separationAtP":2,"separationAtF":2,"ec":"put,puts,putting,put,put"}); const kenaastul = vEntry({"ts":1527812759,"i":11124,"p":"کېناستل","f":"kenaastul","g":"kenaastul","e":"to sit down, to have a seat","r":4,"c":"v. intrans.","psp":"کېن","psf":"ken","noOo":true,"separationAtP":2,"separationAtF":2,"ec":"sit,sits,sitting,sat","ep":"down"}); const ghadzedul = vEntry({"ts":1527812615,"i":9500,"p":"غځېدل","f":"ghadzedul","g":"ghadzedul","e":"stretch out, lie, be extended, expand","r":3,"c":"v. intrans.","ec":"stretch","ep":"out"}); +const prexodul = vEntry({"ts":1527815190,"i":2495,"p":"پرېښودل","f":"prexodúl","g":"prexodul","e":"to leave, abandon, forsake, let go, allow","r":4,"c":"v. trans.","psp":"پرېږد","psf":"preGd","noOo":true,"separationAtP":3,"separationAtF":3,"ec":"abandon"}); +const raawustul = vEntry({"ts":1527819827,"i":6955,"p":"راوستل","f":"raawustúl","g":"raawustul","e":"to bring, deliver (animate objects), obtain, extract","r":3,"c":"v. trans.","psp":"راول","psf":"raawul","noOo":true,"separationAtP":2,"separationAtF":3,"ec":"bring,brings,bringing,brought,brought"}); -const ooPh: T.PH = { - type: "PH", - ps: { p: "و", f: "óo" }, -}; - -type RootsAndStemsTestGroup = { - verb: T.VerbEntry, - result: Record<"stem" | "root", { - imperfective: T.RootStemOutput, - perfective: T.RootStemOutput, - }> -}[]; - -const rootsAndStemsTests: { - title: string, - testGroup: RootsAndStemsTestGroup, -}[] = - [ - { - title: "regular verbs", - testGroup: [ - { - verb: weshul, - result: { - stem: { - perfective: [ - ooPh, - [{ p: "وېش", f: "wesh" }], - ], - imperfective: [ - [{ p: "وېش", f: "wesh" }], - ], - }, - root: { - perfective: [ - ooPh, - { - long: [{ p: "وېشل", f: "weshul" }], - short: [{ p: "وېش", f: "wesh" }], - }, - ], - imperfective: [ - { - long: [{ p: "وېشل", f: "weshúl" }], - short: [{ p: "وېش", f: "weshX" }], - }, - ], - }, - }, - }, - { - verb: ganul, - result: { - stem: { - perfective: [ - ooPh, - [{ p: "ګڼ", f: "gaN" }], - ], - imperfective: [ - [{ p: "ګڼ", f: "gaN" }], - ], - }, - root: { - perfective: [ - ooPh, - { - long: [{ p: "ګڼل", f: "gaNul" }], - short: [{ p: "ګڼ", f: "gaN" }], - }, - ], - imperfective: [ - { - long: [{ p: "ګڼل", f: "gaNúl" }], - short: [{ p: "ګڼ", f: "gaNX" }], - }, - ], - }, - }, - }, - ], - }, - { - title: "intransitive edul verbs", - testGroup: [ - // without shorter intrans version - { - verb: ghadzedul, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "و", - "f": "óo" - } - }, - [ - { - "p": "غځېد", - "f": "ghadzed" - } - ] - ], - "imperfective": [ - [ - { - "p": "غځېږ", - "f": "ghadzéG" - } - ] - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "و", - "f": "óo" - } - }, - { - "long": [ - { - "p": "غځېدل", - "f": "ghadzedul" - } - ], - "short": [ - { - "p": "غځېد", - "f": "ghadzed" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "غځېدل", - "f": "ghadzedúl" - } - ], - "short": [ - { - "p": "غځېد", - "f": "ghadzedX" - }, - ], - }, - ], - }, - }, - }, - // with shorter intrans version - { - verb: rasedul, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "و", - "f": "óo" - } - }, - [ - { - "p": "رسېد", - "f": "rased" - } - ] - ], - "imperfective": [ - { - "long": [ - { - "p": "رسېږ", - "f": "raséG" - } - ], - "short": [ - { - "p": "رس", - "f": "ras" - } - ] - } - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "و", - "f": "óo" - } - }, - { - "long": [ - { - "p": "رسېدل", - "f": "rasedul" - } - ], - "short": [ - { - "p": "رسېد", - "f": "rased" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "رسېدل", - "f": "rasedúl" - } - ], - "short": [ - { - "p": "رسېد", - "f": "rasedX" - } - ] - } - ] - } - }, - }, - ], - }, - { - title: "verbs with irregular stems", - testGroup: [ - { - verb: khorul, - result: { - stem: { - perfective: [ - ooPh, - [{ p: "خور", f: "khor" }], - ], - imperfective: [ - [{ p: "خور", f: "khor" }], - ], - }, - root: { - perfective: [ - ooPh, - { - long: [{ p: "خوړل", f: "khoRul" }], - short: [{ p: "خوړ", f: "khoR" }], - }, - ], - imperfective: [ - { - long: [{ p: "خوړل", f: "khoRúl" }], - short: [{ p: "خوړ", f: "khoRX" }], - }, - ], - }, - }, - }, - { - verb: khatul, - result: { - stem: { - perfective: [ - ooPh, - [{ p: "خېژ", f: "khejz" }], - ], - imperfective: [ - [{ p: "خېژ", f: "khejz" }], - ], - }, - root: { - perfective: [ - ooPh, - { - long: [{ p: "ختل", f: "khatul" }], - short: [{ p: "خت", f: "khat" }], - }, - ], - imperfective: [ - { - long: [{ p: "ختل", f: "khatúl" }], - short: [{ p: "خت", f: "khatX" }], - }, - ], - }, - }, - }, - ], - }, - { - title: "verbs with special prefix behavior", - testGroup: [ - { - verb: achawul, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "وا", - "f": "wáa" - } - }, - [ - { - "p": "چو", - "f": "chaw" - } - ] - ], - "imperfective": [ - [ - { - "p": "اچو", - "f": "achaw" - } - ] - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "وا", - "f": "wáa" - } - }, - { - "long": [ - { - "p": "چول", - "f": "chawul" - } - ], - "short": [ - { - "p": "چو", - "f": "chaw" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "اچول", - "f": "achawúl" - } - ], - "short": [ - { - "p": "اچو", - "f": "achawX" - } - ] - } - ] - } - }, - }, - { - verb: watul, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "wÚ", - "f": "و" - } - }, - [ - { - "p": "وځ", - "f": "oodz" - } - ] - ], - "imperfective": [ - [ - { - "p": "وځ", - "f": "oodz" - } - ] - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "و", - "f": "óo" - } - }, - { - "long": [ - { - "p": "وتل", - "f": "watul" - } - ], - "short": [ - { - "p": "وت", - "f": "wat" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "وتل", - "f": "watúl" - } - ], - "short": [ - { - "p": "وت", - "f": "watX" - } - ] - } - ] - } - }, - }, - { - verb: azmoyul, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "و ", - "f": "óo`" - } - }, - [ - { - "p": "ازموی", - "f": "azmoy" - } - ] - ], - "imperfective": [ - [ - { - "p": "ازموی", - "f": "azmoy" - } - ] - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "و ", - "f": "óo`" - } - }, - { - "long": [ - { - "p": "ازمویل", - "f": "azmoyul" - } - ], - "short": [ - { - "p": "ازموی", - "f": "azmoy" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "ازمویل", - "f": "azmoyúl" - } - ], - "short": [ - { - "p": "ازموی", - "f": "azmoyX" - } - ] - } - ] - } - }, - }, - ], - }, - { - title: "verbs with seperable oo prefix", - testGroup: [ - { - verb: kenaastul, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "کې", - "f": "ké" - } - }, - [ - { - "p": "ن", - "f": "n" - } - ] - ], - "imperfective": [ - [ - { - "p": "کېن", - "f": "ken" - } - ] - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "کې", - "f": "ké" - } - }, - { - "long": [ - { - "p": "ناستل", - "f": "naastul" - } - ], - "short": [ - { - "p": "ناست", - "f": "naast" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "کېناستل", - "f": "kenaastúl" - } - ], - "short": [ - { - "p": "کېناست", - "f": "kenaastX" - } - ] - } - ] - } - }, - }, - ], - }, - { - title: "verbs with irregular roots and stems", - testGroup: [ - { - verb: wurul, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "یو", - "f": "yó" - } - }, - [ - { - "p": "س", - "f": "s" - } - ] - ], - "imperfective": [ - [ - { - "p": "وړ", - "f": "wuR" - } - ] - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "یو", - "f": "yó" - } - }, - { - "long": [ - { - "p": "ړل", - "f": "Rul" - } - ], - "short": [ - { - "p": "ړ", - "f": "R" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "وړل", - "f": "wuRúl" - } - ], - "short": [ - { - "p": "وړ", - "f": "wuRX" - } - ] - } - ] - } - } - }, - { - verb: kexodul, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "کې", - "f": "ké" - } - }, - [ - { - "p": "ږد", - "f": "Gd" - } - ] - ], - "imperfective": [ - [ - { - "p": "ږد", - "f": "Gd" - } - ] - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "کې", - "f": "ké" - } - }, - { - "long": [ - { - "p": "ښودل", - "f": "xodul" - } - ], - "short": [ - { - "p": "ښود", - "f": "xod" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "کېښودل", - "f": "kexodúl" - } - ], - "short": [ - { - "p": "کېښود", - "f": "kexodX" - } - ] - } - ] - } - }, - }, - ], - }, - { - title: "especially irregular verbs", - testGroup: [ - { - verb: kedulStat, - result: { - "stem": { - "perfective": [ - [ - { - "p": "ش", - "f": "sh" - } - ] - ], - "imperfective": [ - [ - { - "p": "کېږ", - "f": "kéG", - }, - ] - ] - }, - "root": { - "perfective": [ - { - "long": [ - { - "p": "شول", - "f": "shwul" - } - ], - "short": [ - { - "p": "شو", - "f": "shw" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "کېدل", - "f": "kedúl" - } - ], - "short": [ - { - "p": "کېد", - "f": "kedX" - } - ] - } - ] - } - }, - }, - { - verb: kedulDyn, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "f": "óo", - "p": "و" - } - }, - [ - { - "p": "ش", - "f": "sh" - } - ] - ], - "imperfective": [ - [ - { - "p": "کېږ", - "f": "kéG" - } - ] - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "f": "óo", - "p": "و" - } - }, - { - "long": [ - { - "p": "شول", - "f": "shwul" - } - ], - "short": [ - { - "p": "شو", - "f": "shw" - } - ] - } - ], - "imperfective": [ - { - "long": [ - { - "p": "کېدل", - "f": "kedúl" - } - ], - "short": [ - { - "p": "کېد", - "f": "kedX" - } - ] - } - ] - } - }, - }, - { - verb: kawulStat, - result: { - "stem": { - "perfective": [{ - long: [ - { - "p": "کړ", - "f": "kR" - } - ], - short: [ - { - p: "ک", - f: "k", - }, - ], - }], - "imperfective": [ - [ - { - "p": "کو", - "f": "kaw" - } - ] - ] - }, - "root": { - "perfective": [ - { - "long": [ - { - "p": "کړل", - "f": "kRul" - } - ], - "short": [ - { - "p": "کړ", - "f": "kR" - } - ], - "mini": [ - { - "p": "ک", - "f": "k", - }, - ], - } - ], - "imperfective": [ - { - "long": [ - { - "p": "کول", - "f": "kawúl" - } - ], - "short": [ - { - "p": "کو", - "f": "kawX" - } - ] - } - ] - } - }, - }, - { - verb: kawulDyn, - result: { - "stem": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "و", - "f": "óo", - } - }, - { - long: [ - { - "p": "کړ", - "f": "kR" - }, - ], - short: [ - { p: "ک", f: "k" }, - ], - }, - ], - "imperfective": [ - [ - { - "p": "کو", - "f": "kaw" - } - ] - ] - }, - "root": { - "perfective": [ - { - "type": "PH", - "ps": { - "p": "و", - "f": "óo", - }, - }, - { - "long": [ - { - "p": "کړل", - "f": "kRul" - } - ], - "short": [ - { - "p": "کړ", - "f": "kR" - } - ], - "mini": [ - { p: "ک", f: "k" }, - ], - }, - ], - "imperfective": [ - { - "long": [ - { - "p": "کول", - "f": "kawúl" - } - ], - "short": [ - { - "p": "کو", - "f": "kawX" - } - ] - } - ] - } - }, - } - ], - } - ]; - -rootsAndStemsTests.forEach(({ title, testGroup }) => { - test(title, () => { - testGroup.forEach(({ verb, result }) => { - expect(getAllRs(verb)).toEqual(result); - }); +describe("past participles", () => { + test("for most verbs are just the imperfective root (imperative) plus ی - ey", () => { + expect(getPastParticiple(rasedul, "active", { gender: "masc", number: "singular" })) + .toEqual({ + type: "VB", + ps: [{ p: "رسېدلی", f: "rasedúley" }], + gender: "masc", + number: "singular", + }); + expect(getPastParticiple(ganul, "active", { gender: "fem", number: "singular" })) + .toEqual({ + type: "VB", + ps: [{ p: "ګڼلې", f: "gaNúle" }], + gender: "fem", + number: "singular", + }); }); + test("for verbs like اېښودل and پرېښودل they have a short version shortened taking off after ښ", () => { + expect(getPastParticiple(prexodul, "active", { gender: "masc", number: "plural" })) + .toEqual({ + type: "VB", + ps: { + long: [{ p: "پرېښودلي", f: "prexodúlee" }], + short: [{ p: "پرېښي", f: "préxee" }], + }, + gender: "masc", + number: "plural", + }); + }); + test("verbs ending in ستل ښتل وتل or وړل verbs also have a short version", () => { + expect(getPastParticiple(raawustul, "active", { gender: "fem", number: "plural" })) + .toEqual({ + type: "VB", + ps: { + long: [{ p: "راوستلې", f: "raawustúle" }], + short: [{ p: "راوستې", f: "raawúste" }], + }, + gender: "fem", + number: "plural", + }); + expect(getPastParticiple(awuxtul, "active", { gender: "masc", number: "plural" })) + .toEqual({ + type: "VB", + ps: { + long: [{ p: "اوښتلي", f: "awUxtúlee" }], + short: [{ p: "اوښتي", f: "awÚxtee" }], + }, + gender: "masc", + number: "plural", + }); + expect(getPastParticiple(watul, "active", { gender: "fem", number: "singular" })) + .toEqual({ + type: "VB", + ps: { + long: [{ p: "وتلې", f: "watúle" }], + short: [{ p: "وتې", f: "wáte" }], + }, + gender: "fem", + number: "singular", + }); + }); + test("but not verbs ending with استل", () => { + expect(getPastParticiple(kenaastul, "active", { gender: "fem", number: "plural" })) + .toEqual({ + type: "VB", + ps: [{ p: "کېناستلې", f: "kenaastúle" }], + gender: "fem", + number: "plural", + }); + }); + test("kawul/kedul verbs have an irregular pprt fields that give us the irregular past participle", () => { + expect(getPastParticiple(kawulDyn, "active", { gender: "masc", number: "singular" })) + .toEqual({ + type: "VB", + ps: [{ p: "کړی", f: "kúRey" }], + gender: "masc", + number: "singular", + }); + expect(getPastParticiple(kawulStat, "active", { gender: "masc", number: "plural" })) + .toEqual({ + type: "VB", + ps: [{ p: "کړي", f: "kúRee" }], + gender: "masc", + number: "plural", + }); + expect(getPastParticiple(kedulStat, "active", { gender: "fem", number: "singular" })) + .toEqual({ + type: "VB", + ps: [{ p: "شوې", f: "shúwe" }], + gender: "fem", + number: "singular", + }); + expect(getPastParticiple(kedulDyn, "active", { gender: "fem", number: "plural" })) + .toEqual({ + type: "VB", + ps: [{ p: "شوې", f: "shúwe" }], + gender: "fem", + number: "plural", + }); + }); + }); + +// const ooPh: T.PH = { +// type: "PH", +// ps: { p: "و", f: "óo" }, +// }; + +// type RootsAndStemsTestGroup = { +// verb: T.VerbEntry, +// result: Record<"stem" | "root", { +// imperfective: T.RootStemOutput, +// perfective: T.RootStemOutput, +// }> +// }[]; + +// const rootsAndStemsTests: { +// title: string, +// testGroup: RootsAndStemsTestGroup, +// }[] = +// [ +// { +// title: "regular verbs", +// testGroup: [ +// { +// verb: weshul, +// result: { +// stem: { +// perfective: [ +// ooPh, +// [{ p: "وېش", f: "wesh" }], +// ], +// imperfective: [ +// [{ p: "وېش", f: "wesh" }], +// ], +// }, +// root: { +// perfective: [ +// ooPh, +// { +// long: [{ p: "وېشل", f: "weshul" }], +// short: [{ p: "وېش", f: "wesh" }], +// }, +// ], +// imperfective: [ +// { +// long: [{ p: "وېشل", f: "weshúl" }], +// short: [{ p: "وېش", f: "weshX" }], +// }, +// ], +// }, +// }, +// }, +// { +// verb: ganul, +// result: { +// stem: { +// perfective: [ +// ooPh, +// [{ p: "ګڼ", f: "gaN" }], +// ], +// imperfective: [ +// [{ p: "ګڼ", f: "gaN" }], +// ], +// }, +// root: { +// perfective: [ +// ooPh, +// { +// long: [{ p: "ګڼل", f: "gaNul" }], +// short: [{ p: "ګڼ", f: "gaN" }], +// }, +// ], +// imperfective: [ +// { +// long: [{ p: "ګڼل", f: "gaNúl" }], +// short: [{ p: "ګڼ", f: "gaNX" }], +// }, +// ], +// }, +// }, +// }, +// ], +// }, +// { +// title: "intransitive edul verbs", +// testGroup: [ +// // without shorter intrans version +// { +// verb: ghadzedul, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "و", +// "f": "óo" +// } +// }, +// [ +// { +// "p": "غځېد", +// "f": "ghadzed" +// } +// ] +// ], +// "imperfective": [ +// [ +// { +// "p": "غځېږ", +// "f": "ghadzéG" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "و", +// "f": "óo" +// } +// }, +// { +// "long": [ +// { +// "p": "غځېدل", +// "f": "ghadzedul" +// } +// ], +// "short": [ +// { +// "p": "غځېد", +// "f": "ghadzed" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "غځېدل", +// "f": "ghadzedúl" +// } +// ], +// "short": [ +// { +// "p": "غځېد", +// "f": "ghadzedX" +// }, +// ], +// }, +// ], +// }, +// }, +// }, +// // with shorter intrans version +// { +// verb: rasedul, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "و", +// "f": "óo" +// } +// }, +// [ +// { +// "p": "رسېد", +// "f": "rased" +// } +// ] +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "رسېږ", +// "f": "raséG" +// } +// ], +// "short": [ +// { +// "p": "رس", +// "f": "ras" +// } +// ] +// } +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "و", +// "f": "óo" +// } +// }, +// { +// "long": [ +// { +// "p": "رسېدل", +// "f": "rasedul" +// } +// ], +// "short": [ +// { +// "p": "رسېد", +// "f": "rased" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "رسېدل", +// "f": "rasedúl" +// } +// ], +// "short": [ +// { +// "p": "رسېد", +// "f": "rasedX" +// } +// ] +// } +// ] +// } +// }, +// }, +// ], +// }, +// { +// title: "verbs with irregular stems", +// testGroup: [ +// { +// verb: khorul, +// result: { +// stem: { +// perfective: [ +// ooPh, +// [{ p: "خور", f: "khor" }], +// ], +// imperfective: [ +// [{ p: "خور", f: "khor" }], +// ], +// }, +// root: { +// perfective: [ +// ooPh, +// { +// long: [{ p: "خوړل", f: "khoRul" }], +// short: [{ p: "خوړ", f: "khoR" }], +// }, +// ], +// imperfective: [ +// { +// long: [{ p: "خوړل", f: "khoRúl" }], +// short: [{ p: "خوړ", f: "khoRX" }], +// }, +// ], +// }, +// }, +// }, +// { +// verb: khatul, +// result: { +// stem: { +// perfective: [ +// ooPh, +// [{ p: "خېژ", f: "khejz" }], +// ], +// imperfective: [ +// [{ p: "خېژ", f: "khejz" }], +// ], +// }, +// root: { +// perfective: [ +// ooPh, +// { +// long: [{ p: "ختل", f: "khatul" }], +// short: [{ p: "خت", f: "khat" }], +// }, +// ], +// imperfective: [ +// { +// long: [{ p: "ختل", f: "khatúl" }], +// short: [{ p: "خت", f: "khatX" }], +// }, +// ], +// }, +// }, +// }, +// ], +// }, +// { +// title: "verbs with special prefix behavior", +// testGroup: [ +// { +// verb: achawul, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "وا", +// "f": "wáa" +// } +// }, +// [ +// { +// "p": "چو", +// "f": "chaw" +// } +// ] +// ], +// "imperfective": [ +// [ +// { +// "p": "اچو", +// "f": "achaw" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "وا", +// "f": "wáa" +// } +// }, +// { +// "long": [ +// { +// "p": "چول", +// "f": "chawul" +// } +// ], +// "short": [ +// { +// "p": "چو", +// "f": "chaw" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "اچول", +// "f": "achawúl" +// } +// ], +// "short": [ +// { +// "p": "اچو", +// "f": "achawX" +// } +// ] +// } +// ] +// } +// }, +// }, +// { +// verb: watul, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "wÚ", +// "f": "و" +// } +// }, +// [ +// { +// "p": "وځ", +// "f": "oodz" +// } +// ] +// ], +// "imperfective": [ +// [ +// { +// "p": "وځ", +// "f": "oodz" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "و", +// "f": "óo" +// } +// }, +// { +// "long": [ +// { +// "p": "وتل", +// "f": "watul" +// } +// ], +// "short": [ +// { +// "p": "وت", +// "f": "wat" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "وتل", +// "f": "watúl" +// } +// ], +// "short": [ +// { +// "p": "وت", +// "f": "watX" +// } +// ] +// } +// ] +// } +// }, +// }, +// { +// verb: azmoyul, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "و ", +// "f": "óo`" +// } +// }, +// [ +// { +// "p": "ازموی", +// "f": "azmoy" +// } +// ] +// ], +// "imperfective": [ +// [ +// { +// "p": "ازموی", +// "f": "azmoy" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "و ", +// "f": "óo`" +// } +// }, +// { +// "long": [ +// { +// "p": "ازمویل", +// "f": "azmoyul" +// } +// ], +// "short": [ +// { +// "p": "ازموی", +// "f": "azmoy" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "ازمویل", +// "f": "azmoyúl" +// } +// ], +// "short": [ +// { +// "p": "ازموی", +// "f": "azmoyX" +// } +// ] +// } +// ] +// } +// }, +// }, +// ], +// }, +// { +// title: "verbs with seperable oo prefix", +// testGroup: [ +// { +// verb: kenaastul, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "کې", +// "f": "ké" +// } +// }, +// [ +// { +// "p": "ن", +// "f": "n" +// } +// ] +// ], +// "imperfective": [ +// [ +// { +// "p": "کېن", +// "f": "ken" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "کې", +// "f": "ké" +// } +// }, +// { +// "long": [ +// { +// "p": "ناستل", +// "f": "naastul" +// } +// ], +// "short": [ +// { +// "p": "ناست", +// "f": "naast" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "کېناستل", +// "f": "kenaastúl" +// } +// ], +// "short": [ +// { +// "p": "کېناست", +// "f": "kenaastX" +// } +// ] +// } +// ] +// } +// }, +// }, +// ], +// }, +// { +// title: "verbs with irregular roots and stems", +// testGroup: [ +// { +// verb: wurul, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "یو", +// "f": "yó" +// } +// }, +// [ +// { +// "p": "س", +// "f": "s" +// } +// ] +// ], +// "imperfective": [ +// [ +// { +// "p": "وړ", +// "f": "wuR" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "یو", +// "f": "yó" +// } +// }, +// { +// "long": [ +// { +// "p": "ړل", +// "f": "Rul" +// } +// ], +// "short": [ +// { +// "p": "ړ", +// "f": "R" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "وړل", +// "f": "wuRúl" +// } +// ], +// "short": [ +// { +// "p": "وړ", +// "f": "wuRX" +// } +// ] +// } +// ] +// } +// } +// }, +// { +// verb: kexodul, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "کې", +// "f": "ké" +// } +// }, +// [ +// { +// "p": "ږد", +// "f": "Gd" +// } +// ] +// ], +// "imperfective": [ +// [ +// { +// "p": "ږد", +// "f": "Gd" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "کې", +// "f": "ké" +// } +// }, +// { +// "long": [ +// { +// "p": "ښودل", +// "f": "xodul" +// } +// ], +// "short": [ +// { +// "p": "ښود", +// "f": "xod" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "کېښودل", +// "f": "kexodúl" +// } +// ], +// "short": [ +// { +// "p": "کېښود", +// "f": "kexodX" +// } +// ] +// } +// ] +// } +// }, +// }, +// ], +// }, +// { +// title: "especially irregular verbs", +// testGroup: [ +// { +// verb: kedulStat, +// result: { +// "stem": { +// "perfective": [ +// [ +// { +// "p": "ش", +// "f": "sh" +// } +// ] +// ], +// "imperfective": [ +// [ +// { +// "p": "کېږ", +// "f": "kéG", +// }, +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "long": [ +// { +// "p": "شول", +// "f": "shwul" +// } +// ], +// "short": [ +// { +// "p": "شو", +// "f": "shw" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "کېدل", +// "f": "kedúl" +// } +// ], +// "short": [ +// { +// "p": "کېد", +// "f": "kedX" +// } +// ] +// } +// ] +// } +// }, +// }, +// { +// verb: kedulDyn, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "f": "óo", +// "p": "و" +// } +// }, +// [ +// { +// "p": "ش", +// "f": "sh" +// } +// ] +// ], +// "imperfective": [ +// [ +// { +// "p": "کېږ", +// "f": "kéG" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "f": "óo", +// "p": "و" +// } +// }, +// { +// "long": [ +// { +// "p": "شول", +// "f": "shwul" +// } +// ], +// "short": [ +// { +// "p": "شو", +// "f": "shw" +// } +// ] +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "کېدل", +// "f": "kedúl" +// } +// ], +// "short": [ +// { +// "p": "کېد", +// "f": "kedX" +// } +// ] +// } +// ] +// } +// }, +// }, +// { +// verb: kawulStat, +// result: { +// "stem": { +// "perfective": [{ +// long: [ +// { +// "p": "کړ", +// "f": "kR" +// } +// ], +// short: [ +// { +// p: "ک", +// f: "k", +// }, +// ], +// }], +// "imperfective": [ +// [ +// { +// "p": "کو", +// "f": "kaw" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "long": [ +// { +// "p": "کړل", +// "f": "kRul" +// } +// ], +// "short": [ +// { +// "p": "کړ", +// "f": "kR" +// } +// ], +// "mini": [ +// { +// "p": "ک", +// "f": "k", +// }, +// ], +// } +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "کول", +// "f": "kawúl" +// } +// ], +// "short": [ +// { +// "p": "کو", +// "f": "kawX" +// } +// ] +// } +// ] +// } +// }, +// }, +// { +// verb: kawulDyn, +// result: { +// "stem": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "و", +// "f": "óo", +// } +// }, +// { +// long: [ +// { +// "p": "کړ", +// "f": "kR" +// }, +// ], +// short: [ +// { p: "ک", f: "k" }, +// ], +// }, +// ], +// "imperfective": [ +// [ +// { +// "p": "کو", +// "f": "kaw" +// } +// ] +// ] +// }, +// "root": { +// "perfective": [ +// { +// "type": "PH", +// "ps": { +// "p": "و", +// "f": "óo", +// }, +// }, +// { +// "long": [ +// { +// "p": "کړل", +// "f": "kRul" +// } +// ], +// "short": [ +// { +// "p": "کړ", +// "f": "kR" +// } +// ], +// "mini": [ +// { p: "ک", f: "k" }, +// ], +// }, +// ], +// "imperfective": [ +// { +// "long": [ +// { +// "p": "کول", +// "f": "kawúl" +// } +// ], +// "short": [ +// { +// "p": "کو", +// "f": "kawX" +// } +// ] +// } +// ] +// } +// }, +// } +// ], +// } +// ]; + +// rootsAndStemsTests.forEach(({ title, testGroup }) => { +// test(title, () => { +// testGroup.forEach(({ verb, result }) => { +// expect(getAllRs(verb)).toEqual(result); +// }); +// }); +// }); diff --git a/src/lib/src/new-verb-engine/roots-and-stems.ts b/src/lib/src/new-verb-engine/roots-and-stems.ts index a260961..e1b2e4c 100644 --- a/src/lib/src/new-verb-engine/roots-and-stems.ts +++ b/src/lib/src/new-verb-engine/roots-and-stems.ts @@ -13,10 +13,11 @@ import * as T from "../../../types"; import { makePsString, removeFVarientsFromVerb } from "../accent-and-ps-utils"; import { accentOnNFromEnd, accentSyllable, removeAccents } from "../accent-helpers"; import { isKawulVerb, isTlulVerb } from "../type-predicates"; -import { vEntry, addAbilityEnding, weld, removeL, addTrailingAccent, tlulPerfectiveStem, getLongVB } from "./rs-helpers"; +import { vEntry, addAbilityEnding, weld, removeL, addTrailingAccent, tlulPerfectiveStem, getLongVB, possiblePPartLengths, isStatComp, statCompImperfectiveSpace, makeComplement } from "./rs-helpers"; import { inflectPattern3 } from "./new-inflectors"; const kedulStat = vEntry({"ts":1581086654898,"i":11100,"p":"کېدل","f":"kedul","g":"kedul","e":"to become _____","r":2,"c":"v. intrans.","ssp":"ش","ssf":"sh","prp":"شول","prf":"shwul","pprtp":"شوی","pprtf":"shúwey","noOo":true,"ec":"become"}); +const kawulStat = vEntry({"ts":1579015359582,"i":11030,"p":"کول","f":"kawul","g":"kawul","e":"to make ____ ____ (as in \"He's making me angry.\")","r":4,"c":"v. trans.","ssp":"کړ","ssf":"kR","prp":"کړل","prf":"kRul","pprtp":"کړی","pprtf":"kúRey","noOo":true,"ec":"make,makes,making,made,made"}); const shwulVB: T.VBBasic = { type: "VB", @@ -30,6 +31,57 @@ const shVB: T.VBBasic = { ps: [{ p: "ش", f: "sh" }], } +// TODO: figure out how to handle dynamic / stative verbs +export function getRootStem({ verb, rs, aspect, type, genderNumber, voice }: { + verb: T.VerbEntry, + rs: "root" | "stem", + aspect: T.Aspect, + voice: T.Voice, + type: "basic" | "ability", + genderNumber: { + gender: T.Gender, + number: T.NounNumber, + }, +}): T.RootsStemsOutput { + const v = removeFVarientsFromVerb(verb); + if (type === "ability") { + return getAbilityRs(v, aspect, rs, voice, genderNumber); + } + if (voice === "passive") { + return getPassiveRs(v, aspect, rs, genderNumber); + } + return rs === "stem" + ? aspect === "imperfective" + ? getImperfectiveStem(v, genderNumber) + : getPerfectiveStem(v, genderNumber) + : aspect === "imperfective" + ? getImperfectiveRoot(v, genderNumber) + : getPerfectiveRoot(v, genderNumber); +} + +function getAbilityRs( + verb: T.VerbEntryNoFVars, + aspect: T.Aspect, + rs: "root" | "stem", + voice: T.Voice, + genderNum: T.GenderNumber, +): [[] | [T.VHead], [T.VB, T.VBA]] { + const losesAspect = isTlulVerb(verb) || (isStatComp(verb) && verb.entry.c?.includes("intrans.")); + const [vhead, [basicroot]] = voice === "passive" + // passive ability loses aspect + ? getPassiveRs(verb, "imperfective", "root", genderNum) + : aspect === "imperfective" || losesAspect + ? getImperfectiveRoot(verb, genderNum) + : getPerfectiveRoot(verb, genderNum); + return [ + vhead, + [ + addAbilityEnding(basicroot), + rs === "root" ? shwulVB : shVB, + ], + ]; +} + // TODO: kuRee shuwey etc export function getPastParticiple(verb: T.VerbEntry, voice: T.Voice, { gender, number }: { gender: T.Gender, number: T.NounNumber }): T.VBGenNum | T.WeldedGN { const v = removeFVarientsFromVerb(verb); @@ -45,7 +97,7 @@ export function getPastParticiple(verb: T.VerbEntry, voice: T.Voice, { gender, n number, }; } - const [_, [basicRoot]] = getImperfectiveRoot(removeFVarientsFromVerb(verb)); + const basicRoot = getImperfectiveRoot(removeFVarientsFromVerb(verb), { gender, number })[1][0]; const longRoot = getLongVB(basicRoot); const rootWLengths = possiblePPartLengths(longRoot); @@ -80,98 +132,19 @@ export function getPastParticiple(verb: T.VerbEntry, voice: T.Voice, { gender, n } } -function possiblePPartLengths(vba: T.VBNoLenghts): T.VBBasic; -function possiblePPartLengths(vba: T.VBNoLenghts): T.VBA; -function possiblePPartLengths(vba: T.VBNoLenghts): T.VBA { - const shortenableEndings = ["ښتل", "ستل", "وتل"]; - const wrul = ["وړل", "راوړل", "وروړل", "دروړل"]; - if ("right" in vba) { - return { - ...vba, - right: possiblePPartLengths(vba.right), - }; - } - const infinitive = vba.ps[0]; - const [trimP, trimF] = (infinitive.p.slice(-4) === "ښودل" && infinitive.p.length > 4 && infinitive.p !== "کېښودل" && infinitive.p !== "کښېښودل") - // special thing for اېښودل - پرېښودل - ? [3, 4] - : (wrul.includes(infinitive.p) || (shortenableEndings.includes(infinitive.p.slice(-3)) && infinitive.p.slice(-4) !== "استل")) - ? [1, 2] - : [0, 0]; - if (trimP) { - return { - type: "VB", - ps: { - long: [infinitive], - short: [accentOnNFromEnd(trimOffPs(infinitive, trimP, trimF), 0)], - }, - }; - } - return vba; -} - -export function getRootStem({ verb, rs, aspect, type, genderNumber, voice }: { - verb: T.VerbEntry, - rs: "root" | "stem", - aspect: T.Aspect, - voice: T.Voice, - type: "basic" | "ability", - genderNumber: { - gender: T.Gender, - number: T.NounNumber, - }, -}): T.RootsStemsOutput { - const v = removeFVarientsFromVerb(verb); - if (type === "ability") { - return getAbilityRs(v, aspect, rs, voice); - } - if (voice === "passive") { - return getPassiveRs(v, aspect, rs); - } - return rs === "stem" - ? aspect === "imperfective" - ? getImperfectiveStem(v) - : getPerfectiveStem(v, genderNumber) - : aspect === "imperfective" - ? getImperfectiveRoot(v) - : getPerfectiveRoot(v); -} - -function getAbilityRs( - verb: T.VerbEntryNoFVars, - aspect: T.Aspect, - rs: "root" | "stem", - voice: T.Voice, -): [[] | [T.VHead], [T.VB, T.VBA]] { - const losesAspect = isTlulVerb(verb); // or is intransitive stative compound - const [vhead, [basicroot]] = voice === "passive" - // passive ability loses aspect - ? getPassiveRs(verb, "imperfective", "root") - : aspect === "imperfective" || losesAspect - ? getImperfectiveRoot(verb) - : getPerfectiveRoot(verb); - return [ - vhead, - [ - addAbilityEnding(basicroot), - rs === "root" ? shwulVB : shVB, - ], - ]; -} - function getPassivePp(verb: T.VerbEntryNoFVars, genderNumber: T.GenderNumber): T.WeldedGN { - const [_, [basicRoot]] = getImperfectiveRoot(verb); + const basicRoot = getImperfectiveRoot(verb, genderNumber)[1][0]; const longRoot = getLongVB(basicRoot); const kedulVb: T.VBGenNum = getPastParticiple(kedulStat, "active", genderNumber) as T.VBGenNum; return weld(longRoot, kedulVb); } // TODO: could combine these two functions... -function getPassiveRs(verb: T.VerbEntryNoFVars, aspect: T.Aspect, rs: "root" | "stem"): [[] | [T.VHead], [T.VBA]] { +function getPassiveRs(verb: T.VerbEntryNoFVars, aspect: T.Aspect, rs: "root" | "stem", genderNumber: T.GenderNumber): [[] | [T.VHead], [T.VBA]] { const [vHead, [basicRoot]] = (aspect === "imperfective" ? getImperfectiveRoot : getPerfectiveRoot - )(verb); + )(verb, genderNumber); const longRoot = getLongVB(basicRoot); const kedulVba = getRootStem({ verb: kedulStat, aspect, rs, type: "basic", voice: "active", genderNumber: { gender: "masc", number: "singular" }})[1][0] as T.VBBasic; return [ @@ -180,7 +153,22 @@ function getPassiveRs(verb: T.VerbEntryNoFVars, aspect: T.Aspect, rs: "root" | " ]; } -function getImperfectiveRoot(verb: T.VerbEntryNoFVars): [[], [T.VBA]] { +function getImperfectiveRoot(verb: T.VerbEntryNoFVars, genderNum: T.GenderNumber): [[], [T.VBA]] { + if (verb.complement && isStatComp(verb) && statCompImperfectiveSpace(verb)) { + const auxStem = getImperfectiveRoot(verb.entry.c?.includes("intrans.") + ? kedulStat + : kawulStat + , genderNum)[1][0]; + return [ + [], + [ + weld( + makeComplement(verb.complement, genderNum), + auxStem as T.VBBasic, + ), + ], + ]; + } const infinitive = accentOnNFromEnd(makePsString(verb.entry.p, verb.entry.f), 0); return [ [], @@ -196,7 +184,17 @@ function getImperfectiveRoot(verb: T.VerbEntryNoFVars): [[], [T.VBA]] { ]; } -function getPerfectiveRoot(verb: T.VerbEntryNoFVars): [[T.VHead] | [], [T.VBA]] { +function getPerfectiveRoot(verb: T.VerbEntryNoFVars, genderNum: T.GenderNumber): [[T.VHead] | [], [T.VBA]] { + if (verb.complement && isStatComp(verb)) { + const auxStem = getPerfectiveRoot(verb.entry.c?.includes("intrans.") + ? kedulStat + : kawulStat, + genderNum)[1][0]; + return [ + [makeComplement(verb.complement, genderNum)], + [auxStem as T.VBBasic], + ]; + } const base = removeAccents( (verb.entry.prp && verb.entry.prf) ? makePsString(verb.entry.prp, verb.entry.prf) @@ -220,7 +218,22 @@ function getPerfectiveRoot(verb: T.VerbEntryNoFVars): [[T.VHead] | [], [T.VBA]] ]; } -function getImperfectiveStem(verb: T.VerbEntryNoFVars): T.RootsStemsOutput { +function getImperfectiveStem(verb: T.VerbEntryNoFVars, genderNum: T.GenderNumber): [[], [T.VB]] { + if (verb.complement && isStatComp(verb) && statCompImperfectiveSpace(verb)) { + const auxStem = getImperfectiveStem(verb.entry.c?.includes("intrans.") + ? kedulStat + : kawulStat, + genderNum)[1][0]; + return [ + [], + [ + weld( + makeComplement(verb.complement, genderNum), + auxStem as T.VBBasic, + ), + ], + ]; + } if (verb.entry.psp && verb.entry.psf) { return [ [], @@ -262,9 +275,19 @@ function getImperfectiveStem(verb: T.VerbEntryNoFVars): T.RootsStemsOutput { ]; } -function getPerfectiveStem(verb: T.VerbEntryNoFVars, person: { gender: T.Gender, number: T.NounNumber }): T.RootsStemsOutput { +function getPerfectiveStem(verb: T.VerbEntryNoFVars, genderNum: { gender: T.Gender, number: T.NounNumber }): [[T.VHead] | [], [T.VB]] { + if (verb.complement && isStatComp(verb)) { + const auxStem = getPerfectiveStem(verb.entry.c?.includes("intrans.") + ? kedulStat + : kawulStat, + genderNum)[1][0]; + return [ + [makeComplement(verb.complement, genderNum)], + [auxStem as T.VBBasic], + ]; + } if (verb.entry.f === "tlul") { - return tlulPerfectiveStem(person); + return tlulPerfectiveStem(genderNum); } const base = (verb.entry.ssp && verb.entry.ssf) // with irregular perfective stem diff --git a/src/lib/src/new-verb-engine/rs-helpers.ts b/src/lib/src/new-verb-engine/rs-helpers.ts index 5cf4986..71ee360 100644 --- a/src/lib/src/new-verb-engine/rs-helpers.ts +++ b/src/lib/src/new-verb-engine/rs-helpers.ts @@ -1,10 +1,51 @@ import * as T from "../../../types"; import { removeFVarients } from "../accent-and-ps-utils"; -import { accentPsSyllable, removeAccents, removeAccentsWLength } from "../accent-helpers"; -import { concatPsString, trimOffPs } from "../p-text-helpers"; +import { accentOnNFromEnd, accentPsSyllable, countSyllables, removeAccents, removeAccentsWLength } from "../accent-helpers"; +import { concatPsString, isUnisexSet, psStringFromEntry, trimOffPs } from "../p-text-helpers"; import { getRootStem } from "./roots-and-stems"; import { inflectPattern1 } from "./new-inflectors"; import { getLength } from "../p-text-helpers"; +import { equativeEndings } from "../grammar-units"; +import { isAdjectiveEntry } from "../type-predicates"; +import { inflectWord } from "../pashto-inflector"; + +export function isStatComp(v: T.VerbEntry): boolean { + return !!v.entry.c?.includes("stat. comp.") && !!v.complement; +} + +export function statCompImperfectiveSpace(v: T.VerbEntryNoFVars): boolean { + return v.entry.p.startsWith(`${v.complement?.p} `); +} + +export function makeComplement(e: T.DictionaryEntryNoFVars, { gender, number }: T.GenderNumber): T.NComp { + if (isAdjectiveEntry(e)) { + const infs = inflectWord(e); + const ps = infs && infs.inflections && isUnisexSet(infs.inflections) + ? infs.inflections[gender][number === "singular" ? 0 : 1][0] + : psStringFromEntry(e); + return { + type: "NComp", + comp: { + type: "AdjComp", + ps: lightEnforceCompAccent(ps), + gender, + number, + }, + }; + } + return { + type: "NComp", + comp: { + type: "Comp", + ps: lightEnforceCompAccent(psStringFromEntry(e)), + }, + }; + function lightEnforceCompAccent(ps: T.PsString): T.PsString { + return countSyllables(ps) === 1 + ? accentPsSyllable(ps) + : ps; + } +} export function vEntry(e: any, c?: any): T.VerbEntryNoFVars { return { @@ -114,7 +155,7 @@ export function removeL(ps: T.PsString): T.PsString { return trimOffPs(ps, 1, 2); } -export function tlulPerfectiveStem(person: { gender: T.Gender, number: T.NounNumber }): T.RootsStemsOutput { +export function tlulPerfectiveStem(person: { gender: T.Gender, number: T.NounNumber }): [[T.PH], [T.VB]] { return [ [ { @@ -161,6 +202,37 @@ export function addToVBBasicEnd(vb: T.VBBasic, end: T.PsString[]): T.VBBasic { }; } +export function possiblePPartLengths(vba: T.VBNoLenghts): T.VBBasic; +export function possiblePPartLengths(vba: T.VBNoLenghts): T.VBA; +export function possiblePPartLengths(vba: T.VBNoLenghts): T.VBA { + const shortenableEndings = ["ښتل", "ستل", "وتل"]; + const wrul = ["وړل", "راوړل", "وروړل", "دروړل"]; + if ("right" in vba) { + return { + ...vba, + right: possiblePPartLengths(vba.right), + }; + } + const infinitive = vba.ps[0]; + const [trimP, trimF] = (infinitive.p.slice(-4) === "ښودل" && infinitive.p.length > 4 && infinitive.p !== "کېښودل" && infinitive.p !== "کښېښودل") + // special thing for اېښودل - پرېښودل + ? [3, 4] + : (wrul.includes(infinitive.p) || (shortenableEndings.includes(infinitive.p.slice(-3)) && infinitive.p.slice(-4) !== "استل")) + ? [1, 2] + : [0, 0]; + if (trimP) { + return { + type: "VB", + ps: { + long: [infinitive], + short: [accentOnNFromEnd(trimOffPs(infinitive, trimP, trimF), 0)], + }, + }; + } + return vba; +} + + export function getLongVB(vb: T.VBBasic): T.VBNoLenghts; export function getLongVB(vb: T.VBA): T.VBNoLenghts; export function getLongVB(vb: T.VBA): T.VBNoLenghts { @@ -174,4 +246,33 @@ export function getLongVB(vb: T.VBA): T.VBNoLenghts { ...vb, ps: getLength(vb.ps, "long"), }; +} + +export function getAspect(tense: T.VerbTense | T.AbilityTense): T.Aspect { + const t = tense.replace("Modal", ""); + if (["presentVerb", "imperfectiveFuture", "imperfectivePast", "habitualImperfectivePast"].includes(t)) { + return "imperfective"; + } else { + return "perfective"; + } +} + +export function isKedul(v: T.VerbEntry): boolean { + return v.entry.p === "کېدل"; +} + +export function perfectTenseToEquative(t: T.PerfectTense): keyof typeof equativeEndings { + return t === "presentPerfect" + ? "present" + : t === "futurePerfect" + ? "habitual" + : t === "habitualPerfect" + ? "habitual" + : t === "pastPerfect" + ? "past" + : t === "pastSubjunctivePerfect" + ? "pastSubjunctive" + : t === "wouldBePerfect" + ? "past" + : "subjunctive" } \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 09729a3..20f6255 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1136,9 +1136,6 @@ export type Comp = { gender: Gender, number: NounNumber, } | { - type: "LocAdvComp", - ps: PsString, -} | { - type: "NounComp", + type: "Comp", ps: PsString, };