added modals 💪
This commit is contained in:
parent
4d7fec9813
commit
40794345b7
|
@ -5,7 +5,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^5.15.4",
|
"@fortawesome/fontawesome-free": "^5.15.4",
|
||||||
"@lingdocs/lingdocs-main": "^0.2.0",
|
"@lingdocs/lingdocs-main": "^0.2.0",
|
||||||
"@lingdocs/pashto-inflector": "^1.5.9",
|
"@lingdocs/pashto-inflector": "^1.6.2",
|
||||||
"@testing-library/jest-dom": "^5.11.4",
|
"@testing-library/jest-dom": "^5.11.4",
|
||||||
"@testing-library/react": "^11.1.0",
|
"@testing-library/react": "^11.1.0",
|
||||||
"@testing-library/user-event": "^12.1.10",
|
"@testing-library/user-event": "^12.1.10",
|
||||||
|
|
|
@ -11,30 +11,30 @@ import {
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
// import { useState } from "react";
|
// import { useState } from "react";
|
||||||
|
|
||||||
const tenseOptions: { label: string, value: VerbTense }[] = [{
|
const tenseOptions: { label: string | JSX.Element, value: VerbTense }[] = [{
|
||||||
label: "present",
|
label: <div><i className="fas fa-video mr-2" />present</div>,
|
||||||
value: "present",
|
value: "present",
|
||||||
}, {
|
}, {
|
||||||
label: "subjunctive",
|
label: <div><i className="fas fa-camera mr-2" />subjunctive</div>,
|
||||||
value: "subjunctive",
|
value: "subjunctive",
|
||||||
}, {
|
}, {
|
||||||
label: "imperf. future",
|
label: <div><i className="fas fa-video mr-2" />imperf. future</div>,
|
||||||
value: "imperfectiveFuture",
|
value: "imperfectiveFuture",
|
||||||
}, {
|
}, {
|
||||||
label: "perf. future",
|
label: <div><i className="fas fa-camera mr-2" />perf. future</div>,
|
||||||
value: "perfectiveFuture",
|
value: "perfectiveFuture",
|
||||||
}, {
|
}, {
|
||||||
label: "simple past",
|
label: <div><i className="fas fa-video mr-2" />continuous past</div>,
|
||||||
value: "perfectivePast",
|
|
||||||
}, {
|
|
||||||
label: "continuous past",
|
|
||||||
value: "imperfectivePast",
|
value: "imperfectivePast",
|
||||||
}, {
|
}, {
|
||||||
label: "habitual simp. past.",
|
label: <div><i className="fas fa-camera mr-2" />simple past</div>,
|
||||||
value: "habitualPerfectivePast",
|
value: "perfectivePast",
|
||||||
}, {
|
}, {
|
||||||
label: "habitual cont. past.",
|
label: <div><i className="fas fa-video mr-2" />habitual cont. past.</div>,
|
||||||
value: "habitualImperfectivePast",
|
value: "habitualImperfectivePast",
|
||||||
|
}, {
|
||||||
|
label: <div><i className="fas fa-camera mr-2" />habitual simp. past.</div>,
|
||||||
|
value: "habitualPerfectivePast",
|
||||||
}];
|
}];
|
||||||
|
|
||||||
// type Filters = {
|
// type Filters = {
|
||||||
|
@ -78,6 +78,14 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function onTenseCategorySelect(value: "basic" | "modal") {
|
||||||
|
if (verb) {
|
||||||
|
onChange({
|
||||||
|
...verb,
|
||||||
|
tenseCategory: value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
function notInstransitive(t: "transitive" | "intransitive" | "grammatically transitive"): "transitive" | "grammatically transitive" {
|
function notInstransitive(t: "transitive" | "intransitive" | "grammatically transitive"): "transitive" | "grammatically transitive" {
|
||||||
return t === "intransitive" ? "transitive" : t;
|
return t === "intransitive" ? "transitive" : t;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +99,7 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
|
||||||
onChange(verb.changeStatDyn(c));
|
onChange(verb.changeStatDyn(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <div style={{ maxWidth: "225px", minWidth: "125px" }}>
|
return <div style={{ maxWidth: "225px", minWidth: "175px" }}>
|
||||||
<div>Verb:</div>
|
<div>Verb:</div>
|
||||||
<Select
|
<Select
|
||||||
value={verb && verb.verb.entry.ts.toString()}
|
value={verb && verb.verb.entry.ts.toString()}
|
||||||
|
@ -105,6 +113,20 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
|
||||||
placeholder={verb ? options.find(o => o.value === (verb.verb.entry).ts.toString())?.label : "Select Verb..."}
|
placeholder={verb ? options.find(o => o.value === (verb.verb.entry).ts.toString())?.label : "Select Verb..."}
|
||||||
{...zIndexProps}
|
{...zIndexProps}
|
||||||
/>
|
/>
|
||||||
|
{verb && <div className="text-center my-3">
|
||||||
|
<ButtonSelect
|
||||||
|
small
|
||||||
|
value={verb.tenseCategory}
|
||||||
|
options={[{
|
||||||
|
label: "Basic",
|
||||||
|
value: "basic",
|
||||||
|
}, {
|
||||||
|
label: "Modal",
|
||||||
|
value: "modal",
|
||||||
|
}]}
|
||||||
|
handleChange={onTenseCategorySelect}
|
||||||
|
/>
|
||||||
|
</div>}
|
||||||
<div>Tense:</div>
|
<div>Tense:</div>
|
||||||
<Select
|
<Select
|
||||||
isSearchable={false}
|
isSearchable={false}
|
||||||
|
@ -205,6 +227,7 @@ function makeVerbSelection(verb: VerbEntry, oldVerbSelection?: VerbSelection): V
|
||||||
object,
|
object,
|
||||||
transitivity,
|
transitivity,
|
||||||
isCompound,
|
isCompound,
|
||||||
|
tenseCategory: oldVerbSelection ? oldVerbSelection.tenseCategory : "basic",
|
||||||
negative: oldVerbSelection ? oldVerbSelection.negative : false,
|
negative: oldVerbSelection ? oldVerbSelection.negative : false,
|
||||||
...("grammaticallyTransitive" in info) ? {
|
...("grammaticallyTransitive" in info) ? {
|
||||||
changeTransitivity: function (t) {
|
changeTransitivity: function (t) {
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
import {
|
||||||
|
Types as T,
|
||||||
|
getVerbBlockPosFromPerson,
|
||||||
|
grammarUnits,
|
||||||
|
parseEc,
|
||||||
|
} from "@lingdocs/pashto-inflector";
|
||||||
|
|
||||||
|
export function renderEnglishVPBase({ subjectPerson, object, vs }: {
|
||||||
|
subjectPerson: T.Person,
|
||||||
|
object: NPSelection | ObjectNP,
|
||||||
|
vs: VerbSelection,
|
||||||
|
}): string[] {
|
||||||
|
const ec = parseEc(vs.verb.entry.ec || "");
|
||||||
|
const ep = vs.verb.entry.ep;
|
||||||
|
const tense = vs.tense;
|
||||||
|
function engEquative(tense: "past" | "present", s: T.Person): string {
|
||||||
|
const [row, col] = getVerbBlockPosFromPerson(s);
|
||||||
|
return grammarUnits.englishEquative[tense][row][col];
|
||||||
|
}
|
||||||
|
function engPresC(s: T.Person, ec: T.EnglishVerbConjugationEc | [string, string]): string {
|
||||||
|
function isThirdPersonSing(p: T.Person): boolean {
|
||||||
|
return (
|
||||||
|
p === T.Person.ThirdSingMale ||
|
||||||
|
p === T.Person.ThirdSingFemale
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return isThirdPersonSing(s) ? ec[1] : ec[0];
|
||||||
|
}
|
||||||
|
function isToBe(v: T.EnglishVerbConjugationEc): boolean {
|
||||||
|
return (v[2] === "being");
|
||||||
|
}
|
||||||
|
const futureEngBuilder: T.EnglishBuilder = (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ will${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
]);
|
||||||
|
// TODO: Pull these out to a seperate entity and import it
|
||||||
|
const builders: Record<
|
||||||
|
VerbTense,
|
||||||
|
(s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => string[]
|
||||||
|
> = {
|
||||||
|
present: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ ${isToBe(ec)
|
||||||
|
? `${engEquative("present", s)}${n ? " not" : ""}`
|
||||||
|
: `${n ? engPresC(s, ["don't", "doesn't"]) : ""} ${n ? ec[0] : engPresC(s, ec)}`}`,
|
||||||
|
`$SUBJ ${engEquative("present", s)}${n ? " not" : ""} ${ec[2]}`,
|
||||||
|
]),
|
||||||
|
subjunctive: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`that $SUBJ ${n ? " won't" : " will"} ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
`should $SUBJ ${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
]),
|
||||||
|
imperfectiveFuture: futureEngBuilder,
|
||||||
|
perfectiveFuture: futureEngBuilder,
|
||||||
|
imperfectivePast: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
// - subj pastEquative (N && "not") ec.2 obj
|
||||||
|
`$SUBJ ${engEquative("past", s)}${n ? " not" : ""} ${ec[2]}`,
|
||||||
|
// - subj "would" (N && "not") ec.0 obj
|
||||||
|
`$SUBJ would${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
// - subj pastEquative (N && "not") going to" ec.0 obj
|
||||||
|
`$SUBJ ${engEquative("past", s)}${n ? " not" : ""} going to ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
]),
|
||||||
|
perfectivePast: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ${isToBe(ec)
|
||||||
|
? ` ${engEquative("past", s)}${n ? " not" : ""}`
|
||||||
|
: (n ? ` did not ${ec[0]}` : ` ${ec[3]}`)
|
||||||
|
}`
|
||||||
|
]),
|
||||||
|
habitualPerfectivePast: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ would${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
`$SUBJ used to${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
]),
|
||||||
|
habitualImperfectivePast: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ would${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
`$SUBJ used to${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
]),
|
||||||
|
};
|
||||||
|
const modalBuilders: Record<
|
||||||
|
VerbTense,
|
||||||
|
(s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => string[]
|
||||||
|
> = {
|
||||||
|
present: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ can${n ? "'t" : ""} ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
]),
|
||||||
|
subjunctive: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`that $SUBJ can${n ? "'t" : ""} ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
]),
|
||||||
|
imperfectiveFuture: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ will${n ? " not" : ""} be able to ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
]),
|
||||||
|
perfectiveFuture: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ will${n ? " not" : ""} be able to ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
]),
|
||||||
|
imperfectivePast: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ ${engEquative("past", s)} ${n ? " not" : ""} able to ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
`$SUBJ could${n ? " not" : ""} ${v[0]}`,
|
||||||
|
]),
|
||||||
|
perfectivePast: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ ${engEquative("past", s)} ${n ? " not" : ""} able to ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
`$SUBJ could${n ? " not" : ""} ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
]),
|
||||||
|
habitualImperfectivePast: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ used to ${n ? " not" : ""} be able to ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
`$SUBJ would ${n ? " not" : ""} be able to ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
]),
|
||||||
|
habitualPerfectivePast: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
|
`$SUBJ used to ${n ? " not" : ""} be able to ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
`$SUBJ would ${n ? " not" : ""} be able to ${isToBe(v) ? "be" : v[0]}`,
|
||||||
|
]),
|
||||||
|
};
|
||||||
|
const base = (vs.tenseCategory === "basic" ? builders : modalBuilders)[tense](subjectPerson, ec, vs.negative);
|
||||||
|
return base.map(b => `${b}${typeof object === "object" ? " $OBJ" : ""}${ep ? ` ${ep}` : ""}`);
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import {
|
||||||
isPastTense,
|
isPastTense,
|
||||||
} from "./vp-tools";
|
} from "./vp-tools";
|
||||||
import { isPattern4Entry } from "../type-predicates";
|
import { isPattern4Entry } from "../type-predicates";
|
||||||
|
import { renderEnglishVPBase } from "./english-vp-rendering";
|
||||||
|
|
||||||
// TODO: ISSUE GETTING SPLIT HEAD NOT MATCHING WITH FUTURE VERBS
|
// TODO: ISSUE GETTING SPLIT HEAD NOT MATCHING WITH FUTURE VERBS
|
||||||
|
|
||||||
|
@ -139,89 +140,18 @@ function renderVerbSelection(vs: VerbSelection, person: T.Person, objectPerson:
|
||||||
return {
|
return {
|
||||||
...vs,
|
...vs,
|
||||||
person,
|
person,
|
||||||
...getPsVerbConjugation(conj, vs.tense, person, objectPerson),
|
...getPsVerbConjugation(conj, vs.tense, vs.tenseCategory, person, objectPerson),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderEnglishVPBase({ subjectPerson, object, vs }: {
|
function getPsVerbConjugation(conj: T.VerbConjugation, tense: VerbTense, tenseCategory: "basic" | "modal", person: T.Person, objectPerson: T.Person | undefined): {
|
||||||
subjectPerson: T.Person,
|
|
||||||
object: NPSelection | ObjectNP,
|
|
||||||
vs: VerbSelection,
|
|
||||||
}): string[] {
|
|
||||||
const ec = parseEc(vs.verb.entry.ec || "");
|
|
||||||
const ep = vs.verb.entry.ep;
|
|
||||||
const tense = vs.tense;
|
|
||||||
function engEquative(tense: "past" | "present", s: T.Person): string {
|
|
||||||
const [row, col] = getVerbBlockPosFromPerson(s);
|
|
||||||
return grammarUnits.englishEquative[tense][row][col];
|
|
||||||
}
|
|
||||||
function engPresC(s: T.Person, ec: T.EnglishVerbConjugationEc | [string, string]): string {
|
|
||||||
function isThirdPersonSing(p: T.Person): boolean {
|
|
||||||
return (
|
|
||||||
p === T.Person.ThirdSingMale ||
|
|
||||||
p === T.Person.ThirdSingFemale
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return isThirdPersonSing(s) ? ec[1] : ec[0];
|
|
||||||
}
|
|
||||||
function isToBe(v: T.EnglishVerbConjugationEc): boolean {
|
|
||||||
return (v[2] === "being");
|
|
||||||
}
|
|
||||||
const futureEngBuilder: T.EnglishBuilder = (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
|
||||||
`$SUBJ will${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
|
||||||
]);
|
|
||||||
// TODO: Pull these out to a seperate entity and import it
|
|
||||||
const builders: Record<
|
|
||||||
VerbTense,
|
|
||||||
(s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => string[]
|
|
||||||
> = {
|
|
||||||
present: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
|
||||||
`$SUBJ ${isToBe(ec)
|
|
||||||
? `${engEquative("present", s)}${n ? " not" : ""}`
|
|
||||||
: `${n ? engPresC(s, ["don't", "doesn't"]) : ""} ${n ? ec[0] : engPresC(s, ec)}`}`,
|
|
||||||
`$SUBJ ${engEquative("present", s)}${n ? " not" : ""} ${ec[2]}`,
|
|
||||||
]),
|
|
||||||
subjunctive: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
|
||||||
`that $SUBJ ${n ? " won't" : " will"} ${isToBe(ec) ? "be" : ec[0]}`,
|
|
||||||
`should $SUBJ ${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
|
||||||
]),
|
|
||||||
imperfectiveFuture: futureEngBuilder,
|
|
||||||
perfectiveFuture: futureEngBuilder,
|
|
||||||
imperfectivePast: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
|
||||||
// - subj pastEquative (N && "not") ec.2 obj
|
|
||||||
`$SUBJ ${engEquative("past", s)}${n ? " not" : ""} ${ec[2]}`,
|
|
||||||
// - subj "would" (N && "not") ec.0 obj
|
|
||||||
`$SUBJ would${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
|
||||||
// - subj pastEquative (N && "not") going to" ec.0 obj
|
|
||||||
`$SUBJ ${engEquative("past", s)}${n ? " not" : ""} going to ${isToBe(ec) ? "be" : ec[0]}`,
|
|
||||||
]),
|
|
||||||
perfectivePast: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
|
||||||
`$SUBJ${isToBe(ec)
|
|
||||||
? ` ${engEquative("past", s)}${n ? " not" : ""}`
|
|
||||||
: (n ? ` did not ${ec[0]}` : ` ${ec[3]}`)
|
|
||||||
}`
|
|
||||||
]),
|
|
||||||
habitualPerfectivePast: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
|
||||||
`$SUBJ would${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
|
||||||
`$SUBJ used to${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
|
||||||
]),
|
|
||||||
habitualImperfectivePast: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
|
||||||
`$SUBJ would${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
|
||||||
`$SUBJ used to${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
|
||||||
]),
|
|
||||||
};
|
|
||||||
const base = builders[tense](subjectPerson, ec, vs.negative);
|
|
||||||
return base.map(b => `${b}${typeof object === "object" ? " $OBJ" : ""}${ep ? ` ${ep}` : ""}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPsVerbConjugation(conj: T.VerbConjugation, tense: VerbTense, person: T.Person, objectPerson: T.Person | undefined): {
|
|
||||||
ps: {
|
ps: {
|
||||||
head: T.PsString | undefined,
|
head: T.PsString | undefined,
|
||||||
rest: T.SingleOrLengthOpts<T.PsString[]>,
|
rest: T.SingleOrLengthOpts<T.PsString[]>,
|
||||||
},
|
},
|
||||||
hasBa: boolean,
|
hasBa: boolean,
|
||||||
} {
|
} {
|
||||||
const f = getTenseVerbForm(conj, tense);
|
const f = getTenseVerbForm(conj, tense, tenseCategory);
|
||||||
const block = getMatrixBlock(f, objectPerson, person);
|
const block = getMatrixBlock(f, objectPerson, person);
|
||||||
const perfective = isPerfective(tense);
|
const perfective = isPerfective(tense);
|
||||||
const verbForm = getVerbFromBlock(block, person);
|
const verbForm = getVerbFromBlock(block, person);
|
||||||
|
@ -233,12 +163,10 @@ function getPsVerbConjugation(conj: T.VerbConjugation, tense: VerbTense, person:
|
||||||
// TODO: Either solve this in the inflector or here, it seems silly (or redundant)
|
// TODO: Either solve this in the inflector or here, it seems silly (or redundant)
|
||||||
// to have a length option in the perfective split stem??
|
// to have a length option in the perfective split stem??
|
||||||
const [splitHead] = getLong(getMatrixBlock(splitInfo, objectPerson, person));
|
const [splitHead] = getLong(getMatrixBlock(splitInfo, objectPerson, person));
|
||||||
|
const ps = getHeadAndRest(splitHead, verbForm);
|
||||||
return {
|
return {
|
||||||
hasBa,
|
hasBa,
|
||||||
ps: {
|
ps,
|
||||||
head: splitHead,
|
|
||||||
rest: removeHead(splitHead, verbForm),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return { hasBa, ps: { head: undefined, rest: verbForm }};
|
return { hasBa, ps: { head: undefined, rest: verbForm }};
|
||||||
|
@ -261,30 +189,42 @@ function getVerbFromBlock(block: T.SingleOrLengthOpts<T.VerbBlock>, person: T.Pe
|
||||||
return grabFromBlock(block, pos);
|
return grabFromBlock(block, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeHead(head: T.PsString, rest: T.PsString[]): T.PsString[];
|
function getHeadAndRest(head: T.PsString, rest: T.PsString[]): { head: T.PsString | undefined, rest: T.PsString[] };
|
||||||
function removeHead(head: T.PsString, rest: T.SingleOrLengthOpts<T.PsString[]>): T.SingleOrLengthOpts<T.PsString[]>;
|
function getHeadAndRest(head: T.PsString, rest: T.SingleOrLengthOpts<T.PsString[]>): { head: T.PsString | undefined, rest: T.SingleOrLengthOpts<T.PsString[]> };
|
||||||
function removeHead(head: T.PsString, rest: T.SingleOrLengthOpts<T.PsString[]>): T.SingleOrLengthOpts<T.PsString[]> {
|
function getHeadAndRest(head: T.PsString, rest: T.SingleOrLengthOpts<T.PsString[]>): { head: T.PsString | undefined, rest: T.SingleOrLengthOpts<T.PsString[]> } {
|
||||||
if ("long" in rest) {
|
if ("long" in rest) {
|
||||||
return {
|
return {
|
||||||
long: removeHead(head, rest.long),
|
// whether or not to include the head (for irreg tlul) -- eww // TODO: make nicer?
|
||||||
short: removeHead(head, rest.short),
|
head: removeBa(rest.long[0]).p.slice(0, head.p.length) === head.p
|
||||||
...rest.mini ? {
|
? head : undefined,
|
||||||
mini: removeHead(head, rest.mini),
|
rest: {
|
||||||
} : {},
|
long: getHeadAndRest(head, rest.long).rest,
|
||||||
}
|
short: getHeadAndRest(head, rest.short).rest,
|
||||||
|
...rest.mini ? {
|
||||||
|
mini: getHeadAndRest(head, rest.mini).rest,
|
||||||
|
} : {},
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return rest.map((psRaw) => {
|
let headMismatch = false;
|
||||||
|
const restM = rest.map((psRaw) => {
|
||||||
const ps = removeBa(psRaw);
|
const ps = removeBa(psRaw);
|
||||||
const pMatches = removeAccents(ps.p.slice(0, head.p.length)) === head.p
|
const pMatches = removeAccents(ps.p.slice(0, head.p.length)) === head.p
|
||||||
const fMatches = removeAccents(ps.f.slice(0, head.f.length)) === removeAccents(head.f);
|
const fMatches = removeAccents(ps.f.slice(0, head.f.length)) === removeAccents(head.f);
|
||||||
if (!(pMatches && fMatches)) {
|
if (!(pMatches && fMatches)) {
|
||||||
throw new Error(`split head does not match - ${JSON.stringify(ps)} ${JSON.stringify(head)}`);
|
headMismatch = true;
|
||||||
|
return psRaw;
|
||||||
|
// throw new Error(`split head does not match - ${JSON.stringify(ps)} ${JSON.stringify(head)}`);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
p: ps.p.slice(head.p.length),
|
p: ps.p.slice(head.p.length),
|
||||||
f: ps.f.slice(head.f.length),
|
f: ps.f.slice(head.f.length),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return {
|
||||||
|
head: headMismatch ? undefined : head,
|
||||||
|
rest: restM,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMatrixBlock<U>(f: {
|
function getMatrixBlock<U>(f: {
|
||||||
|
@ -313,30 +253,58 @@ function getMatrixBlock<U>(f: {
|
||||||
return f[personToLabel(person)];
|
return f[personToLabel(person)];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTenseVerbForm(conj: T.VerbConjugation, tense: VerbTense): T.VerbForm {
|
function getTenseVerbForm(conj: T.VerbConjugation, tense: VerbTense, tenseCategory: "basic" | "modal"): T.VerbForm {
|
||||||
if (tense === "present") {
|
if (tenseCategory === "basic") {
|
||||||
return conj.imperfective.nonImperative;
|
if (tense === "present") {
|
||||||
|
return conj.imperfective.nonImperative;
|
||||||
|
}
|
||||||
|
if (tense === "subjunctive") {
|
||||||
|
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 === "subjunctive") {
|
if (tenseCategory === "modal") {
|
||||||
return conj.perfective.nonImperative;
|
if (tense === "present") {
|
||||||
}
|
return conj.imperfective.modal.nonImperative;
|
||||||
if (tense === "imperfectiveFuture") {
|
}
|
||||||
return conj.imperfective.future;
|
if (tense === "subjunctive") {
|
||||||
}
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw new Error("unknown tense");
|
throw new Error("unknown tense");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ type VerbSelection = {
|
||||||
verb: VerbEntry,
|
verb: VerbEntry,
|
||||||
dynAuxVerb?: VerbEntry,
|
dynAuxVerb?: VerbEntry,
|
||||||
tense: VerbTense,
|
tense: VerbTense,
|
||||||
|
tenseCategory: "basic" | "modal",
|
||||||
object: VerbObject, // TODO: should have a locked in (but number changeable noun) here for dynamic compounds
|
object: VerbObject, // TODO: should have a locked in (but number changeable noun) here for dynamic compounds
|
||||||
transitivity: import("@lingdocs/pashto-inflector").Types.Transitivity,
|
transitivity: import("@lingdocs/pashto-inflector").Types.Transitivity,
|
||||||
isCompound: "stative" | "dynamic" | false,
|
isCompound: "stative" | "dynamic" | false,
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = [
|
||||||
|
{ ts: 1527816016, e: "Pashto" }, // پښټو
|
||||||
|
]
|
File diff suppressed because one or more lines are too long
|
@ -1684,10 +1684,10 @@
|
||||||
pbf "^3.2.1"
|
pbf "^3.2.1"
|
||||||
rambda "^6.7.0"
|
rambda "^6.7.0"
|
||||||
|
|
||||||
"@lingdocs/pashto-inflector@^1.5.9":
|
"@lingdocs/pashto-inflector@^1.6.2":
|
||||||
version "1.5.9"
|
version "1.6.2"
|
||||||
resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-1.5.9.tgz#a5d13b71b39f989aab97fc86aff8e586404a5cde"
|
resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-1.6.2.tgz#956fa4c27af9d0d6e2643cfbd8a3ff1c76edffc5"
|
||||||
integrity sha512-ApWnlTwutQbgbXzh7kCwUJ3nVUISgd8C4O0pkIMIZwkXX8/3ItBEm4+9tHuvuIqBW3qrIDa7+iUNk957Lr39mw==
|
integrity sha512-sCjuzznCmqLkd8U7xr6JMNu7OMgNyAbInC2Szx7JROSOAByv2le3ldeidt/ZuzQN8Plq+oMkIti+VoJ9R7Tg1w==
|
||||||
dependencies:
|
dependencies:
|
||||||
classnames "^2.2.6"
|
classnames "^2.2.6"
|
||||||
pbf "^3.2.1"
|
pbf "^3.2.1"
|
||||||
|
|
Loading…
Reference in New Issue