From 41ffa90e5acdf6eb76374422329f1f5ca4c44791 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Fri, 6 May 2022 14:57:39 -0500 Subject: [PATCH] up --- package.json | 2 +- src/components/np-picker/NPNounPicker.tsx | 2 +- src/components/np-picker/picker-tools.tsx | 6 +++--- src/components/vp-explorer/VPExplorer.tsx | 22 ++++++++++---------- src/components/vp-explorer/verb-selection.ts | 6 +++--- src/lib/phrase-building/compile.ts | 11 +++++++--- src/lib/type-predicates.ts | 2 +- src/library.ts | 4 ++++ 8 files changed, 32 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 2a47a16..852d5ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "2.4.3", + "version": "2.4.4", "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/np-picker/NPNounPicker.tsx b/src/components/np-picker/NPNounPicker.tsx index 2c29f2e..8f9b1f0 100644 --- a/src/components/np-picker/NPNounPicker.tsx +++ b/src/components/np-picker/NPNounPicker.tsx @@ -70,7 +70,7 @@ function NPNounPicker(props: { if (!entry) { return props.onChange(undefined); } - props.onChange(makeNounSelection(entry)); + props.onChange(makeNounSelection(entry, props.noun)); } // function handleFilterClose() { // setPatternFilter(undefined); diff --git a/src/components/np-picker/picker-tools.tsx b/src/components/np-picker/picker-tools.tsx index f7d780d..74afd0b 100644 --- a/src/components/np-picker/picker-tools.tsx +++ b/src/components/np-picker/picker-tools.tsx @@ -96,7 +96,7 @@ export function makeSelectOption( }; } -export function makeNounSelection(entry: T.NounEntry, dynamicComplement?: true): T.NounSelection { +export function makeNounSelection(entry: T.NounEntry, old: T.NounSelection | undefined, dynamicComplement?: true): T.NounSelection { const number = isPluralNounEntry(entry) ? "plural" : "singular"; return { type: "noun", @@ -105,8 +105,8 @@ export function makeNounSelection(entry: T.NounEntry, dynamicComplement?: true): genderCanChange: isUnisexNounEntry(entry), number, numberCanChange: number === "singular", - adjectives: [], - possesor: undefined, + adjectives: (!dynamicComplement && old) ? old.adjectives : [], + possesor: !dynamicComplement ? old?.possesor : undefined, dynamicComplement, }; } \ No newline at end of file diff --git a/src/components/vp-explorer/VPExplorer.tsx b/src/components/vp-explorer/VPExplorer.tsx index 8ffa088..b358f3b 100644 --- a/src/components/vp-explorer/VPExplorer.tsx +++ b/src/components/vp-explorer/VPExplorer.tsx @@ -66,14 +66,14 @@ function VPExplorer(props: { setAlert(undefined); }, 1500); } - // useEffect(() => { - // const newVps = makeVPSelectionState(props.verb, vps); - // adjustVps({ - // type: "load vps", - // payload: newVps, - // }); - // // eslint-disable-next-line - // }, [props.verb]); + useEffect(() => { + const newVps = makeVPSelectionState(props.verb, vps); + adjustVps({ + type: "load vps", + payload: newVps, + }); + // eslint-disable-next-line + }, [props.verb]); useEffect(() => { const VPSFromUrl = getVPSFromUrl(); console.log({ VPSFromUrl }); @@ -123,7 +123,7 @@ function VPExplorer(props: { setShowShareClipped(true); setTimeout(() => { setShowShareClipped(false); - }, 1000); + }, 1250); } const VPS = completeVPSelection(vps); const phraseIsComplete = !!VPS; @@ -180,7 +180,7 @@ function VPExplorer(props: { setShowingExplanation({ role: "servant", item: "subject" })}>{roleIcon.servant} {` `} {(rendered && rendered.whatsAdjustable !== "king") && - + {!servantIsShrunk ? "🪄" : "👶"} } @@ -211,7 +211,7 @@ function VPExplorer(props: { setShowingExplanation({ role: "servant", item: "object" })}>{roleIcon.servant} {` `} {(rendered && rendered.whatsAdjustable !== "king") && - + {!servantIsShrunk ? "🪄" : "👶"} } diff --git a/src/components/vp-explorer/verb-selection.ts b/src/components/vp-explorer/verb-selection.ts index 85aa8ba..067101a 100644 --- a/src/components/vp-explorer/verb-selection.ts +++ b/src/components/vp-explorer/verb-selection.ts @@ -10,7 +10,7 @@ export function makeVPSelectionState( ): T.VPSelectionState { const info = getVerbInfo(verb.entry, verb.complement); const subject = (os?.verb.voice === "passive" && info.type === "dynamic compound") - ? makeNounSelection(info.objComplement.entry as T.NounEntry, true) + ? makeNounSelection(info.objComplement.entry as T.NounEntry, undefined, true) : (os?.subject || undefined); function getTransObjFromos() { if ( @@ -28,7 +28,7 @@ export function makeVPSelectionState( const object = (transitivity === "grammatically transitive") ? T.Person.ThirdPlurMale : (info.type === "dynamic compound" && os?.verb.voice !== "passive") - ? makeNounSelection(info.objComplement.entry as T.NounEntry, true) + ? makeNounSelection(info.objComplement.entry as T.NounEntry, undefined, true) : (transitivity === "transitive" && os?.verb.voice !== "passive") ? getTransObjFromos() : "none"; @@ -79,7 +79,7 @@ export function changeStatDyn(v: T.VerbSelection, s: "dynamic" | "stative"): T.V ...v, isCompound: s, object: s === "dynamic" - ? makeNounSelection(info.dynamic.objComplement.entry as T.NounEntry, true) + ? makeNounSelection(info.dynamic.objComplement.entry as T.NounEntry, undefined, true) : undefined, dynAuxVerb: s === "dynamic" ? { entry: info.dynamic.auxVerb } as T.VerbEntry diff --git a/src/lib/phrase-building/compile.ts b/src/lib/phrase-building/compile.ts index 8c8de72..1e5b676 100644 --- a/src/lib/phrase-building/compile.ts +++ b/src/lib/phrase-building/compile.ts @@ -26,6 +26,11 @@ import { completeEPSelection, renderEP } from "./render-ep"; import { completeVPSelection } from "./vp-tools"; import { renderVP } from "./render-vp"; +const blank: T.PsString = { + p: "_______", + f: "_______", +}; + type Form = T.FormVersion & { OSV?: boolean }; export function compileVP(VP: T.VPRendered, form: Form): { ps: T.SingleOrLengthOpts, e?: string [] }; export function compileVP(VP: T.VPRendered, form: Form, combineLengths: true): { ps: T.PsString[], e?: string [] }; @@ -251,14 +256,14 @@ function arrangeVerbWNegative(head: T.PsString | undefined, restRaw: T.PsString[ export function compileEP(EP: T.EPRendered): { ps: T.SingleOrLengthOpts, e?: string[] }; -export function compileEP(EP: T.EPRendered, combineLengths: true): { ps: T.PsString[], e?: string[] }; -export function compileEP(EP: T.EPRendered, combineLengths?: true): { ps: T.SingleOrLengthOpts, e?: string[] } { +export function compileEP(EP: T.EPRendered, combineLengths: true, blankOut?: { equative: boolean }): { ps: T.PsString[], e?: string[] }; +export function compileEP(EP: T.EPRendered, combineLengths?: true, blankOut?: { equative: boolean }): { ps: T.SingleOrLengthOpts, e?: string[] } { const { kids, NPs } = getEPSegmentsAndKids(EP); const equative = EP.equative.ps; const psResult = compileEPPs({ NPs, kids, - equative, + equative: blankOut?.equative ? [blank] : equative, negative: EP.equative.negative, }); return { diff --git a/src/lib/type-predicates.ts b/src/lib/type-predicates.ts index acc50e1..7421b22 100644 --- a/src/lib/type-predicates.ts +++ b/src/lib/type-predicates.ts @@ -140,7 +140,7 @@ export function isPattern5Entry(e: T return ( !!(e.infap && e.infaf && e.infbp && e.infbf) && - e.infap.includes("ا") + e.infap.slice(-1) === "ه" && e.infap.charAt(e.infap.length - 3) === "ا" ); } diff --git a/src/library.ts b/src/library.ts index ba71038..8dd2a5f 100644 --- a/src/library.ts +++ b/src/library.ts @@ -112,6 +112,9 @@ import { splitUpSyllables, countSyllables, } from "./lib/accent-helpers"; +import { + makeNounSelection, +} from "./components/np-picker/picker-tools"; import NPPicker from "./components/np-picker/NPPicker"; import EPExplorer from "./components/ep-explorer/EPExplorer"; import shuffleArray from "./lib/shuffle-array"; @@ -173,6 +176,7 @@ export { randomSubjObj, shuffleArray, personNumber, + makeNounSelection, // protobuf helpers readDictionary, writeDictionary,