bug fixes and better disploy
This commit is contained in:
parent
fc27807858
commit
51d2eeed25
|
@ -12,6 +12,7 @@
|
||||||
"@types/cron": "^1.7.3",
|
"@types/cron": "^1.7.3",
|
||||||
"@types/react-router-dom": "^5.3.1",
|
"@types/react-router-dom": "^5.3.1",
|
||||||
"bootstrap": "4.5.3",
|
"bootstrap": "4.5.3",
|
||||||
|
"classnames": "^2.3.1",
|
||||||
"cron": "^1.8.2",
|
"cron": "^1.8.2",
|
||||||
"markdown-to-jsx": "^7.1.3",
|
"markdown-to-jsx": "^7.1.3",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
|
|
|
@ -79,7 +79,7 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <div style={{ maxWidth: "225px", minWidth: "10px" }}>
|
return <div style={{ maxWidth: "225px", minWidth: "150px" }}>
|
||||||
<div>Verb:</div>
|
<div>Verb:</div>
|
||||||
<Select
|
<Select
|
||||||
value={verb && verb.verb.entry.ts.toString()}
|
value={verb && verb.verb.entry.ts.toString()}
|
||||||
|
|
|
@ -34,7 +34,7 @@ function NPPicker({ np, onChange, counterPart }: { onChange: (nps: NPSelection |
|
||||||
setNpType(ntp);
|
setNpType(ntp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <div style={{ maxWidth: "300px"}}>
|
return <div>
|
||||||
{!npType ? <div className="text-center mt-3">
|
{!npType ? <div className="text-center mt-3">
|
||||||
{npTypes.map((npt) => <div className="mb-2">
|
{npTypes.map((npt) => <div className="mb-2">
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {
|
||||||
ButtonSelect,
|
ButtonSelect,
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
import useStickyState from "../../useStickyState";
|
import useStickyState from "../../useStickyState";
|
||||||
|
import classNames from "classnames";
|
||||||
|
|
||||||
const gColors = {
|
const gColors = {
|
||||||
masc: "LightSkyBlue",
|
masc: "LightSkyBlue",
|
||||||
|
@ -84,7 +85,7 @@ function NPPronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onC
|
||||||
}
|
}
|
||||||
const prs = labels[display];
|
const prs = labels[display];
|
||||||
const pSpec = "near" in prs ? prs[pronoun.distance] : prs;
|
const pSpec = "near" in prs ? prs[pronoun.distance] : prs;
|
||||||
return <div style={{ maxWidth: "225px" }}>
|
return <div style={{ maxWidth: "225px", 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
|
||||||
|
@ -97,7 +98,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" style={{ textAlign: "center", minWidth: "200px", tableLayout: "fixed" }}>
|
<table className="table table-bordered table-sm" style={{ textAlign: "center", minWidth: "200px", tableLayout: "fixed" }}>
|
||||||
<tbody>
|
<tbody>
|
||||||
{pSpec.map((rw, i) => (
|
{pSpec.map((rw, i) => (
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -105,10 +106,12 @@ function NPPronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onC
|
||||||
const active = (p.row === i && p.col === j)
|
const active = (p.row === i && p.col === j)
|
||||||
return <td
|
return <td
|
||||||
onClick={() => handleClick(i, j)}
|
onClick={() => handleClick(i, j)}
|
||||||
className={active ? "table-active" : ""}
|
className={classNames({ "table-active": active })}
|
||||||
style={active ? { backgroundColor: gColors[p.gender] } : {}}
|
style={active ? { backgroundColor: gColors[p.gender] } : {}}
|
||||||
>
|
>
|
||||||
{typeof r === "string" ? r : r[p.gender]}
|
<div className="my-1">
|
||||||
|
{typeof r === "string" ? r : r[p.gender]}
|
||||||
|
</div>
|
||||||
</td>;
|
</td>;
|
||||||
})}
|
})}
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -117,9 +120,10 @@ function NPPronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onC
|
||||||
</table>
|
</table>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<ButtonSelect
|
<ButtonSelect
|
||||||
|
small
|
||||||
options={[
|
options={[
|
||||||
{ label: "Masc.", value: "masc", color: gColors.masc },
|
{ label: <div style={{ margin: "0.15rem"}}>Masc.</div>, value: "masc", color: gColors.masc },
|
||||||
{ label: "Fem.", value: "fem", color: gColors.fem },
|
{ label: <div style={{ margin: "0.15rem"}}>Fem.</div>, value: "fem", color: gColors.fem },
|
||||||
]}
|
]}
|
||||||
value={p.gender}
|
value={p.gender}
|
||||||
handleChange={(g) => handleGenderChange(g as T.Gender)}
|
handleChange={(g) => handleGenderChange(g as T.Gender)}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import VerbPicker from "../VerbPicker";
|
||||||
import VPDisplay from "./VPDisplay";
|
import VPDisplay from "./VPDisplay";
|
||||||
import ObjectDisplay from "./ObjectDisplay";
|
import ObjectDisplay from "./ObjectDisplay";
|
||||||
import { verbs as verbsRaw } from "../../words/words";
|
import { verbs as verbsRaw } from "../../words/words";
|
||||||
|
import { renderVP } from "../../lib/phrase-building";
|
||||||
import {
|
import {
|
||||||
isInvalidSubjObjCombo,
|
isInvalidSubjObjCombo,
|
||||||
} from "../../lib/np-tools";
|
} from "../../lib/np-tools";
|
||||||
|
@ -24,6 +25,7 @@ function verbPhraseComplete({ subject, verb }: { subject: NPSelection | undefine
|
||||||
|
|
||||||
// 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
|
||||||
export function PhraseBuilder() {
|
export function PhraseBuilder() {
|
||||||
const [subject, setSubject] = useState<NPSelection | undefined>(undefined);
|
const [subject, setSubject] = useState<NPSelection | undefined>(undefined);
|
||||||
const [verb, setVerb] = useState<VerbSelection | undefined>(undefined);
|
const [verb, setVerb] = useState<VerbSelection | undefined>(undefined);
|
||||||
|
@ -60,21 +62,22 @@ export function PhraseBuilder() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const verbPhrase: VPSelection | undefined = verbPhraseComplete({ subject, verb });
|
const verbPhrase: VPSelection | undefined = verbPhraseComplete({ subject, verb });
|
||||||
|
const VPRendered = verbPhrase && renderVP(verbPhrase);
|
||||||
return <div className="mt-3">
|
return <div className="mt-3">
|
||||||
<div className="row">
|
<div className="d-flex flex-row justify-content-around flex-wrap">
|
||||||
<div className="col mb-2">
|
<div className="mb-2">
|
||||||
<div className="h4">Subject</div>
|
<div className="h4">Subject {(VPRendered && VPRendered.king === "subject") ? "👑" : ""}</div>
|
||||||
<NPPicker
|
<NPPicker
|
||||||
np={subject}
|
np={subject}
|
||||||
counterPart={verb ? verb.object : undefined}
|
counterPart={verb ? verb.object : undefined}
|
||||||
onChange={handleSubjectChange}
|
onChange={handleSubjectChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{verb && (verb.object !== "none") && <div className="col mb-2">
|
{verb && (verb.object !== "none") && <div className="mb-2">
|
||||||
<div className="h4">Object</div>
|
<div className="h4">Object {(VPRendered && VPRendered.king === "object") ? "👑" : ""}</div>
|
||||||
<ObjectDisplay object={verb.object} counterPart={subject} onChange={handleObjectChange} />
|
<ObjectDisplay object={verb.object} counterPart={subject} onChange={handleObjectChange} />
|
||||||
</div>}
|
</div>}
|
||||||
<div className="col mb-2">
|
<div className="mb-2">
|
||||||
<div className="h4">Verb</div>
|
<div className="h4">Verb</div>
|
||||||
<VerbPicker verbs={verbs} verb={verb} onChange={setVerb} />
|
<VerbPicker verbs={verbs} verb={verb} onChange={setVerb} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,8 @@ import {
|
||||||
grammarUnits,
|
grammarUnits,
|
||||||
getVerbBlockPosFromPerson,
|
getVerbBlockPosFromPerson,
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
import { hasBaParticle, psRemove } from "@lingdocs/pashto-inflector/dist/lib/p-text-helpers";
|
import { hasBaParticle } from "@lingdocs/pashto-inflector/dist/lib/p-text-helpers";
|
||||||
|
import { removeBa } from "./vp-tools";
|
||||||
|
|
||||||
type ListOfEntities = (T.PsString & { isVerbPrefix?: boolean, prefixFollowedByParticle?: boolean })[][];
|
type ListOfEntities = (T.PsString & { isVerbPrefix?: boolean, prefixFollowedByParticle?: boolean })[][];
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ function compileVerbWNegative(head: T.PsString | undefined, restRaw: T.PsString[
|
||||||
} {
|
} {
|
||||||
const hasBa = hasBaParticle(restRaw[0]);
|
const hasBa = hasBaParticle(restRaw[0]);
|
||||||
const rest = hasBa
|
const rest = hasBa
|
||||||
? restRaw.map(ps => psRemove(ps, concatPsString(grammarUnits.baParticle, " ")))
|
? restRaw.map(removeBa)
|
||||||
: restRaw;
|
: restRaw;
|
||||||
if (!negative) {
|
if (!negative) {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -15,10 +15,12 @@ import {
|
||||||
getLong,
|
getLong,
|
||||||
} from "../text-tools";
|
} from "../text-tools";
|
||||||
import {
|
import {
|
||||||
getPersonFromNP,
|
getPersonFromNP, removeBa,
|
||||||
} from "./vp-tools";
|
} from "./vp-tools";
|
||||||
import { isPattern4Entry } from "../type-predicates";
|
import { isPattern4Entry } from "../type-predicates";
|
||||||
|
|
||||||
|
// TODO: ISSUE GETTING SPLIT HEAD NOT MATCHING WITH FUTURE VERBS
|
||||||
|
|
||||||
export function renderVP(VP: VPSelection): VPRendered {
|
export function renderVP(VP: VPSelection): VPRendered {
|
||||||
// Sentence Rules Logic
|
// Sentence Rules Logic
|
||||||
const isPast = isPastTense(VP.verb.tense);
|
const isPast = isPastTense(VP.verb.tense);
|
||||||
|
@ -249,8 +251,9 @@ function removeHead(head: T.PsString, rest: T.SingleOrLengthOpts<T.PsString[]>):
|
||||||
} : {},
|
} : {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rest.map((ps) => {
|
return rest.map((psRaw) => {
|
||||||
const pMatches = removeAccents(ps.p.slice(0, head.p.length)) === removeAccents(head.p);
|
const ps = removeBa(psRaw);
|
||||||
|
const pMatches = removeAccents(ps.p.slice(0, head.p.length)) === head.p
|
||||||
const fMatches = removeAccents(ps.f.slice(0, head.f.length)) === removeAccents(head.f);
|
const fMatches = removeAccents(ps.f.slice(0, head.f.length)) === removeAccents(head.f);
|
||||||
if (!(pMatches && fMatches)) {
|
if (!(pMatches && fMatches)) {
|
||||||
throw new Error(`split head does not match - ${JSON.stringify(ps)} ${JSON.stringify(head)}`);
|
throw new Error(`split head does not match - ${JSON.stringify(ps)} ${JSON.stringify(head)}`);
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import {
|
import {
|
||||||
Types as T,
|
Types as T,
|
||||||
|
concatPsString,
|
||||||
|
grammarUnits,
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
|
import { psRemove } from "@lingdocs/pashto-inflector/dist/lib/p-text-helpers";
|
||||||
|
|
||||||
export function getPersonFromNP(np: NPSelection): T.Person;
|
export function getPersonFromNP(np: NPSelection): T.Person;
|
||||||
export function getPersonFromNP(np: NPSelection | ObjectNP): T.Person | undefined;
|
export function getPersonFromNP(np: NPSelection | ObjectNP): T.Person | undefined;
|
||||||
|
@ -18,4 +21,8 @@ export function getPersonFromNP(np: NPSelection | ObjectNP): T.Person | undefine
|
||||||
return np.number === "plural"
|
return np.number === "plural"
|
||||||
? (np.gender === "masc" ? T.Person.ThirdPlurMale : T.Person.ThirdPlurFemale)
|
? (np.gender === "masc" ? T.Person.ThirdPlurMale : T.Person.ThirdPlurFemale)
|
||||||
: (np.gender === "masc" ? T.Person.ThirdSingMale : T.Person.ThirdSingFemale);
|
: (np.gender === "masc" ? T.Person.ThirdSingMale : T.Person.ThirdSingFemale);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeBa(ps: T.PsString): T.PsString {
|
||||||
|
return psRemove(ps, concatPsString(grammarUnits.baParticle, " "));
|
||||||
}
|
}
|
Loading…
Reference in New Issue