more perfect vars

This commit is contained in:
lingdocs 2022-03-30 23:36:15 +05:00
parent eef285aead
commit d94b1d3d71
3 changed files with 86 additions and 56 deletions

View File

@ -269,18 +269,26 @@ function makeVerbSelection(verb: VerbEntry, oldVerbSelection?: VerbSelection): V
: "dynamic" in info : "dynamic" in info
? { entry: info.dynamic.auxVerb } as VerbEntry ? { entry: info.dynamic.auxVerb } as VerbEntry
: undefined; : undefined;
const tenseSelection = ((): { tenseCategory: "perfect", tense: PerfectTense } | {
tenseCategory: "basic" | "modal",
tense: VerbTense,
} => {
if (!oldVerbSelection) {
return { tense: "presentVerb", tenseCategory: "basic" };
}
if (oldVerbSelection.tenseCategory === "modal") {
return { tenseCategory: "modal", tense: isPerfectTense(oldVerbSelection.tense) ? "presentVerb" : oldVerbSelection.tense };
}
if (oldVerbSelection.tenseCategory === "basic") {
return { tenseCategory: "basic", tense: isPerfectTense(oldVerbSelection.tense) ? "presentVerb" : oldVerbSelection.tense };
}
return { tenseCategory: "perfect", tense: isPerfectTense(oldVerbSelection.tense) ? oldVerbSelection.tense : "present perfect" };
})();
return { return {
type: "verb", type: "verb",
verb: verb, verb: verb,
dynAuxVerb, dynAuxVerb,
...oldVerbSelection ? { ...tenseSelection,
// TODO: carry it over from the old selection!!
tense: "presentVerb",
tenseCategory: "basic",
} : {
tense: "presentVerb",
tenseCategory: "basic",
},
object, object,
transitivity, transitivity,
isCompound, isCompound,

View File

@ -8,6 +8,12 @@ import {
} from "@lingdocs/pashto-inflector"; } from "@lingdocs/pashto-inflector";
import { removeBa } from "./vp-tools"; import { removeBa } from "./vp-tools";
// also
// nú dey me leeduley
// نه مې دی لیدلی - nú me dey leeduley
// لیدلی مې نه دی - leeduley me nú dey
//
// TODO: make it an option to include O S V order ? // TODO: make it an option to include O S V order ?
// TODO: tu ba laaR nu she hyphens all messed up // TODO: tu ba laaR nu she hyphens all messed up
type Form = FormVersion & { OSV?: boolean }; type Form = FormVersion & { OSV?: boolean };
@ -161,6 +167,14 @@ function arrangeVerbWNegative(head: T.PsString | undefined, restRaw: T.PsString[
if (!headSegment) { if (!headSegment) {
if ("front" in rest) { if ("front" in rest) {
return [ return [
// pefect nu dey me leeduley and nu me dey leeduley
[
mergeSegments(
makeSegment(nu, ["isNu"]),
rest.last.adjust({ ps: removeAccents }),
),
rest.front.adjust({ ps: removeAccents }),
],
[ [
makeSegment(nu, ["isNu"]), makeSegment(nu, ["isNu"]),
rest.last.adjust({ ps: removeAccents }), rest.last.adjust({ ps: removeAccents }),
@ -233,6 +247,10 @@ function shrinkNP(np: Rendered<NPSelection>): Segment {
return makeSegment(grammarUnits.pronouns.mini[row][col], ["isKid", "isMiniPronoun"]); return makeSegment(grammarUnits.pronouns.mini[row][col], ["isKid", "isMiniPronoun"]);
} }
function mergeSegments(s1: Segment, s2: Segment): Segment {
return s2.adjust({ ps: (p) => concatPsString(s1.ps[0], " ", p) });
}
function addSpacesBetweenSegments(segments: Segment[]): (Segment | " " | "" | T.PsString)[] { function addSpacesBetweenSegments(segments: Segment[]): (Segment | " " | "" | T.PsString)[] {
const o: (Segment | " " | "" | T.PsString)[] = []; const o: (Segment | " " | "" | T.PsString)[] = [];
for (let i = 0; i < segments.length; i++) { for (let i = 0; i < segments.length; i++) {

View File

@ -152,7 +152,7 @@ function getPsVerbConjugation(conj: T.VerbConjugation, vs: VerbSelection, person
}, },
hasBa: boolean, hasBa: boolean,
} { } {
const f = getTenseVerbForm(conj, vs.tense); const f = getTenseVerbForm(conj, vs.tense, vs.tenseCategory);
const block = getMatrixBlock(f, objectPerson, person); const block = getMatrixBlock(f, objectPerson, person);
const perfective = isPerfective(vs.tense); const perfective = isPerfective(vs.tense);
const verbForm = getVerbFromBlock(block, person); const verbForm = getVerbFromBlock(block, person);
@ -254,30 +254,58 @@ function getMatrixBlock<U>(f: {
return f[personToLabel(person)]; return f[personToLabel(person)];
} }
function getTenseVerbForm(conj: T.VerbConjugation, tense: VerbTense | PerfectTense): T.VerbForm { function getTenseVerbForm(conj: T.VerbConjugation, tense: VerbTense | PerfectTense, tenseCategory: "basic" | "modal" | "perfect"): T.VerbForm {
if (tense === "presentVerb") { if (tenseCategory === "basic") {
return conj.imperfective.nonImperative; if (tense === "presentVerb") {
return conj.imperfective.nonImperative;
}
if (tense === "subjunctiveVerb") {
return conj.perfective.nonImperative;
}
if (tense === "imperfectiveFuture") {
return conj.imperfective.future;
}
if (tense === "perfectiveFuture") {
return conj.perfective.future;
}
if (tense === "imperfectivePast") {
return conj.imperfective.past;
}
if (tense === "perfectivePast") {
return conj.perfective.past;
}
if (tense === "habitualImperfectivePast") {
return conj.imperfective.habitualPast;
}
if (tense === "habitualPerfectivePast") {
return conj.perfective.habitualPast;
}
} }
if (tense === "subjunctiveVerb") { if (tenseCategory === "modal") {
return conj.perfective.nonImperative; if (tense === "presentVerb") {
} return conj.imperfective.modal.nonImperative;
if (tense === "imperfectiveFuture") { }
return conj.imperfective.future; if (tense === "subjunctiveVerb") {
} return conj.perfective.modal.nonImperative;
if (tense === "perfectiveFuture") { }
return conj.perfective.future; if (tense === "imperfectiveFuture") {
} return conj.imperfective.modal.future;
if (tense === "imperfectivePast") { }
return conj.imperfective.past; if (tense === "perfectiveFuture") {
} return conj.perfective.modal.future;
if (tense === "perfectivePast") { }
return conj.perfective.past; if (tense === "imperfectivePast") {
} return conj.imperfective.modal.past;
if (tense === "habitualImperfectivePast") { }
return conj.imperfective.habitualPast; if (tense === "perfectivePast") {
} return conj.perfective.modal.past;
if (tense === "habitualPerfectivePast") { }
return conj.perfective.habitualPast; if (tense === "habitualImperfectivePast") {
return conj.imperfective.modal.habitualPast;
}
if (tense === "habitualPerfectivePast") {
return conj.perfective.modal.habitualPast;
}
} }
if (tense === "present perfect") { if (tense === "present perfect") {
return conj.perfect.present; return conj.perfect.present;
@ -300,30 +328,6 @@ function getTenseVerbForm(conj: T.VerbConjugation, tense: VerbTense | PerfectTen
if (tense === "pastSubjunctive perfect") { if (tense === "pastSubjunctive perfect") {
return conj.perfect.pastSubjunctiveHypothetical; return conj.perfect.pastSubjunctiveHypothetical;
} }
if (tense === "presentVerb") {
return conj.imperfective.modal.nonImperative;
}
if (tense === "subjunctiveVerb") {
return conj.perfective.modal.nonImperative;
}
if (tense === "imperfectiveFuture") {
return conj.imperfective.modal.future;
}
if (tense === "perfectiveFuture") {
return conj.perfective.modal.future;
}
if (tense === "imperfectivePast") {
return conj.imperfective.modal.past;
}
if (tense === "perfectivePast") {
return conj.perfective.modal.past;
}
if (tense === "habitualImperfectivePast") {
return conj.imperfective.modal.habitualPast;
}
if (tense === "habitualPerfectivePast") {
return conj.perfective.modal.habitualPast;
}
throw new Error("unknown tense"); throw new Error("unknown tense");
} }