more on roots/stems
This commit is contained in:
parent
93776bb98d
commit
1dbe0a42f4
|
@ -14,6 +14,7 @@ import {
|
||||||
import { entryFeeder } from "./entryFeeder";
|
import { entryFeeder } from "./entryFeeder";
|
||||||
import { renderVerb } from "../lib/src/new-verb-engine/render-verb";
|
import { renderVerb } from "../lib/src/new-verb-engine/render-verb";
|
||||||
import NPPronounPicker from "../components/src/np-picker/NPPronounPicker";
|
import NPPronounPicker from "../components/src/np-picker/NPPronounPicker";
|
||||||
|
import { getAllRs } from "../lib/src/new-verb-engine/rs-helpers";
|
||||||
|
|
||||||
|
|
||||||
const transitivities: T.Transitivity[] = [
|
const transitivities: T.Transitivity[] = [
|
||||||
|
@ -152,6 +153,7 @@ function VPBuilderDemo({ opts }: {
|
||||||
person: testPerson.person,
|
person: testPerson.person,
|
||||||
voice: testVoice,
|
voice: testVoice,
|
||||||
}) : undefined;
|
}) : undefined;
|
||||||
|
const rs = v ? getAllRs(v.verb as T.VerbEntry) : undefined
|
||||||
return <div className="mt-4">
|
return <div className="mt-4">
|
||||||
<div className="d-block mx-auto card" style={{ maxWidth: "700px", background: "var(--closer)"}}>
|
<div className="d-block mx-auto card" style={{ maxWidth: "700px", background: "var(--closer)"}}>
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
|
@ -250,6 +252,9 @@ function VPBuilderDemo({ opts }: {
|
||||||
role="subject"
|
role="subject"
|
||||||
opts={opts}
|
opts={opts}
|
||||||
/>
|
/>
|
||||||
|
<pre>
|
||||||
|
{JSON.stringify(rs, null, " ")}
|
||||||
|
</pre>
|
||||||
<pre>
|
<pre>
|
||||||
{JSON.stringify(rv, null, " ")}
|
{JSON.stringify(rv, null, " ")}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
export function assertNever(x: never) {
|
||||||
|
throw new Error("unexpected object: "+x);
|
||||||
|
return x;
|
||||||
|
}
|
|
@ -1,14 +1,6 @@
|
||||||
import * as T from "../../../types";
|
import * as T from "../../../types";
|
||||||
import { renderVerb } from "./render-verb";
|
import { renderVerb } from "./render-verb";
|
||||||
|
import { vEntry } from "./rs-helpers";
|
||||||
export function vEntry(e: any, c?: any): T.VerbEntry {
|
|
||||||
return {
|
|
||||||
entry: e,
|
|
||||||
...c ? {
|
|
||||||
c,
|
|
||||||
} : {},
|
|
||||||
} as T.VerbEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
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"});
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,8 +12,7 @@ import {
|
||||||
import * as T from "../../../types";
|
import * as T from "../../../types";
|
||||||
import { makePsString, removeFVarientsFromVerb } from "../accent-and-ps-utils";
|
import { makePsString, removeFVarientsFromVerb } from "../accent-and-ps-utils";
|
||||||
import { accentOnNFromEnd, removeAccents } from "../accent-helpers";
|
import { accentOnNFromEnd, removeAccents } from "../accent-helpers";
|
||||||
|
import { assertNever } from "../assert-never";
|
||||||
type RootStemOutput = (T.PH | T.SingleOrLengthOpts<T.PsString[]>)[];
|
|
||||||
|
|
||||||
export function getRootStem({ verb, part, type, person }: {
|
export function getRootStem({ verb, part, type, person }: {
|
||||||
verb: T.VerbEntry,
|
verb: T.VerbEntry,
|
||||||
|
@ -28,19 +27,17 @@ export function getRootStem({ verb, part, type, person }: {
|
||||||
gender: T.Gender,
|
gender: T.Gender,
|
||||||
number: T.NounNumber,
|
number: T.NounNumber,
|
||||||
} | undefined,
|
} | undefined,
|
||||||
}): RootStemOutput {
|
}): T.RootStemOutput {
|
||||||
const v = removeFVarientsFromVerb(verb);
|
const v = removeFVarientsFromVerb(verb);
|
||||||
if ("participle" in part) {
|
if ("participle" in part) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (part.rs === "stem") {
|
return part.rs === "stem"
|
||||||
return getStem(v, part.aspect);
|
? getStem(v, part.aspect)
|
||||||
} else {
|
: getRoot(v, part.aspect);
|
||||||
return 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") {
|
if (aspect === "imperfective") {
|
||||||
const infinitive = accentOnNFromEnd(makePsString(verb.entry.p, verb.entry.f), 0);
|
const infinitive = accentOnNFromEnd(makePsString(verb.entry.p, verb.entry.f), 0);
|
||||||
return [
|
return [
|
||||||
|
@ -50,33 +47,43 @@ function getRoot(verb: T.VerbEntryNoFVars, aspect: T.Aspect): RootStemOutput {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (aspect === "perfective") {
|
// aspect === "perfective"
|
||||||
const base = removeAccents(
|
const base = removeAccents(
|
||||||
(verb.entry.prp && verb.entry.prf)
|
(verb.entry.prp && verb.entry.prf)
|
||||||
? 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)
|
||||||
);
|
);
|
||||||
const [perfectiveHead, rest] = getPerfectiveHead(base, verb);
|
const [perfectiveHead, rest] = getPerfectiveHead(base, verb);
|
||||||
return [
|
return [
|
||||||
...perfectiveHead ? [perfectiveHead] : [],
|
...perfectiveHead ? [perfectiveHead] : [],
|
||||||
{
|
{
|
||||||
long: [rest],
|
long: [rest],
|
||||||
short: [removeL(rest)],
|
short: [removeL(rest)],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
|
||||||
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") {
|
if (aspect === "imperfective") {
|
||||||
const base = (verb.entry.psp && verb.entry.psf)
|
if (verb.entry.psp && verb.entry.psf) {
|
||||||
// with irregular imperfective stem
|
return [[makePsString(verb.entry.psp, verb.entry.psf)]];
|
||||||
? makePsString(verb.entry.psp, verb.entry.psf)
|
}
|
||||||
// with regular infinitive based imperfective stem
|
const rawBase = removeL(makePsString(verb.entry.p, verb.entry.f));
|
||||||
: 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 [
|
return [
|
||||||
[base],
|
[rawBase],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (aspect === "perfective") {
|
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) {
|
// if ((verb.entry.ssp && verb.entry.ssf) || verb.entry.separationAtP) {
|
||||||
// // handle split
|
// // 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
|
const [ph, rest]: [T.PH | undefined, T.PsString] = entry.noOo
|
||||||
? [undefined, base]
|
? [undefined, base]
|
||||||
: entry.sepOo
|
: entry.sepOo
|
||||||
|
|
|
@ -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 }),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
|
@ -1140,3 +1140,4 @@ export type Welded = {
|
||||||
right: VA | PT | VI,
|
right: VA | PT | VI,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type RootStemOutput = (PH | SingleOrLengthOpts<PsString[]>)[];
|
||||||
|
|
Loading…
Reference in New Issue