beta of both versions of aay tail included

This commit is contained in:
lingdocs 2021-07-24 14:43:35 +03:00
parent 7a8edbc4ce
commit beb24bc820
5 changed files with 683 additions and 809 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "0.8.4", "version": "0.8.5",
"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

@ -33,7 +33,6 @@ const VerbChoiceWarning = () => (
const stateLocalStorageName = "explorerState6"; const stateLocalStorageName = "explorerState6";
type Difficulty = "beginner" | "advanced";
// remember to increment the stateLocalStorageName whenever changing // remember to increment the stateLocalStorageName whenever changing
// the State type // the State type
type State = { type State = {
@ -45,7 +44,6 @@ type State = {
transitivitySelected: "transitive" | "grammatically transitive"; transitivitySelected: "transitive" | "grammatically transitive";
compoundComplementVersionSelected: "sing" | "plur"; compoundComplementVersionSelected: "sing" | "plur";
showingStemsAndRoots: boolean; showingStemsAndRoots: boolean;
difficulty: Difficulty;
formsOpened: string[]; formsOpened: string[];
showingFormInfo: boolean; showingFormInfo: boolean;
} }
@ -56,9 +54,6 @@ type Action = {
} | { } | {
type: "set forms opened", type: "set forms opened",
payload: string, payload: string,
} | {
type: "set difficulty",
payload: Difficulty,
} | { } | {
type: "set compound complement version", type: "set compound complement version",
payload: "sing" | "plur", payload: "sing" | "plur",
@ -119,8 +114,6 @@ function reducer(state: State, action: Action): State {
...state, ...state,
formsOpened: applyFormOpen(action.payload, state.formsOpened), formsOpened: applyFormOpen(action.payload, state.formsOpened),
}; };
case "set difficulty":
return { ...state, difficulty: action.payload };
case "set compound complement version": case "set compound complement version":
return { ...state, compoundComplementVersionSelected: action.payload }; return { ...state, compoundComplementVersionSelected: action.payload };
case "toggle showingStemsAndRoots": case "toggle showingStemsAndRoots":
@ -166,7 +159,6 @@ const initialState: State = {
transitivitySelected: "transitive", transitivitySelected: "transitive",
mode: "chart", mode: "chart",
compoundComplementVersionSelected: "plur", compoundComplementVersionSelected: "plur",
difficulty: "beginner",
showingStemsAndRoots: false, showingStemsAndRoots: false,
showingFormInfo: false, showingFormInfo: false,
formsOpened: [], formsOpened: [],
@ -223,9 +215,6 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight
ep: entry.ep, ep: entry.ep,
} : undefined; } : undefined;
const filterDifficulty = (f: T.DisplayForm): boolean => (
state.difficulty === "advanced" || !!showOnly || !f.advanced
);
const limitTo = !showOnly const limitTo = !showOnly
? undefined ? undefined
: Array.isArray(showOnly) : Array.isArray(showOnly)
@ -234,7 +223,6 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight
const forms = getForms({ const forms = getForms({
conj: verbConj, conj: verbConj,
filterFunc: [ filterFunc: [
filterDifficulty,
...limitTo ? [(f: T.DisplayForm): boolean => limitTo.includes(f.label) ...limitTo ? [(f: T.DisplayForm): boolean => limitTo.includes(f.label)
] : [], ] : [],
], ],
@ -317,16 +305,6 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight
/> />
</div>} </div>}
{!limitTo && <> {!limitTo && <>
<div className="mb-3">
<ButtonSelect
options={[
{ label: "👶 Beginner", value: "beginner" },
{ label: "🤓 Advanced", value: "advanced" },
]}
value={state.difficulty}
handleChange={(p) => dispatch({ type: "set difficulty", payload: p as Difficulty })}
/>
</div>
<div className="form-group form-check"> <div className="form-group form-check">
<input <input
type="checkbox" type="checkbox"

View File

@ -193,6 +193,22 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
englishBuilder: futureEngBuilder, englishBuilder: futureEngBuilder,
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",
}, },
...conj.imperfective.imperative ?
[{
label: "Imperfective Imperative",
aspect: "imperfective",
form: conj.imperfective.imperative,
formula: "Imperfective Stem + Imperative Ending",
explanation: "Commanding someone/people to do something repeatedly, or in general",
} as T.DisplayForm] : [],
...conj.perfective.imperative ?
[{
label: "Perfective Imperative",
aspect: "perfective",
form: conj.perfective.imperative,
formula: "Perfective Stem + Imperative Ending",
explanation: "Commanding someone/people to do something one time",
} as T.DisplayForm] : [],
{ {
label: "Continuous Past", label: "Continuous Past",
aspect: "imperfective", aspect: "imperfective",
@ -222,6 +238,98 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
explanation: "Saying something happened ('I ____ed')", explanation: "Saying something happened ('I ____ed')",
past: true, past: true,
}, },
{
label: "Perfect",
subgroup: "perfect",
sentence: true,
content: [
{
label: "Half Perfect",
form: conj.perfect.halfPerfect,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engHave(s)}${n ? " not" : ""} ${v[4]}`,
]),
formula: "Past participle inflected",
secondPronounNeeded: true,
explanation: "The base of all perfect forms. Used on it's own as a sort of weaker form of the present perfect.",
},
{
label: "Past Perfect",
form: conj.perfect.past,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} had${n ? " not" : ""} ${v[4]}`,
]),
formula: "Past participle inflected + Past Equative",
explanation: "Talking about events that had happened in the past, or had affected a past situation ('I had ____ed')",
reorderWithNegative: true,
},
{
label: "Present Perfect",
form: conj.perfect.present,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engHave(s)}${n ? " not" : ""} ${v[4]}`,
]),
formula: "Past participle inflected + Present Equative",
explanation: "Talking about that something happened in the past and it affects the present ('I have _____ed')",
reorderWithNegative: true,
},
{
label: "Subjunctive/Habitual Perfect",
form: conj.perfect.subjunctive,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`that ${engSubj(s, true)} will have${n ? " not" : ""} ${v[4]}`,
]),
formula: "Past participle inflected + Subjunctive/Habitual Equative",
explanation: "Talking about something that will have happened habitually, or expressing hope, desire, or judgement about an action having happened",
reorderWithNegative: true,
},
{
label: "Future/Presumptive Perfect",
form: conj.perfect.future,
advanced: true,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} have ${v[4]}`,
]),
formula: "به - ba + Past participle Inflected + Future Equative",
explanation: "Talking about something that will have happened in the future, or guessing that the event will have occured presently ('I will have ____ed')",
reorderWithNegative: true,
},
{
label: "Affirmational Perfect",
form: conj.perfect.affirmational,
advanced: true,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} have ${v[4]}`,
]),
explanation: "Affirming that an event will have taken place ('I will have ____ed')",
formula: "به - ba + Past Participle Inflected + Past Equative",
reorderWithNegative: true,
},
{
label: "Conterfactual/Past Subjunctive Perfect",
form: conj.perfect.pastSubjunctiveHypothetical,
advanced: true,
past: true,
sentence: true,
secondPronounNeeded: true,
explanation: "Talking about an event that would have hypothetically taken place (but didn't), or that should have taken place but didn't",
formula: "به - ba + Past Participle Inflected + Past Subjunctive / Hypothetical Equative",
reorderWithNegative: true,
},
],
},
{ {
label: "Modal (ability/possibility)", label: "Modal (ability/possibility)",
subgroup: "modal", subgroup: "modal",
@ -332,114 +440,6 @@ const formsOfConjugation = (conj: T.VerbConjugation): T.DisplayFormItem[] => [
}, },
], ],
}, },
...conj.imperfective.imperative ?
[{
label: "Imperfective Imperative",
aspect: "imperfective",
form: conj.imperfective.imperative,
formula: "Imperfective Stem + Imperative Ending",
explanation: "Commanding someone/people to do something repeatedly, or in general",
} as T.DisplayForm] : [],
...conj.perfective.imperative ?
[{
label: "Perfective Imperative",
aspect: "perfective",
form: conj.perfective.imperative,
formula: "Perfective Stem + Imperative Ending",
explanation: "Commanding someone/people to do something one time",
} as T.DisplayForm] : [],
{
label: "Perfect",
subgroup: "perfect",
sentence: true,
content: [
{
label: "Half Perfect",
form: conj.perfect.halfPerfect,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engHave(s)}${n ? " not" : ""} ${v[4]}`,
]),
formula: "Past participle inflected",
secondPronounNeeded: true,
explanation: "The base of all perfect forms. Used on it's own as a sort of weaker form of the present perfect.",
},
{
label: "Past Perfect",
form: conj.perfect.past,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} had${n ? " not" : ""} ${v[4]}`,
]),
formula: "Past participle inflected + Past Equative",
explanation: "Talking about events that had happened in the past, or had affected a past situation ('I had ____ed')",
reorderWithNegative: true,
},
{
label: "Present Perfect",
form: conj.perfect.present,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} ${engHave(s)}${n ? " not" : ""} ${v[4]}`,
]),
formula: "Past participle inflected + Present Equative",
explanation: "Talking about that something happened in the past and it affects the present ('I have _____ed')",
reorderWithNegative: true,
},
{
label: "Subjunctive/Habitual Perfect",
form: conj.perfect.subjunctive,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`that ${engSubj(s, true)} will have${n ? " not" : ""} ${v[4]}`,
]),
formula: "Past participle inflected + Subjunctive/Habitual Equative",
explanation: "Talking about something that will have happened habitually, or expressing hope, desire, or judgement about an action having happened",
reorderWithNegative: true,
},
{
label: "Future/Presumptive Perfect",
form: conj.perfect.future,
advanced: true,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} have ${v[4]}`,
]),
formula: "به - ba + Past participle Inflected + Future Equative",
explanation: "Talking about something that will have happened in the future, or guessing that the event will have occured presently ('I will have ____ed')",
reorderWithNegative: true,
},
{
label: "Affirmational Perfect",
form: conj.perfect.affirmational,
advanced: true,
past: true,
sentence: true,
englishBuilder: (s: T.Person, v: T.EnglishVerbConjugationEc, n: boolean) => ([
`${engSubj(s)} will${n ? " not" : ""} have ${v[4]}`,
]),
explanation: "Affirming that an event will have taken place ('I will have ____ed')",
formula: "به - ba + Past Participle Inflected + Past Equative",
reorderWithNegative: true,
},
{
label: "Conterfactual/Past Subjunctive Perfect",
form: conj.perfect.pastSubjunctiveHypothetical,
advanced: true,
past: true,
sentence: true,
secondPronounNeeded: true,
explanation: "Talking about an event that would have hypothetically taken place (but didn't), or that should have taken place but didn't",
formula: "به - ba + Past Participle Inflected + Past Subjunctive / Hypothetical Equative",
reorderWithNegative: true,
},
],
},
{ {
label: "Hypothetical/Wish", label: "Hypothetical/Wish",
advanced: true, advanced: true,

File diff suppressed because it is too large Load Diff

View File

@ -118,7 +118,7 @@ function conjugateDynamicCompound(info: T.DynamicCompoundVerbInfo): T.VerbConjug
? info.objComplement.plural ? info.objComplement.plural
: psStringFromEntry(info.objComplement.entry); : psStringFromEntry(info.objComplement.entry);
const makeAspectContent = (aspect: T.Aspect): T.AspectContent => { const makeAspectContent = (aspect: T.Aspect): T.AspectContent => {
const makeModalContent = (): T.ModalContent => { const makeDynamicModalContent = (): T.ModalContent => {
const nonImperative = addToForm([complement, " "], auxConj[aspect].modal.nonImperative); const nonImperative = addToForm([complement, " "], auxConj[aspect].modal.nonImperative);
const future = addToForm([baParticle, " "], nonImperative); const future = addToForm([baParticle, " "], nonImperative);
const past = addToForm([complement, " "], auxConj[aspect].modal.past); const past = addToForm([complement, " "], auxConj[aspect].modal.past);
@ -137,7 +137,7 @@ function conjugateDynamicCompound(info: T.DynamicCompoundVerbInfo): T.VerbConjug
? addToForm([complement, " "], ac.imperative) ? addToForm([complement, " "], ac.imperative)
: null; : null;
const past = addToForm([complement, " "], auxConj[aspect].past); const past = addToForm([complement, " "], auxConj[aspect].past);
const modal = makeModalContent(); const modal = makeDynamicModalContent();
return { return {
nonImperative, nonImperative,
future, future,
@ -228,10 +228,10 @@ function makeJoinedModalContent(info: T.NonComboVerbInfo, aspectIn: T.Aspect): T
const aspect: T.Aspect = noPerfectiveModal(info) ? "imperfective" : aspectIn; const aspect: T.Aspect = noPerfectiveModal(info) ? "imperfective" : aspectIn;
const aux = stativeAux.intransitive.perfective; const aux = stativeAux.intransitive.perfective;
const rAndT = info.yulEnding const rAndT = info.yulEnding
? concatPsString(noPersInfs(info.root[aspect]).long, aayTail[1]) ? [concatPsString(noPersInfs(info.root[aspect]).long, aayTail[1]), concatPsString(noPersInfs(info.root[aspect]).long, aayTail[0])]
: concatPsString(noPersInfs(info.root[aspect]), aayTail[1]); : [concatPsString(noPersInfs(info.root[aspect]), aayTail[1]), concatPsString(noPersInfs(info.root[aspect]), aayTail[0])]
const rootAndTail = aspect === "imperfective" const rootAndTail = aspect === "imperfective"
? accentImperfectiveModalRootAndTail(info, rAndT) ? rAndT.map((x: T.PsString | T.LengthOptions<T.PsString>) => accentImperfectiveModalRootAndTail(info, x))
: rAndT; : rAndT;
const nonImperative = addToForm([rootAndTail, " "], aux.nonImperative); const nonImperative = addToForm([rootAndTail, " "], aux.nonImperative);
@ -241,7 +241,31 @@ function makeJoinedModalContent(info: T.NonComboVerbInfo, aspectIn: T.Aspect): T
// @ts-ignore // @ts-ignore
aux.past.short, aux.past.short,
); );
const hypotheticalPast = addToForm([rootAndTail, " ", { p: "شو", f: "shw" }, aayTail], emptyVerbBlock); function mhp(rt: T.PsString[]): T.VerbBlock {
const form = [
concatPsString(rt[0], " ", { p: "سو", f: "shw" }, aayTail[0]),
concatPsString(rt[0], " ", { p: "سو", f: "shw" }, aayTail[1]),
concatPsString(rt[1], " ", { p: "سو", f: "shw" }, aayTail[0]),
] as T.ArrayOneOrMore<T.PsString>;
return [
[form, form],
[form, form],
[form, form],
[form, form],
[form, form],
[form, form],
];
}
const hypotheticalPast = "short" in rootAndTail[0]
? {
short: mhp(rootAndTail.map((rt) => "short" in rt ? rt.short : rt)),
long: mhp(rootAndTail.map((rt) => "short" in rt ? rt.long : rt)),
} : mhp(rootAndTail.map((rt) => "short" in rt ? rt.long : rt));
// const hypotheticalPast = [
// [concatPsString(rootAndTail[0], " ", { p: "سو", f: "shw" }, aayTail[0])]
// ]
// const hypotheticalPast = addToForm([rootAndTail, " ", { p: "شو", f: "shw" }, aayTail[0]], emptyVerbBlock);
return { return {
nonImperative, // ROOT + aayTail + kedulStat subjunctive nonImperative, // ROOT + aayTail + kedulStat subjunctive
future, // به - ba + modal nonImperative future, // به - ba + modal nonImperative
@ -324,12 +348,26 @@ function makeHypotheticalContent(info: T.NonComboVerbInfo): T.VerbForm {
), ),
]; ];
}; };
const hyp = { const short = makeHypothetical(info.root.imperfective, "short") as T.ArrayOneOrMore<T.PsString>;
short: makeHypothetical(info.root.imperfective, "short"), const long = makeHypothetical(info.root.imperfective, "long") as T.ArrayOneOrMore<T.PsString>;
long: makeHypothetical(info.root.imperfective, "long"), return {
short: [
[short, short],
[short, short],
[short, short],
[short, short],
[short, short],
[short, short],
],
long: [
[long, long],
[long, long],
[long, long],
[long, long],
[long, long],
[long, long],
],
}; };
// TODO: ADD TO FORM IS NOT ADDING THE SECOND VARIATION PASSED IN!
return addToForm([hyp], emptyVerbBlock);
} }
function makeParticipleContent(info: T.NonComboVerbInfo): T.ParticipleContent { function makeParticipleContent(info: T.NonComboVerbInfo): T.ParticipleContent {