This commit is contained in:
lingdocs 2022-03-23 23:28:27 +05:00
parent f0ff07aedb
commit b88312ba74
12 changed files with 41 additions and 24 deletions

View File

@ -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 }) {
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 }) {
const v = verbs.find(v => v.entry.ts.toString() === value);
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>
<Select
value={verb && verb.verb.entry.ts.toString()}

View File

@ -10,7 +10,7 @@ import {
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 }) {
const entry = nouns.find(n => n.ts.toString() === value);
if (!entry) {
@ -19,7 +19,7 @@ function NPNounPicker({ onChange, noun, nouns }: { nouns: NounEntry[], noun: Nou
}
onChange(makeNounSelection(entry));
}
return <div style={{ maxWidth: "225px", minWidth: "150px" }}>
return <div style={{ maxWidth: "225px", minWidth: "125px" }}>
<Select
value={noun && noun.entry.ts.toString()}
// @ts-ignore

View File

@ -10,7 +10,7 @@ import { nouns, verbs } from "../../words/words";
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
const [npType, setNpType] = useState<NPType | undefined>(np ? np.type : undefined);
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>}
{np ?
((np.type === "pronoun"
? <PronounPicker pronoun={np} onChange={onChange} />
? <PronounPicker asObject={asObject} pronoun={np} onChange={onChange} />
: np.type === "noun"
? <NounPicker nouns={nouns} noun={np} onChange={onChange} />
: <ParticiplePicker verbs={verbs} participle={np} onChange={onChange} />))

View File

@ -10,13 +10,17 @@ const gColors = {
fem: "pink",
};
const labels = {
const labels = (asObject: boolean) => ({
persons: [
["1st", "1st pl."],
["2nd", "2nd pl."],
["3rd", "3rd pl."],
],
e: [
e: asObject ? [
["me", "us"],
["you", "you pl."],
[{ masc: "him/it", fem: "her/it"}, "them"],
] : [
["I", "We"],
["You", "You pl."],
[{ masc: "He/It", fem: "She/It"}, "They"],
@ -33,7 +37,7 @@ const labels = {
[{ masc: "دی", fem: "دا" }, "دوي"],
],
},
};
});
type PickerState = { row: number, col: number, gender: T.Gender };
@ -51,7 +55,7 @@ function pickerStateToPerson(s: PickerState): T.Person {
+ (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 p = personToPickerState(pronoun.person);
@ -83,9 +87,9 @@ function NPPronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onC
: "persons";
setDisplay(newPerson);
}
const prs = labels[display];
const prs = labels(!!asObject)[display];
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">
<ButtonSelect
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>
</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>
{pSpec.map((rw, i) => (
<tr>

View File

@ -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>
</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>
{pSpec.map((rw, i) => (
<tr>

View File

@ -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 }) {
return (typeof object === "number")
? <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;

View File

@ -9,7 +9,9 @@ import {
isInvalidSubjObjCombo,
} 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 {
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
// IT CAN SAY THE COMBO IS NOT ALLOWED AND SHOW SOMETHING BLANK
// TODO: error handling on error with rendering etc
@ -64,9 +74,13 @@ export function PhraseBuilder() {
const verbPhrase: VPSelection | undefined = verbPhraseComplete({ subject, verb });
const VPRendered = verbPhrase && renderVP(verbPhrase);
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="mb-2">
<div className="h4">Subject {(VPRendered && VPRendered.king === "subject") ? "👑" : ""}</div>
<div className="h4">Subject {showRole(VPRendered, "subject")}</div>
<NPPicker
np={subject}
counterPart={verb ? verb.object : undefined}
@ -74,7 +88,7 @@ export function PhraseBuilder() {
/>
</div>
{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} />
</div>}
<div className="mb-2">

View File

@ -22,7 +22,7 @@ function VPDisplay({ VP }: { VP: VPSelection }) {
const [form, setForm] = useState<FormVersion>("full");
// TODO: Possibly put the servant shrinking in here after the render
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">
<div className="my-3">
<ButtonSelect

View File

@ -131,7 +131,6 @@ function combineEntities(loe: ListOfEntities): T.PsString[] {
function compileVerbWNegative(head: T.PsString | undefined, restRaw: T.PsString[], negative: boolean): ListOfEntities {
console.log({ head, restRaw });
const rest = restRaw.map(removeBa);
if (!negative) {
return [

View File

@ -126,7 +126,8 @@ function renderVerbSelection(vs: VerbSelection, person: T.Person, objectPerson:
// TODO: error handle this?
// TODO: option to manually select these
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
? conjugations.stative
: 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)
// to have a length option in the perfective split stem??
const [splitHead] = getLong(getMatrixBlock(splitInfo, objectPerson, person));
console.log("removing from verb form", { splitHead, verbForm });
console.log(removeHead(splitHead, verbForm));
return {
hasBa,
ps: {

View File

@ -1,4 +1,5 @@
module.exports = [
{ ts: 1527812797, e: "woman" }, // xudza
{ ts: 1527816466, e: `peace` }, // صلح - sUlha
{ ts: 1527816589, e: `plan` }, // طرح - tarha
{ ts: 1589023873660, e: `victory, conquest` }, // فتح - fathá

File diff suppressed because one or more lines are too long