diff --git a/package.json b/package.json index b729408..1691516 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "dependencies": { "@fortawesome/fontawesome-free": "^5.15.4", "@lingdocs/lingdocs-main": "^0.2.0", - "@lingdocs/pashto-inflector": "^2.5.1", + "@lingdocs/pashto-inflector": "^2.5.4", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", diff --git a/src/components/NPPlayground.tsx b/src/components/NPPlayground.tsx new file mode 100644 index 0000000..d44e0d7 --- /dev/null +++ b/src/components/NPPlayground.tsx @@ -0,0 +1,31 @@ +import { + Types as T, + NPPicker, +} from "@lingdocs/pashto-inflector"; +import entryFeeder from "../lib/entry-feeder"; +import { useState } from "react"; +import PhraseDiagram from "./phrase-diagram/PhraseDiagram"; + +function NPPlayground({ opts }: { + opts: T.TextOptions, +}) { + const [np, setNp] = useState(undefined); + return
+
+ +
+ {np && {[ + { type: "NP", block: np }, + ]}} +
+} + +export default NPPlayground; \ No newline at end of file diff --git a/src/components/phrase-diagram/PhraseDiagram.tsx b/src/components/phrase-diagram/PhraseDiagram.tsx new file mode 100644 index 0000000..ab222b9 --- /dev/null +++ b/src/components/phrase-diagram/PhraseDiagram.tsx @@ -0,0 +1,91 @@ +import { + renderNPSelection, + Types as T, + getEnglishFromRendered, +} from "@lingdocs/pashto-inflector"; + +type BlockInput = { type: "NP", block: T.NPSelection }; + +function PhraseDiagram({ opts, children }: { + opts: T.TextOptions, + children: BlockInput[] +}) { + return
+ {children.map(block => ( + {block} + ))} +
; +} + +function Block({ opts, children }: { + opts: T.TextOptions, + children: BlockInput, +}) { + // const possesor = children.block.possesor; + const rendered = renderNPSelection(children.block, false, false, "subject", "none"); + const english = getEnglishFromRendered(rendered) + return
+ {rendered} + {english &&
{english}
} +
; +} + +function NP({ opts, children, inside }: { + opts: T.TextOptions, + children: T.Rendered, + inside?: boolean, +}) { + const np = children; + return
+
+ {!inside && {np.type !== "pronoun" ? np.possesor : undefined}} + {np.adjectives} +
{np.ps[0].f}
+
+
NP
+
+} + +function Possesors({ opts, children }: { + opts: T.TextOptions, + children: { shrunken: boolean, np: T.Rendered } | undefined, +}) { + if (!children) { + return null; + } + const hasPossesor = !!(children.np.type !== "pronoun" && children.np.possesor); + return
+ {children.np.type !== "pronoun" && {children.np.possesor}} +
+
+
du
+
+ {children.np} +
+
+ +
+
+} + +function Adjectives({ opts, children }: { + opts: T.TextOptions, + children: T.Rendered[] | undefined, +}) { + if (!children) { + return null; + } + return + {children.map(a => a.ps[0].f).join(" ")}{` `} + +} + +export default PhraseDiagram; \ No newline at end of file diff --git a/src/content/index.ts b/src/content/index.ts index fb50ab1..860c6af 100644 --- a/src/content/index.ts +++ b/src/content/index.ts @@ -19,6 +19,9 @@ import * as otherEquatives from "!babel-loader!@lingdocs/mdx-loader!./equatives/ // @ts-ignore import * as equativeExplorer from "!babel-loader!@lingdocs/mdx-loader!./equatives/equative-explorer.mdx"; +// @ts-ignore +import * as NPIntro from "!babel-loader!@lingdocs/mdx-loader!./phrase-structure/np.mdx"; + // @ts-ignore import * as nounsGender from "!babel-loader!@lingdocs/mdx-loader!./nouns/nouns-gender.mdx"; // @ts-ignore @@ -94,6 +97,16 @@ const contentTree = [ import: intro, slug: "intro", }, + { + heading: "Phrase Structure", + subdirectory: "phrase-structure", + chapters: [ + { + import: NPIntro, + slug: "np", + }, + ], + }, { heading: "Equatives", subdirectory: "equatives", diff --git a/src/content/phrase-structure/np.mdx b/src/content/phrase-structure/np.mdx new file mode 100644 index 0000000..7dd1d66 --- /dev/null +++ b/src/content/phrase-structure/np.mdx @@ -0,0 +1,226 @@ +--- +title: NPs +--- + +import { + defaultTextOptions as opts, + InlinePs, +} from "@lingdocs/pashto-inflector"; +import Link from "../../components/Link"; +import PhraseDiagram from "../../components/phrase-diagram/PhraseDiagram"; +import NPPlayground from "../../components/NPPlayground"; + +👷 * this page is correct, but incomplete - in progress* 🚧 + +## Basic building blocks + +Pashto phrases are built with a few basic ingredients: NPs, APs, Particles, Verbs, Equatives. + +
+
+
+
AP
+
+
+
+
NP
+
+
+
+
NP
+
+
+
+
V
+
+
+ +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. + +### A Noun Phrase (NP) + +A noun phrase (NP) in Pashto is one of the following: + +- a noun +- a pronoun +- a participle + +#### Nouns + +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: { + type: "noun", + entry: {"ts":1527812817,"i":9999,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m."}, + gender: "masc", + genderCanChange: false, + number: "singular", + numberCanChange: true, + adjectives: [], + possesor: undefined, + }, + }, +]} + +But we can also **extend our noun by adding *adjectives***. Let's add the *adjective* to our NP. + +{[ + { + type: "NP", + block: { + type: "noun", + entry: {"ts":1527812817,"i":9999,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m."}, + gender: "masc", + genderCanChange: false, + number: "singular", + numberCanChange: true, + adjectives: [{ + type: "adjective", + entry: {"ts":1527815451,"i":7245,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"}, + }], + possesor: undefined, + }, + }, +]} + +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. + +{[ + { + type: "NP", + block: { + type: "noun", + entry: {"ts":1527812817,"i":9999,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m."}, + gender: "masc", + genderCanChange: false, + number: "singular", + numberCanChange: true, + adjectives: [ + { + type: "adjective", + entry: {"ts":1527812625,"i":9119,"p":"غټ","f":"ghuT, ghaT","g":"ghuT,ghaT","e":"big, fat","c":"adj."}, + }, + { + type: "adjective", + entry: {"ts":1527815451,"i":7245,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"}, + }, + { + type: "adjective", + entry: {"ts":1578329248464,"i":7542,"p":"سپین","f":"speen","g":"speen","e":"white (fig. clear, honest, beautiful)","c":"adj."}, + }, + ], + 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: { + type: "noun", + entry: {"ts":1527812817,"i":9999,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m."}, + gender: "masc", + genderCanChange: false, + number: "singular", + numberCanChange: true, + adjectives: [ + { + type: "adjective", + entry: {"ts":1527815451,"i":7245,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"}, + }, + ], + possesor: { + shrunken: false, + np: { + type: "noun", + entry: {"ts":1527812881,"i":11694,"p":"ماشوم","f":"maashoom","g":"maashoom","e":"child, kid","c":"n. m. anim. unisex","ec":"child","ep":"children"}, + gender: "masc", + genderCanChange: true, + number: "singular", + numberCanChange: true, + adjectives: [], + }, + }, + }, + }, +]} + +If we add another noun like this, we can add a possesor to *it*. This is *recursion*! (Nerdy math word 🤓) + +{[ + { + type: "NP", + block: { + type: "noun", + entry: {"ts":1527812817,"i":9999,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m."}, + gender: "masc", + genderCanChange: false, + number: "singular", + numberCanChange: true, + adjectives: [ + { + type: "adjective", + entry: {"ts":1527815451,"i":7245,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"}, + }, + ], + possesor: { + shrunken: false, + np: { + type: "noun", + entry: {"ts":1527812881,"i":11694,"p":"ماشوم","f":"maashoom","g":"maashoom","e":"child, kid","c":"n. m. anim. unisex","ec":"child","ep":"children"}, + gender: "masc", + genderCanChange: true, + number: "singular", + numberCanChange: true, + adjectives: [], + possesor: { + shrunken: false, + np: { + type: "noun", + entry: {"ts":1527815177,"i":2530,"p":"پلار","f":"plaar","g":"plaar","e":"father","c":"n. m."}, + gender: "masc", + genderCanChange: false, + number: "singular", + numberCanChange: true, + adjectives: [], + }, + }, + }, + }, + }, + }, +]} + +#### Pronouns + +coming soon + +#### Participles + +coming soon + +Now try to make your own! + + diff --git a/src/words/noun-adj-categories/basic-masc.js b/src/words/noun-adj-categories/basic-masc.js index 79b756f..2a03159 100644 --- a/src/words/noun-adj-categories/basic-masc.js +++ b/src/words/noun-adj-categories/basic-masc.js @@ -1,4 +1,5 @@ module.exports = [ + { ts: 1527815177, e: "father" }, // پلار { ts: 1527812432, e: `sky, heaven` }, // آسمان - aasmaan { ts: 1527812431, e: `mango` }, // آم - aam { ts: 1527812434, e: `sound, voice` }, // آواز - aawaaz diff --git a/yarn.lock b/yarn.lock index 25f2c14..1db48e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1684,10 +1684,10 @@ pbf "^3.2.1" rambda "^6.7.0" -"@lingdocs/pashto-inflector@^2.4.9": - version "2.5.0" - resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-2.5.0.tgz#4f90a1d2db15e8389cd84f0a576c37b814f303fd" - integrity sha512-RwlBQNwNsKxvICHjx6MwOwetzGQWLdrwjWOBLMfSqbRqQzNWQrjm/Gp4+TfIT89IUtutxVSxLXlgwgUq6ebKpA== +"@lingdocs/pashto-inflector@^2.5.4": + version "2.5.4" + resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-2.5.4.tgz#9cf0029b4aeb6e1c41aa65bac0b98028d3db2dba" + integrity sha512-KSzTlN+lVZbkoQ61GdgnVvLknaCcwrAx48PHogmSuDnZbQeObqgBt1PHTV7KUw+aBDQaUjQmrm/oe+HKfEnDOw== dependencies: classnames "^2.2.6" jsurl2 "^2.1.0"