more on roots/stems

This commit is contained in:
adueck 2023-04-05 15:54:00 +04:00
parent 93776bb98d
commit 1dbe0a42f4
7 changed files with 1100 additions and 192 deletions

View File

@ -14,6 +14,7 @@ import {
import { entryFeeder } from "./entryFeeder";
import { renderVerb } from "../lib/src/new-verb-engine/render-verb";
import NPPronounPicker from "../components/src/np-picker/NPPronounPicker";
import { getAllRs } from "../lib/src/new-verb-engine/rs-helpers";
const transitivities: T.Transitivity[] = [
@ -152,6 +153,7 @@ function VPBuilderDemo({ opts }: {
person: testPerson.person,
voice: testVoice,
}) : undefined;
const rs = v ? getAllRs(v.verb as T.VerbEntry) : undefined
return <div className="mt-4">
<div className="d-block mx-auto card" style={{ maxWidth: "700px", background: "var(--closer)"}}>
<div className="card-body">
@ -250,6 +252,9 @@ function VPBuilderDemo({ opts }: {
role="subject"
opts={opts}
/>
<pre>
{JSON.stringify(rs, null, " ")}
</pre>
<pre>
{JSON.stringify(rv, null, " ")}
</pre>

View File

@ -0,0 +1,4 @@
export function assertNever(x: never) {
throw new Error("unexpected object: "+x);
return x;
}

View File

@ -1,14 +1,6 @@
import * as T from "../../../types";
import { renderVerb } from "./render-verb";
export function vEntry(e: any, c?: any): T.VerbEntry {
return {
entry: e,
...c ? {
c,
} : {},
} as T.VerbEntry;
}
import { vEntry } from "./rs-helpers";
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"});

View File

@ -1,15 +1,14 @@
import * as T from "../../../types";
import { getRootStem } from "./roots-and-stems";
import { vEntry } from "./render-verb.test";
import { ooPrefix } from "../grammar-units";
import { vEntry } from "./rs-helpers";
import { getAllRs } from "./rs-helpers";
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 ganul = vEntry({"ts":1527812000,"i":11398,"p":"ګڼل","f":"gaNul, guNul","g":"gaNul,guNul","e":"to count, consider, reckon, suppose, assume","r":4,"c":"v. trans.","tppp":"ګاڼه","tppf":"gaaNu","ec":"deem"});
const kawulStat = vEntry({"ts":1579015359582,"i":11030,"p":"کول","f":"kawul","g":"kawul","e":"to make ____ ____ (as in \"He's making me angry.\")","r":4,"c":"v. trans.","ssp":"کړ","ssf":"kR","prp":"کړل","prf":"kRul","pprtp":"کړی","pprtf":"kúRey","noOo":true,"ec":"make,makes,making,made,made"});
const kawulDyn = vEntry({"ts":1527812752,"i":11031,"p":"کول","f":"kawul","g":"kawul","e":"to do (an action or activity)","r":4,"c":"v. trans./gramm. trans.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true,"ec":"do,does,doing,did,done"});
const kawulDyn = vEntry({"ts":1527812752,"i":11031,"p":"کول","f":"kawul","g":"kawul","e":"to do (an action or activity)","r":4,"c":"v. trans./gramm. trans.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true,"ec":"do,does,doing,did,done","separationAtP":1,"separationAtF":2});
const kedulStat = vEntry({"ts":1581086654898,"i":11100,"p":"کېدل","f":"kedul","g":"kedul","e":"to become _____","r":2,"c":"v. intrans.","ssp":"ش","ssf":"sh","prp":"شول","prf":"shwul","pprtp":"شوی","pprtf":"shúwey","noOo":true,"ec":"become"});
const kedulDyn = vEntry({"ts":1527812754,"i":11101,"p":"کېدل","f":"kedul","g":"kedul","e":"to happen, occur","r":2,"c":"v. intrans.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true,"ec":"happen"});
const kedulDyn = vEntry({"ts":1527812754,"i":11101,"p":"کېدل","f":"kedul","g":"kedul","e":"to happen, occur","r":2,"c":"v. intrans.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true,"ec":"happen","separationAtP":1,"separationAtF":2});
const raatlul = vEntry({"ts":1527815216,"i":6875,"p":"راتلل","f":"raatlúl","g":"raatlul","e":"to come","r":4,"c":"v. intrans.","psp":"راځ","psf":"raadz","ssp":"راش","ssf":"ráash","prp":"راغلل","prf":"ráaghlul","pprtp":"راغلی","pprtf":"raaghúley","tppp":"راغی","tppf":"ráaghey","noOo":true,"separationAtP":2,"separationAtF":3,"ec":"come,comes,coming,came,come"});
const wartlul = vEntry({"ts":1585228579997,"i":14821,"p":"ورتلل","f":"wărtlul","g":"wartlul","e":"to come / go over to (third person or place)","r":4,"c":"v. intrans.","psp":"ورځ","psf":"wărdz","ssp":"ورش","ssf":"wársh","prp":"ورغلل","prf":"wárghlul","pprtp":"ورغلی","pprtf":"wărghúley","tppp":"ورغی","tppf":"wărghey","noOo":true,"separationAtP":2,"separationAtF":3,"ec":"come,comes,coming,came,come"});
const tlul = vEntry({"ts":1527815348,"i":3791,"p":"تلل","f":"tlul","g":"tlul","e":"to go","r":4,"c":"v. intrans.","psp":"ځ","psf":"dz","ssp":"لاړ ش","ssf":"láaR sh","prp":"لاړ","prf":"láaR","ec":"go,goes,going,went,gone"});
@ -19,33 +18,33 @@ const azmoyul = vEntry({"ts":1527811605,"i":468,"p":"ازمویل","f":"azmoyul"
const khatul = vEntry({"ts":1527814025,"i":5677,"p":"ختل","f":"khatul","g":"khatul","e":"to climb, ascend, rise, go up; to fall out, to fall off, to leave/dissapear; to turn out to be ...; to give a sentence (in law)","r":3,"c":"v. intrans.","psp":"خېژ","psf":"khejz","tppp":"خوت","tppf":"khot","ec":"climb"});
const rasedul = vEntry({"ts":1527813573,"i":7057,"p":"رسېدل","f":"rasedul","g":"rasedul","e":"arrive, reach; (fig.) understand, attain to; mature, ripen","r":4,"c":"v. intrans.","shortIntrans":true,"ec":"arrive"});
const weshul = vEntry({"ts":1527811701,"i":15106,"p":"وېشل","f":"weshul","g":"weshul","e":"divide, distribute, share","r":4,"c":"v. trans.","ec":"divide"});
type RSO = ReturnType<typeof getRootStem>;
function getAllRs(verb: T.VerbEntry): (typeof regularVerbs)[0]["result"] {
return {
stem: {
perfective: getRootStem({ verb, type: "basic", part: { rs: "stem", aspect: "perfective" }, person: undefined }),
imperfective: getRootStem({ verb, type: "basic", part: { rs: "stem", aspect: "imperfective" }, person: undefined }),
},
root: {
perfective: getRootStem({ verb, type: "basic", part: { rs: "root", aspect: "perfective" }, person: undefined }),
imperfective: getRootStem({ verb, type: "basic", part: { rs: "root", aspect: "imperfective" }, person: undefined }),
},
};
}
const watul = vEntry({"ts":1527823376,"i":14759,"p":"وتل","f":"watul","g":"watul","e":"to go out, exit, leave, emerge","r":4,"c":"v. intrans.","psp":"وځ","psf":"oodz","tppp":"واته","tppf":"waatu","ec":"go,goes,going,went,gone","ep":"out"});
const wurul = vEntry({"ts":1527816865,"i":14903,"p":"وړل","f":"wuRúl, oRúl, wRul","g":"wuRul,oRul,wRul","e":"to take, carry, bear, move (inanimate objects); to win, earn (subjunctive یوسي - yósee or ویسي - wéesee, simple past یو یې وړلو - yo ye wRulo)","r":3,"c":"v. trans.","ssp":"یوس","ssf":"yos","prp":"یوړل","prf":"yóRul","tppp":"یوړ","tppf":"yoR","noOo":true,"separationAtP":2,"separationAtF":2,"diacExcept":true,"ec":"take,takes,taking,took,taken"});
const kexodul = vEntry({"ts":1527812284,"i":11113,"p":"کېښودل","f":"kexodul","g":"kexodul","e":"to put, to put down, to set in place","r":4,"c":"v. trans.","psp":"ږد","psf":"Gd","ssp":"کېږد","ssf":"kéGd","noOo":true,"separationAtP":2,"separationAtF":2,"ec":"put,puts,putting,put,put"});
const kenaastul = vEntry({"ts":1527812759,"i":11124,"p":"کېناستل","f":"kenaastul","g":"kenaastul","e":"to sit down, to have a seat","r":4,"c":"v. intrans.","psp":"کېن","psf":"ken","noOo":true,"separationAtP":2,"separationAtF":2,"ec":"sit,sits,sitting,sat","ep":"down"});
const ghadzedul = vEntry({"ts":1527812615,"i":9500,"p":"غځېدل","f":"ghadzedul","g":"ghadzedul","e":"stretch out, lie, be extended, expand","r":3,"c":"v. intrans.","ec":"stretch","ep":"out"});
const ooPh: T.PH = {
type: "PH",
ps: { p: "و", f: "óo" },
};
const regularVerbs: {
type TestGroup = {
verb: T.VerbEntry,
result: Record<"stem" | "root", {
imperfective: RSO,
perfective: RSO,
imperfective: T.RootStemOutput,
perfective: T.RootStemOutput,
}>
}[] = [
}[];
const tests: {
title: string,
testGroup: TestGroup,
}[] =
[
{
title: "regular verbs",
testGroup: [
{
verb: weshul,
result: {
@ -104,15 +103,168 @@ const regularVerbs: {
},
},
},
];
const verbsWithIrregularStems: {
verb: T.VerbEntry,
result: Record<"stem" | "root", {
imperfective: RSO,
perfective: RSO,
}>
}[] = [
],
},
{
title: "intransitive edul verbs",
testGroup: [
// without shorter intrans version
{
verb: ghadzedul,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "و",
"f": "óo"
}
},
[
{
"p": "غځېد",
"f": "ghadzed"
}
]
],
"imperfective": [
[
{
"p": "غځېږ",
"f": "ghadzéG"
}
]
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "و",
"f": "óo"
}
},
{
"long": [
{
"p": "غځېدل",
"f": "ghadzedul"
}
],
"short": [
{
"p": "غځېد",
"f": "ghadzed"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "غځېدل",
"f": "ghadzedúl"
}
],
"short": [
{
"p": "غځېد",
"f": "ghadzedX"
},
],
},
],
},
},
},
// with shorter intrans version
{
verb: rasedul,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "و",
"f": "óo"
}
},
[
{
"p": "رسېد",
"f": "rased"
}
]
],
"imperfective": [
{
"long": [
{
"p": "رسېږ",
"f": "raséG"
}
],
"short": [
{
"p": "رس",
"f": "ras"
}
]
}
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "و",
"f": "óo"
}
},
{
"long": [
{
"p": "رسېدل",
"f": "rasedul"
}
],
"short": [
{
"p": "رسېد",
"f": "rased"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "رسېدل",
"f": "rasedúl"
}
],
"short": [
{
"p": "رسېد",
"f": "rasedX"
}
]
}
]
}
},
},
],
},
{
title: "verbs with irregular stems",
testGroup: [
{
verb: khorul,
result: {
@ -171,16 +323,716 @@ const verbsWithIrregularStems: {
},
},
},
],
},
{
title: "verbs with special prefix behavior",
testGroup: [
{
verb: achawul,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "وا",
"f": "wáa"
}
},
[
{
"p": "چو",
"f": "chaw"
}
]
],
"imperfective": [
[
{
"p": "اچو",
"f": "achaw"
}
]
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "وا",
"f": "wáa"
}
},
{
"long": [
{
"p": "چول",
"f": "chawul"
}
],
"short": [
{
"p": "چو",
"f": "chaw"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "اچول",
"f": "achawúl"
}
],
"short": [
{
"p": "اچو",
"f": "achawX"
}
]
}
]
}
},
},
{
verb: watul,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "wÚ",
"f": "و"
}
},
[
{
"p": "وځ",
"f": "oodz"
}
]
],
"imperfective": [
[
{
"p": "وځ",
"f": "oodz"
}
]
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "و",
"f": "óo"
}
},
{
"long": [
{
"p": "وتل",
"f": "watul"
}
],
"short": [
{
"p": "وت",
"f": "wat"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "وتل",
"f": "watúl"
}
],
"short": [
{
"p": "وت",
"f": "watX"
}
]
}
]
}
},
},
{
verb: azmoyul,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "و ",
"f": "óo`"
}
},
[
{
"p": "ازموی",
"f": "azmoy"
}
]
],
"imperfective": [
[
{
"p": "ازموی",
"f": "azmoy"
}
]
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "و ",
"f": "óo`"
}
},
{
"long": [
{
"p": "ازمویل",
"f": "azmoyul"
}
],
"short": [
{
"p": "ازموی",
"f": "azmoy"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "ازمویل",
"f": "azmoyúl"
}
],
"short": [
{
"p": "ازموی",
"f": "azmoyX"
}
]
}
]
}
},
},
],
},
{
title: "verbs with seperable oo prefix",
testGroup: [
{
verb: kenaastul,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "کې",
"f": "ké"
}
},
[
{
"p": "ن",
"f": "n"
}
]
],
"imperfective": [
[
{
"p": "کېن",
"f": "ken"
}
]
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "کې",
"f": "ké"
}
},
{
"long": [
{
"p": "ناستل",
"f": "naastul"
}
],
"short": [
{
"p": "ناست",
"f": "naast"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "کېناستل",
"f": "kenaastúl"
}
],
"short": [
{
"p": "کېناست",
"f": "kenaastX"
}
]
}
]
}
},
},
],
},
{
title: "verbs with irregular roots and stems",
testGroup: [
{
verb: wurul,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "یو",
"f": "yó"
}
},
[
{
"p": "س",
"f": "s"
}
]
],
"imperfective": [
[
{
"p": "وړ",
"f": "wuR"
}
]
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "یو",
"f": "yó"
}
},
{
"long": [
{
"p": "ړل",
"f": "Rul"
}
],
"short": [
{
"p": "ړ",
"f": "R"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "وړل",
"f": "wuRúl"
}
],
"short": [
{
"p": "وړ",
"f": "wuRX"
}
]
}
]
}
}
},
{
verb: kexodul,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "کې",
"f": "ké"
}
},
[
{
"p": "ږد",
"f": "Gd"
}
]
],
"imperfective": [
[
{
"p": "ږد",
"f": "Gd"
}
]
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "کې",
"f": "ké"
}
},
{
"long": [
{
"p": "ښودل",
"f": "xodul"
}
],
"short": [
{
"p": "ښود",
"f": "xod"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "کېښودل",
"f": "kexodúl"
}
],
"short": [
{
"p": "کېښود",
"f": "kexodX"
}
]
}
]
}
},
},
],
},
{
title: "especially irregular verbs",
testGroup: [
{
verb: kedulStat,
result: {
"stem": {
"perfective": [
[
{
"p": "ش",
"f": "sh"
}
]
],
"imperfective": [
[
{
"p": "کېږ",
"f": "kéG",
},
]
]
},
"root": {
"perfective": [
{
"long": [
{
"p": "شول",
"f": "shwul"
}
],
"short": [
{
"p": "شو",
"f": "shw"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "کېدل",
"f": "kedúl"
}
],
"short": [
{
"p": "کېد",
"f": "kedX"
}
]
}
]
}
},
},
{
verb: kedulDyn,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"f": "óo",
"p": "و"
}
},
[
{
"p": "ش",
"f": "sh"
}
]
],
"imperfective": [
[
{
"p": "کېږ",
"f": "kéG"
}
]
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"f": "óo",
"p": "و"
}
},
{
"long": [
{
"p": "شول",
"f": "shwul"
}
],
"short": [
{
"p": "شو",
"f": "shw"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "کېدل",
"f": "kedúl"
}
],
"short": [
{
"p": "کېد",
"f": "kedX"
}
]
}
]
}
},
},
{
verb: kawulStat,
result: {
"stem": {
"perfective": [
[
{
"p": "کړ",
"f": "kR"
}
]
],
"imperfective": [
[
{
"p": "کو",
"f": "kaw"
}
]
]
},
"root": {
"perfective": [
{
"long": [
{
"p": "کړل",
"f": "kRul"
}
],
"short": [
{
"p": "کړ",
"f": "kR"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "کول",
"f": "kawúl"
}
],
"short": [
{
"p": "کو",
"f": "kawX"
}
]
}
]
}
},
},
{
verb: kawulDyn,
result: {
"stem": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "و",
"f": "óo",
}
},
[
{
"p": "کړ",
"f": "kR"
}
]
],
"imperfective": [
[
{
"p": "کو",
"f": "kaw"
}
]
]
},
"root": {
"perfective": [
{
"type": "PH",
"ps": {
"p": "و",
"f": "óo",
},
},
{
"long": [
{
"p": "کړل",
"f": "kRul"
}
],
"short": [
{
"p": "کړ",
"f": "kR"
}
]
}
],
"imperfective": [
{
"long": [
{
"p": "کول",
"f": "kawúl"
}
],
"short": [
{
"p": "کو",
"f": "kawX"
}
]
}
]
}
},
}
],
}
];
test("basic roots and stems with regular verbs", () => {
regularVerbs.forEach(({ verb, result }) => {
tests.forEach(({ title, testGroup }) => {
test(title, () => {
testGroup.forEach(({ verb, result }) => {
expect(getAllRs(verb)).toEqual(result);
});
});
test("baisc roots and stems with verbs with irregular stems", () => {
verbsWithIrregularStems.forEach(({ verb, result }) => {
expect(getAllRs(verb)).toEqual(result);
});
});

View File

@ -12,8 +12,7 @@ import {
import * as T from "../../../types";
import { makePsString, removeFVarientsFromVerb } from "../accent-and-ps-utils";
import { accentOnNFromEnd, removeAccents } from "../accent-helpers";
type RootStemOutput = (T.PH | T.SingleOrLengthOpts<T.PsString[]>)[];
import { assertNever } from "../assert-never";
export function getRootStem({ verb, part, type, person }: {
verb: T.VerbEntry,
@ -28,19 +27,17 @@ export function getRootStem({ verb, part, type, person }: {
gender: T.Gender,
number: T.NounNumber,
} | undefined,
}): RootStemOutput {
}): T.RootStemOutput {
const v = removeFVarientsFromVerb(verb);
if ("participle" in part) {
return [];
}
if (part.rs === "stem") {
return getStem(v, part.aspect);
} else {
return getRoot(v, part.aspect);
}
return part.rs === "stem"
? getStem(v, part.aspect)
: getRoot(v, part.aspect);
}
function getRoot(verb: T.VerbEntryNoFVars, aspect: T.Aspect): RootStemOutput {
function getRoot(verb: T.VerbEntryNoFVars, aspect: T.Aspect): T.RootStemOutput {
if (aspect === "imperfective") {
const infinitive = accentOnNFromEnd(makePsString(verb.entry.p, verb.entry.f), 0);
return [
@ -50,7 +47,7 @@ function getRoot(verb: T.VerbEntryNoFVars, aspect: T.Aspect): RootStemOutput {
},
];
}
if (aspect === "perfective") {
// aspect === "perfective"
const base = removeAccents(
(verb.entry.prp && verb.entry.prf)
? makePsString(verb.entry.prp, verb.entry.prf)
@ -65,18 +62,28 @@ function getRoot(verb: T.VerbEntryNoFVars, aspect: T.Aspect): RootStemOutput {
},
];
}
throw new Error("unknown aspect");
}
function getStem(verb: T.VerbEntryNoFVars, aspect: T.Aspect): RootStemOutput {
function getStem(verb: T.VerbEntryNoFVars, aspect: T.Aspect): T.RootStemOutput {
if (aspect === "imperfective") {
const base = (verb.entry.psp && verb.entry.psf)
// with irregular imperfective stem
? makePsString(verb.entry.psp, verb.entry.psf)
// with regular infinitive based imperfective stem
: removeL(makePsString(verb.entry.p, verb.entry.f));
if (verb.entry.psp && verb.entry.psf) {
return [[makePsString(verb.entry.psp, verb.entry.psf)]];
}
const rawBase = removeL(makePsString(verb.entry.p, verb.entry.f));
if (verb.entry.c?.includes("intrans.") && rawBase.p.endsWith("ېد")) {
const long: T.PsString[] = [{
p: rawBase.p.slice(0, -1) + "ږ",
f: rawBase.f.slice(0, -2) + "éG",
}];
const short: T.PsString[] | undefined = (verb.entry.shortIntrans)
? [{
p: rawBase.p.slice(0, -2),
f: rawBase.f.slice(0, -2),
}]
: undefined;
return short ? [{ long, short }] : [long]
}
return [
[base],
[rawBase],
];
}
if (aspect === "perfective") {
@ -101,6 +108,20 @@ function getPerfectiveHead(base: T.PsString, { entry }: T.VerbEntry): [T.PH, T.P
// if ((verb.entry.ssp && verb.entry.ssf) || verb.entry.separationAtP) {
// // handle split
// }
if (entry.separationAtP && entry.separationAtF) {
const ph: T.PH = {
type: "PH",
ps: accentOnNFromEnd({
p: base.p.slice(0, entry.separationAtP),
f: base.f.slice(0, entry.separationAtF),
}, 0),
};
const rest = {
p: base.p.slice(entry.separationAtP),
f: base.f.slice(entry.separationAtF),
};
return [ph, rest];
}
const [ph, rest]: [T.PH | undefined, T.PsString] = entry.noOo
? [undefined, base]
: entry.sepOo

View File

@ -0,0 +1,33 @@
import * as T from "../../../types";
import { getRootStem } from "./roots-and-stems";
export function vEntry(e: any, c?: any): T.VerbEntry {
return {
entry: e,
...c ? {
c,
} : {},
} as T.VerbEntry;
}
export function getAllRs(verb: T.VerbEntry): {
stem: {
perfective: T.RootStemOutput,
imperfective: T.RootStemOutput,
},
root: {
perfective: T.RootStemOutput,
imperfective: T.RootStemOutput,
},
} {
return {
stem: {
perfective: getRootStem({ verb, type: "basic", part: { rs: "stem", aspect: "perfective" }, person: undefined }),
imperfective: getRootStem({ verb, type: "basic", part: { rs: "stem", aspect: "imperfective" }, person: undefined }),
},
root: {
perfective: getRootStem({ verb, type: "basic", part: { rs: "root", aspect: "perfective" }, person: undefined }),
imperfective: getRootStem({ verb, type: "basic", part: { rs: "root", aspect: "imperfective" }, person: undefined }),
},
};
}

View File

@ -1140,3 +1140,4 @@ export type Welded = {
right: VA | PT | VI,
};
export type RootStemOutput = (PH | SingleOrLengthOpts<PsString[]>)[];