wonderfly Blog

Build Up Spanish Vocabulary Programmatically

Background

I am trying to build up my Spanish vocabulary by reading books. Every week I learn about 200 new words. I’ve been using Quizlet in the past to put new words into study sets which are basically sets of flash cards. With 200 new words every week it’s almost impossible to type them in by hand. I am a software engineer, so naturally I seek a programmatic way, to scale up. Here in this post I write about the solution I have come up with, and as you will see shortly it is pretty effective.

Children’s books

My Spanish vocabulary is limited to reading children’s books. Every two weeks I borrow a new book from the library. In my first round I try to go through the entire book before stopping for new words, while circling them out throughout the process. At the end, I typically get about 200 new words that I need to study.

Translate

Now that I have circled out 200 words from the book, I create a Google Spreadsheet, and start typing each word in the vertical column. Once I am done typing, I copy the column, and paste it to the column next to it. I select the entire second column, and click “Add-ons” > “Translate My Sheet” > “Start a new translation”. In the pop-out window, I select the source and target languages, and select “Override cells”. Once I click the “Translate” button, a magic sequence happens and all the words in the second column will be replaced by their English translations.

Flashcards

So that saved me a lot of time typing and translating each word using Google Translate or SpanisDict, but having it in a spreadsheet isn’t as handy as in the flashcards that I like a lot from Quizlet and TinyCards. I read online that Quizlet does have an API that can be used to create cards programmatically, but for some reason they’ve paused the API since December 2018. So I needed to find an alternative.

Anki

A number of search results pointed to this open sourced flash card application that lets you bulk create flash cards from a CSV file. It has a desktop version (Mac, Windows, Linux) and a mobile version (iPhone, Android). Better yet, you could sync the cards you’ve created on your desktop to your mobile app - exactly what I wanted, via a free web service called AnkiWeb. You do have to sign up for an account and acknowledge some privacy agreements, but if you are only uploading third-grade Spanish words you probably don’t care too much. It’s clearly stated on the website that it is run by the money the Anki developers get from the paid iPhone app so they may start charging in the future for the sync service if that revenue couldn’t sustain the cost of running the service. I like their honesty.

Anyway, I installed the Mac version on my iMac, downloaded the Google Spreadsheet I just made as a CSV file (the Google Spreadsheet UI lets you do that), and “imported” it into the Anki app as a new set. As can be seen from the following screenshot, it took almost no time to load a 200 word set.

Sync

Now that I’ve created a new deck, how do I get it on my Android app? Well, I first need to upload the new deck through the Mac app to AnkiWeb.

If I go to the web UI of AnkiWeb now, I can see that the new deck has just been uploaded. I can browse cards and study right from the web UI if I wanted. But I could also log in to AnkiWeb on my AnkiDroid app, and in a few seconds I will see the same deck there too. It’s that easy.

Summary

To summarize, I read a book, circling out the new words while reading it. When I finish reading, I go to my computer, and type those new words in a Google Spreadsheet. With the help of the Google Translate “add-on”, I get the translations of every word in less than a minute. I download the spreadsheet as a CSV file, import it into the Anki app on my iMac. That will create a new deck with all the word pairs automatically. After syncing with AnkiWeb, I go to my AnkiDroid app and do the sync there, I get to see the same deck. Ready to study!