KindleVocabToAnki app: importing words from your Kindle to Anki for language learning
Introduction
I enjoy reading books and learning foreign languages, so naturally, I frequently read books in foreign languages. In the past, I mainly read them on my smartphone, but last year I purchased a Kindle and absolutely loved it.
Reading on Kindle is a delightful experience on its own (I can read both in direct sunlight and in the dark), but it is especially useful for studying foreign languages. While reading a book, you can simply tap on a word and a pop-up with its translation appears. Moreover, these words are stored in a so-called “Vocabulary Builder”, from which you can extract them and perform various actions - like creating flashcards in Anki (or any other spaced repetition software).
I experimented with multiple apps for exporting and converting the vocabulary, but none of them fully met my requirements. As a result, I decided to create my own app. In this blog post, I will share my journey of developing this app and how it helped me.
What is Anki
If you aren’t familiar with Anki, let me explain the concept.
Learning new things involves not only understanding them initially but also retaining the information. The key to retention is repetition - repeatedly exposing yourself to the information at specific intervals. This is where Spaced Repetition comes into play.
Spaced Repetition is a technique that involves reviewing information just when you’re about to forget it. By doing so, you strengthen your memory each time.
At the core of SRS are the flashcards. On one side, you have a question or prompt, and on the reverse, the answer. The Spaced Repetition approach developed by Leitner is a system of organizing these flashcards into different decks or piles. Answer a card correctly? It goes into a pile that you’ll review less frequently. Get it wrong? It goes back to a pile you’ll see again sooner. This way, you focus more on what you don’t know and less on what you do, making your study sessions more efficient.
And that’s where Anki excels. As one of the best apps based on the Spaced Repetition System, it’s designed to help you learn and remember information for the long term. You can find more information about Anki here.
Overview of the existing tools for vocabulary export
As I already mentioned, there are existing apps for this purpose, but they were not flexible enough for me. I would like to share some of them here, in case people prefer them.
- https://github.com/prz3m/kind2anki -The main advantage of this solution is that it is an Anki addon, so it only requires adding it to Anki without any additional setups. However, it is not very customizable and crashes for me.
- https://kmate.me/ - This is quite a complex and advanced solution, but it only runs on Windows, and I am currently using a Mac.
- https://fluentcards.com/kindle - This website has a nice interface and the words are organized by books; there are several options for exporting, making it one of the best solutions. The main problem for me was that I couldn’t limit the list of words based on certain criteria. For example, when I’m reading a long book, I export the words multiple times throughout the reading and I wouldn’t want to retranslate them every time.
There are also other solutions, but they usually need to be run from the command line in Python or other programming languages and often require multiple steps, making them inconvenient.
And, as a result, I decided to make my own app.
My app
The app itself is built using the Streamlit Python library and hosted on Streamlit Cloud. This is one of the simplest ways to make and deploy simple apps in Python.
Uploading the data
To begin, we need some data. I have provided a sample of data for testing purposes, but I assume you will upload your Kindle vocabulary to extract the data from it. Please note that your data is only saved in your current session and is not logged or uploaded anywhere else.
Getting your Kindle vocabulary is straightforward: you need to connect your Kindle to your PC or laptop and get the vocabulary file (usually Kindle/system/vocabulary/vocab.db
) from it.
Next, you can see the data from your vocabulary: the word and its sentence, the stem of the word, and the book information.
I also provide a simple analysis of the data. You can see some statistics about the books and the information on the looked-up words.
Translating the data
You have the choice to translate either the word itself or the entire sentence. Note that the translation quality may not be perfect for complex cases since it relies on the Google Translate API. To improve accuracy, I’ve experimented with sending the context along with the word to the API. This involves enclosing the word with special marks and extracting it afterward.
In addition, I’ve tested the OpenAI API, which performed well. It gives better translations, but takes much more time than Google Translate to provide the results it is slower on its own, and it has rate limiting. And, sometimes, it gives timeout errors. If you are interested in it, you could try OpenAI API by yourself, my current prompt looks like this:
‘Given the context “{text}” translate the word “{word}” into {lang}. If there are several possible translations, provide them. Provide only the translations, not any descriptive words.’
Once you have configured all the options, simply click “Translate” and wait as calling the Google Translate API may take some time.
Downloading the data
Finally, you can review the translated data and customize the table before downloading it. You have the option to select and reorder the columns, and even rename them.
One of the most important aspects is the word’s display in the sentence: I provide different methods of highlighting, including cloze deletion. This is a unique Anki format where the word is initially hidden and can be revealed by clicking on it.
Lastly, you can download the CSV file with the data and import it into Anki later.
I frequently use the app myself. As shown in one of the screenshots above, I have looked up approximately 2700 words on Kindle. Reading and reviewing the words later is one of my favorite ways of obtaining and retaining new words. I always double-check translations when studying new cards, which helps me remember them better.
I have personally benefited greatly from this app and I hope it will be useful for others as well.
blogpost languages