support for English phrasal verbs

This commit is contained in:
lingdocs 2021-07-05 11:21:57 +03:00
parent 3c0ef80de7
commit d3647ee0d5
10 changed files with 74 additions and 52 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "0.5.2", "version": "0.5.3",
"author": "lingdocs.com", "author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com", "homepage": "https://verbs.lingdocs.com",

View File

@ -312,6 +312,7 @@ function App() {
conjugation={conjugation} conjugation={conjugation}
textOptions={textOptions} textOptions={textOptions}
ec={v ? v.verb.entry.ec : undefined} ec={v ? v.verb.entry.ec : undefined}
ep={v ? v.verb.entry.ep : undefined}
/>} />}
</div> </div>
</main> </main>

View File

@ -171,10 +171,11 @@ const initialState: State = {
formsOpened: [], formsOpened: [],
}; };
function ConjugationViewer({ conjugation, textOptions, ec }: { function ConjugationViewer({ conjugation, textOptions, ec, ep }: {
conjugation: T.VerbOutput, conjugation: T.VerbOutput,
textOptions: T.TextOptions, textOptions: T.TextOptions,
ec?: string | undefined, ec?: string | undefined,
ep?: string | undefined,
}) { }) {
const [state, dispatch] = useReducer(reducer, initialState); const [state, dispatch] = useReducer(reducer, initialState);
useEffect(() => { useEffect(() => {
@ -196,7 +197,10 @@ function ConjugationViewer({ conjugation, textOptions, ec }: {
const verbConj = (verbConj1.singularForm && state.compoundComplementVersionSelected === "sing") const verbConj = (verbConj1.singularForm && state.compoundComplementVersionSelected === "sing")
? verbConj1.singularForm ? verbConj1.singularForm
: verbConj1; : verbConj1;
const englishConjugation = parseEc(ec); const englishConjugation: T.EnglishVerbConjugation | undefined = ec ? {
ec: parseEc(ec),
ep: ep,
} : undefined;
useEffect(() => { useEffect(() => {
localStorage.setItem(stateLocalStorageName, JSON.stringify(state)); localStorage.setItem(stateLocalStorageName, JSON.stringify(state));

View File

@ -12,6 +12,18 @@ import * as T from "../types";
type PsStringWSub = T.PsString & { sub?: any }; type PsStringWSub = T.PsString & { sub?: any };
function EnglishContent({ children }: { children: (string | JSX.Element)[] | (string | JSX.Element) }) {
if (Array.isArray(children)) {
console.log(children);
return <>
{children.map((x) => <EnglishContent>{x}</EnglishContent>)}
</>
}
return <div className="text-muted">
{children}
</div>;
}
function Examples({ function Examples({
children, children,
ex, ex,
@ -30,9 +42,9 @@ function Examples({
<div> <div>
<Phonetics opts={opts}>{text}</Phonetics> <Phonetics opts={opts}>{text}</Phonetics>
</div> </div>
{text.e && <div className="text-muted"> {text.e && <EnglishContent>
{text.e} {text.e}
</div>} </EnglishContent>}
{text.sub && <div className="small text-muted"> {text.sub && <div className="small text-muted">
{text.sub} {text.sub}
</div>} </div>}

View File

@ -19,7 +19,7 @@ function SingleItemDisplay({ item, textOptions, english }: {
return <div className="text-center mt-3 mb-2"> return <div className="text-center mt-3 mb-2">
<div><Pashto opts={textOptions}>{item}</Pashto></div> <div><Pashto opts={textOptions}>{item}</Pashto></div>
<div><Phonetics opts={textOptions}>{item}</Phonetics></div> <div><Phonetics opts={textOptions}>{item}</Phonetics></div>
{eng && <div>{eng}</div>} {eng && <div className="text-muted">{eng}</div>}
</div>; </div>;
} }

View File

@ -35,7 +35,9 @@ function TableCell({ item, textOptions, center, noBorder }: {
<div> <div>
<Phonetics opts={textOptions}>{w}</Phonetics> <Phonetics opts={textOptions}>{w}</Phonetics>
</div> </div>
{w.e && <div className="text-muted">{w.e}</div>} {w.e && (Array.isArray(w.e)
? w.e.map(e => <div key={e} className="text-muted small">{e}</div>)
: <div className="text-muted">{w.e}</div>)}
</div> </div>
{item.length > 1 && {item.length > 1 &&
<button className="btn btn-sm btn-light mx-2 my-2" onClick={advanceVersion}> <button className="btn btn-sm btn-light mx-2 my-2" onClick={advanceVersion}>

View File

@ -126,9 +126,11 @@ export default function addPronouns({ s, subject, object, info, displayForm, int
mini: miniPronoun, mini: miniPronoun,
}; };
const english = (displayForm.englishBuilder && englishConjugation) const english = (displayForm.englishBuilder && englishConjugation)
? displayForm.englishBuilder(subject, englishConjugation, negative).map(baseS => ( ? displayForm.englishBuilder(subject, englishConjugation.ec, negative).map(baseS => (
(intransitive || info.transitivity === "grammatically transitive") ? baseS : `${baseS} ${engObj(object)}` (intransitive || info.transitivity === "grammatically transitive")
)).join(" / ") ? baseS
: `${baseS} ${engObj(object)}${englishConjugation.ep ? ` ${englishConjugation.ep}` : ""}`
))
: undefined; : undefined;
function attachPronounsToVariation(ps: T.PsString, prns: Pronouns): T.ArrayOneOrMore<T.PsString> { function attachPronounsToVariation(ps: T.PsString, prns: Pronouns): T.ArrayOneOrMore<T.PsString> {

View File

@ -141,7 +141,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.imperfective.nonImperative, form: conj.imperfective.nonImperative,
formula: "Imperfective Stem + Present Ending", formula: "Imperfective Stem + Present Ending",
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${n ? `${engPresC(s, ["don't", "doesn't"])} ` : ""}${n ? v[0] : engPresC(s, v)}`, `${engSubj(s)} ${n ? `${engPresC(s, ["don't", "doesn't"])} ` : ""}${n ? v[0] : engPresC(s, v)}`,
`${engSubj(s)} ${engEquative("present", s)}${n ? " not" : ""} ${v[2]}`, `${engSubj(s)} ${engEquative("present", s)}${n ? " not" : ""} ${v[2]}`,
]), ]),
@ -153,7 +153,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.perfective.nonImperative, form: conj.perfective.nonImperative,
formula: "Perfective Stem + Present Ending", formula: "Perfective Stem + Present Ending",
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`that ${engSubj(s, true)}${n ? " won't" : "'ll"} ${v[0]}`, `that ${engSubj(s, true)}${n ? " won't" : "'ll"} ${v[0]}`,
`should ${engSubj(s, true)}${n ? " not" : ""} ${v[0]}`, `should ${engSubj(s, true)}${n ? " not" : ""} ${v[0]}`,
]), ]),
@ -166,7 +166,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
advanced: true, advanced: true,
formula: "به - ba + Present", formula: "به - ba + Present",
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} ${v[0]}`, `${engSubj(s)} will${n ? " not" : ""} ${v[0]}`,
]), ]),
explanation: "Saying something will happen, repeatedly or as an ongoing action", explanation: "Saying something will happen, repeatedly or as an ongoing action",
@ -178,7 +178,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
advanced: true, advanced: true,
formula: "به - ba + Subjunctive", formula: "به - ba + Subjunctive",
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} ${v[0]}`, `${engSubj(s)} will${n ? " not" : ""} ${v[0]}`,
]), ]),
explanation: "Saying something will happen as a one-time event - May also used when there is some doubt", explanation: "Saying something will happen as a one-time event - May also used when there is some doubt",
@ -189,7 +189,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.imperfective.past, form: conj.imperfective.past,
formula: "Imperfective Root + Past Ending", formula: "Imperfective Root + Past Ending",
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
// - subj "was" (N && "not") v.2 obj // - subj "was" (N && "not") v.2 obj
`${engSubj(s)} ${engEquative("past", s)}${n ? " not" : ""} ${v[2]}`, `${engSubj(s)} ${engEquative("past", s)}${n ? " not" : ""} ${v[2]}`,
// - subj "would" (N && "not") v.0 obj // - subj "would" (N && "not") v.0 obj
@ -204,7 +204,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.perfective.past, form: conj.perfective.past,
formula: "Perfective Root + Past Ending", formula: "Perfective Root + Past Ending",
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)}${n ? " did not" : ""} ${v[3]}`, `${engSubj(s)}${n ? " did not" : ""} ${v[3]}`,
]), ]),
explanation: "Saying something happened ('I ____ed')", explanation: "Saying something happened ('I ____ed')",
@ -220,7 +220,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
aspect: "imperfective", aspect: "imperfective",
form: conj.imperfective.modal.nonImperative, form: conj.imperfective.modal.nonImperative,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} can${n ? "'t" : ""} ${v[0]}`, `${engSubj(s)} can${n ? "'t" : ""} ${v[0]}`,
]), ]),
formula: "Imperfective Root + Non-Inflectinig Ey-Tail + Subjunctive کېدل - to become", formula: "Imperfective Root + Non-Inflectinig Ey-Tail + Subjunctive کېدل - to become",
@ -233,7 +233,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.perfective.modal.nonImperative, form: conj.perfective.modal.nonImperative,
advanced: true, advanced: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`that ${engSubj(s, true)} can${n ? "'t" : ""} ${v[0]}`, `that ${engSubj(s, true)} can${n ? "'t" : ""} ${v[0]}`,
]), ]),
formula: "Perfective Root + Non-Inflectinig Ey-Tail + Subjunctive کېدل - to become", formula: "Perfective Root + Non-Inflectinig Ey-Tail + Subjunctive کېدل - to become",
@ -246,7 +246,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.imperfective.modal.future, form: conj.imperfective.modal.future,
advanced: true, advanced: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} be able to ${v[0]}`, `${engSubj(s)} will${n ? " not" : ""} be able to ${v[0]}`,
]), ]),
formula: "به - ba + Present Modal", formula: "به - ba + Present Modal",
@ -259,7 +259,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.perfective.modal.future, form: conj.perfective.modal.future,
advanced: true, advanced: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} be able to ${v[0]}`, `${engSubj(s)} will${n ? " not" : ""} be able to ${v[0]}`,
]), ]),
formula: "به - ba + Subjunctive Modal", formula: "به - ba + Subjunctive Modal",
@ -273,7 +273,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
advanced: true, advanced: true,
past: true, past: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engEquative("past", s)} ${n ? " not" : ""} able to ${v[0]}`, `${engSubj(s)} ${engEquative("past", s)} ${n ? " not" : ""} able to ${v[0]}`,
`${engSubj(s)} could${n ? " not" : ""} ${v[0]}`, `${engSubj(s)} could${n ? " not" : ""} ${v[0]}`,
]), ]),
@ -288,7 +288,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
formula: "Perfective Root + Non-Inflectinig Ey-Tail + Simple Past کېدل - to become", formula: "Perfective Root + Non-Inflectinig Ey-Tail + Simple Past کېدل - to become",
explanation: "saying that something was possible at a certain point in time ('I was able to ____, at one particular point in time')", explanation: "saying that something was possible at a certain point in time ('I was able to ____, at one particular point in time')",
past: true, past: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engEquative("past", s)} ${n ? " not" : ""} able to ${v[0]}`, `${engSubj(s)} ${engEquative("past", s)} ${n ? " not" : ""} able to ${v[0]}`,
`${engSubj(s)} could${n ? " not" : ""} ${v[0]}`, `${engSubj(s)} could${n ? " not" : ""} ${v[0]}`,
]), ]),
@ -325,7 +325,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
label: "Imperfective Imperative", label: "Imperfective Imperative",
aspect: "imperfective", aspect: "imperfective",
form: conj.imperfective.imperative, form: conj.imperfective.imperative,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${v[0]}`, `${v[0]}`,
]), ]),
formula: "Imperfective Stem + Imperative Ending", formula: "Imperfective Stem + Imperative Ending",
@ -336,7 +336,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
label: "Perfective Imperative", label: "Perfective Imperative",
aspect: "perfective", aspect: "perfective",
form: conj.perfective.imperative, form: conj.perfective.imperative,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${v[0]}`, `${v[0]}`,
]), ]),
formula: "Perfective Stem + Imperative Ending", formula: "Perfective Stem + Imperative Ending",
@ -352,7 +352,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.perfect.halfPerfect, form: conj.perfect.halfPerfect,
past: true, past: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engHave(s)}${n ? " not" : ""} ${v[4]}`, `${engSubj(s)} ${engHave(s)}${n ? " not" : ""} ${v[4]}`,
]), ]),
formula: "Past participle inflected", formula: "Past participle inflected",
@ -364,7 +364,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.perfect.past, form: conj.perfect.past,
past: true, past: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} had${n ? " not" : ""} ${v[4]}`, `${engSubj(s)} had${n ? " not" : ""} ${v[4]}`,
]), ]),
formula: "Past participle inflected + Past Equative", formula: "Past participle inflected + Past Equative",
@ -376,7 +376,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.perfect.present, form: conj.perfect.present,
past: true, past: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engHave(s)}${n ? " not" : ""} ${v[4]}`, `${engSubj(s)} ${engHave(s)}${n ? " not" : ""} ${v[4]}`,
]), ]),
formula: "Past participle inflected + Present Equative", formula: "Past participle inflected + Present Equative",
@ -388,7 +388,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.perfect.subjunctive, form: conj.perfect.subjunctive,
past: true, past: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`that ${engSubj(s, true)} will have${n ? " not" : ""} ${v[4]}`, `that ${engSubj(s, true)} will have${n ? " not" : ""} ${v[4]}`,
]), ]),
formula: "Past participle inflected + Subjunctive/Habitual Equative", formula: "Past participle inflected + Subjunctive/Habitual Equative",
@ -401,7 +401,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
advanced: true, advanced: true,
past: true, past: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} have ${v[4]}`, `${engSubj(s)} will${n ? " not" : ""} have ${v[4]}`,
]), ]),
formula: "به - ba + Past participle Inflected + Future Equative", formula: "به - ba + Past participle Inflected + Future Equative",
@ -414,7 +414,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
advanced: true, advanced: true,
past: true, past: true,
sentence: true, sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} have ${v[4]}`, `${engSubj(s)} will${n ? " not" : ""} have ${v[4]}`,
]), ]),
explanation: "Affirming that an event will have taken place ('I will have ____ed')", explanation: "Affirming that an event will have taken place ('I will have ____ed')",
@ -475,7 +475,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.passive.imperfective.nonImperative, form: conj.passive.imperfective.nonImperative,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engEquative("present", s)}${n ? " not" : ""} being ${v[4]}`, `${engSubj(s)} ${engEquative("present", s)}${n ? " not" : ""} being ${v[4]}`,
]), ]),
formula: "Long Imperfective Root + Present کېدل - to become", formula: "Long Imperfective Root + Present کېدل - to become",
@ -487,7 +487,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.passive.perfective.nonImperative, form: conj.passive.perfective.nonImperative,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`that ${engSubj(s, true)} will${n ? " not" : ""} be ${v[4]}`, `that ${engSubj(s, true)} will${n ? " not" : ""} be ${v[4]}`,
]), ]),
formula: "Long Perfective Root + Subjunctive کېدل - to become", formula: "Long Perfective Root + Subjunctive کېدل - to become",
@ -499,7 +499,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.passive.imperfective.future, form: conj.passive.imperfective.future,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} be ${v[4]}`, `${engSubj(s)} will${n ? " not" : ""} be ${v[4]}`,
]), ]),
formula: "به - ba + Passive Present", formula: "به - ba + Passive Present",
@ -511,7 +511,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
form: conj.passive.perfective.future, form: conj.passive.perfective.future,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} be ${v[4]}`, `${engSubj(s)} will${n ? " not" : ""} be ${v[4]}`,
]), ]),
formula: "به - ba + Passive Subjunctive", formula: "به - ba + Passive Subjunctive",
@ -524,7 +524,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
past: true, past: true,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engEquative("past", s)}${n ? " not" : ""} being ${v[4]}`, `${engSubj(s)} ${engEquative("past", s)}${n ? " not" : ""} being ${v[4]}`,
]), ]),
formula: "Long Imperfective Root + Continuous Past کېدل - to become", formula: "Long Imperfective Root + Continuous Past کېدل - to become",
@ -537,7 +537,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
past: true, past: true,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engEquative("past", s)}${n ? " not" : ""} ${v[4]}`, `${engSubj(s)} ${engEquative("past", s)}${n ? " not" : ""} ${v[4]}`,
]), ]),
formula: "Long Perfective Root + Simple Past کېدل - to become", formula: "Long Perfective Root + Simple Past کېدل - to become",
@ -555,7 +555,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
past: true, past: true,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engHave(s)}${n ? " not" : ""} been ${v[4]}`, `${engSubj(s)} ${engHave(s)}${n ? " not" : ""} been ${v[4]}`,
]), ]),
formula: "Infinitive + کېدل (to be) past participle inflected", formula: "Infinitive + کېدل (to be) past participle inflected",
@ -567,7 +567,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
past: true, past: true,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} had${n ? " not" : ""} been ${v[4]}`, `${engSubj(s)} had${n ? " not" : ""} been ${v[4]}`,
]), ]),
formula: "Infinitive + کېدل (to be) past participle inflected + Past Equative", formula: "Infinitive + کېدل (to be) past participle inflected + Past Equative",
@ -579,7 +579,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
past: true, past: true,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engHave(s)}${n ? " not" : ""} been ${v[4]}`, `${engSubj(s)} ${engHave(s)}${n ? " not" : ""} been ${v[4]}`,
]), ]),
formula: "Infinitive + کېدل (to be) past participle inflected + Present Equative", formula: "Infinitive + کېدل (to be) past participle inflected + Present Equative",
@ -591,7 +591,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
past: true, past: true,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`that ${engSubj(s, true)} will have been ${v[4]}`, `that ${engSubj(s, true)} will have been ${v[4]}`,
]), ]),
formula: "Infinitive + کېدل (to be) past participle inflected + Subjunctive/Habitual Equative", formula: "Infinitive + کېدل (to be) past participle inflected + Subjunctive/Habitual Equative",
@ -603,7 +603,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
past: true, past: true,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will have been ${v[4]}`, `${engSubj(s)} will have been ${v[4]}`,
]), ]),
formula: "به - ba + Infinitive + کېدل (to be) past participle inflected + Future Equative", formula: "به - ba + Infinitive + کېدل (to be) past participle inflected + Future Equative",
@ -616,7 +616,7 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
past: true, past: true,
sentence: true, sentence: true,
passive: true, passive: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugation, n: boolean) => ([ englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will have been ${v[4]}`, `${engSubj(s)} will have been ${v[4]}`,
]), ]),
explanation: "Affirming that an event will have taken place (Passive voice) ('I will have been ____ed')", explanation: "Affirming that an event will have taken place (Passive voice) ('I will have been ____ed')",
@ -675,7 +675,7 @@ function isThirdPerson(p: T.Person): boolean {
); );
} }
function engPresC(s: T.Person, ec: T.EnglishVerbConjugation | [string, string]): string { function engPresC(s: T.Person, ec: T.EnglishVerbConjugationEc | [string, string]): string {
return isThirdPerson(s) ? ec[1] : ec[0]; return isThirdPerson(s) ? ec[1] : ec[0];
} }

View File

@ -214,16 +214,13 @@ export function isNounAdjOrVerb(entry: T.DictionaryEntry): "nounAdj" | "verb" |
* @param ec * @param ec
* @returns * @returns
*/ */
export function parseEc(ec: string | undefined): T.EnglishVerbConjugation | undefined { export function parseEc(ec: string): T.EnglishVerbConjugationEc {
function makeRegularConjugations(s: string): T.EnglishVerbConjugation { function makeRegularConjugations(s: string): T.EnglishVerbConjugationEc {
const b = (s.slice(-1) === "e") const b = (s.slice(-1) === "e")
? s.slice(0, -1) ? s.slice(0, -1)
: s; : s;
return [`${s}`, `${s}s`, `${b}ing`, `${b}ed`, `${b}ed`]; return [`${s}`, `${s}s`, `${b}ing`, `${b}ed`, `${b}ed`];
} }
if (!ec) {
return undefined;
}
const items = ec.split(",").map(x => x.trim()); const items = ec.split(",").map(x => x.trim());
return (items.length !== 5) return (items.length !== 5)
? makeRegularConjugations(items[0]) ? makeRegularConjugations(items[0])

View File

@ -389,8 +389,12 @@ export type ArrayOneOrMore<T> = {
0: T 0: T
} & Array<T> } & Array<T>
/* i.e. ["eat", "eats", "eating", "ate", "eaten"] */ /* i.e. ec: ["take", "takes", "taking", "took", "taken"], ep: out */
export type EnglishVerbConjugation = [string, string, string, string, string]; export type EnglishVerbConjugationEc = [string, string, string, string, string];
export type EnglishVerbConjugation = {
ec: EnglishVerbConjugationEc,
ep: string | undefined,
};
export type DisplayFormItem = DisplayForm | DisplayFormSubgroup | DisplayFormForSentence; export type DisplayFormItem = DisplayForm | DisplayFormSubgroup | DisplayFormForSentence;
@ -399,7 +403,7 @@ export type DisplayForm = {
aspect?: Aspect, aspect?: Aspect,
form: VerbForm | ImperativeForm | ParticipleForm | SentenceForm, form: VerbForm | ImperativeForm | ParticipleForm | SentenceForm,
advanced?: boolean, advanced?: boolean,
englishBuilder?: (subject: Person, ec: EnglishVerbConjugation, neg: boolean) => string[], englishBuilder?: (subject: Person, ec: EnglishVerbConjugationEc, neg: boolean) => string[],
formula: React.ReactNode, formula: React.ReactNode,
explanation: React.ReactNode, explanation: React.ReactNode,
sentence?: boolean, sentence?: boolean,
@ -412,7 +416,7 @@ export type DisplayFormForSentence = {
aspect?: Aspect, aspect?: Aspect,
form: VerbForm, form: VerbForm,
advanced?: boolean, advanced?: boolean,
englishBuilder?: (subject: Person, ec: EnglishVerbConjugation, neg: boolean) => string[], englishBuilder?: (subject: Person, ec: EnglishVerbConjugationEc, neg: boolean) => string[],
formula: React.ReactNode, formula: React.ReactNode,
secondPronounNeeded?: boolean, secondPronounNeeded?: boolean,
explanation: React.ReactNode, explanation: React.ReactNode,