working more with dynamic / passive
This commit is contained in:
parent
12039e6cb8
commit
91458c0114
|
@ -69,7 +69,13 @@ const perfectTenseOptions: { label: string | JSX.Element, value: PerfectTense }[
|
|||
// grammaticallyTransitive: boolean,
|
||||
// }
|
||||
|
||||
function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbSelection | undefined, onChange: (p: VerbSelection) => void }) {
|
||||
function VerbPicker({ onChange, subject, changeSubject, verb, verbs }: {
|
||||
verbs: VerbEntry[],
|
||||
verb: VerbSelection | undefined,
|
||||
subject: NPSelection | undefined,
|
||||
onChange: (p: VerbSelection) => void,
|
||||
changeSubject: (p: NPSelection | undefined) => void,
|
||||
}) {
|
||||
// const [filters, useFilters] = useState<Filters>({
|
||||
// stative: true,
|
||||
// dynamic: true,
|
||||
|
@ -84,7 +90,7 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
|
|||
console.error("entry not found");
|
||||
return;
|
||||
}
|
||||
onChange(makeVerbSelection(v, verb));
|
||||
onChange(makeVerbSelection(v, changeSubject, verb));
|
||||
}
|
||||
function onTenseSelect({ value }: { label: string | JSX.Element, value: VerbTense | PerfectTense }) {
|
||||
if (verb) {
|
||||
|
@ -146,7 +152,13 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
|
|||
}
|
||||
function onVoiceSelect(value: "active" | "passive") {
|
||||
if (verb && verb.changeVoice) {
|
||||
onChange(verb.changeVoice(value));
|
||||
if (value === "passive" && (typeof verb.object === "object")) {
|
||||
changeSubject(verb.object);
|
||||
}
|
||||
if (value === "active") {
|
||||
changeSubject(undefined);
|
||||
}
|
||||
onChange(verb.changeVoice(value, value === "active" ? subject : undefined));
|
||||
}
|
||||
}
|
||||
function notInstransitive(t: "transitive" | "intransitive" | "grammatically transitive"): "transitive" | "grammatically transitive" {
|
||||
|
@ -275,7 +287,7 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
|
|||
</div>;
|
||||
}
|
||||
|
||||
function makeVerbSelection(verb: VerbEntry, oldVerbSelection?: VerbSelection): VerbSelection {
|
||||
function makeVerbSelection(verb: VerbEntry, changeSubject: (s: NPSelection | undefined) => void, oldVerbSelection?: VerbSelection): VerbSelection {
|
||||
const info = getVerbInfo(verb.entry, verb.complement);
|
||||
function getTransObjFromOldVerbSelection() {
|
||||
if (
|
||||
|
@ -292,11 +304,14 @@ function makeVerbSelection(verb: VerbEntry, oldVerbSelection?: VerbSelection): V
|
|||
: info.transitivity;
|
||||
const object = (transitivity === "grammatically transitive")
|
||||
? T.Person.ThirdPlurMale
|
||||
: info.type === "dynamic compound"
|
||||
: (info.type === "dynamic compound" && oldVerbSelection?.voice !== "passive")
|
||||
? makeNounSelection(info.objComplement.entry as NounEntry, true)
|
||||
: (transitivity === "transitive" && oldVerbSelection?.voice !== "passive")
|
||||
? getTransObjFromOldVerbSelection()
|
||||
: "none";
|
||||
if (oldVerbSelection?.voice === "passive" && info.type === "dynamic compound") {
|
||||
changeSubject(makeNounSelection(info.objComplement.entry as NounEntry, true));
|
||||
}
|
||||
const isCompound = ("stative" in info || info.type === "stative compound")
|
||||
? "stative"
|
||||
: info.type === "dynamic compound"
|
||||
|
@ -361,11 +376,11 @@ function makeVerbSelection(verb: VerbEntry, oldVerbSelection?: VerbSelection): V
|
|||
}
|
||||
} : {},
|
||||
...(transitivity === "transitive") ? {
|
||||
changeVoice: function(v) {
|
||||
changeVoice: function(v, s) {
|
||||
return {
|
||||
...this,
|
||||
voice: v,
|
||||
object: v === "passive" ? "none" : undefined,
|
||||
object: v === "active" ? s : "none",
|
||||
};
|
||||
},
|
||||
} : {},
|
||||
|
|
|
@ -18,8 +18,8 @@ const servantEmoji = "🙇♂️";
|
|||
export function PhraseBuilder() {
|
||||
const [subject, setSubject] = useState<NPSelection | undefined>(undefined);
|
||||
const [verb, setVerb] = useState<VerbSelection | undefined>(undefined);
|
||||
function handleSubjectChange(subject: NPSelection | undefined) {
|
||||
if (hasPronounConflict(subject, verb?.object)) {
|
||||
function handleSubjectChange(subject: NPSelection | undefined, skipPronounConflictCheck?: boolean) {
|
||||
if (!skipPronounConflictCheck && hasPronounConflict(subject, verb?.object)) {
|
||||
alert("That combination of pronouns is not allowed");
|
||||
return;
|
||||
}
|
||||
|
@ -74,7 +74,13 @@ export function PhraseBuilder() {
|
|||
</div>}
|
||||
<div className="my-2">
|
||||
<div className="h4">Verb</div>
|
||||
<VerbPicker verbs={verbs} verb={verb} onChange={setVerb} />
|
||||
<VerbPicker
|
||||
verbs={verbs}
|
||||
verb={verb}
|
||||
subject={subject}
|
||||
changeSubject={(s) => handleSubjectChange(s, true)}
|
||||
onChange={setVerb}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{verbPhrase && <div>
|
||||
|
|
|
@ -30,7 +30,8 @@ export function compileVP(VP: VPRendered, form: Form, combineLengths?: true): {
|
|||
});
|
||||
return {
|
||||
ps: combineLengths ? flattenLengths(psResult) : psResult,
|
||||
e: compileEnglish(VP),
|
||||
// TODO: English doesn't quite work for dynamic compounds in passive voice
|
||||
e: (VP.verb.voice === "passive" && VP.isCompound === "dynamic") ? undefined : compileEnglish(VP),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ type VerbSelection = {
|
|||
voice: "active" | "passive",
|
||||
changeTransitivity?: (t: "transitive" | "grammatically transitive") => VerbSelection,
|
||||
changeStatDyn?: (t: "stative" | "dynamic") => VerbSelection,
|
||||
changeVoice?: (v: "active" | "passive") => VerbSelection,
|
||||
changeVoice?: (v: "active" | "passive", subj?: NPSelection) => VerbSelection,
|
||||
// TODO: changeStativeDynamic
|
||||
// TODO: add in aspect element here??
|
||||
negative: boolean,
|
||||
|
|
Loading…
Reference in New Issue