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: [
["زه", "مونږ"],
["ته", "تاسو"],
["هغه", "هغوي"],
["هغه", "هغوی"],
],
near: [
["زه", "مونږ"],
["ته", "تاسو"],
[{ masc: "دی", fem: "دا" }, "دوي"],
[{ masc: "دی", fem: "دا" }, "دوی"],
],
} : role === "object" ? {
far: [
["زه", "مونږ"],
["ته", "تاسو"],
[{ masc: "هغهٔ", fem: "هغې" }, "هغوي"],
[{ masc: "هغهٔ", fem: "هغې" }, "هغوی"],
],
near: [
["زه", "مونږ"],
["ته", "تاسو"],
[{ masc: "دهٔ", fem: "دې" }, "دوي"],
[{ masc: "دهٔ", fem: "دې" }, "دوی"],
],
} : role === "possesor" ? {
far: [
["زما", "زمونږ"],
["ستا", "ستاسو"],
[{ masc: "د هغهٔ", fem: "د هغې" }, "د هغوي"],
[{ masc: "د هغهٔ", fem: "د هغې" }, "د هغوی"],
],
near: [
["زما", "زمونږ"],
["ستا", "ستاسو"],
[{ masc: "د دهٔ", fem: "د دې" }, "د دوي"],
[{ masc: "د دهٔ", fem: "د دې" }, "د دوی"],
],
} : {
far: [
["ما", "مونږ"],
["تا", "تاسو"],
[{ masc: "هغهٔ", fem: "هغې" }, "هغوي"],
[{ masc: "هغهٔ", fem: "هغې" }, "هغوی"],
],
near: [
["ما", "مونږ"],
["تا", "تاسو"],
[{ masc: "دهٔ", fem: "دې" }, "دوي"],
[{ masc: "دهٔ", fem: "دې" }, "دوی"],
],
},
});

View File

@ -95,7 +95,8 @@ function renderPerfectVerb({ tense, verb, voice, person }: {
verb: T.VerbEntry,
voice: T.Voice,
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 genderNumber = {
gender: personGender(person),

View File

@ -30,8 +30,8 @@ const shVB: T.VBBasic = {
ps: [{ p: "ش", f: "sh" }],
}
// TODO: kuRee shuwey etc
export function getPastParticiple(verb: T.VerbEntry, voice: T.Voice, { gender, number }: { gender: T.Gender, number: T.NounNumber }): T.VBGenNum {
// 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);
if (voice === "passive") {
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 longRoot = getLongVB(basicRoot);
const rootWLengths = possiblePPartLengths(longRoot);
if ("right" in longRoot) {
if ("right" in rootWLengths) {
return {
...longRoot,
...rootWLengths,
right: {
...longRoot.right,
ps: addTail(longRoot.right.ps),
...rootWLengths.right,
ps: addTail(rootWLengths.right.ps),
gender,
number,
},
gender,
number,
};
} else {
return {
...longRoot,
ps: addTail(longRoot.ps),
...rootWLengths,
ps: addTail(rootWLengths.ps),
gender,
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 }: {
verb: T.VerbEntry,
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 longRoot = getLongVB(basicRoot);
const kedulVbGenNum = getPastParticiple(kedulStat, "active", genderNumber) as T.VBBasic & T.GenderNumber;
const kedulVb: T.VBBasic = {
type: "VB",
ps: kedulVbGenNum.ps,
};
return weld(longRoot, kedulVb, genderNumber);
}
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]] {
const [vHead, [basicRoot]] = (aspect === "imperfective"
? 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.Welded["right"]): 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.Welded["right"], genderNum?: T.GenderNumber): T.Welded {
export function weld(left: T.Welded["left"], right: T.VBGenNum): T.WeldedGN;
export function weld(left: T.Welded["left"], right: T.VBBasic): T.Welded;
export function weld(left: T.Welded["left"], right: T.VBBasic | T.VBGenNum): T.Welded | T.WeldedGN {
return {
type: "welded",
left: removeAccentsFromLeft(left),
right,
...genderNum ? {
...genderNum,
} : {},
}
};
function removeAccentsFromLeft(left: T.Welded["left"]): T.Welded["left"] {
if (left.type === "VB") {
return {
...left,
ps: removeAccentsWLength(left.ps),
...genderNum ? {
...genderNum,
} : {},
}
}
if (left.type === "NComp") {
@ -96,9 +89,6 @@ export function weld(left: T.Welded["left"], right: T.Welded["right"], genderNum
...left.comp,
ps: removeAccents(left.comp.ps),
},
...genderNum ? {
...genderNum,
} : {},
};
}
return {
@ -107,9 +97,6 @@ export function weld(left: T.Welded["left"], right: T.Welded["right"], genderNum
...left.right,
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") {
return {
...vb,
right: getLongVB(vb) as T.VBBasic,
right: getLongVB(vb.right),
};
}
return {

View File

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