more verb games

This commit is contained in:
lingdocs 2022-09-09 18:09:48 +04:00
parent ae0d1d1fdb
commit 6344b59034
13 changed files with 158 additions and 72 deletions

View File

@ -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.8.8",
"@lingdocs/pashto-inflector": "^3.8.9",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",

View File

@ -1,26 +1,28 @@
import {
Types as T,
} from "@lingdocs/pashto-inflector";
import { wordQuery } from "../../words/words";
// @ts-ignore
export const basicVerbs: T.VerbEntry[] = [
{"ts":1527812856,"i":11630,"p":"لیکل","f":"leekul","g":"leekul","e":"to write, draw","c":"v. trans./gramm. trans.","ec":"write,writes,writing,wrote,written"},
{"ts":1527815399,"i":14480,"p":"وهل","f":"wahul","g":"wahul","e":"to hit","c":"v. trans.","tppp":"واهه","tppf":"waahu","ec":"hit,hits,hitting,hit,hit"},
{"ts":1527817750,"i":7843,"p":"سکل","f":"skul","g":"skul","e":"to drink","c":"v. trans.","ec":"drink,drinks,drinking,drank,drank"},
{"ts":1527812752,"i":10625,"p":"کول","f":"kawul","g":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true,"ec":"do,does,doing,did,done"},
{"ts":1527812275,"i":11608,"p":"لیدل","f":"leedul","g":"leedul","e":"to see","c":"v. trans./gramm. trans.","psp":"وین","psf":"ween","tppp":"لید","tppf":"leed","ec":"see,sees,seeing,saw,seen"},
{"ts":1577049208257,"i":1068,"p":"اورېدل","f":"awredul","g":"awredul","e":"to hear, listen","c":"v. trans./gramm. trans.","psp":"اور","psf":"awr","tppp":"اورېد","tppf":"awred","ec":"hear,hears,hearing,heard"},
{"ts":1527812790,"i":5795,"p":"خوړل","f":"khoRul","g":"khoRul","e":"to eat, to bite","c":"v. trans.","psp":"خور","psf":"khor","tppp":"خوړ","tppf":"khoR","ec":"eat,eats,eating,ate,eaten"},
].map(entry => ({ entry }));
export const basicVerbs: T.VerbEntry[] = wordQuery("verbs", [
"leekul",
"wahul",
"skul",
"kawul",
"leedul",
"awredul",
"khoRul",
]);
// @ts-ignore
export const intransitivePastVerbs: T.VerbEntry[] = [
{"ts":1527813573,"i":6809,"p":"رسېدل","f":"rasedul","g":"rasedul","e":"arrive, reached; (fig.) understand, attain to; mature, ripen","c":"v. intrans.","shortIntrans":true,"ec":"arrive"},
{"ts":1527812645,"i":10822,"p":"ګرځېدل","f":"gurdzedul","g":"gurdzedul","e":"to walk, wander, turn about; to become, to be","c":"v. intrans.","shortIntrans":true,"ec":"walk"},
{"ts":1527816495,"i":3470,"p":"تښتېدل","f":"tuxtedul","g":"tuxtedul","e":"to run off, escape, flee","c":"v. intrans.","shortIntrans":true,"ec":"escape"},
{"ts":1527813680,"i":9218,"p":"غږېدل","f":"ghuGedul, ghaGedul","g":"ghugedul,ghagedul","e":"to speak, talk, converse, sing","c":"v. intrans.","ec":"speak,speaks,speaking,spoke"},
{"ts":1527813994,"i":11676,"p":"لوېدل","f":"lwedul","g":"lwedul","e":"to fall, to tumble, go down, settle","c":"v. intrans.","tppp":"لوېد","tppf":"lwed","ec":"fall,falls,falling,fell,fallen"},
{"ts":1527815216,"i":6630,"p":"راتلل","f":"raatlúl","g":"raatlul","e":"to come","c":"v. intrans. irreg.","psp":"راځ","psf":"raadz","ssp":"راش","ssf":"ráash","prp":"راغلل","prf":"ráaghlul","pprtp":"راغلی","pprtf":"raaghúley","tppp":"راغی","tppf":"ráaghey","noOo":true,"separationAtP":2,"separationAtF":3,"ec":"come,comes,coming,came,come"},
{"ts":1527813710,"i":7321,"p":"زېږېدل","f":"zeGedul","g":"zegedul","e":"to be born, to appear, arise","c":"v. intrans.","ec":"be","ep":"born"},
{"ts":1527812759,"i":10796,"p":"کېناستل","f":"kenaastul","g":"kenaastul","e":"to sit down, to have a seat","c":"v. intrans. irreg.","psp":"کېن","psf":"ken","noOo":true,"separationAtP":2,"separationAtF":2,"ec":"sit,sits,sitting,sat","ep":"down"},
].map(entry => ({ entry }));
export const intransitivePastVerbs: T.VerbEntry[] = wordQuery("verbs", [
"rasedul",
"gurdzedul",
"tuxtedul",
"ghuGedul",
"lwedul",
"raatlúl",
"zeGedul",
"kenaastul",
"alwatul",
"prewatul",
"خوځېدل",
]);

View File

@ -29,6 +29,8 @@ import {
transitiveImperfectivePastVerbGame2,
transitivePerfectivePastVerbGame1,
transitivePerfectivePastVerbGame2,
habitualPastVerbGame1,
habitualPastVerbGame2,
} from "../../games/games";
import GameDisplay from "../../games/GameDisplay";
@ -239,4 +241,8 @@ The habitual continuous past is **also used to say what would happen if some con
{ p: "**که زه ستړې نه وای، **پارک ته به تلم", f: "ku zu stuRe nu waay, **paark ta ba tlum**", e: "If I (f.) wasn't tired, **I would go to the park**." }
])}</Examples>
<GameDisplay record={habitualPastVerbGame1} />
<GameDisplay record={habitualPastVerbGame2} />

View File

@ -64,7 +64,7 @@ function ChapterDisplay({ chapter, user, handleClick, expanded }: {
</div>
</div>
<SmoothCollapse expanded={open}>
<Game inChapter={false} />
{open && <Game inChapter={false} />}
</SmoothCollapse>
</div>
})}

View File

@ -208,7 +208,7 @@ export const transitivePerfectivePastVerbGame2 = makeGameRecord({
});
export const transitiveImperfectivePastVerbGame1 = makeGameRecord({
title: "Write the transitive continuous past verb (one)",
id: "transitive-imperfective-past-verbs-write",
id: "transitive-imperfective-past-verbs-write-1",
link: "/verbs/past-verbs/#past-tense-with-transitive-verbs-",
level: { level: 1, type :"transitiveImperfectivePast" },
SubCore: VerbGame,
@ -220,6 +220,34 @@ export const transitiveImperfectivePastVerbGame2 = makeGameRecord({
level: { level: 2, type :"transitiveImperfectivePast" },
SubCore: VerbGame,
});
export const habitualPastVerbGame1 = makeGameRecord({
title: "Write the habitual past verb (one)",
id: "habitual-past-verbs-write-1",
link: "/verbs/past-verbs/#habitual-past-tenses",
level: { level: 1, type : "habitualPast" },
SubCore: VerbGame,
});
export const habitualPastVerbGame2 = makeGameRecord({
title: "Write the habitual past verb (mix)",
id: "habitual-past-verbs-write-2",
link: "/verbs/past-verbs/#habitual-past-tenses",
level: { level: 2, type: "habitualPast" },
SubCore: VerbGame,
});
export const allPastVerbGame1 = makeGameRecord({
title: "Write the past verb (one)",
id: "all-past-verbs-write-1",
link: "/verbs/past-verbs/",
level: { level: 1, type : "allPast" },
SubCore: VerbGame,
});
export const allPastVerbGame2 = makeGameRecord({
title: "Write past verb (mix)",
id: "all-past-verbs-write-2",
link: "/verbs/past-verbs/",
level: { level: 2, type: "allPast" },
SubCore: VerbGame,
});
const games: { chapter: string, items: GameRecord[] }[] = [
{
@ -265,10 +293,21 @@ const games: { chapter: string, items: GameRecord[] }[] = [
transitiveImperfectivePastVerbGame2,
transitivePerfectivePastVerbGame1,
transitivePerfectivePastVerbGame2,
habitualPastVerbGame1,
habitualPastVerbGame2,
allPastVerbGame1,
allPastVerbGame2,
],
}
},
];
// check to make sure we have no duplicate game keys
games.forEach(({ items }) => {
const allAreUnique = (arr: unknown[]) => arr.length === new Set(arr).size;
const ids = items.map(x => x.id);
if (!allAreUnique(ids)) throw new Error("duplicate game key");
})
export default games;
function makeGameRecord<T>({ title, id, link, level, SubCore }:{

View File

@ -6,7 +6,6 @@ import GameCore from "../GameCore";
import {
Types as T,
defaultTextOptions as opts,
typePredicates as tp,
makeNounSelection,
randFromArray,
flattenLengths,
@ -35,6 +34,7 @@ import { getVerbFromBlocks } from "@lingdocs/pashto-inflector/dist/lib/phrase-bu
import { baParticle } from "@lingdocs/pashto-inflector/dist/lib/grammar-units";
import { intransitivePastVerbs } from "../../content/verbs/basic-present-verbs";
import { makePool } from "../../lib/pool";
import { wordQuery } from "../../words/words";
const kidsColor = "#017BFE";
@ -46,35 +46,35 @@ type Question = {
phrase: { ps: T.SingleOrLengthOpts<T.PsString[]>, e?: string[] },
};
// TODO: Make a mechanism where we just create a list of words like "leedul", "wahul" and it searches them out of the pool of words in the grammar
const transitivePastVerbs = wordQuery("verbs", [
"leedul",
"wahul",
"khoRul",
"shărmawul",
"pejzandul",
"taRul",
]);
const transitivePastVerbs: T.VerbEntry[] = [
{"ts":1527812275,"i":11698,"p":"لیدل","f":"leedul","g":"leedul","e":"to see","c":"v. trans./gramm. trans.","psp":"وین","psf":"ween","tppp":"لید","tppf":"leed","ec":"see,sees,seeing,saw,seen"},
{"ts":1527815399,"i":14594,"p":"وهل","f":"wahul","g":"wahul","e":"to hit","c":"v. trans.","tppp":"واهه","tppf":"waahu","ec":"hit,hits,hitting,hit,hit"},
{"ts":1527812790,"i":5840,"p":"خوړل","f":"khoRul","g":"khoRul","e":"to eat, to bite","c":"v. trans.","psp":"خور","psf":"khor","tppp":"خوړ","tppf":"khoR","ec":"eat,eats,eating,ate,eaten"},
{"ts":1527814596,"i":8398,"p":"شرمول","f":"shărmawul","g":"sharmawul","e":"to shame, to disgrace, to dishonor","c":"v. trans.","ec":"embarrass"},
].map(entry => ({ entry })) as T.VerbEntry[]
const verbs = wordQuery("verbs", [
"leekul",
"wahul",
"leedul",
"awredul",
"khoRul",
"akhistul",
"katul",
"lwedul",
]);
const verbs: T.VerbEntry[] = [
{"ts":1527812856,"i":11630,"p":"لیکل","f":"leekul","g":"leekul","e":"to write, draw","c":"v. trans./gramm. trans.","ec":"write,writes,writing,wrote,written"},
{"ts":1527815399,"i":14480,"p":"وهل","f":"wahul","g":"wahul","e":"to hit","c":"v. trans.","tppp":"واهه","tppf":"waahu","ec":"hit,hits,hitting,hit,hit"},
{"ts":1527812275,"i":11608,"p":"لیدل","f":"leedul","g":"leedul","e":"to see","c":"v. trans./gramm. trans.","psp":"وین","psf":"ween","tppp":"لید","tppf":"leed","ec":"see,sees,seeing,saw,seen"},
{"ts":1577049208257,"i":1068,"p":"اورېدل","f":"awredul","g":"awredul","e":"to hear, listen","c":"v. trans./gramm. trans.","psp":"اور","psf":"awr","tppp":"اورېد","tppf":"awred","ec":"hear,hears,hearing,heard"},
{"ts":1527812790,"i":5813,"p":"خوړل","f":"khoRul","g":"khoRul","e":"to eat, to bite","c":"v. trans.","psp":"خور","psf":"khor","tppp":"خوړ","tppf":"khoR","ec":"eat,eats,eating,ate,eaten"},
{"ts":1527812447,"i":292,"p":"اخستل","f":"akhistúl, akhustúl","g":"akhistul,akhustul","e":"to take, buy, purchase, receive; to shave, cut with scissors","c":"v. trans.","psp":"اخل","psf":"akhl","tppp":"اخست","tppf":"akhist","ec":"take,takes,taking,took,taken"},
{"ts":1527812751,"i":10083,"p":"کتل","f":"katul","g":"katul","e":"to look, see, watch, examine; to meet with","c":"v. trans./gramm. trans.","psp":"ګور","psf":"gor","tppp":"کوت","tppf":"kot","ec":"look"},
{"ts":1527813994,"i":11654,"p":"لوېدل","f":"lwedul","g":"lwedul","e":"to fall, to tumble, go down, settle","c":"v. intrans.","ec":"fall,falls,falling,fell,fallen"},
].map(entry => ({ entry })) as T.VerbEntry[];
// @ts-ignore
const nouns: T.NounEntry[] = [
{"ts":1527815251,"i":7790,"p":"سړی","f":"saRéy","g":"saRey","e":"man","c":"n. m.","ec":"man","ep":"men"},
{"ts":1527812797,"i":8605,"p":"ښځه","f":"xúdza","g":"xudza","e":"woman, wife","c":"n. f.","ec":"woman","ep":"women"},
{"ts":1527812881,"i":11691,"p":"ماشوم","f":"maashoom","g":"maashoom","e":"child, kid","c":"n. m. anim. unisex","ec":"child","ep":"children"},
{"ts":1527815197,"i":2503,"p":"پښتون","f":"puxtoon","g":"puxtoon","e":"Pashtun","c":"n. m. anim. unisex / adj.","infap":"پښتانه","infaf":"puxtaanu","infbp":"پښتن","infbf":"puxtan"},
{"ts":1527815737,"i":484,"p":"استاذ","f":"Ustaaz","g":"Ustaaz","e":"teacher, professor, expert, master (in a field)","c":"n. m. anim. unisex anim.","ec":"teacher"},
{"ts":1527816747,"i":6418,"p":"ډاکټر","f":"DaakTar","g":"DaakTar","e":"doctor","c":"n. m. anim. unisex"},
{"ts":1527812661,"i":13938,"p":"هلک","f":"halík, halúk","g":"halik,haluk","e":"boy, young lad","c":"n. m. anim."},
].filter(tp.isNounEntry);
const nouns = wordQuery("nouns", [
"saRey",
"xudza",
"maashoom",
"puxtoon",
"Ustaaz",
"DaakTar",
"halik",
]);
const persons: T.Person[] = [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
@ -92,9 +92,10 @@ type VerbGameLevel = {
level: 1 | 2,
type: "presentVerb" | "subjunctiveVerb"
| "futureVerb" | "imperative" | "intransitivePerfectivePast"
| "intransitiveImperfectivePast" | "transitivePerfectivePast" | "transitiveImperfectivePast";
| "intransitiveImperfectivePast" | "transitivePerfectivePast" | "transitiveImperfectivePast"
| "allPast" | "habitualPast";
}
type VerbPoolName = "basic" | "transitivePast" | "intransitivePast";
type VerbPoolName = "basic" | "transitivePast" | "intransitivePast" | "mixedPast";
function selectVerbPool({ type }: VerbGameLevel): VerbPoolName {
return type === "presentVerb"
@ -111,8 +112,10 @@ function selectVerbPool({ type }: VerbGameLevel): VerbPoolName {
? "intransitivePast"
: type === "transitiveImperfectivePast"
? "transitivePast"
// : type === "transitivePerfectivePast"
: "transitivePast";
: type === "transitivePerfectivePast"
? "transitivePast"
// : type === "habitualPast" || type === "allPast"
: "mixedPast";
}
// TODO: Level where you create the formulas (seperate file)
@ -132,6 +135,7 @@ const VerbGame: GameSubCore<VerbGameLevel> = ({ id, link, level, inChapter }: {
basic: makePool(verbs, 15),
transitivePast: makePool(transitivePastVerbs, 15),
intransitivePast: makePool(intransitivePastVerbs, 15),
mixedPast: makePool([...transitivePastVerbs, ...intransitivePastVerbs], 15),
};
const oneVerb: T.VerbEntry = verbPools[selectVerbPool(level)]();
const getVerb = level.level === 1
@ -145,7 +149,7 @@ const VerbGame: GameSubCore<VerbGameLevel> = ({ id, link, level, inChapter }: {
number: n.numberCanChange ? randFromArray(["singular", "plural"]) : n.number,
};
}
function makeRandomVPS(l: T.VerbTense | T.ImperativeTense): T.VPSelectionComplete {
function makeRandomVPS(tense: T.VerbTense | T.ImperativeTense): T.VPSelectionComplete {
function personToNPSelection(p: T.Person): T.NPSelection {
if (isThirdPerson(p)) {
return {
@ -175,10 +179,6 @@ const VerbGame: GameSubCore<VerbGameLevel> = ({ id, link, level, inChapter }: {
do {
servant = randomPerson();
} while (isInvalidSubjObjCombo(king, servant));
// const tense = (l === "allIdentify" || l === "allProduce")
// ? randFromArray(tenses)
// : l;
const tense = l;
return makeVPS({
verb,
king: personToNPSelection(king),
@ -212,6 +212,11 @@ const VerbGame: GameSubCore<VerbGameLevel> = ({ id, link, level, inChapter }: {
const [answer, setAnswer] = useState<string>("");
const [withBa, setWithBa] = useState<boolean>(false);
const handleInput = ({ target: { value }}: React.ChangeEvent<HTMLInputElement>) => {
if (value === "به " || value === "به ") {
setWithBa(true);
setAnswer("");
return;
}
setAnswer(value);
}
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
@ -388,7 +393,12 @@ function levelToDescription({ type }: VerbGameLevel): string {
? "continuous past transitive"
: type === "transitivePerfectivePast"
? "simple past transitive"
: "imperfective imperative or perfective imperative";
: type === "imperative"
? "imperfective imperative or perfective imperative"
: type === "allPast"
? "past tense"
// : type === "habitualPast"
: "habitual past";
}
function levelToTense({ type }: VerbGameLevel): T.VerbTense | T.ImperativeTense {
@ -400,10 +410,19 @@ function levelToTense({ type }: VerbGameLevel): T.VerbTense | T.ImperativeTense
? randFromArray(["perfectiveFuture", "imperfectiveFuture"])
: type === "imperative"
? randFromArray(["perfectiveImperative", "imperfectiveImperative"])
: type.includes("ImperfectivePast")
: (type === "intransitiveImperfectivePast" || type === "transitiveImperfectivePast")
? "imperfectivePast"
// : level.includes("perfectivePast")
: "perfectivePast";
: (type === "intransitivePerfectivePast" || type === "transitivePerfectivePast")
? "perfectivePast"
: type === "habitualPast"
? randFromArray(["habitualPerfectivePast", "habitualImperfectivePast"])
// : type === "allPast"
: randFromArray([
"perfectivePast",
"imperfectivePast",
"habitualPerfectivePast",
"habitualImperfectivePast",
]);
}
function makeVPS({ verb, king, servant, tense, defaultTransitivity }: {

View File

@ -17,6 +17,7 @@ module.exports = [
1527817664, // تود
1577408901204, // ځنګون
1527819238, // ورون
1527815162, // پتنوس
1527816071, // خپور
1574865652928, // خوږ
1527813499, // دروند

View File

@ -7,6 +7,7 @@
*/
module.exports = [
1527817036, // astáazey
1582853867682, // اوسېدونکی
1527813469, // بخښونکی
1527817829, // پوروړی

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,7 @@
*/
module.exports = [
1527813710, // zeGedul
1527813473,// الوتل - to fly
1527814012,// اوښتل - to pass over, overturn, be flipped over, spill over, shift, change, diverge, pass, cross, abandon
1527822843,// برېښېدل - to appear, seem; to shine, sparkle; to smart, have a pricking pain

View File

@ -8,6 +8,7 @@
module.exports = [
1527814617, // نیول - to take
1527812447, // akhistul
1527811872, // اچول - to put, pour, drop, throw, put on
1527817298, // اخیستل - to take, buy, purchase, receive; to shave, cut with scissors
1527816127, // اړول - to turn over, flip over; convert, change; to move over to, establish oneself in a new spot; divert, turn away, hijack

View File

@ -31,7 +31,23 @@ export function wordQuery(category: "nouns", w: string[]): T.NounEntry[];
export function wordQuery(category: "adjectives", w: string[]): T.AdjectiveEntry[];
export function wordQuery(category: "adverbs", w: string[]): T.AdverbEntry[];
export function wordQuery(category: "locativeAdverbs", w: string[]): T.LocativeAdverbEntry[];
export function wordQuery(category: "nouns" | "adjectives" | "adverbs" | "locativeAdverbs", w: string[]): T.NounEntry[] | T.AdjectiveEntry[] | T.AdverbEntry[] | T.LocativeAdverbEntry[] {
export function wordQuery(category: "verbs", w: string[]): T.VerbEntry[];
export function wordQuery(
category: "nouns" | "adjectives" | "adverbs" | "locativeAdverbs" | "verbs",
w: string[],
): T.NounEntry[] | T.AdjectiveEntry[] | T.AdverbEntry[] | T.LocativeAdverbEntry[] | T.VerbEntry[] {
if (category === "verbs") {
return w.map(word => {
const l = words[category];
const found = l.find(x => vMatches(x, word));
if (!found) throw new Error(`${word} not found by wordQuery`);
return found;
});
}
function vMatches(x: T.VerbEntry, y: string) {
return (y === x.entry.p)
|| (removeAccents(y) === removeAccents(removeFVarients(x.entry.f)));
}
function wMatches(x: T.DictionaryEntry, y: string) {
return (y === x.p)
|| (removeAccents(y) === removeAccents(removeFVarients(x.f)));

View File

@ -1804,10 +1804,10 @@
rambda "^6.7.0"
react-select "^5.2.2"
"@lingdocs/pashto-inflector@^3.8.8":
version "3.8.8"
resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-3.8.8.tgz#fd9f2344b8ea6c6a541a24c565b5b0a771e53915"
integrity sha512-GUr3MwM6m0+IqFQopkn1+/s2rEF8u626ZpvullGVejB+Z5PEcIV5WzulM6aDAqgsMCPAy7qulJIxjQ9anGSvcw==
"@lingdocs/pashto-inflector@^3.8.9":
version "3.8.9"
resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-3.8.9.tgz#c023449dc13dbc32ef95cef172a68b5b0b4659bf"
integrity sha512-60hAao+ADerI5hOMeJzYmrSCliwTqCndbUlx1Ke58s2FikxDqUb9/wb700JVbhsVLyRdr6tGg+YslDf4irr5tA==
dependencies:
"@formkit/auto-animate" "^1.0.0-beta.1"
classnames "^2.2.6"