more on new verb engine
This commit is contained in:
parent
1658f021a0
commit
93776bb98d
|
@ -1,7 +1,7 @@
|
||||||
import * as T from "../../../types";
|
import * as T from "../../../types";
|
||||||
import { getRootStem } from "./roots-and-stems";
|
import { getRootStem } from "./roots-and-stems";
|
||||||
import { vEntry } from "./render-verb.test";
|
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 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"});
|
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: {
|
const regularVerbs: {
|
||||||
verb: T.VerbEntry,
|
verb: T.VerbEntry,
|
||||||
result: Record<"stem" | "root", {
|
result: Record<"stem" | "root", {
|
||||||
|
@ -46,7 +51,7 @@ const regularVerbs: {
|
||||||
result: {
|
result: {
|
||||||
stem: {
|
stem: {
|
||||||
perfective: [
|
perfective: [
|
||||||
ooPrefix,
|
ooPh,
|
||||||
[{ p: "وېش", f: "wesh" }],
|
[{ p: "وېش", f: "wesh" }],
|
||||||
],
|
],
|
||||||
imperfective: [
|
imperfective: [
|
||||||
|
@ -55,7 +60,7 @@ const regularVerbs: {
|
||||||
},
|
},
|
||||||
root: {
|
root: {
|
||||||
perfective: [
|
perfective: [
|
||||||
ooPrefix,
|
ooPh,
|
||||||
{
|
{
|
||||||
long: [{ p: "وېشل", f: "weshul" }],
|
long: [{ p: "وېشل", f: "weshul" }],
|
||||||
short: [{ p: "وېش", f: "wesh" }],
|
short: [{ p: "وېش", f: "wesh" }],
|
||||||
|
@ -75,7 +80,7 @@ const regularVerbs: {
|
||||||
result: {
|
result: {
|
||||||
stem: {
|
stem: {
|
||||||
perfective: [
|
perfective: [
|
||||||
ooPrefix,
|
ooPh,
|
||||||
[{ p: "ګڼ", f: "gaN" }],
|
[{ p: "ګڼ", f: "gaN" }],
|
||||||
],
|
],
|
||||||
imperfective: [
|
imperfective: [
|
||||||
|
@ -84,7 +89,7 @@ const regularVerbs: {
|
||||||
},
|
},
|
||||||
root: {
|
root: {
|
||||||
perfective: [
|
perfective: [
|
||||||
ooPrefix,
|
ooPh,
|
||||||
{
|
{
|
||||||
long: [{ p: "ګڼل", f: "gaNul" }],
|
long: [{ p: "ګڼل", f: "gaNul" }],
|
||||||
short: [{ p: "ګڼ", f: "gaN" }],
|
short: [{ p: "ګڼ", f: "gaN" }],
|
||||||
|
@ -113,7 +118,7 @@ const verbsWithIrregularStems: {
|
||||||
result: {
|
result: {
|
||||||
stem: {
|
stem: {
|
||||||
perfective: [
|
perfective: [
|
||||||
ooPrefix,
|
ooPh,
|
||||||
[{ p: "خور", f: "khor" }],
|
[{ p: "خور", f: "khor" }],
|
||||||
],
|
],
|
||||||
imperfective: [
|
imperfective: [
|
||||||
|
@ -122,7 +127,7 @@ const verbsWithIrregularStems: {
|
||||||
},
|
},
|
||||||
root: {
|
root: {
|
||||||
perfective: [
|
perfective: [
|
||||||
ooPrefix,
|
ooPh,
|
||||||
{
|
{
|
||||||
long: [{ p: "خوړل", f: "khoRul" }],
|
long: [{ p: "خوړل", f: "khoRul" }],
|
||||||
short: [{ p: "خوړ", f: "khoR" }],
|
short: [{ p: "خوړ", f: "khoR" }],
|
||||||
|
@ -142,7 +147,7 @@ const verbsWithIrregularStems: {
|
||||||
result: {
|
result: {
|
||||||
stem: {
|
stem: {
|
||||||
perfective: [
|
perfective: [
|
||||||
ooPrefix,
|
ooPh,
|
||||||
[{ p: "خېژ", f: "khejz" }],
|
[{ p: "خېژ", f: "khejz" }],
|
||||||
],
|
],
|
||||||
imperfective: [
|
imperfective: [
|
||||||
|
@ -151,7 +156,7 @@ const verbsWithIrregularStems: {
|
||||||
},
|
},
|
||||||
root: {
|
root: {
|
||||||
perfective: [
|
perfective: [
|
||||||
ooPrefix,
|
ooPh,
|
||||||
{
|
{
|
||||||
long: [{ p: "ختل", f: "khatul" }],
|
long: [{ p: "ختل", f: "khatul" }],
|
||||||
short: [{ p: "خت", f: "khat" }],
|
short: [{ p: "خت", f: "khat" }],
|
||||||
|
|
|
@ -15,11 +15,6 @@ import { accentOnNFromEnd, removeAccents } from "../accent-helpers";
|
||||||
|
|
||||||
type RootStemOutput = (T.PH | T.SingleOrLengthOpts<T.PsString[]>)[];
|
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 }: {
|
export function getRootStem({ verb, part, type, person }: {
|
||||||
verb: T.VerbEntry,
|
verb: T.VerbEntry,
|
||||||
part: {
|
part: {
|
||||||
|
@ -61,12 +56,12 @@ function getRoot(verb: T.VerbEntryNoFVars, aspect: T.Aspect): RootStemOutput {
|
||||||
? makePsString(verb.entry.prp, verb.entry.prf)
|
? makePsString(verb.entry.prp, verb.entry.prf)
|
||||||
: makePsString(verb.entry.p, verb.entry.f)
|
: makePsString(verb.entry.p, verb.entry.f)
|
||||||
);
|
);
|
||||||
// TODO: determine ph and base
|
const [perfectiveHead, rest] = getPerfectiveHead(base, verb);
|
||||||
return [
|
return [
|
||||||
ooPrefix,
|
...perfectiveHead ? [perfectiveHead] : [],
|
||||||
{
|
{
|
||||||
long: [base],
|
long: [rest],
|
||||||
short: [removeL(base)],
|
short: [removeL(rest)],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -93,15 +88,78 @@ function getStem(verb: T.VerbEntryNoFVars, aspect: T.Aspect): RootStemOutput {
|
||||||
? makePsString(verb.entry.psp, verb.entry.psf)
|
? makePsString(verb.entry.psp, verb.entry.psf)
|
||||||
// with regular infinitive based perfective stem
|
// with regular infinitive based perfective stem
|
||||||
: removeL(makePsString(verb.entry.p, verb.entry.f));
|
: removeL(makePsString(verb.entry.p, verb.entry.f));
|
||||||
// TODO: determine ph and base
|
const [perfectiveHead, rest] = getPerfectiveHead(base, verb);
|
||||||
return [
|
return [
|
||||||
ooPrefix,
|
...perfectiveHead ? [perfectiveHead] : [],
|
||||||
[base],
|
[rest],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return [];
|
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 {
|
function addTrailingAccent(ps: T.PsString): T.PsString {
|
||||||
return {
|
return {
|
||||||
p: ps.p,
|
p: ps.p,
|
||||||
|
|
Loading…
Reference in New Issue