better
This commit is contained in:
parent
f0ff07aedb
commit
b88312ba74
|
@ -54,7 +54,7 @@ function makeVerbSelection(verb: VerbEntry, oldVerbSelection?: VerbSelection): V
|
||||||
}
|
}
|
||||||
|
|
||||||
function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbSelection | undefined, onChange: (p: VerbSelection) => void }) {
|
function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbSelection | undefined, onChange: (p: VerbSelection) => void }) {
|
||||||
const options = verbs.map(makeVerbSelectOption)
|
const options = verbs.sort((a, b) => (a.entry.p.localeCompare(b.entry.p, "af-PS"))).map(makeVerbSelectOption);
|
||||||
function onEntrySelect({ value }: { label: string, value: string }) {
|
function onEntrySelect({ value }: { label: string, value: string }) {
|
||||||
const v = verbs.find(v => v.entry.ts.toString() === value);
|
const v = verbs.find(v => v.entry.ts.toString() === value);
|
||||||
if (!v) {
|
if (!v) {
|
||||||
|
@ -79,7 +79,7 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <div style={{ maxWidth: "225px", minWidth: "150px" }}>
|
return <div style={{ maxWidth: "225px", minWidth: "125px" }}>
|
||||||
<div>Verb:</div>
|
<div>Verb:</div>
|
||||||
<Select
|
<Select
|
||||||
value={verb && verb.verb.entry.ts.toString()}
|
value={verb && verb.verb.entry.ts.toString()}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
|
|
||||||
|
|
||||||
function NPNounPicker({ onChange, noun, nouns }: { nouns: NounEntry[], noun: NounSelection | undefined, onChange: (p: NounSelection) => void }) {
|
function NPNounPicker({ onChange, noun, nouns }: { nouns: NounEntry[], noun: NounSelection | undefined, onChange: (p: NounSelection) => void }) {
|
||||||
const options = nouns.map(makeSelectOption)
|
const options = nouns.sort((a, b) => (a.p.localeCompare(b.p, "af-PS"))).map(makeSelectOption)
|
||||||
function onEntrySelect({ value }: { label: string, value: string }) {
|
function onEntrySelect({ value }: { label: string, value: string }) {
|
||||||
const entry = nouns.find(n => n.ts.toString() === value);
|
const entry = nouns.find(n => n.ts.toString() === value);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
|
@ -19,7 +19,7 @@ function NPNounPicker({ onChange, noun, nouns }: { nouns: NounEntry[], noun: Nou
|
||||||
}
|
}
|
||||||
onChange(makeNounSelection(entry));
|
onChange(makeNounSelection(entry));
|
||||||
}
|
}
|
||||||
return <div style={{ maxWidth: "225px", minWidth: "150px" }}>
|
return <div style={{ maxWidth: "225px", minWidth: "125px" }}>
|
||||||
<Select
|
<Select
|
||||||
value={noun && noun.entry.ts.toString()}
|
value={noun && noun.entry.ts.toString()}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { nouns, verbs } from "../../words/words";
|
||||||
|
|
||||||
const npTypes: NPType[] = ["pronoun", "noun", "participle"];
|
const npTypes: NPType[] = ["pronoun", "noun", "participle"];
|
||||||
|
|
||||||
function NPPicker({ np, onChange, counterPart }: { onChange: (nps: NPSelection | undefined) => void, np: NPSelection | undefined, counterPart: NPSelection | VerbObject | undefined }) {
|
function NPPicker({ np, onChange, counterPart, asObject }: { onChange: (nps: NPSelection | undefined) => void, np: NPSelection | undefined, counterPart: NPSelection | VerbObject | undefined, asObject?: boolean }) {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const [npType, setNpType] = useState<NPType | undefined>(np ? np.type : undefined);
|
const [npType, setNpType] = useState<NPType | undefined>(np ? np.type : undefined);
|
||||||
function handleClear() {
|
function handleClear() {
|
||||||
|
@ -50,7 +50,7 @@ function NPPicker({ np, onChange, counterPart }: { onChange: (nps: NPSelection |
|
||||||
: <button className="btn btn-sm btn-light mb-2" onClick={handleClear}>X</button>}
|
: <button className="btn btn-sm btn-light mb-2" onClick={handleClear}>X</button>}
|
||||||
{np ?
|
{np ?
|
||||||
((np.type === "pronoun"
|
((np.type === "pronoun"
|
||||||
? <PronounPicker pronoun={np} onChange={onChange} />
|
? <PronounPicker asObject={asObject} pronoun={np} onChange={onChange} />
|
||||||
: np.type === "noun"
|
: np.type === "noun"
|
||||||
? <NounPicker nouns={nouns} noun={np} onChange={onChange} />
|
? <NounPicker nouns={nouns} noun={np} onChange={onChange} />
|
||||||
: <ParticiplePicker verbs={verbs} participle={np} onChange={onChange} />))
|
: <ParticiplePicker verbs={verbs} participle={np} onChange={onChange} />))
|
||||||
|
|
|
@ -10,13 +10,17 @@ const gColors = {
|
||||||
fem: "pink",
|
fem: "pink",
|
||||||
};
|
};
|
||||||
|
|
||||||
const labels = {
|
const labels = (asObject: boolean) => ({
|
||||||
persons: [
|
persons: [
|
||||||
["1st", "1st pl."],
|
["1st", "1st pl."],
|
||||||
["2nd", "2nd pl."],
|
["2nd", "2nd pl."],
|
||||||
["3rd", "3rd pl."],
|
["3rd", "3rd pl."],
|
||||||
],
|
],
|
||||||
e: [
|
e: asObject ? [
|
||||||
|
["me", "us"],
|
||||||
|
["you", "you pl."],
|
||||||
|
[{ masc: "him/it", fem: "her/it"}, "them"],
|
||||||
|
] : [
|
||||||
["I", "We"],
|
["I", "We"],
|
||||||
["You", "You pl."],
|
["You", "You pl."],
|
||||||
[{ masc: "He/It", fem: "She/It"}, "They"],
|
[{ masc: "He/It", fem: "She/It"}, "They"],
|
||||||
|
@ -33,7 +37,7 @@ const labels = {
|
||||||
[{ masc: "دی", fem: "دا" }, "دوي"],
|
[{ masc: "دی", fem: "دا" }, "دوي"],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
|
|
||||||
type PickerState = { row: number, col: number, gender: T.Gender };
|
type PickerState = { row: number, col: number, gender: T.Gender };
|
||||||
|
@ -51,7 +55,7 @@ function pickerStateToPerson(s: PickerState): T.Person {
|
||||||
+ (6 * s.col);
|
+ (6 * s.col);
|
||||||
}
|
}
|
||||||
|
|
||||||
function NPPronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onChange: (p: PronounSelection) => void }) {
|
function NPPronounPicker({ onChange, pronoun, asObject }: { pronoun: PronounSelection, onChange: (p: PronounSelection) => void , asObject?: boolean }) {
|
||||||
const [display, setDisplay] = useStickyState<"persons" | "p" | "e">("persons", "prounoun-picker-display");
|
const [display, setDisplay] = useStickyState<"persons" | "p" | "e">("persons", "prounoun-picker-display");
|
||||||
|
|
||||||
const p = personToPickerState(pronoun.person);
|
const p = personToPickerState(pronoun.person);
|
||||||
|
@ -83,9 +87,9 @@ function NPPronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onC
|
||||||
: "persons";
|
: "persons";
|
||||||
setDisplay(newPerson);
|
setDisplay(newPerson);
|
||||||
}
|
}
|
||||||
const prs = labels[display];
|
const prs = labels(!!asObject)[display];
|
||||||
const pSpec = "near" in prs ? prs[pronoun.distance] : prs;
|
const pSpec = "near" in prs ? prs[pronoun.distance] : prs;
|
||||||
return <div style={{ maxWidth: "225px", padding: 0 }}>
|
return <div style={{ maxWidth: "225px", minWidth: "125px", padding: 0 }}>
|
||||||
<div className="d-flex flex-row justify-content-around mb-3">
|
<div className="d-flex flex-row justify-content-around mb-3">
|
||||||
<ButtonSelect
|
<ButtonSelect
|
||||||
xSmall
|
xSmall
|
||||||
|
@ -98,7 +102,7 @@ function NPPronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onC
|
||||||
/>
|
/>
|
||||||
<button className="btn btn-sm btn-outline" onClick={handleDisplayChange}>{display === "persons" ? "#" : display === "p" ? "PS" : "EN"}</button>
|
<button className="btn btn-sm btn-outline" onClick={handleDisplayChange}>{display === "persons" ? "#" : display === "p" ? "PS" : "EN"}</button>
|
||||||
</div>
|
</div>
|
||||||
<table className="table table-bordered table-sm" style={{ textAlign: "center", minWidth: "200px", tableLayout: "fixed" }}>
|
<table className="table table-bordered table-sm" style={{ textAlign: "center", minWidth: "125px", tableLayout: "fixed" }}>
|
||||||
<tbody>
|
<tbody>
|
||||||
{pSpec.map((rw, i) => (
|
{pSpec.map((rw, i) => (
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -111,7 +111,7 @@ function PronounPicker({ onChange, pronoun, isObject }: {
|
||||||
/>
|
/>
|
||||||
<button className="btn btn-sm btn-outline-secondary" onClick={handleDisplayChange}>{display === "persons" ? "#" : display === "p" ? "PS" : "EN"}</button>
|
<button className="btn btn-sm btn-outline-secondary" onClick={handleDisplayChange}>{display === "persons" ? "#" : display === "p" ? "PS" : "EN"}</button>
|
||||||
</div>
|
</div>
|
||||||
<table className="table table-bordered" style={{ textAlign: "center", minWidth: "160px", tableLayout: "fixed" }}>
|
<table className="table table-bordered" style={{ textAlign: "center", minWidth: "125px", tableLayout: "fixed" }}>
|
||||||
<tbody>
|
<tbody>
|
||||||
{pSpec.map((rw, i) => (
|
{pSpec.map((rw, i) => (
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import NPPicker from "../np-picker/NPPicker";
|
||||||
function ObjectDisplay({ object, onChange, counterPart }: { object: Exclude<VerbObject, "none">, onChange: (o: NPSelection | undefined) => void, counterPart: NPSelection | undefined }) {
|
function ObjectDisplay({ object, onChange, counterPart }: { object: Exclude<VerbObject, "none">, onChange: (o: NPSelection | undefined) => void, counterPart: NPSelection | undefined }) {
|
||||||
return (typeof object === "number")
|
return (typeof object === "number")
|
||||||
? <div className="text-muted">Unspoken 3rd Pers. Masc. Plur.</div>
|
? <div className="text-muted">Unspoken 3rd Pers. Masc. Plur.</div>
|
||||||
: <NPPicker np={object} counterPart={counterPart} onChange={onChange} />;
|
: <NPPicker asObject np={object} counterPart={counterPart} onChange={onChange} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ObjectDisplay;
|
export default ObjectDisplay;
|
||||||
|
|
|
@ -9,7 +9,9 @@ import {
|
||||||
isInvalidSubjObjCombo,
|
isInvalidSubjObjCombo,
|
||||||
} from "../../lib/np-tools";
|
} from "../../lib/np-tools";
|
||||||
|
|
||||||
const verbs = verbsRaw.filter(v => !v.entry.c?.includes("gramm."))
|
const kingEmoji = "👑";
|
||||||
|
const servantEmoji = "🙇♂️";
|
||||||
|
const verbs = verbsRaw;
|
||||||
|
|
||||||
function verbPhraseComplete({ subject, verb }: { subject: NPSelection | undefined, verb: VerbSelection | undefined }): VPSelection | undefined {
|
function verbPhraseComplete({ subject, verb }: { subject: NPSelection | undefined, verb: VerbSelection | undefined }): VPSelection | undefined {
|
||||||
if (!subject) return undefined;
|
if (!subject) return undefined;
|
||||||
|
@ -23,6 +25,14 @@ function verbPhraseComplete({ subject, verb }: { subject: NPSelection | undefine
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showRole(VP: VPRendered | undefined, member: "subject" | "object") {
|
||||||
|
return VP
|
||||||
|
? <span className="ml-2">
|
||||||
|
{(VP.king === member ? kingEmoji : VP.servant === member ? servantEmoji : "")}
|
||||||
|
</span>
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: BIG ISSUE, IF YOU OPEN THE OBJECT PRONOUN BOX AND IT CONFLICTS WITH THE SUBJECT
|
// TODO: BIG ISSUE, IF YOU OPEN THE OBJECT PRONOUN BOX AND IT CONFLICTS WITH THE SUBJECT
|
||||||
// IT CAN SAY THE COMBO IS NOT ALLOWED AND SHOW SOMETHING BLANK
|
// IT CAN SAY THE COMBO IS NOT ALLOWED AND SHOW SOMETHING BLANK
|
||||||
// TODO: error handling on error with rendering etc
|
// TODO: error handling on error with rendering etc
|
||||||
|
@ -64,9 +74,13 @@ export function PhraseBuilder() {
|
||||||
const verbPhrase: VPSelection | undefined = verbPhraseComplete({ subject, verb });
|
const verbPhrase: VPSelection | undefined = verbPhraseComplete({ subject, verb });
|
||||||
const VPRendered = verbPhrase && renderVP(verbPhrase);
|
const VPRendered = verbPhrase && renderVP(verbPhrase);
|
||||||
return <div className="mt-3">
|
return <div className="mt-3">
|
||||||
|
<div className="mb-3">
|
||||||
|
<div>{kingEmoji} = <abbr title="controls the verb conjugation, can be removed">king</abbr> of phrase</div>
|
||||||
|
<div>{servantEmoji} = <abbr title="can be shrunken into a mini-pronoun">servant</abbr> of phrase</div>
|
||||||
|
</div>
|
||||||
<div className="d-flex flex-row justify-content-around flex-wrap">
|
<div className="d-flex flex-row justify-content-around flex-wrap">
|
||||||
<div className="mb-2">
|
<div className="mb-2">
|
||||||
<div className="h4">Subject {(VPRendered && VPRendered.king === "subject") ? "👑" : ""}</div>
|
<div className="h4">Subject {showRole(VPRendered, "subject")}</div>
|
||||||
<NPPicker
|
<NPPicker
|
||||||
np={subject}
|
np={subject}
|
||||||
counterPart={verb ? verb.object : undefined}
|
counterPart={verb ? verb.object : undefined}
|
||||||
|
@ -74,7 +88,7 @@ export function PhraseBuilder() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{verb && (verb.object !== "none") && <div className="mb-2">
|
{verb && (verb.object !== "none") && <div className="mb-2">
|
||||||
<div className="h4">Object {(VPRendered && VPRendered.king === "object") ? "👑" : ""}</div>
|
<div className="h4">Object {showRole(VPRendered, "object")}</div>
|
||||||
<ObjectDisplay object={verb.object} counterPart={subject} onChange={handleObjectChange} />
|
<ObjectDisplay object={verb.object} counterPart={subject} onChange={handleObjectChange} />
|
||||||
</div>}
|
</div>}
|
||||||
<div className="mb-2">
|
<div className="mb-2">
|
||||||
|
|
|
@ -22,7 +22,7 @@ function VPDisplay({ VP }: { VP: VPSelection }) {
|
||||||
const [form, setForm] = useState<FormVersion>("full");
|
const [form, setForm] = useState<FormVersion>("full");
|
||||||
// TODO: Possibly put the servant shrinking in here after the render
|
// TODO: Possibly put the servant shrinking in here after the render
|
||||||
const result = compileVP(renderVP(VP), form);
|
const result = compileVP(renderVP(VP), form);
|
||||||
const servantShrinkable = VP.object && typeof VP.object === "object";
|
const servantShrinkable = VP.object && VP.object !== "none";
|
||||||
return <div className="text-center mt-2">
|
return <div className="text-center mt-2">
|
||||||
<div className="my-3">
|
<div className="my-3">
|
||||||
<ButtonSelect
|
<ButtonSelect
|
||||||
|
|
|
@ -131,7 +131,6 @@ function combineEntities(loe: ListOfEntities): T.PsString[] {
|
||||||
|
|
||||||
|
|
||||||
function compileVerbWNegative(head: T.PsString | undefined, restRaw: T.PsString[], negative: boolean): ListOfEntities {
|
function compileVerbWNegative(head: T.PsString | undefined, restRaw: T.PsString[], negative: boolean): ListOfEntities {
|
||||||
console.log({ head, restRaw });
|
|
||||||
const rest = restRaw.map(removeBa);
|
const rest = restRaw.map(removeBa);
|
||||||
if (!negative) {
|
if (!negative) {
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -126,7 +126,8 @@ function renderVerbSelection(vs: VerbSelection, person: T.Person, objectPerson:
|
||||||
// TODO: error handle this?
|
// TODO: error handle this?
|
||||||
// TODO: option to manually select these
|
// TODO: option to manually select these
|
||||||
const conj = "grammaticallyTransitive" in conjugations
|
const conj = "grammaticallyTransitive" in conjugations
|
||||||
? conjugations.grammaticallyTransitive
|
// BIG TODO: allow for choice of grmatically transitive over transitive if there's both
|
||||||
|
? conjugations.transitive
|
||||||
: "stative" in conjugations
|
: "stative" in conjugations
|
||||||
? conjugations.stative
|
? conjugations.stative
|
||||||
: conjugations;
|
: conjugations;
|
||||||
|
@ -219,8 +220,6 @@ 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));
|
||||||
console.log("removing from verb form", { splitHead, verbForm });
|
|
||||||
console.log(removeHead(splitHead, verbForm));
|
|
||||||
return {
|
return {
|
||||||
hasBa,
|
hasBa,
|
||||||
ps: {
|
ps: {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
module.exports = [
|
module.exports = [
|
||||||
|
{ ts: 1527812797, e: "woman" }, // xudza
|
||||||
{ ts: 1527816466, e: `peace` }, // صلح - sUlha
|
{ ts: 1527816466, e: `peace` }, // صلح - sUlha
|
||||||
{ ts: 1527816589, e: `plan` }, // طرح - tarha
|
{ ts: 1527816589, e: `plan` }, // طرح - tarha
|
||||||
{ ts: 1589023873660, e: `victory, conquest` }, // فتح - fathá
|
{ ts: 1589023873660, e: `victory, conquest` }, // فتح - fathá
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue