From db77dd81bbd896ed7055e460f935597298b35850 Mon Sep 17 00:00:00 2001 From: adueck Date: Wed, 18 Jan 2023 23:34:39 +0500 Subject: [PATCH] touchup --- src/App.css | 5 + src/games/sub-cores/NPAdjGame.tsx | 92 ++----------------- .../np-adj-generator.ts | 13 ++- .../block-generators/sandwich-generator.ts | 83 +++++++++++++++++ 4 files changed, 102 insertions(+), 91 deletions(-) rename src/lib/{ => block-generators}/np-adj-generator.ts (77%) create mode 100644 src/lib/block-generators/sandwich-generator.ts diff --git a/src/App.css b/src/App.css index 76a6213..529d3a5 100644 --- a/src/App.css +++ b/src/App.css @@ -10,6 +10,11 @@ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; } +/* html, body { + font-family: monospace; + unicode-range: U+0600-06FF; +} */ + .ais-SearchBox { margin: 1em 0; } .table-of-contents { diff --git a/src/games/sub-cores/NPAdjGame.tsx b/src/games/sub-cores/NPAdjGame.tsx index f0349fb..469cce5 100644 --- a/src/games/sub-cores/NPAdjGame.tsx +++ b/src/games/sub-cores/NPAdjGame.tsx @@ -3,20 +3,20 @@ import { Types as T, renderNPSelection, getEnglishFromRendered, - randFromArray, getPashtoFromRendered, renderAPSelection, InlinePs, defaultTextOptions as opts, concatPsString, } from "@lingdocs/ps-react"; -import { makeNPAdjGenerator } from "../../lib/np-adj-generator"; +import { makeNPAdjGenerator } from "../../lib/block-generators/np-adj-generator"; import { useState } from "react"; import { comparePs } from "../../lib/game-utils"; import WordCard from "../../components/WordCard"; +import { makeSandwich } from "../../lib/block-generators/sandwich-generator"; -const amount = 15; -const timeLimit = 230; +const amount = 14; +const timeLimit = 275; type Question = { selection: T.NPSelection | T.APSelection, @@ -26,98 +26,18 @@ type Question = { type Level = "hints" | "no-hints" | "sandwiches"; -export const sandwiches: T.Sandwich[] = [ - { - type: "sandwich", - before: { p: "له", f: "la" }, - after: { p: "نه", f: "na" }, - e: "from", - }, - { - type: "sandwich", - before: { p: "له", f: "la" }, - after: { p: "څخه", f: "tsuxa" }, - e: "from", - }, - { - type: "sandwich", - before: { p: "له", f: "la" }, - after: { p: "سره", f: "sara" }, - e: "with", - }, - { - type: "sandwich", - before: undefined, - after: { p: "ته", f: "ta" }, - e: "to", - }, - { - type: "sandwich", - before: { p: "د", f: "du" }, - after: { p: "لپاره", f: "lapaara" }, - e: "for", - }, - { - type: "sandwich", - before: { p: "د", f: "du" }, - after: { p: "په څانګ", f: "pu tsaang" }, - e: "beside", - }, - // { - // type: "sandwich", - // before: { p: "په", f: "pu" }, - // after: { p: "کې", f: "ke" }, - // e: "in", - // }, - { - type: "sandwich", - before: { p: "د", f: "du" }, - after: { p: "لاندې", f: "laande" }, - e: "under", - }, - { - type: "sandwich", - before: { p: "د", f: "du" }, - after: { p: "په شان", f: "pu shaan" }, - e: "like", - }, - { - type: "sandwich", - before: { p: "د", f: "du" }, - after: { p: "غوندې", f: "ghwunde" }, - e: "like", - }, - // { - // type: "sandwich", - // before: { p: "د", f: "du" }, - // after: { p: "په اړه", f: "pu aRa" }, - // e: "about", - // }, -]; - - -// LEVELS -// - without plurals -// - with inflection category hinting - const NPAdjWriting: GameSubCore = ({ inChapter, id, link, level }: { inChapter: boolean, id: string, link: string, level: Level, }) => { - const npPool = makeNPAdjGenerator(); + const npPool = makeNPAdjGenerator(level === "sandwiches" ? "low" : "high"); function getQuestion(): Question { const np = npPool(); const selection: T.NPSelection | T.APSelection = level === "sandwiches" - ? { - type: "AP", - selection: { - ...randFromArray(sandwiches), - inside: np, - }, - } : np; + ? makeSandwich(np) : np; const rendered: T.Rendered | T.Rendered = selection.type === "AP" ? renderAPSelection(selection, 0) // WOULD BE CLEANER IF THIS WAS JUST A PURE SANDWICH, NOT AT AP : renderNPSelection(np, false, false, "subject", "none", false); diff --git a/src/lib/np-adj-generator.ts b/src/lib/block-generators/np-adj-generator.ts similarity index 77% rename from src/lib/np-adj-generator.ts rename to src/lib/block-generators/np-adj-generator.ts index dc6b9d3..b81a891 100644 --- a/src/lib/np-adj-generator.ts +++ b/src/lib/block-generators/np-adj-generator.ts @@ -4,8 +4,8 @@ import { makeAdjectiveSelection, randFromArray, } from "@lingdocs/ps-react"; -import { makePool } from "./pool"; -import { wordQuery } from "../words/words"; +import { makePool } from "../pool"; +import { wordQuery } from "../../words/words"; const nouns = wordQuery("nouns", [ "saRey", @@ -35,6 +35,7 @@ const nouns = wordQuery("nouns", [ const adjectives = wordQuery("adjectives", [ "muR", + "jzwundey", "sheen", "soor", "rixtooney", @@ -50,6 +51,7 @@ const adjectives = wordQuery("adjectives", [ "koochney", "wroostey", "pradey", + "treew", "zoR", "moR", "treekh", @@ -69,9 +71,10 @@ const adjectives = wordQuery("adjectives", [ "kooN", "koG", "zeeG", + "naast", ]); -export function makeNPAdjGenerator(avoidPlurals?: boolean): () => T.NPSelection { +export function makeNPAdjGenerator(pluralsLevel: "none" | "low" | "high"): () => T.NPSelection { const nounPool = makePool(nouns); const adjPool = makePool(adjectives); @@ -80,8 +83,8 @@ export function makeNPAdjGenerator(avoidPlurals?: boolean): () => T.NPSelection const selection: T.NounSelection = { ...ns, adjectives: [makeAdjectiveSelection(adjPool())], - ...(ns.numberCanChange && !avoidPlurals) ? { - number: randFromArray(["singular", "plural", "plural", "plural", "singular"]), + ...(ns.numberCanChange && pluralsLevel !== "none") ? { + number: randFromArray(pluralsLevel === "high" ? ["singular", "plural", "plural", "plural", "singular"] : ["singular", "plural", "singular"]), } : {}, ...ns.genderCanChange ? { gender: randFromArray(["masc", "fem", "fem", "fem", "masc"]), diff --git a/src/lib/block-generators/sandwich-generator.ts b/src/lib/block-generators/sandwich-generator.ts new file mode 100644 index 0000000..a4ddfb9 --- /dev/null +++ b/src/lib/block-generators/sandwich-generator.ts @@ -0,0 +1,83 @@ +import { + Types as T, + randFromArray, +} from "@lingdocs/ps-react"; + +export const sandwiches: T.Sandwich[] = [ + { + type: "sandwich", + before: { p: "له", f: "la" }, + after: { p: "نه", f: "na" }, + e: "from", + }, + { + type: "sandwich", + before: { p: "له", f: "la" }, + after: { p: "څخه", f: "tsuxa" }, + e: "from", + }, + { + type: "sandwich", + before: { p: "له", f: "la" }, + after: { p: "سره", f: "sara" }, + e: "with", + }, + { + type: "sandwich", + before: undefined, + after: { p: "ته", f: "ta" }, + e: "to", + }, + { + type: "sandwich", + before: { p: "د", f: "du" }, + after: { p: "لپاره", f: "lapaara" }, + e: "for", + }, + { + type: "sandwich", + before: { p: "د", f: "du" }, + after: { p: "په څانګ", f: "pu tsaang" }, + e: "beside", + }, + // { + // type: "sandwich", + // before: { p: "په", f: "pu" }, + // after: { p: "کې", f: "ke" }, + // e: "in", + // }, + { + type: "sandwich", + before: { p: "د", f: "du" }, + after: { p: "لاندې", f: "laande" }, + e: "under", + }, + { + type: "sandwich", + before: { p: "د", f: "du" }, + after: { p: "په شان", f: "pu shaan" }, + e: "like", + }, + { + type: "sandwich", + before: { p: "د", f: "du" }, + after: { p: "غوندې", f: "ghwunde" }, + e: "like", + }, + // { + // type: "sandwich", + // before: { p: "د", f: "du" }, + // after: { p: "په اړه", f: "pu aRa" }, + // e: "about", + // }, +]; + +export function makeSandwich(np: T.NPSelection): T.APSelection { + return { + type: "AP", + selection: { + ...randFromArray(sandwiches), + inside: np, + }, + }; +}