working with basic verbs with participles - testing totally broken and needs to be redone

This commit is contained in:
adueck 2023-04-11 13:53:10 +04:00
parent ed4e494e54
commit 76f9158e2a
5 changed files with 73 additions and 49 deletions

View File

@ -35,45 +35,45 @@ const labels = (role: "subject" | "object" | "ergative" | "possesor") => ({
far: [ far: [
["زه", "مونږ"], ["زه", "مونږ"],
["ته", "تاسو"], ["ته", "تاسو"],
["هغه", "هغوي"], ["هغه", "هغوی"],
], ],
near: [ near: [
["زه", "مونږ"], ["زه", "مونږ"],
["ته", "تاسو"], ["ته", "تاسو"],
[{ masc: "دی", fem: "دا" }, "دوي"], [{ masc: "دی", fem: "دا" }, "دوی"],
], ],
} : role === "object" ? { } : role === "object" ? {
far: [ far: [
["زه", "مونږ"], ["زه", "مونږ"],
["ته", "تاسو"], ["ته", "تاسو"],
[{ masc: "هغهٔ", fem: "هغې" }, "هغوي"], [{ masc: "هغهٔ", fem: "هغې" }, "هغوی"],
], ],
near: [ near: [
["زه", "مونږ"], ["زه", "مونږ"],
["ته", "تاسو"], ["ته", "تاسو"],
[{ masc: "دهٔ", fem: "دې" }, "دوي"], [{ masc: "دهٔ", fem: "دې" }, "دوی"],
], ],
} : role === "possesor" ? { } : role === "possesor" ? {
far: [ far: [
["زما", "زمونږ"], ["زما", "زمونږ"],
["ستا", "ستاسو"], ["ستا", "ستاسو"],
[{ masc: "د هغهٔ", fem: "د هغې" }, "د هغوي"], [{ masc: "د هغهٔ", fem: "د هغې" }, "د هغوی"],
], ],
near: [ near: [
["زما", "زمونږ"], ["زما", "زمونږ"],
["ستا", "ستاسو"], ["ستا", "ستاسو"],
[{ masc: "د دهٔ", fem: "د دې" }, "د دوي"], [{ masc: "د دهٔ", fem: "د دې" }, "د دوی"],
], ],
} : { } : {
far: [ far: [
["ما", "مونږ"], ["ما", "مونږ"],
["تا", "تاسو"], ["تا", "تاسو"],
[{ masc: "هغهٔ", fem: "هغې" }, "هغوي"], [{ masc: "هغهٔ", fem: "هغې" }, "هغوی"],
], ],
near: [ near: [
["ما", "مونږ"], ["ما", "مونږ"],
["تا", "تاسو"], ["تا", "تاسو"],
[{ masc: "دهٔ", fem: "دې" }, "دوي"], [{ masc: "دهٔ", fem: "دې" }, "دوی"],
], ],
}, },
}); });

View File

@ -95,7 +95,8 @@ function renderPerfectVerb({ tense, verb, voice, person }: {
verb: T.VerbEntry, verb: T.VerbEntry,
voice: T.Voice, voice: T.Voice,
person: T.Person, person: T.Person,
}): { hasBa: boolean, vbs: [[], [T.VBGenNum, T.VBE]] } { // TODO: Tighter typing on the output for T.VB (enforce genderNumber?)
}): { hasBa: boolean, vbs: [[], [T.VB, T.VBE]] } {
const hasBa = tenseHasBa(tense); const hasBa = tenseHasBa(tense);
const genderNumber = { const genderNumber = {
gender: personGender(person), gender: personGender(person),

View File

@ -30,8 +30,8 @@ const shVB: T.VBBasic = {
ps: [{ p: "ش", f: "sh" }], ps: [{ p: "ش", f: "sh" }],
} }
// TODO: kuRee shuwey etc // TODO: kuRee shuwey etc
export function getPastParticiple(verb: T.VerbEntry, voice: T.Voice, { gender, number }: { gender: T.Gender, number: T.NounNumber }): T.VBGenNum { 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); const v = removeFVarientsFromVerb(verb);
if (voice === "passive") { if (voice === "passive") {
return getPassivePp(v, { gender, number }); return getPassivePp(v, { gender, number });
@ -47,21 +47,22 @@ export function getPastParticiple(verb: T.VerbEntry, voice: T.Voice, { gender, n
} }
const [_, [basicRoot]] = getImperfectiveRoot(removeFVarientsFromVerb(verb)); const [_, [basicRoot]] = getImperfectiveRoot(removeFVarientsFromVerb(verb));
const longRoot = getLongVB(basicRoot); const longRoot = getLongVB(basicRoot);
const rootWLengths = possiblePPartLengths(longRoot);
if ("right" in longRoot) { if ("right" in rootWLengths) {
return { return {
...longRoot, ...rootWLengths,
right: { right: {
...longRoot.right, ...rootWLengths.right,
ps: addTail(longRoot.right.ps), ps: addTail(rootWLengths.right.ps),
gender,
number,
}, },
gender,
number,
}; };
} else { } else {
return { return {
...longRoot, ...rootWLengths,
ps: addTail(longRoot.ps), ps: addTail(rootWLengths.ps),
gender, gender,
number, number,
}; };
@ -79,6 +80,36 @@ export function getPastParticiple(verb: T.VerbEntry, voice: T.Voice, { gender, n
} }
} }
function possiblePPartLengths(vba: T.VBNoLenghts<T.VBBasic>): T.VBBasic;
function possiblePPartLengths(vba: T.VBNoLenghts<T.VBA>): T.VBA;
function possiblePPartLengths(vba: T.VBNoLenghts<T.VBA>): 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 }: { export function getRootStem({ verb, rs, aspect, type, genderNumber, voice }: {
verb: T.VerbEntry, verb: T.VerbEntry,
rs: "root" | "stem", rs: "root" | "stem",
@ -128,17 +159,14 @@ function getAbilityRs(
]; ];
} }
function getPassivePp(verb: T.VerbEntryNoFVars, genderNumber: T.GenderNumber): T.VBGenNum { function getPassivePp(verb: T.VerbEntryNoFVars, genderNumber: T.GenderNumber): T.WeldedGN {
const [_, [basicRoot]] = getImperfectiveRoot(verb); const [_, [basicRoot]] = getImperfectiveRoot(verb);
const longRoot = getLongVB(basicRoot); const longRoot = getLongVB(basicRoot);
const kedulVbGenNum = getPastParticiple(kedulStat, "active", genderNumber) as T.VBBasic & T.GenderNumber; const kedulVb: T.VBGenNum = getPastParticiple(kedulStat, "active", genderNumber) as T.VBGenNum;
const kedulVb: T.VBBasic = { return weld(longRoot, kedulVb);
type: "VB", }
ps: kedulVbGenNum.ps,
};
return weld(longRoot, kedulVb, genderNumber);
}
// 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"): [[] | [T.VHead], [T.VBA]] {
const [vHead, [basicRoot]] = (aspect === "imperfective" const [vHead, [basicRoot]] = (aspect === "imperfective"
? getImperfectiveRoot ? getImperfectiveRoot

View File

@ -67,26 +67,19 @@ export function verbEndingConcat(ps: T.PsString[], end: T.PsString[]): T.PsStrin
)); ));
} }
// TODO: better to have the genderNumber included and inferred in the right? export function weld(left: T.Welded["left"], right: T.VBGenNum): T.WeldedGN;
export function weld(left: T.Welded["left"], right: T.Welded["right"]): T.Welded; export function weld(left: T.Welded["left"], right: T.VBBasic): T.Welded;
export function weld(left: T.Welded["left"], right: T.Welded["right"], genderNum: T.GenderNumber): T.Welded & T.GenderNumber; export function weld(left: T.Welded["left"], right: T.VBBasic | T.VBGenNum): T.Welded | T.WeldedGN {
export function weld(left: T.Welded["left"], right: T.Welded["right"], genderNum?: T.GenderNumber): T.Welded {
return { return {
type: "welded", type: "welded",
left: removeAccentsFromLeft(left), left: removeAccentsFromLeft(left),
right, right,
...genderNum ? { };
...genderNum,
} : {},
}
function removeAccentsFromLeft(left: T.Welded["left"]): T.Welded["left"] { function removeAccentsFromLeft(left: T.Welded["left"]): T.Welded["left"] {
if (left.type === "VB") { if (left.type === "VB") {
return { return {
...left, ...left,
ps: removeAccentsWLength(left.ps), ps: removeAccentsWLength(left.ps),
...genderNum ? {
...genderNum,
} : {},
} }
} }
if (left.type === "NComp") { if (left.type === "NComp") {
@ -96,9 +89,6 @@ export function weld(left: T.Welded["left"], right: T.Welded["right"], genderNum
...left.comp, ...left.comp,
ps: removeAccents(left.comp.ps), ps: removeAccents(left.comp.ps),
}, },
...genderNum ? {
...genderNum,
} : {},
}; };
} }
return { return {
@ -107,9 +97,6 @@ export function weld(left: T.Welded["left"], right: T.Welded["right"], genderNum
...left.right, ...left.right,
ps: removeAccentsWLength(left.right.ps), ps: removeAccentsWLength(left.right.ps),
}, },
...genderNum ? {
...genderNum,
} : {},
}; };
} }
} }
@ -174,11 +161,13 @@ export function addToVBBasicEnd(vb: T.VBBasic, end: T.PsString[]): T.VBBasic {
}; };
} }
export function getLongVB(vb: T.VBA): T.VBA { export function getLongVB(vb: T.VBBasic): T.VBNoLenghts<T.VBBasic>;
export function getLongVB(vb: T.VBA): T.VBNoLenghts<T.VBA>;
export function getLongVB(vb: T.VBA): T.VBNoLenghts<T.VBA> {
if (vb.type === "welded") { if (vb.type === "welded") {
return { return {
...vb, ...vb,
right: getLongVB(vb) as T.VBBasic, right: getLongVB(vb.right),
}; };
} }
return { return {

View File

@ -1077,14 +1077,18 @@ export type MiniPronoun = {
export type VerbRenderedOutput = [[VHead] | [], [VB, VBE] | [VBE]]; export type VerbRenderedOutput = [[VHead] | [], [VB, VBE] | [VBE]];
export type RootsStemsOutput = [[VHead] | [], [VB, VBA] | [VBA]]; // or perfect / equative export type RootsStemsOutput = [[VHead] | [], [VB, VBA] | [VBA]]; // or perfect / equative
export type VB = VBBasic | VBGenNum | Welded; export type VB = VBBasic | VBGenNum | Welded | WeldedGN;
/** A VB block that can have endings attached to it */ /** A VB block that can have endings attached to it */
export type VBA = Exclude<VB, VBGenNum>; export type VBA = Exclude<VB, VBGenNum | WeldedGN>;
/** A VB block that has had a person verb ending attached */ /** A VB block that has had a person verb ending attached */
export type VBE = (VBBasic | Welded) & { export type VBE = (VBBasic | Welded) & {
person: Person, person: Person,
}; // or equative }; // or equative
export type VBNoLenghts<V extends VB> = V extends VBBasic
? Omit<VBBasic, "ps"> & { ps: PsString[] }
: Omit<Welded, "right"> & { right: VBNoLenghts<Exclude<VB, Welded>> };
export type VBBasic = { export type VBBasic = {
type: "VB", type: "VB",
ps: SingleOrLengthOpts<PsString[]>, ps: SingleOrLengthOpts<PsString[]>,
@ -1092,7 +1096,7 @@ export type VBBasic = {
// TODO: might be a better design decision to keep the GenderNuber stuff // TODO: might be a better design decision to keep the GenderNuber stuff
// in the RIGHT side of the weld // in the RIGHT side of the weld
export type VBGenNum = (VBBasic | Welded) & GenderNumber; export type VBGenNum = VBBasic & GenderNumber;
export type GenderNumber = { export type GenderNumber = {
gender: Gender, gender: Gender,
@ -1105,6 +1109,8 @@ export type Welded = {
right: VBBasic, right: VBBasic,
}; };
export type WeldedGN = Omit<Welded, "right"> & { right: VBGenNum };
export type VHead = PH | NComp; export type VHead = PH | NComp;
/** perfective head block */ /** perfective head block */