From d40cf1014426b5eebae30a0e8bff7ef6f5082588 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 12 Sep 2022 20:59:45 +0400 Subject: [PATCH] inflection games started --- package.json | 2 +- src/content/index.ts | 6 - .../inflection/feminine-inflection.mdx | 44 ----- .../inflection/inflection-patterns.mdx | 24 ++- .../inflection/masculine-inflection.mdx | 0 src/games/games.tsx | 24 +++ src/games/sub-cores/InflectionPatterns.tsx | 150 ++++++++++++++++++ yarn.lock | 8 +- 8 files changed, 200 insertions(+), 58 deletions(-) delete mode 100644 src/content/inflection/feminine-inflection.mdx delete mode 100644 src/content/inflection/masculine-inflection.mdx create mode 100644 src/games/sub-cores/InflectionPatterns.tsx diff --git a/package.json b/package.json index 6eb42ca..36c3e31 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "@formkit/auto-animate": "^1.0.0-beta.1", "@fortawesome/fontawesome-free": "^5.15.4", "@lingdocs/lingdocs-main": "^0.3.3", - "@lingdocs/pashto-inflector": "^3.9.0", + "@lingdocs/pashto-inflector": "^3.9.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/content/index.ts b/src/content/index.ts index 52addfc..7dab117 100644 --- a/src/content/index.ts +++ b/src/content/index.ts @@ -101,8 +101,6 @@ import * as directionalPronouns from "!babel-loader!@lingdocs/mdx-loader!./prono import * as inflectionIntro from "!babel-loader!@lingdocs/mdx-loader!./inflection/inflection-intro.mdx"; // @ts-ignore import * as inflectionPatterns from "!babel-loader!@lingdocs/mdx-loader!./inflection/inflection-patterns.mdx"; -// @ts-ignore -import * as feminineInflection from "!babel-loader!@lingdocs/mdx-loader!./inflection/feminine-inflection.mdx"; // @ts-ignore import * as sandwiches from "!babel-loader!@lingdocs/mdx-loader!./sandwiches/sandwiches.mdx"; @@ -360,10 +358,6 @@ const contentTree: (ChapterSection | ChaptersSection)[] = [ import: inflectionPatterns, slug: "inflection-patterns", }, - { - import: feminineInflection, - slug: "feminine-inflection", - }, ], }, { diff --git a/src/content/inflection/feminine-inflection.mdx b/src/content/inflection/feminine-inflection.mdx deleted file mode 100644 index ca1a0a7..0000000 --- a/src/content/inflection/feminine-inflection.mdx +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: Feminine Inflection Patterns ---- - - - - -import { - defaultTextOptions as opts, - Examples, - InlinePs, - grammarUnits, - removeFVarients, - InflectionsTable, - inflectWord, - typePredicates as tp, -} from "@lingdocs/pashto-inflector"; -import shuffle from "../../lib/shuffle-array"; -import InflectionCarousel from "../../components/InflectionCarousel"; -import { nouns } from "../../words/words"; -import Link from "../../components/Link"; -import Table from "../../components/Table"; -import { startingWord } from "../../lib/starting-word"; - -export const femNouns = nouns.filter(tp.isFemNounEntry); - -The 5 basic patterns in the last chapter work with both masculine and feminine words (nouns and adjectives). - -There are also a few more patterns that are only for **feminine nouns**. - -## Feminine Nouns Ending in ي - ee - - - -**Note:** This only works with **inanimate nouns**. (ie. words for people like will not inflect like this.) diff --git a/src/content/inflection/inflection-patterns.mdx b/src/content/inflection/inflection-patterns.mdx index 00eeacb..5cfc379 100644 --- a/src/content/inflection/inflection-patterns.mdx +++ b/src/content/inflection/inflection-patterns.mdx @@ -32,12 +32,18 @@ export const words = [ ...nouns.filter(tp.isUnisexNounEntry), ...adjectives, ]; +export const femNouns = nouns.filter(tp.isFemNounEntry); +import { + inflectionPatternsGame1, + inflectionPatternsGame2, +} from "../../games/games"; +import GameDisplay from "../../games/GameDisplay"; In the previous chapter we talked about **why** words inflect. Now we will explain **how** words inflect. What actualy happens to them? How do they change? Like many things in Pashto, inflection can seem mysterious and intimidating. Why do the words change so much, and how!? 😩 But, we'll see that there are just a few basic patterns that the words follow, and it's not so scary or confusing after all. -Below are the **5 basic patterns for inflecting** nouns and adjectives. Notice how all these patterns work with both masculine and feminine genders. +Below are the **6 basic patterns for inflecting** nouns and adjectives. Notice how all these patterns work with both masculine and feminine genders. Don't worry about memorizing them all perfectly to start. Instead keep looking back and use them as guides to help you as you get familiar with the inflections over time. @@ -92,11 +98,19 @@ These are also a little irregular but instead of lengthening the 1st masculine i +)} /> + +## 6. Inanimate feminine nouns ending in ي - ee + +There is one more pattern which only works for **inanimate feminine nouns ending in **. + + + +Animate nouns like will not inflect like this, and masculine nouns like also will not inflect. ## Not all words inflect -It's important to know that *not all words can be inflected*. If a word doesn't fit into one of these 5 patterns, you can't inflect it. For example, if an adjective ends in an in the masculine form, you can't inflect it because it doesn't fit any of the patterns above. 🙅‍♂️ +It's important to know that *not all words can be inflected*. If a word doesn't fit into one of these 6 patterns, you can't inflect it. For example, if an adjective ends in an in the masculine form, you can't inflect it because it doesn't fit any of the patterns above. 🙅‍♂️ {[ { p: "خفه", f: "khufa", e: "sad", sub: "...is also sad because it can't inflect like all the other words 😢" }, @@ -210,3 +224,7 @@ But these words will *always* use the first inflection for the plural. e: "This is **the Pashtuns'** custom" }, ])} + + + + \ No newline at end of file diff --git a/src/content/inflection/masculine-inflection.mdx b/src/content/inflection/masculine-inflection.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/games/games.tsx b/src/games/games.tsx index 6a744db..31ad945 100644 --- a/src/games/games.tsx +++ b/src/games/games.tsx @@ -6,6 +6,7 @@ import EquativeSituations from "./sub-cores/EquativeSituations"; import VerbSituations from "./sub-cores/VerbSituations"; import EquativeIdentify from "./sub-cores/EquativeIdentify"; import VerbFormulas from "./sub-cores/VerbFormulas"; +import InflectionPatterns from "./sub-cores/InflectionPatterns"; // NOUNS export const nounGenderGame1 = makeGameRecord({ @@ -30,6 +31,22 @@ export const unisexNounGame = makeGameRecord({ SubCore: UnisexNounGame, }); +// INFLECTIONS +export const inflectionPatternsGame1 = makeGameRecord({ + title: "Identify the inflection pattern (Level 1)", + id: "inflection-patterns-1", + link: "/inflection/inflection-patterns/", + level: 1, + SubCore: InflectionPatterns, +}); +export const inflectionPatternsGame2 = makeGameRecord({ + title: "Identify the inflection pattern (Level 2)", + id: "inflection-patterns-2", + link: "/inflection/inflection-patterns/", + level: 2, + SubCore: InflectionPatterns, +}); + // EQUATIVES export const equativeGamePresent = makeGameRecord({ title: "Write the present equative", @@ -288,6 +305,13 @@ const games: { chapter: string, items: GameRecord[] }[] = [ unisexNounGame, ], }, + { + chapter: "Inflection", + items: [ + inflectionPatternsGame1, + inflectionPatternsGame2, + ], + }, { chapter: "Equatives", items: [ diff --git a/src/games/sub-cores/InflectionPatterns.tsx b/src/games/sub-cores/InflectionPatterns.tsx new file mode 100644 index 0000000..af9fc81 --- /dev/null +++ b/src/games/sub-cores/InflectionPatterns.tsx @@ -0,0 +1,150 @@ +import GameCore from "../GameCore"; +import { + Types as T, + getInflectionPattern, + Examples, + defaultTextOptions as opts, + firstVariation, +} from "@lingdocs/pashto-inflector"; +import { makePool } from "../../lib/pool"; +import { nouns, adjectives } from "../../words/words"; +import * as tp from "@lingdocs/pashto-inflector/dist/lib/type-predicates"; + +const amount = 20; +const timeLimit = 150; + +type Question = { + entry: T.NounEntry | T.AdjectiveEntry, + pattern: T.InflectionPattern, +} + +const categories: { label: string, value: T.InflectionPattern }[] = [ + { + label: "#1 Basic", + value: T.InflectionPattern.Basic, + }, + { + label: "#2 Unstressed ی", + value: T.InflectionPattern.UnstressedEy, + }, + { + label: "#3 Stressed ی", + value: T.InflectionPattern.StressedEy, + }, + { + label: `#4 "Pashtoon"`, + value: T.InflectionPattern.Pashtun, + }, + { + label: `#5 Short Squish`, + value: T.InflectionPattern.Squish, + }, + { + label: "#6 Inan. Fem. ي", + value: T.InflectionPattern.FemInanEe, + }, + { + label: "No Inflection", + value: T.InflectionPattern.None, + }, +]; + +export default function InflectionPatterns({ inChapter, id, link, level }: { inChapter: boolean, id: string, link: string, level: 1 | 2 }) { + const w = [...nouns, ...adjectives] + .filter(level === 2 ? x => x : x => (tp.isUnisexNounEntry(x) || tp.isAdjectiveEntry(x) || (tp.isFemNounEntry(x) && tp.isPattern6FemEntry(x)))) + .map(x => ({ entry: x, pattern: getInflectionPattern(x) })); + const words: Record = { + 0: w.filter(x => x.pattern === 0).map(x => x.entry), + 1: w.filter(x => x.pattern === 1).map(x => x.entry), + 2: w.filter(x => x.pattern === 2).map(x => x.entry), + 3: w.filter(x => x.pattern === 3).map(x => x.entry), + 4: w.filter(x => x.pattern === 4).map(x => x.entry), + 5: w.filter(x => x.pattern === 5).map(x => x.entry), + 6: w.filter(x => x.pattern === 6).map(x => x.entry), + }; + const pools: Record (T.NounEntry | T.AdjectiveEntry)> = { + 0: makePool(words[0]), + 1: makePool(words[1]), + 2: makePool(words[2]), + 3: makePool(words[3]), + 4: makePool(words[4]), + 5: makePool(words[5]), + 6: makePool(words[6]), + } + const patternPool = makePool([ + T.InflectionPattern.None, + T.InflectionPattern.Basic, + T.InflectionPattern.UnstressedEy, + T.InflectionPattern.StressedEy, + T.InflectionPattern.Pashtun, + T.InflectionPattern.Squish, + T.InflectionPattern.FemInanEe, + ]); + function getQuestion(): Question { + const pattern = patternPool(); + const entry = pools[pattern](); + if (getInflectionPattern(entry) !== pattern) { + throw Error("wrong pattern on word"); + } + return { entry, pattern }; + }; + + function Display({ question, callback }: QuestionDisplayProps) { + function handleChoice(ic: T.InflectionPattern) { + return callback(ic === question.pattern); + } + return
+
+ {[ + { + p: firstVariation(question.entry.p), + f: firstVariation(question.entry.f), + e: `${firstVariation(question.entry.e)} - ${question.entry.c}`, + } + ]} +
+
+
+ {categories.map(c =>
+ +
)} +
+
+
+ } + + function Instructions() { + return
+

Choose the inflection pattern that each noun/adjective follows

+
+ } + + return +}; + +function DisplayCorrectAnswer({ question }: { question: Question }): JSX.Element { + + // callback(
+ // {possibleCorrect.map(humanReadableTense).join(" or ")} + //
) + return
+

{categories.find(c => c.value === question.pattern)?.label}

+
; +} + diff --git a/yarn.lock b/yarn.lock index 3e0273e..4777686 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1804,10 +1804,10 @@ rambda "^6.7.0" react-select "^5.2.2" -"@lingdocs/pashto-inflector@^3.9.0": - version "3.9.0" - resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-3.9.0.tgz#abcea34db1d7031e7915c1bc6281b88df6c8ca2b" - integrity sha512-6KARwTVmt/qJaOrvIbQlQhIfseB0sM9HrfWGpkRUQZK4eGmo6Qpnne8PBJQe1CQZCuAKgDjpwDHz3CssFIOegA== +"@lingdocs/pashto-inflector@^3.9.4": + version "3.9.4" + resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-3.9.4.tgz#b85bd8b9c235da1b77a04bd4178be91371a94726" + integrity sha512-bthgBbzkFHIYUOTFNUNcwWFuhCkFlX7RCPQIbZdXFPOdUoEGtlngqJkECKm+pIShQioEGuMxhW0plhXDIccA8w== dependencies: "@formkit/auto-animate" "^1.0.0-beta.1" classnames "^2.2.6"