I’ve always been a huge fan of notecards. Ever since I had to memorize the 27 amendments to the constitution in 8th grade I’ve understood the power of “spaced repetition”. I’ve tried online solutions before like Quizlet but nothing felt quite as natural to me as the real index cards in my hand. Only problem — it takes forever to handwrite these cards. Apparently I’ve been living under a rock because there is a tool called “Anki” that is a desktop/mobile synced notecard application that when utilized with ChatGPT, can expedite making useful study cards in an instant.
Huge thanks to Otavio Ehrenberger who’s guide I followed here as well as kerrickstaley who authored the genanki library.
More about Anki
Anki is a popular spaced repetition software that allows users to create digital flashcards to help them memorize information. It uses an algorithm that schedules cards based on how well the user has remembered them in the past. This means that if you remember a card well, you will see it less frequently, and if you struggle with a card, you will see it more often. This helps optimize the learning process, ensuring that you are focusing on the information you need to study the most.
Another benefit of using Python with Anki is the ability to customize the learning experience. Anki comes with a set of predefined card types, but with Python, you can create custom card types that fit your specific needs. For example, if you are studying anatomy, you could create cards that show images of the human body and ask you to label the different organs (apparently Anki is very popular in the medical school field).
The Chat-GPT Part
This is where the time consuming part happens in seconds. Simply ask the AI for the data you want:
Then ask for it in the Python friendly format:
It is really that easy.
The Python Code
Next you just have ensure you have the genanki library installed, switch the mlb_teams
variable for your data, and run the script. After which you will receive the output of a file with the .apkg
extension which can be important from the Anki app directly. It’s really that easy.
import genanki
# List of MLB teams and their stadium
mlb_teams = [
('Arizona Diamondbacks', 'Chase Field'),
('Atlanta Braves', 'Truist Park'),
('Baltimore Orioles', 'Oriole Park at Camden Yards'),
('Boston Red Sox', 'Fenway Park'),
('Chicago Cubs', 'Wrigley Field'),
('Chicago White Sox', 'Guaranteed Rate Field'),
('Cincinnati Reds', 'Great American Ball Park'),
('Cleveland Indians', 'Progressive Field'),
('Colorado Rockies', 'Coors Field'),
('Detroit Tigers', 'Comerica Park'),
('Houston Astros', 'Minute Maid Park'),
('Kansas City Royals', 'Kauffman Stadium'),
('Los Angeles Angels', 'Angel Stadium'),
('Los Angeles Dodgers', 'Dodger Stadium'),
('Miami Marlins', 'LoanDepot Park'),
('Milwaukee Brewers', 'American Family Field'),
('Minnesota Twins', 'Target Field'),
('New York Mets', 'Citi Field'),
('New York Yankees', 'Yankee Stadium'),
('Oakland Athletics', 'RingCentral Coliseum'),
('Philadelphia Phillies', 'Citizens Bank Park'),
('Pittsburgh Pirates', 'PNC Park'),
('San Diego Padres', 'Petco Park'),
('San Francisco Giants', 'Oracle Park'),
('Seattle Mariners', 'T-Mobile Park'),
('St. Louis Cardinals', 'Busch Stadium'),
('Tampa Bay Rays', 'Tropicana Field'),
('Texas Rangers', 'Globe Life Field'),
('Toronto Blue Jays', 'Rogers Centre'),
('Washington Nationals', 'Nationals Park')
]
# Define Anki note model
model_id = 1607392319 #random number here
model = genanki.Model(
model_id,
'Simple Model',
fields=[
{'name': 'Directory'},
{'name': 'Description'},
],
templates=[
{
'name': 'Card 1',
'qfmt': '{{Directory}}',
'afmt': '{{Description}}',
},
{
'name': 'Card 2',
'qfmt': '{{Description}}',
'afmt': '{{Directory}}',
},
])
# Generate Anki cards and add them to a deck
deck_id = 2059400110
deck = genanki.Deck(deck_id, 'MLB Stadiums')
for team_name, stadium in mlb_teams:
note = genanki.Note(model=model, fields=[team_name, stadium])
deck.add_note(note)
# Save the deck to an Anki package (*.apkg) file
genanki.Package(deck).write_to_file('mlb_stadiums.apkg')
see the full code here.
In conclusion, I’m optimistic that Anki can be a powerful tool for expediting studying. I should also mentioned that you can just google existing notecards that many people have already made which you can download and import — saving you the need to even run this script at all! I hope you enjoy these tools as much as I do.