decks/make_deck.py
2024-05-04 14:31:52 -07:00

1003 lines
16 KiB
Python

import os
import pathlib
import shutil
import subprocess
import genanki
print("Cleanup...")
root = pathlib.Path(__file__).parent / "build"
if root.exists():
shutil.rmtree(root)
os.mkdir(root)
os.mkdir(root / "words")
########################################################################3
model = genanki.Model(
1535966710,
"Addition Problem",
fields=[
{"name": "Problem"},
{"name": "Sum"},
],
templates=[
{
"name": "Card 1",
"qfmt": "{{Problem}}<br/><br/>{{type:Sum}}",
"afmt": '{{FrontSide}}<hr id="answer">',
},
],
)
print("Addition 1-10...")
deck = genanki.Deck(1360034114, "Addition 1-10")
for x in range(11):
for y in range(11):
note = genanki.Note(model=model, fields=[f"{x} + {y}", str(x + y)])
deck.add_note(note)
genanki.Package(deck).write_to_file(str(root / "addition_1_10.apkg"))
print("Addition 11-20...")
deck = genanki.Deck(1354309777, "Addition 11-20")
for x in range(11, 21):
for y in range(11, 21):
note = genanki.Note(model=model, fields=[f"{x} + {y}", str(x + y)])
deck.add_note(note)
genanki.Package(deck).write_to_file(str(root / "addition_11_20.apkg"))
########################################################################3
model = genanki.Model(
1964109108,
"Multiplication Problem",
fields=[
{"name": "Problem"},
{"name": "Product"},
],
templates=[
{
"name": "Card 1",
"qfmt": "{{Problem}}<br/><br/>{{type:Product}}",
"afmt": '{{FrontSide}}<hr id="answer">',
},
],
)
print("Multiplication 1-12...")
deck = genanki.Deck(1644222090, "Multiplication 1-12")
for x in range(13):
for y in range(13):
note = genanki.Note(model=model, fields=[f"{x} x {y}", str(x * y)])
deck.add_note(note)
genanki.Package(deck).write_to_file(str(root / "multiplication_1_12.apkg"))
########################################################################3
model = genanki.Model(
1588793726,
"Spelling Problem",
fields=[
{"name": "Pronounciation"},
{"name": "Sentance Front"},
{"name": "Sentence Back"},
{"name": "Spelling"},
],
templates=[
{
"name": "Card 1",
"qfmt": "Spell the word that goes here:<br/>{{Sentence Front}} __________ {{Sentence Back}}<br/>{{Pronounciation}}<br/><br/>{{type:Spelling}}",
"afmt": '{{FrontSide}}<hr id="answer">',
},
],
)
def spelling_deck(id, title, file_name, words):
print(f"{title}...")
deck = genanki.Deck(id, title)
media_files = []
for word in words:
print(f" {word}")
output_file = str(root / "words" / f"{word}.wav")
subprocess.run(["espeak-ng", "-s", "125", word, "-w", output_file])
media_files.append(output_file)
note = genanki.Note(model=model, fields=[f"[sound:{word}.wav]", word])
deck.add_note(note)
package = genanki.Package(deck)
package.media_files = media_files
package.write_to_file(str(root / f"{file_name}.apkg"))
spelling_deck(
1745896623,
"Spelling: First Grade",
"spelling_first_grade",
[
"a",
"all",
"am",
"and",
"at",
"ball",
"be",
"bed",
"big",
"book",
"box",
"boy",
"but",
"came",
"can",
"car",
"cat",
"come",
"cow",
"dad",
"day",
"did",
"do",
"dog",
"fat",
"for",
"fun",
"get",
"go",
"good",
"got",
"had",
"hat",
"he",
"hen",
"here",
"him",
"his",
"home",
"hot",
"if",
"in",
"into",
"is",
"it",
"its",
"let",
"like",
"look",
"man",
"may",
"me",
"mom",
"my",
"no",
"not",
"of",
"oh",
"old",
"on",
"one",
"out",
"pan",
"pet",
"pig",
"play",
"ran",
"rat",
"red",
"ride",
"run",
"sat",
"see",
"she",
"sit",
"six",
"so",
"stop",
"sun",
"ten",
"the",
"this",
"to",
"top",
"toy",
"two",
"up",
"us",
"was",
"we",
"will",
"yes",
"you",
],
)
spelling_deck(
1748224344,
"Spelling: Second Grade",
"spelling_second_grade",
[
"about",
"add",
"after",
"ago",
"an",
"any",
"apple",
"are",
"as",
"ask",
"ate",
"away",
"baby",
"back",
"bad",
"bag",
"base",
"bat",
"bee",
"been",
"before",
"being",
"best",
"bike",
"bill",
"bird",
"black",
"blue",
"boat",
"both",
"bring",
"brother",
"brown",
"bus",
"buy",
"by",
"cake",
"call",
"candy",
"change",
"child",
"city",
"clean",
"club",
"coat",
"cold",
"coming",
"corn",
"could",
"cry",
"cup",
"cut",
"daddy",
"dear",
"deep",
"deer",
"doing",
"doll",
"door",
"down",
"dress",
"drive",
"drop",
"dry",
"duck",
"each",
"eat",
"eating",
"egg",
"end",
"fall",
"far",
"farm",
"fast",
"father",
"feed",
"feel",
"feet",
"fell",
"find",
"fine",
"fire",
"first",
"fish",
"five",
"fix",
"flag",
"floor",
"fly",
"food",
"foot",
"four",
"fox",
"from",
"full",
"funny",
"game",
"gas",
"gave",
"girl",
"give",
"glad",
"goat",
"goes",
"going",
"gold",
"gone",
"grade",
"grass",
"green",
"grow",
"hand",
"happy",
"hard",
"has",
"have",
"hear",
"help",
"here",
"hill",
"hit",
"hold",
"hole",
"hop",
"hope",
"horse",
"house",
"how",
"ice",
"inch",
"inside",
"job",
"jump",
"just",
"keep",
"king",
"know",
"lake",
"land",
"last",
"late",
"lay",
"left",
"leg",
"light",
"line",
"little",
"live",
"lives",
"long",
"looking",
"lost",
"lot",
"love",
"mad",
"made",
"make",
"many",
"meat",
"men",
"met",
"mile",
"milk",
"mine",
"miss",
"moon",
"more",
"most",
"mother",
"move",
"much",
"must",
"myself",
"nail",
"name",
"need",
"new",
"next",
"nice",
"night",
"nine",
"north",
"now",
"nut",
"off",
"only",
"open",
"or",
"other",
"our",
"outside",
"over",
"page",
"park",
"part",
"pay",
"pick",
"plant",
"playing",
"pony",
"post",
"pull",
"put",
"rabbit",
"rain",
"read",
"rest",
"riding",
"road",
"rock",
"room",
"said",
"same",
"sang",
"saw",
"say",
"school",
"sea",
"seat",
"seem",
"seen",
"send",
"set",
"seven",
"sheep",
"ship",
"shoe",
"show",
"sick",
"side",
"sing",
"sky",
"sleep",
"small",
"snow",
"some",
"soon",
"spell",
"start",
"stay",
"still",
"store",
"story",
"take",
"talk",
"tall",
"teach",
"tell",
"than",
"thank",
"that",
"them",
"then",
"there",
"they",
"thing",
"think",
"three",
"time",
"today",
"told",
"too",
"took",
"train",
"tree",
"truck",
"try",
"use",
"very",
"walk",
"want",
"warm",
"wash",
"way",
"week",
"well",
"went",
"were",
"wet",
"what",
"when",
"while",
"white",
"who",
"why",
"wind",
"wish",
"with",
"woke",
"wood",
"work",
"yellow",
"yet",
"your",
"zoo",
],
)
grade_3 = [
"able",
"above",
"afraid",
"afternoon",
"again",
"age",
"air",
"airplane",
"almost",
"alone",
"along",
"already",
"also",
"always",
"animal",
"another",
"anything",
"around",
"art",
"aunt",
"balloon",
"bark",
"barn",
"basket",
"beach",
"bear",
"because",
"become",
"began",
"begin",
"behind",
"believe",
"below",
"belt",
"better",
"birthday",
"body",
"bones",
"born",
"bought",
"bread",
"bright",
"broke",
"brought",
"busy",
"cabin",
"cage",
"camp",
"can't",
"care",
"carry",
"catch",
"cattle",
"cave",
"children",
"class",
"close",
"cloth",
"coal",
"color",
"corner",
"cotton",
"cover",
"dark",
"desert",
"didn't",
"dinner",
"dishes",
"does",
"done",
"don't",
"dragon",
"draw",
"dream",
"drink",
"early",
"earth",
"east",
"eight",
"even",
"ever",
"every",
"everyone",
"everything",
"eyes",
"face",
"family",
"feeling",
"felt",
"few",
"fight",
"fishing",
"flower",
"flying",
"follow",
"forest",
"forgot",
"form",
"found",
"fourth",
"free",
"Friday",
"friend",
"front",
"getting",
"given",
"grandmother",
"great",
"grew",
"ground",
"guess",
"hair",
"half",
"having",
"head",
"heard",
"he's",
"heat",
"hello",
"high",
"himself",
"hour",
"hundred",
"hurry",
"hurt",
"I'd",
"I'll",
"I'm",
"inches",
"isn't",
"it's",
"I've",
"kept",
"kids",
"kind",
"kitten",
"knew",
"knife",
"lady",
"large",
"largest",
"later",
"learn",
"leave",
"let's",
"letter",
"life",
"list",
"living",
"lovely",
"loving",
"lunch",
"mail",
"making",
"maybe",
"mean",
"merry",
"might",
"mind",
"money",
"month",
"morning",
"mouse",
"mouth",
"Mr.",
"Mrs.",
"Ms.",
"music",
"near",
"nearly",
"never",
"news",
"noise",
"nothing",
"number",
"o'clock",
"often",
"oil",
"once",
"orange",
"order",
"own",
"pair",
"paint",
"paper",
"party",
"pass",
"past",
"penny",
"people",
"person",
"picture",
"place",
"plan",
"plane",
"please",
"pocket",
"point",
"poor",
"race",
"reach",
"reading",
"ready",
"real",
"rich",
"right",
"river",
"rocket",
"rode",
"round",
"rule",
"running",
"salt",
"says",
"sending",
"sent",
"seventh",
"sew",
"shall",
"short",
"shot",
"should",
"sight",
"sister",
"sitting",
"sixth",
"sled",
"smoke",
"soap",
"someone",
"something",
"sometime",
"song",
"sorry",
"sound",
"south",
"space",
"spelling",
"spent",
"sport",
"spring",
"stairs",
"stand",
"state",
"step",
"stick",
"stood",
"stopped",
"stove",
"street",
"strong",
"study",
"such",
"sugar",
"summer",
"Sunday",
"supper",
"table",
"taken",
"taking",
"talking",
"teacher",
"team",
"teeth",
"tenth",
"that's",
"these",
"thinking",
"third",
"those",
"thought",
"throw",
"tonight",
"trade",
"trick",
"trip",
"trying",
"turn",
"twelve",
"twenty",
"uncle",
"under",
"upon",
"wagon",
"wait",
"walking",
"wasn't",
"watch",
"water",
"weather",
"we're",
"west",
"wheat",
"where",
"which",
"wife",
"wild",
"win",
"window",
"winter",
"without",
"woman",
"won",
"won't",
"wool",
"word",
"working",
"world",
"would",
"write",
"wrong",
"yard",
"year",
"yesterday",
"you're",
]
spelling_deck(
1283128462,
"Spelling: Third Grade",
"spelling_third_grade",
grade_3,
)
grade_4 = [
"across",
"against",
"answer",
"awhile",
"between",
"board",
"bottom",
"breakfast",
"broken",
"build",
"building",
"built",
"captain",
"carried",
"caught",
"charge",
"chicken",
"circus",
"cities",
"clothes",
"company",
"couldn't",
"country",
"discover",
"doctor",
"doesn't",
"dollar",
"during",
"eighth",
"else",
"enjoy",
"enough",
"everybody",
"example",
"except",
"excuse",
"field",
"fifth",
"finish",
"following",
"good-by",
"group",
"happened",
"harden",
"haven't",
"heavy",
"held",
"hospital",
"idea",
"instead",
"known",
"laugh",
"middle",
"minute",
"mountain",
"ninth",
"ocean",
"office",
"parent",
"peanut",
"pencil",
"picnic",
"police",
"pretty",
"prize",
"quite",
"radio",
"raise",
"really",
"reason",
"remember",
"return",
"Saturday",
"scare",
"second",
"since",
"slowly",
"stories",
"student",
"sudden",
"suit",
"sure",
"swimming",
"though",
"threw",
"tired",
"together",
"tomorrow",
"toward",
"tried",
"trouble",
"truly",
"turtle",
"until",
"village",
"visit",
"wear",
"we'll",
"whole",
"whose",
"women",
"wouldn't",
"writing",
"written",
"wrote",
"yell",
"young",
]
spelling_deck(
1576866982,
"Spelling: Fourth Grade",
"spelling_fourth_grade",
grade_4,
)
grade_5 = [
"although",
"America",
"among",
"arrive",
"attention",
"beautiful",
"countries",
"course",
"cousin",
"decide",
"different",
"evening",
"favorite",
"finally",
"future",
"happiest",
"happiness",
"important",
"interest",
"piece",
"planet",
"present",
"president",
"principal",
"probably",
"problem",
"receive",
"sentence",
"several",
"special",
"suddenly",
"suppose",
"surely",
"surprise",
"they're",
"through",
"usually",
]
spelling_deck(
2087228596,
"Spelling: Fifth Grade",
"spelling_fifth_grade",
grade_5,
)