Ankivalenz: Turn notes into Anki cards

Creating and managing cards for Anki, the spaced-repetition software, can be tedious. Ankivalenz is a tool for automatically creating Anki cards from notes.

Author

Harry Vangberg

Published

October 30, 2022

Sometimes you need to memorize things to properly learn them. You are learning a new language, and you want to expand your vocabulary. You are studying for a biology exam, and you find it difficult to keep track of the endless stream of new concepts: prokaryotes, eukaryotes, endosymbionts, the citric acid cycle, glucose 6-phosphate.

Maybe you start creating flashcards. It helps, but soon you find yourself overwhelmed by the workload of reviewing them. Enter Anki, an app using spaced repetition. Anki decides when you will review a card, based on your previous ability to recall the answer to the card. The better you remember it, the less often you see it. The end result is, that you can keep adding cards to Anki, while maintaining a mostly constant review time.

Anki is great for reviewing cards, both on desktop and mobile, and provides free sync. What works less well, is creating and maintaining cards. This became obvious to me, when I used Anki to prepare for an admissions test, as part of my application to study biology at the University of Vienna.

This is what the process looked like: I would read a chapter at a time of the test literature, while taking extensive notes. After finishing a chapter, I would create cards in Anki, based on the notes I had taken.

So far, so good. You learn something, you memorize it. At some point you might even learn something, that replaces what you have previously learned. This is the blessing and the curse of deepening your understanding of a subject. In physics, you learn the Bohr model and everything seems fine: electrons orbit the nucleus in neat circles (Figure 1). Then you get to the atomic orbital model, and the picture becomes a lot more complicated (Figure 2).

Figure 1: The Bohr model. By JabberWok, CC BY-SA 3.0, (link)

Figure 2: Atomic orbitals of the electron in a hydrogen atom at different energy levels. By PoorLeno, (link)

Whenever this happened (i.e. all the time), I would go back to my notes on the given subject, and update them. Then I would open Anki, create cards with the new knowledge, and go hunting for old cards that needed to be updated or deleted. Anki gives you a list of all your cards, with some search and filter abilities (Figure 3), so the hunting metaphor is to be taken quite seriously. A decidedly unpleasant experience: cumbersome and frustrating.

Figure 3: Browsing cards in Anki.

Automation

The astute reader will have noticed, that I was essentially synchronizing my notes manually to Anki. I write my notes in Markdown, using the excellent visual editor in RStudio, and realized that it would make more sense to automatically generate Anki cards directly from those notes. My new tool Ankivalenz lets you do exactly that.

Here is an example of a Markdown file, from which a number of Anki cards can automatically be created:

# The Solar System

- Number of planets ?:: 8

## Planets

- Mars
  - ::? fourth planet
  - Color ?:: red

Cards are created from list items, with the delimeters ::, ?:: and ::? separating the question and the answer. The question mark in the delimeter indicates which part is the question, and which part is the answer: Question ?:: Answer and Answer ::? Question. The last variant (::) creates two cards, testing both sides.

Running Ankivalenz against the above Markdown file creates an Anki deck with the following cards:

Path Front Back
The Solar System Number of planets 8
The Solar System > Planets fourth planet Mars
The Solar System > Planets > Mars Color red

This is what the last one looks like in Anki:

Figure 4: A card in Anki, created by Ankivalenz.

The path, which is visible at the top of the card, shows where in the note hierarchy the card is. This gives you some context when reviewing cards, allowing for more succinct questions/answers. Instead of “What is the radius of Mars?”, you just need “Radius?” as a question.

It is early days, but I have used Ankivalenz for a couple of months, and so far I have created 500 Anki cards, spanning multiple subjects. As an unexpected side effect my notes have also improved: formulating them in an Anki-friendly way, seem to make them less verbose, and more focused. I also find myself creating Anki cards for a wider variety of subjects, simply because it has become easier to do so.

I am excited to see how this will play out in the long run, and I would love to hear from you, if Ankivalenz could be of interest to you.

And the admissions test? I passed.

Get it

Ankivalenz is distributed as a Python package on PyPI. To get started, take a look at the README in the GitHub repo.