From ab12c18a1f8ed5ad26a2088524ed22cf7ca01283 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Sat, 14 May 2022 21:19:17 -0500 Subject: [PATCH] more --- src/components/NPPlayground.tsx | 5 +- .../phrase-diagram/EditablePhraseDiagram.tsx | 33 +++++++ .../phrase-diagram/PhraseDiagram.tsx | 28 ++++-- src/content/index.ts | 2 +- src/content/phrase-structure/np.mdx | 90 ++++++++++++++----- src/types/gramm-types.d.ts | 4 +- 6 files changed, 130 insertions(+), 32 deletions(-) create mode 100644 src/components/phrase-diagram/EditablePhraseDiagram.tsx diff --git a/src/components/NPPlayground.tsx b/src/components/NPPlayground.tsx index d44e0d7..b67aa2e 100644 --- a/src/components/NPPlayground.tsx +++ b/src/components/NPPlayground.tsx @@ -6,10 +6,11 @@ import entryFeeder from "../lib/entry-feeder"; import { useState } from "react"; import PhraseDiagram from "./phrase-diagram/PhraseDiagram"; -function NPPlayground({ opts }: { +function NPPlayground({ opts, npIn }: { opts: T.TextOptions, + npIn: T.NPSelection | undefined, }) { - const [np, setNp] = useState(undefined); + const [np, setNp] = useState(npIn); return
; +} + +function EditablePhraseDiagram({ opts, children }: { + opts: T.TextOptions, + children: BlockInput[], +}) { + const np = children[0].block; + const [editing, setEditing] = useState(false); + if (children.length === 0) return null; + return
+
setEditing(e => !e)}> + {!editing ? : } +
+
+ {editing + ? + : {[ + { type: "NP", block: np }, + ]}} +
+
; +} + +export default EditablePhraseDiagram; \ No newline at end of file diff --git a/src/components/phrase-diagram/PhraseDiagram.tsx b/src/components/phrase-diagram/PhraseDiagram.tsx index ab222b9..c308e29 100644 --- a/src/components/phrase-diagram/PhraseDiagram.tsx +++ b/src/components/phrase-diagram/PhraseDiagram.tsx @@ -3,16 +3,15 @@ import { Types as T, getEnglishFromRendered, } from "@lingdocs/pashto-inflector"; - -type BlockInput = { type: "NP", block: T.NPSelection }; +import classNames from "classnames"; function PhraseDiagram({ opts, children }: { opts: T.TextOptions, children: BlockInput[] }) { return
- {children.map(block => ( - {block} + {children.map((block) => ( + {block} ))}
; } @@ -58,6 +57,7 @@ function Possesors({ opts, children }: { return null; } const hasPossesor = !!(children.np.type !== "pronoun" && children.np.possesor); + const contraction = checkForContraction(children.np); return
{children.np.type !== "pronoun" && {children.np.possesor}}
-
+ {contraction &&
({contraction})
} +
du
{children.np} @@ -76,6 +77,23 @@ function Possesors({ opts, children }: {
} +function checkForContraction(np: T.Rendered): string | undefined { + if (np.type !== "pronoun") return undefined; + if (np.person === T.Person.FirstSingMale || np.person === T.Person.FirstSingFemale) { + return "zmaa" + } + if (np.person === T.Person.SecondSingMale || np.person === T.Person.SecondSingFemale) { + return "staa" + } + if (np.person === T.Person.FirstPlurMale || np.person === T.Person.FirstPlurFemale) { + return "zmoonG" + } + if (np.person === T.Person.SecondPlurMale || np.person === T.Person.SecondPlurFemale) { + return "staaso" + } + return undefined; +} + function Adjectives({ opts, children }: { opts: T.TextOptions, children: T.Rendered[] | undefined, diff --git a/src/content/index.ts b/src/content/index.ts index 860c6af..a322a91 100644 --- a/src/content/index.ts +++ b/src/content/index.ts @@ -98,7 +98,7 @@ const contentTree = [ slug: "intro", }, { - heading: "Phrase Structure", + heading: "Phrase Structure 🧱", subdirectory: "phrase-structure", chapters: [ { diff --git a/src/content/phrase-structure/np.mdx b/src/content/phrase-structure/np.mdx index 7dd1d66..3da34da 100644 --- a/src/content/phrase-structure/np.mdx +++ b/src/content/phrase-structure/np.mdx @@ -8,15 +8,16 @@ import { } from "@lingdocs/pashto-inflector"; import Link from "../../components/Link"; import PhraseDiagram from "../../components/phrase-diagram/PhraseDiagram"; +import EditablePhraseDiagram, { + EditIcon, +} from "../../components/phrase-diagram/EditablePhraseDiagram"; import NPPlayground from "../../components/NPPlayground"; 👷 * this page is correct, but incomplete - in progress* 🚧 -## Basic building blocks +Pashto phrases are built with a basic **building blocks** 🧱 like NPs, APs, verbs, and equatives. We can think of phrases in Pashto as a line of blocks like this: -Pashto phrases are built with a few basic ingredients: NPs, APs, Particles, Verbs, Equatives. - -
+
-
V
+
Verb
-In Pashto, it's important to know how these building blocks line up. But first, what is actually inside each of these blocks? Let's take a look at the NP. +Or like this... -### A Noun Phrase (NP) +
+
+
+
NP
+
+
+
+
NP
+
+
+
+
Equative
+
+
-A noun phrase (NP) in Pashto is one of the following: +In Pashto, it's important to know how these building blocks line up. But first, let's look at what these blocks actually are blocks. In this chapter we'll look at the NP. + +## Noun Phrase (NP) + +A noun phrase (NP) in Pashto is one of the following three things: - a noun - a pronoun - a participle -#### Nouns +### Noun A **noun** is a word that we use to identify people, places, things, or ideas. One of these words by itself it forms a NP, one of the basic building blocks. -{[ +{[ { type: "NP", block: { @@ -81,9 +111,9 @@ A **noun** is a word that we use to identify people, places, things, or ideas. O }, ]} -But we can also **extend our noun by adding *adjectives***. Let's add the *adjective* to our NP. +We can also **extend our noun by adding *adjectives***. Let's add the *adjective* to our NP. -{[ +{[ { type: "NP", block: { @@ -102,9 +132,9 @@ But we can also **extend our noun by adding *adjectives***. Let's add the *adjec }, ]} -Now we have two words, but it's still **one NP**, one building block. We can add as many adjectives as we want, and it still stays as one single building block. +Now we have two words, but it's still **one NP**, one building block. We can add as many adjectives as we want, and it still stays as one single building block. Click on the icon below to try adding or removing more adjectives. -{[ +{[ { type: "NP", block: { @@ -131,11 +161,11 @@ Now we have two words, but it's still **one NP**, one building block. We can add possesor: undefined, }, }, -]} +]} We can also add a **possesor** by adding another NP sandwiched in with a . Now we have a NP inside of an NP, but it's still all **one NP** or **one building block**. -{[ +{[ { type: "NP", block: { @@ -165,11 +195,11 @@ We can also add a **possesor** by adding another NP +]} -#### Pronouns +A possesor can have another possesor which can have another posseser and so-on and on *forever*. The nerdy word for this phenomenon where things reference/repeat themselves is called [recursion](https://en.wikipedia.org/wiki/Recursion). 🤓 + +
+ Click here for another example of what recursion looks like +
+ +
+

The starbucks cup has a picture of a starbucks cup, which has a picture of a starbucks cup which has a...

+
+ +**So in summary:** 👨🏻‍🏫 + +A noun is one of three starting points for making an NP. When you start with a noun you can add adjectives and a possesor to it. (The possesor is another NP, which you can keep building on in the same way.) + +### Pronoun coming soon -#### Participles +### Participle coming soon -Now try to make your own! +Now try to make your own from scratch! diff --git a/src/types/gramm-types.d.ts b/src/types/gramm-types.d.ts index 46b657e..6623489 100644 --- a/src/types/gramm-types.d.ts +++ b/src/types/gramm-types.d.ts @@ -2,4 +2,6 @@ type Pronoun = { type: "pronoun", pronounType: "near" | "far", person: import("@lingdocs/pashto-inflector").Types.Person, -}; \ No newline at end of file +}; + +type BlockInput = { type: "NP", block: T.NPSelection };