stat/dyn choice

This commit is contained in:
lingdocs 2022-03-29 15:19:21 +05:00
parent 90fec81da9
commit 4d7fec9813
5 changed files with 42 additions and 4 deletions

View File

@ -85,7 +85,12 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
if (verb && verb.changeTransitivity) {
onChange(verb.changeTransitivity(t));
}
}
}
function handleChangeStatDyn(c: "stative" | "dynamic") {
if (verb && verb.changeStatDyn) {
onChange(verb.changeStatDyn(c));
}
}
return <div style={{ maxWidth: "225px", minWidth: "125px" }}>
<div>Verb:</div>
<Select
@ -140,6 +145,20 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
handleChange={handleChangeTransitivity}
/>
</div>}
{verb && verb.changeStatDyn && <div className="text-center">
<ButtonSelect
small
options={[{
label: "stative",
value: "stative",
}, {
label: "dynamic",
value: "dynamic",
}]}
value={verb.isCompound ? verb.isCompound : "stative"}
handleChange={handleChangeStatDyn}
/>
</div>}
</div>;
}
@ -170,6 +189,7 @@ function makeVerbSelection(verb: VerbEntry, oldVerbSelection?: VerbSelection): V
: info.type === "dynamic compound"
? "dynamic"
: false;
// TODO: here and below in the changeStatDyn function ... allow for entries with complement
const dynAuxVerb: VerbEntry | undefined = isCompound !== "dynamic"
? undefined
: info.type === "dynamic compound"
@ -195,6 +215,20 @@ function makeVerbSelection(verb: VerbEntry, oldVerbSelection?: VerbSelection): V
};
},
} : {},
...("stative" in info) ? {
changeStatDyn: function (c) {
return {
...this,
isCompound: c,
object: c === "dynamic"
? makeNounSelection(info.dynamic.objComplement.entry as NounEntry, true)
: undefined,
dynAuxVerb: c === "dynamic"
? { entry: info.dynamic.auxVerb } as VerbEntry
: undefined,
};
}
} : {},
};
}

View File

@ -3,7 +3,7 @@ import NPPicker from "../np-picker/NPPicker";
import VerbPicker from "../VerbPicker";
import VPDisplay from "./VPDisplay";
import ObjectDisplay from "./ObjectDisplay";
import { verbs as verbsRaw } from "../../words/words";
import { verbs } from "../../words/words";
import { renderVP } from "../../lib/phrase-building";
import {
isInvalidSubjObjCombo,
@ -11,7 +11,6 @@ import {
const kingEmoji = "👑";
const servantEmoji = "🙇‍♂️";
const verbs = verbsRaw;
// TODO: Ability to choose stative/dynamic compounds when both work

View File

@ -44,6 +44,7 @@ type VerbSelection = {
transitivity: import("@lingdocs/pashto-inflector").Types.Transitivity,
isCompound: "stative" | "dynamic" | false,
changeTransitivity?: (t: "transitive" | "grammatically transitive") => VerbSelection,
changeStatDyn?: (t: "stative" | "dynamic") => VerbSelection,
// TODO: changeStativeDynamic
// TODO: add in aspect element here??
negative: boolean,

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
module.exports = [
{ ts: 1527819253 },
{ ts: 1527812566 },
];