See GitHub repository here
As a student of the Japanese language, one of the challenges I face is the sheer volume of flashcards that I must create to fulfill my study needs. My program of choice for creating and studying flashcards is Anki , a powerful SRS-based flashcard system.
Note: I no longer reccomend using Anki, while a great program, I found that Migaku better suits my needs.
While creating the cards manually is possible, in volumes of more than a few dozen, the creation process is tedious and time-consuming. However, by creating a Python script, I can easily shorten the amount of time to make the cards down to just a few hours.
I knew that Python was going to be the tool to do this. Its reputation for being able to automate anything made it clear that I was to use Python for this. However, I had only ever used Python for one semester at school and was quite inexperienced in using it. However, this was a challenge I was more than willing to overcome.
After researching different Python libraries, I could use, my plan for the script was as follows:
Acquire a list of words to use to create the flashcards. (Already completed)
Use a dictionary API to translate the words accurately.
Parse the data into a format that can be used to create flashcards on Anki.
Create the cards.
The frequency list in Excel.
A while back, I had seen a video by a channel called OhTalkWho オタク in which they described how they created a frequency list of 12,000 words curated from Japanese Netflix. This list was then provided as a CSV, which I used as my dataset.
Example data returned after appending the term 'house'
The obvious dictionary of choice was to use Jisho, a dictionary used by both Japanese and English language students alike. After researching, I found an API that allows for simply appending the desired search term to the end of the HTTP request string: http://beta.jisho.org/api/v1/search/words?keyword= which then returns JSON data containing all of the information about that word entry.
Anki fields that can be populated when creating a flashcard.
After retrieving the data from the server, Python’s json library can be used to convert the data into a dictionary, the contents of which can be used when incrementing over the input fields of the Anki card as seen here.
The resulting script creating flashcards.
With all the JSON data automatically parsed into a usable dictionary, creating cards from the deck is quite simple. After doing some research I could not find any information on possible APIs to create Anki cards directly, so rather I decided to have Python emulate creating them manually. Using two more libraries pyautogui and pyperclip I can iterate over each field and paste the data from the dictionary. Then all that needs to be done is to let the program run!
Overall, this project was a great experience. Not only was I able to learn a lot about automation using Python, but I also now have a huge deck of Japanese flashcards that I am studying right now!
Improvements and further developments on this project include:
Making the code more robust, fixing formatting issues and small bugs.
Re-formatting the card design and re-creating the deck to distribute as a way to give back to the Japanese language-learning community.
Creating more decks to learn from.