This commit is contained in:
lingdocs 2022-05-06 14:57:39 -05:00
parent 8ad69a0a0c
commit 41ffa90e5a
8 changed files with 32 additions and 23 deletions

View File

@ -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",

View File

@ -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);

View File

@ -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,
};
}

View File

@ -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: {
<span className="clickable" onClick={() => setShowingExplanation({ role: "servant", item: "subject" })}>{roleIcon.servant}</span>
{` `}
{(rendered && rendered.whatsAdjustable !== "king") &&
<span onClick={toggleServantShrink} className="ml-3 clickable">
<span onClick={toggleServantShrink} className="mx-2 clickable">
{!servantIsShrunk ? "🪄" : "👶"}
</span>
}
@ -211,7 +211,7 @@ function VPExplorer(props: {
<span className="clickable" onClick={() => setShowingExplanation({ role: "servant", item: "object" })}>{roleIcon.servant}</span>
{` `}
{(rendered && rendered.whatsAdjustable !== "king") &&
<span onClick={toggleServantShrink} className="ml-3 clickable">
<span onClick={toggleServantShrink} className="mx-2 clickable">
{!servantIsShrunk ? "🪄" : "👶"}
</span>
}

View File

@ -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

View File

@ -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<T.PsString[]>, 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<T.PsString[]>, 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<T.PsString[]>, 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<T.PsString[]>, 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 {

View File

@ -140,7 +140,7 @@ export function isPattern5Entry<T extends (T.NounEntry | T.AdjectiveEntry)>(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) === "ا"
);
}

View File

@ -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,