Two bug fixes:

1. Don't show sentence forms when the conjugation viewer is limited to forms
that don't have sentence capability
2. Fixed English conjugation of "they ~sees~ see" etc.
This commit is contained in:
lingdocs 2021-07-20 15:41:55 +03:00
parent 2a16468f52
commit a909ff533f
4 changed files with 15 additions and 27 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "0.8.1", "version": "0.8.2",
"author": "lingdocs.com", "author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com", "homepage": "https://verbs.lingdocs.com",

View File

@ -11,7 +11,6 @@ import ConjugationViewer from "./components/ConjugationViewer";
import verbs from "./verbs"; import verbs from "./verbs";
import Pashto from "./components/Pashto"; import Pashto from "./components/Pashto";
import Phonetics from "./components/Phonetics"; import Phonetics from "./components/Phonetics";
import InlinePs from "./components/InlinePs";
import { getVerbInfo } from "./lib/verb-info"; import { getVerbInfo } from "./lib/verb-info";
import ButtonSelect from "./components/ButtonSelect"; import ButtonSelect from "./components/ButtonSelect";
import { import {
@ -51,7 +50,6 @@ function App() {
const [transitivityShowing, setTransitivityShowing] = useState<T.Transitivity>("intransitive"); const [transitivityShowing, setTransitivityShowing] = useState<T.Transitivity>("intransitive");
const [showingTextOptions, setShowingTextOptions] = useState<boolean>(false); const [showingTextOptions, setShowingTextOptions] = useState<boolean>(false);
const [textOptions, setTextOptions] = useState<T.TextOptions>(defualtTextOptions); const [textOptions, setTextOptions] = useState<T.TextOptions>(defualtTextOptions);
const [aayTailType, setAayTailType] = useState<T.AayTail>("aay");
const [theme, setTheme] = useState<"light" | "dark">("light"); const [theme, setTheme] = useState<"light" | "dark">("light");
// const onlyGrammTrans = (arr: Transitivity[]) => ( // const onlyGrammTrans = (arr: Transitivity[]) => (
// arr.length === 1 && arr[0] === "grammatically transitive" // arr.length === 1 && arr[0] === "grammatically transitive"
@ -69,7 +67,6 @@ function App() {
const transitivitiyShowing = localStorage.getItem("transitivityShowing") as undefined | T.Transitivity; const transitivitiyShowing = localStorage.getItem("transitivityShowing") as undefined | T.Transitivity;
const theme = localStorage.getItem("theme"); const theme = localStorage.getItem("theme");
const textOptionst = localStorage.getItem("textOptions"); const textOptionst = localStorage.getItem("textOptions");
const aayTailType = localStorage.getItem("aayType");
if (regularIrregular) { if (regularIrregular) {
setRegularIrregular(regularIrregular); setRegularIrregular(regularIrregular);
} }
@ -91,9 +88,6 @@ function App() {
if (textOptionst) { if (textOptionst) {
setTextOptions(JSON.parse(textOptionst) as T.TextOptions); setTextOptions(JSON.parse(textOptionst) as T.TextOptions);
} }
if (aayTailType) {
setAayTailType(aayTailType as T.AayTail);
}
}, []); }, []);
useEffect(() => { useEffect(() => {
@ -103,7 +97,6 @@ function App() {
localStorage.setItem("transitivityShowing", transitivityShowing); localStorage.setItem("transitivityShowing", transitivityShowing);
localStorage.setItem("textOptions", JSON.stringify(textOptions)); localStorage.setItem("textOptions", JSON.stringify(textOptions));
localStorage.setItem("theme", theme); localStorage.setItem("theme", theme);
localStorage.setItem("aayType", aayTailType);
}); });
useEffect(() => { useEffect(() => {
@ -301,7 +294,6 @@ function App() {
entry={v?.verb.entry} entry={v?.verb.entry}
complement={v?.verb.complement} complement={v?.verb.complement}
textOptions={textOptions} textOptions={textOptions}
showOnly={["Perfective Future"]}
/>} />}
</div> </div>
</main> </main>
@ -322,20 +314,8 @@ function App() {
...textOptions, ...textOptions,
spelling: p as "Afghan" | "Pakistani", spelling: p as "Afghan" | "Pakistani",
}); });
if (p === "Pakistani") setAayTailType("ey");
}} }}
/> />
{textOptions.spelling !== "Pakistani" && <>
<h6 className="mt-3">Non-Inflecting Tail Spelling</h6>
<ButtonSelect
options={[
{ label: <InlinePs opts={textOptions}>{{ p: "ی", f: "ey" }}</InlinePs>, value: "ey" },
{ label: <InlinePs opts={textOptions}>{{ p: "ای", f: "aay" }}</InlinePs>, value: "aay" },
]}
value={aayTailType}
handleChange={(p) => setAayTailType(p as "ey" | "aay")}
/>
</>}
<h6 className="mt-3">Diacritics</h6> <h6 className="mt-3">Diacritics</h6>
<ButtonSelect <ButtonSelect
options={[ options={[

View File

@ -244,7 +244,8 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight
negative: state.negative, negative: state.negative,
sentenceLevel, sentenceLevel,
englishConjugation, englishConjugation,
}) });
const sentencesAvailable = forms.some((form) => "sentence" in form);
return <div className="mb-4"> return <div className="mb-4">
{"transitive" in conjugation && <div className="text-center my-2"> {"transitive" in conjugation && <div className="text-center my-2">
<VerbChoiceWarning /> <VerbChoiceWarning />
@ -305,7 +306,7 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight
hideTypeInfo={!!limitTo} hideTypeInfo={!!limitTo}
/> />
<div className="d-flex flex-row align-items-center justify-content-around flex-wrap mt-4 mb-2"> <div className="d-flex flex-row align-items-center justify-content-around flex-wrap mt-4 mb-2">
<div className="mb-3"> {sentencesAvailable && <div className="mb-3">
<ButtonSelect <ButtonSelect
options={[ options={[
{ label: `Chart${forms.length !== 1 ? "s" : ""}`, value: "chart" }, { label: `Chart${forms.length !== 1 ? "s" : ""}`, value: "chart" },
@ -314,7 +315,7 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight
value={state.mode} value={state.mode}
handleChange={(p) => dispatch({ type: "setMode", payload: p as "chart" | "sentence" })} handleChange={(p) => dispatch({ type: "setMode", payload: p as "chart" | "sentence" })}
/> />
</div> </div>}
{!limitTo && <> {!limitTo && <>
<div className="mb-3"> <div className="mb-3">
<ButtonSelect <ButtonSelect
@ -339,7 +340,7 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight
</div> </div>
</>} </>}
</div> </div>
{state.mode === "sentence" && {(state.mode === "sentence" && sentencesAvailable) &&
<div className="position-sticky pb-1" style={{ top: 0, background: "var(--theme-shade)", zIndex: 1000 }}> <div className="position-sticky pb-1" style={{ top: 0, background: "var(--theme-shade)", zIndex: 1000 }}>
<PersonSelection <PersonSelection
subject={state.subject} subject={state.subject}
@ -367,7 +368,7 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight
} }
<FormsDisplay <FormsDisplay
forms={forms} forms={forms}
state={state} state={{ ...state, mode: sentencesAvailable ? "chart" : state.mode }}
handleChange={(payload: string) => dispatch({ type: "set forms opened", payload })} handleChange={(payload: string) => dispatch({ type: "set forms opened", payload })}
verbConj={verbConj} verbConj={verbConj}
textOptions={textOptions} textOptions={textOptions}

View File

@ -683,8 +683,15 @@ function isThirdPerson(p: T.Person): boolean {
); );
} }
function isThirdPersonSing(p: T.Person): boolean {
return (
p === T.Person.ThirdSingMale ||
p === T.Person.ThirdSingFemale
);
}
function engPresC(s: T.Person, ec: T.EnglishVerbConjugationEc | [string, string]): string { function engPresC(s: T.Person, ec: T.EnglishVerbConjugationEc | [string, string]): string {
return isThirdPerson(s) ? ec[1] : ec[0]; return isThirdPersonSing(s) ? ec[1] : ec[0];
} }
function engEquative(tense: "past" | "present", s: T.Person): string { function engEquative(tense: "past" | "present", s: T.Person): string {