This commit is contained in:
adueck 2023-01-18 23:34:39 +05:00
parent 89261434ee
commit db77dd81bb
4 changed files with 102 additions and 91 deletions

View File

@ -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 {

View File

@ -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<Level> = ({ 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.NPSelection> | T.Rendered<T.APSelection> = 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);

View File

@ -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"]),

View File

@ -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,
},
};
}