From 8c7c89611ea2d081710fcf6ddb43d1a46dda20ae Mon Sep 17 00:00:00 2001 From: adueck Date: Tue, 24 Jan 2023 13:48:49 +0500 Subject: [PATCH] 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. --- package-lock.json | 4 +-- package.json | 2 +- src/components/package.json | 2 +- .../src/vp-explorer/AllTensesDisplay.tsx | 25 ++++++++++--------- .../src/vp-explorer/TensePicker.tsx | 5 ++-- .../src/vp-explorer/VPChartDisplay.tsx | 20 ++++++--------- src/components/src/vp-explorer/VerbPicker.tsx | 24 +++++++++--------- src/lib/package.json | 2 +- src/lib/src/phrase-building/render-vp.ts | 2 +- src/lib/src/phrase-building/vp-tools.ts | 11 +++++++- src/lib/src/phrase-building/vps-reducer.ts | 3 +-- 11 files changed, 51 insertions(+), 49 deletions(-) diff --git a/package-lock.json b/package-lock.json index 261fe0b..760b9da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/package.json b/package.json index 4cb39f5..7fc3d58 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/package.json b/src/components/package.json index 0898c44..3d57fa4 100644 --- a/src/components/package.json +++ b/src/components/package.json @@ -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", diff --git a/src/components/src/vp-explorer/AllTensesDisplay.tsx b/src/components/src/vp-explorer/AllTensesDisplay.tsx index 57ae42f..146d18c 100644 --- a/src/components/src/vp-explorer/AllTensesDisplay.tsx +++ b/src/components/src/vp-explorer/AllTensesDisplay.tsx @@ -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([], "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
setShowFormulas(x => !x)}> 🧪 {!showFormulas ? "Show" : "Hide"} Formulas @@ -37,17 +46,9 @@ function AllTensesDisplay({ VS, opts }: { VS: T.VerbSelection, opts: T.TextOptio {tense.formula}
} diff --git a/src/components/src/vp-explorer/TensePicker.tsx b/src/components/src/vp-explorer/TensePicker.tsx index aee1370..deeec23 100644 --- a/src/components/src/vp-explorer/TensePicker.tsx +++ b/src/components/src/vp-explorer/TensePicker.tsx @@ -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} />
} diff --git a/src/components/src/vp-explorer/VPChartDisplay.tsx b/src/components/src/vp-explorer/VPChartDisplay.tsx index 22ca699..97547e9 100644 --- a/src/components/src/vp-explorer/VPChartDisplay.tsx +++ b/src/components/src/vp-explorer/VPChartDisplay.tsx @@ -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
Error conjugating verb
; - } - 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
} diff --git a/src/lib/package.json b/src/lib/package.json index 4c540a2..4a31c72 100644 --- a/src/lib/package.json +++ b/src/lib/package.json @@ -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", diff --git a/src/lib/src/phrase-building/render-vp.ts b/src/lib/src/phrase-building/render-vp.ts index b592038..3459875 100644 --- a/src/lib/src/phrase-building/render-vp.ts +++ b/src/lib/src/phrase-building/render-vp.ts @@ -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 diff --git a/src/lib/src/phrase-building/vp-tools.ts b/src/lib/src/phrase-building/vp-tools.ts index 911030c..fcfaac4 100644 --- a/src/lib/src/phrase-building/vp-tools.ts +++ b/src/lib/src/phrase-building/vp-tools.ts @@ -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; } diff --git a/src/lib/src/phrase-building/vps-reducer.ts b/src/lib/src/phrase-building/vps-reducer.ts index e4a543e..efe433b 100644 --- a/src/lib/src/phrase-building/vps-reducer.ts +++ b/src/lib/src/phrase-building/vps-reducer.ts @@ -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", }, } }