more on new verb engine

This commit is contained in:
adueck 2023-04-03 12:04:34 +04:00
parent 1658f021a0
commit 93776bb98d
2 changed files with 84 additions and 21 deletions

View File

@ -1,7 +1,7 @@
import * as T from "../../../types";
import { getRootStem } from "./roots-and-stems";
import { vEntry } from "./render-verb.test";
import { ooPrefix } from "./roots-and-stems";
import { ooPrefix } from "../grammar-units";
const wahul = vEntry({"ts":1527815399,"i":15049,"p":"وهل","f":"wahul","g":"wahul","e":"to hit","r":4,"c":"v. trans.","tppp":"واهه","tppf":"waahu","ec":"hit,hits,hitting,hit,hit"});
const achawul = vEntry({"ts":1527811872,"i":224,"p":"اچول","f":"achawul","g":"achawul","e":"to put, pour, drop, throw, put on","r":4,"c":"v. trans.","ec":"put,puts,putting,put,put"});
@ -34,6 +34,11 @@ function getAllRs(verb: T.VerbEntry): (typeof regularVerbs)[0]["result"] {
};
}
const ooPh: T.PH = {
type: "PH",
ps: { p: "و", f: "óo" },
};
const regularVerbs: {
verb: T.VerbEntry,
result: Record<"stem" | "root", {
@ -46,7 +51,7 @@ const regularVerbs: {
result: {
stem: {
perfective: [
ooPrefix,
ooPh,
[{ p: "وېش", f: "wesh" }],
],
imperfective: [
@ -55,7 +60,7 @@ const regularVerbs: {
},
root: {
perfective: [
ooPrefix,
ooPh,
{
long: [{ p: "وېشل", f: "weshul" }],
short: [{ p: "وېش", f: "wesh" }],
@ -75,7 +80,7 @@ const regularVerbs: {
result: {
stem: {
perfective: [
ooPrefix,
ooPh,
[{ p: "ګڼ", f: "gaN" }],
],
imperfective: [
@ -84,7 +89,7 @@ const regularVerbs: {
},
root: {
perfective: [
ooPrefix,
ooPh,
{
long: [{ p: "ګڼل", f: "gaNul" }],
short: [{ p: "ګڼ", f: "gaN" }],
@ -113,7 +118,7 @@ const verbsWithIrregularStems: {
result: {
stem: {
perfective: [
ooPrefix,
ooPh,
[{ p: "خور", f: "khor" }],
],
imperfective: [
@ -122,7 +127,7 @@ const verbsWithIrregularStems: {
},
root: {
perfective: [
ooPrefix,
ooPh,
{
long: [{ p: "خوړل", f: "khoRul" }],
short: [{ p: "خوړ", f: "khoR" }],
@ -142,7 +147,7 @@ const verbsWithIrregularStems: {
result: {
stem: {
perfective: [
ooPrefix,
ooPh,
[{ p: "خېژ", f: "khejz" }],
],
imperfective: [
@ -151,7 +156,7 @@ const verbsWithIrregularStems: {
},
root: {
perfective: [
ooPrefix,
ooPh,
{
long: [{ p: "ختل", f: "khatul" }],
short: [{ p: "خت", f: "khat" }],

View File

@ -15,11 +15,6 @@ import { accentOnNFromEnd, removeAccents } from "../accent-helpers";
type RootStemOutput = (T.PH | T.SingleOrLengthOpts<T.PsString[]>)[];
export const ooPrefix: T.PH = {
type: "PH",
ps: { p: "و", f: "óo" },
};
export function getRootStem({ verb, part, type, person }: {
verb: T.VerbEntry,
part: {
@ -61,12 +56,12 @@ function getRoot(verb: T.VerbEntryNoFVars, aspect: T.Aspect): RootStemOutput {
? makePsString(verb.entry.prp, verb.entry.prf)
: makePsString(verb.entry.p, verb.entry.f)
);
// TODO: determine ph and base
const [perfectiveHead, rest] = getPerfectiveHead(base, verb);
return [
ooPrefix,
...perfectiveHead ? [perfectiveHead] : [],
{
long: [base],
short: [removeL(base)],
long: [rest],
short: [removeL(rest)],
},
];
}
@ -93,15 +88,78 @@ function getStem(verb: T.VerbEntryNoFVars, aspect: T.Aspect): RootStemOutput {
? makePsString(verb.entry.psp, verb.entry.psf)
// with regular infinitive based perfective stem
: removeL(makePsString(verb.entry.p, verb.entry.f));
// TODO: determine ph and base
const [perfectiveHead, rest] = getPerfectiveHead(base, verb);
return [
ooPrefix,
[base],
...perfectiveHead ? [perfectiveHead] : [],
[rest],
];
}
return [];
}
function getPerfectiveHead(base: T.PsString, { entry }: T.VerbEntry): [T.PH, T.PsString] | [undefined, T.PsString] {
// if ((verb.entry.ssp && verb.entry.ssf) || verb.entry.separationAtP) {
// // handle split
// }
const [ph, rest]: [T.PH | undefined, T.PsString] = entry.noOo
? [undefined, base]
: entry.sepOo
? [
{ type: "PH", ps: { p: "و ", f: "óo`"}},
base,
]
: base.p.charAt(0) === "ا" && base.f.charAt(0) === "a"
? [
{ type: "PH", ps: { p: "وا", f: "wáa" }},
removeAStart(base),
]
: ["آ", "ا"].includes(base.p.charAt(0)) && base.f.slice(0, 2) === "aa"
? [
{ type: "PH", ps: { p: "وا", f: "wáa" }},
removeAStart(base),
]
: ["óo", "oo"].includes(base.f.slice(0, 2))
? [
{ type: "PH", ps: { p: "wÚ", f: "و" }},
base,
]
: ["ée", "ee"].includes(base.f.slice(0, 2)) && base.p.slice(0, 2) === "ای"
? [
{ type: "PH", ps: { p: "وي", f: "wée" }},
{
p: base.p.slice(2),
f: base.f.slice(2),
},
] : ["é", "e"].includes(base.f.slice(0, 2)) && base.p.slice(0, 2) === "اې"
? [
{ type: "PH", ps: { p: "وي", f: "wé" }},
{
p: base.p.slice(2),
f: base.f.slice(1),
},
] : ["ó", "o"].includes(base.f[0]) && base.p.slice(0, 2) === "او"
? [
{ type: "PH", ps: { p: "و", f: "óo`"}},
{
p: base.p.slice(2),
f: base.f.slice(1),
},
] : [
{ type: "PH", ps: { p: "و", f: "óo" }},
base,
];
return [
ph,
removeAccents(rest),
];
function removeAStart(ps: T.PsString) {
return {
p: ps.p.slice(1),
f: ps.f.slice(ps.f[1] === "a" ? 2 : 1),
};
}
}
function addTrailingAccent(ps: T.PsString): T.PsString {
return {
p: ps.p,