This commit is contained in:
adueck 2023-04-18 12:50:52 -04:00
parent 623db598bb
commit 878b39b654
4 changed files with 168 additions and 1797 deletions

File diff suppressed because it is too large Load Diff

View File

@ -630,6 +630,152 @@ test("special endings", () => {
}); });
}); });
test("imperative tenses", () => {
expect(renderVerb({
verb: wahul,
tense: "imperfectiveImperative",
person: T.Person.SecondSingMale,
voice: "active",
})).toEqual({
hasBa: false,
vbs: [
[],
[
{ type: "VB", ps: [{ p: "وهه", f: "wahá" } ], person: 2},
],
],
});
expect(renderVerb({
verb: wahul,
tense: "perfectiveImperative",
person: T.Person.SecondSingFemale,
voice: "active",
})).toEqual({
hasBa: false,
vbs: [
[ooPh],
[
{ type: "VB", ps: [{ p: "وهه", f: "waha" }], person: 3 },
],
],
});
expect(renderVerb({
verb: wahul,
tense: "imperfectiveImperative",
person: T.Person.SecondPlurMale,
voice: "active",
})).toEqual({
hasBa: false,
vbs: [
[],
[
{ type: "VB", ps: [{ p: "وهئ", f: "wahéyy" } ], person: 8 },
],
],
});
expect(renderVerb({
verb: wahul,
tense: "perfectiveImperative",
person: T.Person.SecondPlurFemale,
voice: "active",
})).toEqual({
hasBa: false,
vbs: [
[ooPh],
[
{ type: "VB", ps: [{ p: "وهئ", f: "waheyy" }], person: 9 },
],
],
});
});
test("ability tenses", () => {
expect(renderVerb({
verb: wahul,
tense: "presentVerbModal",
person: T.Person.FirstSingMale,
voice: "active",
})).toEqual({
hasBa: false,
vbs: [
[],
[
{
type: "VB",
ps: {
long: [
{ p: "وهلی", f: "wahúley" },
{ p: "وهلای", f: "wahúlaay" },
],
short: [
{ p: "وهی", f: "wahéy" },
{ p: "وهای", f: "waháay" },
],
},
},
{
type: "VB",
ps: [{ p: "شم", f: "shum" }],
person: T.Person.FirstSingMale,
},
],
],
});
});
test("basic tenses", () => {
expect(renderVerb({
verb: wahul,
tense: "presentVerb",
person: T.Person.FirstSingMale,
voice: "active",
})).toEqual({
hasBa: false,
vbs: [
[],
[
{ type: "VB", ps: [{ p: "وهم", f: "wahum" }], person: T.Person.FirstSingMale },
],
],
});
expect(renderVerb({
verb: wahul,
tense: "subjunctiveVerb",
person: T.Person.SecondSingMale,
voice: "active",
})).toEqual({
hasBa: false,
vbs: [
[{ type: "PH", ps: { f: "óo", p: "و" }}],
[
{ type: "VB", ps: [{ p: "وهې", f: "wahe" }], person: T.Person.SecondSingMale },
],
],
});
expect(renderVerb({
verb: wahul,
tense: "habitualPerfectivePast",
person: T.Person.ThirdSingFemale,
voice: "active",
})).toEqual({
hasBa: true,
vbs: [
[{ type: "PH", ps: { f: "óo", p: "و" }}],
[
{
type: "VB",
ps: {
long: [{ p: "وهله", f: "wahula" }],
short: [{ p: "وهه", f: "waha" }],
},
person: T.Person.ThirdSingFemale
},
],
],
});
});
test("perfect tenses", () => { test("perfect tenses", () => {
expect(renderVerb({ expect(renderVerb({
verb: wahul, verb: wahul,
@ -790,40 +936,6 @@ test("perfect tenses", () => {
}); });
}); });
test("ability tenses", () => {
expect(renderVerb({
verb: wahul,
tense: "presentVerbModal",
person: T.Person.FirstSingMale,
voice: "active",
})).toEqual({
hasBa: false,
vbs: [
[],
[
{
type: "VB",
ps: {
long: [
{ p: "وهلی", f: "wahúley" },
{ p: "وهلای", f: "wahúlaay" },
],
short: [
{ p: "وهی", f: "wahéy" },
{ p: "وهای", f: "waháay" },
],
},
},
{
type: "VB",
ps: [{ p: "شم", f: "shum" }],
person: T.Person.FirstSingMale,
},
],
],
});
});
test("ending on complex verbs", () => { test("ending on complex verbs", () => {
expect(renderVerb({ expect(renderVerb({
verb: stureyKawul, verb: stureyKawul,

View File

@ -1,6 +1,7 @@
import * as T from "../../../types"; import * as T from "../../../types";
import { import {
getVerbBlockPosFromPerson, getVerbBlockPosFromPerson,
isSecondPerson,
personGender, personGender,
personNumber, personNumber,
} from "../misc-helpers"; } from "../misc-helpers";
@ -12,21 +13,20 @@ import {
presentEndings, presentEndings,
pastEndings, pastEndings,
equativeEndings, equativeEndings,
imperativeEndings,
} from "../grammar-units"; } from "../grammar-units";
import { isKawulVerb, isAbilityTense, isPerfectTense, isTlulVerb } from "../type-predicates"; import { isKawulVerb, isAbilityTense, isPerfectTense, isTlulVerb, isImperativeTense } from "../type-predicates";
import { tenseHasBa } from "../phrase-building/vp-tools"; import { tenseHasBa } from "../phrase-building/vp-tools";
import { isPastTense } from "../phrase-building/vp-tools"; import { isPastTense } from "../phrase-building/vp-tools";
import { makePsString, removeFVarients } from "../accent-and-ps-utils"; import { makePsString, removeFVarients } from "../accent-and-ps-utils";
import { getPastParticiple, getRootStem } from "./roots-and-stems"; import { getPastParticiple, getRootStem } from "./roots-and-stems";
import { getAspect, isKedul, perfectTenseToEquative, verbEndingConcat } from "./rs-helpers"; import { getAspect, isKedul, perfectTenseToEquative, verbEndingConcat } from "./rs-helpers";
import { accentOnNFromEnd, removeAccents } from "../accent-helpers"; import { accentOnNFromEnd, accentPsSyllable, removeAccents } from "../accent-helpers";
// TODO: problem with laaR - no perfective split
// TODO: non past compounds with different object
// TODO: coverage of rs-helpers
// TODO: problem with laaR - no perfective split
export function renderVerb({ verb, tense, person, voice, presObj }: { export function renderVerb({ verb, tense, person, voice, presObj }: {
verb: T.VerbEntry, verb: T.VerbEntry,
tense: T.VerbTense | T.PerfectTense | T.AbilityTense, // TODO: make T.Tense tense: T.VerbTense | T.PerfectTense | T.AbilityTense | T.ImperativeTense, // TODO: make T.Tense
person: T.Person, person: T.Person,
voice: T.Voice, voice: T.Voice,
presObj?: T.Person, presObj?: T.Person,
@ -46,6 +46,7 @@ export function renderVerb({ verb, tense, person, voice, presObj }: {
number: personNumber(rootPerson), number: personNumber(rootPerson),
}; };
const aspect = getAspect(tense); const aspect = getAspect(tense);
const isImperative = isImperativeTense(tense);
const type = isAbilityTense(tense) ? "ability" : "basic"; const type = isAbilityTense(tense) ? "ability" : "basic";
// #1 get the appropriate root / stem // #1 get the appropriate root / stem
@ -58,7 +59,7 @@ export function renderVerb({ verb, tense, person, voice, presObj }: {
genderNumber, genderNumber,
}); });
// #2 add the verb ending to it // #2 add the verb ending to it
const ending = getEnding(person, isPast); const ending = getEnding(person, isPast, isImperative, aspect);
return { return {
hasBa, hasBa,
vbs: [ vbs: [
@ -167,7 +168,17 @@ function addEnding({ verb, rs, ending, person, pastThird, aspect, basicForm }: {
} }
} }
function getEnding(person: T.Person, isPast: boolean) { function getEnding(person: T.Person, isPast: boolean, isImperative: boolean, aspect: T.Aspect) {
if (isImperative) {
if (!isSecondPerson(person)) {
throw new Error("imperative forms must be second person");
}
const number = personNumber(person);
const ends = imperativeEndings[0][number === "singular" ? 0 : 1];
return aspect === "imperfective"
? ends.map(e => accentPsSyllable(e))
: ends;
}
const [row, col] = getVerbBlockPosFromPerson(person); const [row, col] = getVerbBlockPosFromPerson(person);
return isPast ? { return isPast ? {
long: pastEndings.long[row][col], long: pastEndings.long[row][col],

View File

@ -273,9 +273,10 @@ export function getLongVB(vb: T.VBA): T.VBNoLenghts<T.VBA> {
}; };
} }
export function getAspect(tense: T.VerbTense | T.AbilityTense): T.Aspect { export function getAspect(tense: T.VerbTense | T.AbilityTense | T.ImperativeTense): T.Aspect {
const t = tense.replace("Modal", ""); const t = tense.replace("Modal", "");
if (["presentVerb", "imperfectiveFuture", "imperfectivePast", "habitualImperfectivePast"].includes(t)) { const imperfectives: Parameters<typeof getAspect>[0][] = ["presentVerb", "imperfectiveFuture", "imperfectivePast", "habitualImperfectivePast", "imperfectiveImperative"];
if (imperfectives.includes(t as Parameters<typeof getAspect>[0])) {
return "imperfective"; return "imperfective";
} else { } else {
return "perfective"; return "perfective";