From 693aecdd706656708b5a520ee8ad975146197f09 Mon Sep 17 00:00:00 2001
From: lingdocs <71590811+lingdocs@users.noreply.github.com>
Date: Mon, 28 Mar 2022 11:08:08 +0500
Subject: [PATCH] now working with dynamic compounds and OSV
---
src/components/VerbPicker.tsx | 52 ++++++++++-------
src/components/np-picker/NPNounPicker.tsx | 17 +++++-
src/components/np-picker/NPPicker.tsx | 40 +++++++------
src/components/np-picker/picker-tools.ts | 3 +-
.../AbbreviationFormSelector.tsx | 2 +-
.../phrase-builder/ObjectDisplay.tsx | 11 +++-
.../phrase-builder/PhraseBuilder.tsx | 11 +++-
src/components/phrase-builder/VPDisplay.tsx | 22 ++++++-
src/lib/phrase-building/compile-vp.ts | 57 +++++++++++--------
src/lib/phrase-building/render-vp.ts | 11 ++--
src/types/gen-g.d.ts | 6 +-
src/words/raw-words.ts | 2 +-
src/words/verb-categories/dynamic-trans.js | 4 ++
13 files changed, 156 insertions(+), 82 deletions(-)
create mode 100644 src/words/verb-categories/dynamic-trans.js
diff --git a/src/components/VerbPicker.tsx b/src/components/VerbPicker.tsx
index e96d48d..f5d40ff 100644
--- a/src/components/VerbPicker.tsx
+++ b/src/components/VerbPicker.tsx
@@ -1,11 +1,13 @@
import Select from "react-select";
import {
+ makeNounSelection,
makeVerbSelectOption,
zIndexProps,
} from "./np-picker/picker-tools";
import {
Types as T,
ButtonSelect,
+ getVerbInfo,
} from "@lingdocs/pashto-inflector";
const tenseOptions: { label: string, value: VerbTense }[] = [{
@@ -29,42 +31,54 @@ const tenseOptions: { label: string, value: VerbTense }[] = [{
}];
function makeVerbSelection(verb: VerbEntry, oldVerbSelection?: VerbSelection): VerbSelection {
+ const info = getVerbInfo(verb.entry, verb.complement);
function getTransObjFromOldVerbSelection() {
- if (!oldVerbSelection || oldVerbSelection.object === "none" || typeof oldVerbSelection.object === "number") return undefined;
+ if (
+ !oldVerbSelection ||
+ oldVerbSelection.object === "none" ||
+ typeof oldVerbSelection.object === "number" ||
+ oldVerbSelection.isCompound === "dynamic" ||
+ (oldVerbSelection.object?.type === "noun" && oldVerbSelection.object.dynamicComplement)
+ ) return undefined;
return oldVerbSelection.object;
}
- // TODO: more complex types and unchangeable dynamic compound objects
- // TODO: use proper type predicates
- const transitivity: "intransitive" | "transitive" | "grammaticallyTransitive" = verb.entry.c?.includes("intrans.")
- ? "intransitive"
- : verb.entry.c?.includes("v. gramm. trans.")
- ? "grammaticallyTransitive"
- : "transitive";
- const object = (transitivity === "grammaticallyTransitive")
+ const transitivity: T.Transitivity = "grammaticallyTransitive" in info
+ ? "grammatically transitive"
+ : info.transitivity;
+ const object = (transitivity === "grammatically transitive")
? T.Person.ThirdPlurMale
- : transitivity === "transitive"
+ : info.type === "dynamic compound"
+ ? makeNounSelection(info.objComplement.entry as NounEntry, true)
+ : (transitivity === "transitive")
? getTransObjFromOldVerbSelection()
: "none";
- // TODO: better here based on selection of which type
- const isCompound = verb.entry.c?.includes("stat. comp.")
+ const isCompound = "stative" in info
? "stative"
- : verb.entry.c?.includes("dyn. comp.")
+ : info.type === "dynamic compound"
? "dynamic"
: false;
+ const dynAuxVerb: VerbEntry | undefined = isCompound !== "dynamic"
+ ? undefined
+ : info.type === "dynamic compound"
+ ? { entry: info.auxVerb } as VerbEntry
+ : "dynamic" in info
+ ? { entry: info.dynamic.auxVerb } as VerbEntry
+ : undefined;
return {
type: "verb",
- verb,
+ verb: verb,
+ dynAuxVerb,
tense: oldVerbSelection ? oldVerbSelection.tense : "present",
object,
transitivity,
isCompound,
negative: oldVerbSelection ? oldVerbSelection.negative : false,
- ...verb.entry.c?.includes("v. trans./gramm. trans") ? {
+ ...("grammaticallyTransitive" in info) ? {
changeTransitivity: function (t) {
return {
...this,
transitivity: t,
- object: t === "grammaticallyTransitive" ? T.Person.ThirdPlurMale : undefined,
+ object: t === "grammatically transitive" ? T.Person.ThirdPlurMale : undefined,
};
},
} : {},
@@ -97,10 +111,10 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
});
}
}
- function notInstransitive(t: "transitive" | "intransitive" | "grammaticallyTransitive"): "transitive" | "grammaticallyTransitive" {
+ function notInstransitive(t: "transitive" | "intransitive" | "grammatically transitive"): "transitive" | "grammatically transitive" {
return t === "intransitive" ? "transitive" : t;
}
- function handleChangeTransitivity(t: "transitive" | "grammaticallyTransitive") {
+ function handleChangeTransitivity(t: "transitive" | "grammatically transitive") {
if (verb && verb.changeTransitivity) {
onChange(verb.changeTransitivity(t));
}
@@ -150,7 +164,7 @@ function VerbPicker({ onChange, verb, verbs }: { verbs: VerbEntry[], verb: VerbS
small
options={[{
label: "gramm. trans.",
- value: "grammaticallyTransitive",
+ value: "grammatically transitive",
}, {
label: "trans.",
value: "transitive",
diff --git a/src/components/np-picker/NPNounPicker.tsx b/src/components/np-picker/NPNounPicker.tsx
index dbebfc2..000691a 100644
--- a/src/components/np-picker/NPNounPicker.tsx
+++ b/src/components/np-picker/NPNounPicker.tsx
@@ -6,9 +6,10 @@ import {
} from "./picker-tools";
import {
ButtonSelect,
+ InlinePs,
+ defaultTextOptions as opts,
} from "@lingdocs/pashto-inflector";
-
function NPNounPicker({ onChange, noun, nouns }: { nouns: NounEntry[], noun: NounSelection | undefined, onChange: (p: NounSelection) => void }) {
const options = nouns.sort((a, b) => (a.p.localeCompare(b.p, "af-PS"))).map(makeSelectOption)
function onEntrySelect({ value }: { label: string, value: string }) {
@@ -20,7 +21,7 @@ function NPNounPicker({ onChange, noun, nouns }: { nouns: NounEntry[], noun: Nou
onChange(makeNounSelection(entry));
}
return
-