BIG error fixed - the charts were picking up on the negative option left over from the phrase builder and only displaying the imperfective imperative when the negative was selected. Also allowed passive voice on ability verbs.

This commit is contained in:
adueck 2023-01-24 13:48:49 +05:00
parent f7a80efb5e
commit 8c7c89611e
11 changed files with 51 additions and 49 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "pashto-inflector",
"version": "5.4.3",
"version": "5.5.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "pashto-inflector",
"version": "5.4.3",
"version": "5.5.0",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/ps-react",
"version": "5.4.3",
"version": "5.5.0",
"description": "Pashto inflector library module with React components",
"main": "dist/components/library.js",
"module": "dist/components/library.js",

View File

@ -3,7 +3,7 @@ import ChartDisplay from "./VPChartDisplay";
import Hider from "../Hider";
import * as T from "../../../types";
import useStickyState from "../useStickyState";
import { isModalTense, isPerfectTense, isVerbTense } from "../../../lib/src/type-predicates";
import { conjugateVerb } from "../../dist/lib/src/verb-conjugation";
function AllTensesDisplay({ VS, opts }: { VS: T.VerbSelection, opts: T.TextOptions }) {
const [showing, setShowing] = useStickyState<string[]>([], "VPTensesShowing");
@ -22,6 +22,15 @@ function AllTensesDisplay({ VS, opts }: { VS: T.VerbSelection, opts: T.TextOptio
: VS.tenseCategory === "modal"
? abilityTenseOptions
: imperativeTenseOptions;
const rawConjugations = conjugateVerb(VS.verb.entry, VS.verb.complement);
const conjugations = ("stative" in rawConjugations)
? rawConjugations[VS.isCompound === "stative" ? "stative" : "dynamic"]
: ("transitive" in rawConjugations)
? rawConjugations[VS.transitivity === "grammatically transitive" ? "grammaticallyTransitive" : "transitive"]
: rawConjugations;
function getTense(baseTense: T.VerbTense | T.PerfectTense | T.ImperativeTense): T.VerbTense | T.PerfectTense | T.ImperativeTense | T.ModalTense {
return VS.tenseCategory === "modal" ? `${baseTense}Modal` as T.ModalTense : baseTense;
}
return <div>
<div className="clickable mb-2 small text-center" onClick={() => setShowFormulas(x => !x)}>
🧪 {!showFormulas ? "Show" : "Hide"} Formulas
@ -37,17 +46,9 @@ function AllTensesDisplay({ VS, opts }: { VS: T.VerbSelection, opts: T.TextOptio
<samp>{tense.formula}</samp>
</div>}
<ChartDisplay
VS={{
...VS,
[isVerbTense(tense.value)
? "verbTense"
: isPerfectTense(tense.value)
? "perfectTense"
: isModalTense(tense.value)
? "modalTense"
: "imperativeTense"
]: tense.value,
}}
conjugations={conjugations}
tense={getTense(tense.value)}
voice={VS.voice}
opts={opts}
/>
</Hider>

View File

@ -5,7 +5,7 @@ import { isImperativeTense, isModalTense, isPerfectTense, isVerbTense } from "..
import useStickyState from "../useStickyState";
import { customStyles } from "../EntrySelect";
import {
VpsReducerAction
VpsReducerAction,
} from "../../../lib/src/phrase-building/vps-reducer";
import { imperativeTenseOptions, perfectTenseOptions, verbTenseOptions } from "./verbTenseOptions";
@ -106,7 +106,6 @@ function TensePicker(props: ({
: verbTenseOptions;
const showImperativeOption = ("vps" in props && props.vps.verb.voice === "active")
|| ("vpsComplete" in props && props.vpsComplete.verb.voice !== "active");
const inPassiveVoice = ("vps" in props && props.vps.verb.voice === "passive") || ("vpsComplete" in props && props.vpsComplete.verb.voice === "passive");;
const inAllTensesMode = props.mode === "charts";
const canHaveFormula = "vps" in props
&& props.mode !== "quiz"
@ -151,7 +150,7 @@ function TensePicker(props: ({
}, {
label: "Ability",
value: "modal",
}].filter(x => !(inPassiveVoice && x.value === "modal"))}
}]}
handleChange={props.mode !== "quiz" ? onTenseCategorySelect : () => null}
/>
</div>}

View File

@ -1,22 +1,16 @@
import {
getTenseVerbForm,
getTenseFromVerbSelection,
} from "../../../lib/src/phrase-building/vp-tools";
import VerbFormDisplay from "../VerbFormDisplay";
import { conjugateVerb } from "../../../lib/src/verb-conjugation";
import * as T from "../../../types";
function ChartDisplay({ VS, opts }: { VS: T.VerbSelection, opts: T.TextOptions }) {
const rawConjugations = conjugateVerb(VS.verb.entry, VS.verb.complement);
if (!rawConjugations) {
return <div>Error conjugating verb</div>;
}
const conjugations = ("stative" in rawConjugations)
? rawConjugations[VS.isCompound === "stative" ? "stative" : "dynamic"]
: ("transitive" in rawConjugations)
? rawConjugations[VS.transitivity === "grammatically transitive" ? "grammaticallyTransitive" : "transitive"]
: rawConjugations;
const form = getTenseVerbForm(conjugations, getTenseFromVerbSelection(VS), VS.voice, VS.negative);
function ChartDisplay({ conjugations, tense, opts, voice }: {
conjugations: T.VerbConjugation,
tense: T.VerbTense | T.PerfectTense | T.ModalTense | T.ImperativeTense,
opts: T.TextOptions,
voice: T.VerbSelection["voice"],
}) {
const form = getTenseVerbForm(conjugations, tense, voice, "charts", false);
return <div className="mb-4">
<VerbFormDisplay
displayForm={form}

View File

@ -104,7 +104,7 @@ function VerbPicker(props: {
<ButtonSelect
small
value={props.vps.verb.voice}
options={(props.vps.verb.tenseCategory === "imperative" || props.vps.verb.tenseCategory === "modal")
options={(props.vps.verb.tenseCategory === "imperative") // || props.vps.verb.tenseCategory === "modal")
? [{
label: "Active",
value: "active",

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/inflect",
"version": "5.4.3",
"version": "5.5.0",
"description": "Pashto inflector library",
"main": "dist/index.js",
"types": "dist/lib/library.d.ts",

View File

@ -554,7 +554,7 @@ function getPsVerbConjugation(conj: T.VerbConjugation, vs: T.VerbSelectionComple
hasBa: boolean,
} {
// TODO: handle the imperative form here
const f = getTenseVerbForm(conj, vs.tense, vs.voice, vs.negative);
const f = getTenseVerbForm(conj, vs.tense, vs.voice, "phrase-building", vs.negative);
const block = getMatrixBlock(f, objectPerson, person);
const perfective = (vs.tense === "perfectiveImperative" && vs.negative)
? false

View File

@ -29,10 +29,18 @@ export function isInvalidSubjObjCombo(subj: T.Person, obj: T.Person): boolean {
);
}
/**
* @param conjR
* @param tense
* @param voice
* @param negative
* @returns
*/
export function getTenseVerbForm(
conjR: T.VerbConjugation,
tense: T.VerbTense | T.PerfectTense | T.ModalTense | T.ImperativeTense,
voice: "active" | "passive",
mode: "charts" | "phrase-building",
negative: boolean,
): T.VerbForm | T.ImperativeForm {
const conj = (voice === "passive" && conjR.passive) ? conjR.passive : conjR;
@ -42,7 +50,8 @@ export function getTenseVerbForm(
throw impPassError;
}
if (!conj.imperfective.imperative || !conj.perfective.imperative) throw impPassError;
return (tense === "perfectiveImperative" && !negative)
// charts can't display negative form
return (tense === "perfectiveImperative" && (!negative || mode === "charts"))
? conj.perfective.imperative
: conj.imperfective.imperative;
}

View File

@ -152,7 +152,7 @@ export function vpsReducer(vps: T.VPSelectionState, action: VpsReducerAction, se
verb: {
...vps.verb,
voice,
tenseCategory: vps.verb.tenseCategory === "modal" ? "basic" : vps.verb.tenseCategory,
// tenseCategory: vps.verb.tenseCategory === "modal" ? "basic" : vps.verb.tenseCategory,
},
};
} else {
@ -243,7 +243,6 @@ export function vpsReducer(vps: T.VPSelectionState, action: VpsReducerAction, se
verb: {
...vps.verb,
tenseCategory: category,
voice: "active",
},
}
}