Automated flashcard generator

Suppose you are learning a language, and you want to create digital flashcards from a vocabulary list. For example, I am learning Chinese, and the vocabulary list looks like:

  121 付款/fùkuǎn To Pay

  Qǐngwèn zài nǎr fùkuǎn?
  请问在哪儿付款?

  Excuse me, where do I pay?

  122 复制/fùzhì To Copy

  Wǒ xiǎng bǎ zhège wénjiànjiā fùzhì dào wǒ de yìngpán lǐ.
  我想把这个文件夹复制到我的硬盘里。

  I want to copy this folder to my hard disk.
  ...
      

One approach is to go through the list and copy/paste the term and definition for each entry. This approach is slow and repetitive. You have to constantly switch between your vocabulary list and your flashcard tool.

Another approach is to use an automated flashcard generator. You can invest a little bit of time upfront and let technology to make the flashcards for you. I've created 50+ flashcard sets for Chinese, and each set only takes about 2 minutes to create. Here's how it works.

Instead of creating flashcards one by one, you can import a pre-formatted list. In Quizlet, the option is called "Import from Word, Excel, Google Docs, etc.". The steps are:

  1. Copy/paste an entire vocabulary list.
  2. Specify what separates the term and definition and what separates the cards.
  3. Preview + create the flashcards.

For example, you can easily import a vocabulary list like:

  121 付款/fùkuǎn To Pay
  122 复制/fùzhì To Copy
  ...

This works because the format is consistent. A forward slash (/) separates the term and definition, and a new line (\n) separates each card. However, if the format is inconsistent, the tool will create invalid flashcards. Depending on the vocabulary list format, you may need to edit the list so it's more consistent. To do so, you can either 1) make the changes yourself or 2) write code to make the changes.

Make the changes yourself

It is faster to make text changes in a code editor like Sublime Text. You can download Sublime here. Sublime and other code editors support keyboard shortcuts. These shortcuts aren't available in regular text editors like TextEdit or Pages on a Mac. In this example, you can:

  1. Highlight a forward slash.
  2. Type Cmd - D to select all instances of a forward slash.
  3. Press the arrow keys to move multiple cursors.
  4. Type Cmd - X to cut an entire line.

This lets you quickly remove unnecessary information and format the list. Here's an example video.

Write code to make the changes

You can also write code to make the changes for you. This is useful if it's hard to make changes yourself or if you're persnickety about flashcard formatting. For example, suppose you want flashcards like:

  付款;fùkuǎn, to pay
  复制;fùzhì, to copy

The changes here are:

If you learn basic programming, you can write code to automate these changes. I recommend you start by learning a scripting language like Python, NodeJS, or Ruby. These languages are relatively easy to learn and come in handy for short code scripts.

For example, here's a video with a Python code sample. When you run the code, it formats the vocabulary list into the desired flashcard format. This saves a lot of time for long vocabulary lists.

With a little upfront investment, you can save time and frustration on repetitive tasks. With a little bit of code, you can build even more efficient and robust solutions.

Appendix

Here is the Python code.


  # Define the data.
  data = """121 付款/fùkuǎn To Pay

  Qǐngwèn zài nǎr fùkuǎn?
  请问在哪儿付款?

  Excuse me, where do I pay?

  122 复制/fùzhì To Copy

  Wǒ xiǎng bǎ zhège wénjiànjiā fùzhì dào wǒ de yìngpán lǐ.
  我想把这个文件夹复制到我的硬盘里。

  I want to copy this folder to my hard disk."""

  # Look at each line of the data.
  lines = data.split("\n")
  for l in lines:
      # Check if the line has the vocab term.
      # This filters out sentences and empty lines.
      if "/" in l:
          # Split the line on the space i.e.
          # 121 付款/fùkuǎn To Pay => ["121", "付款/fùkuǎn", "To Pay"]
          # Then, find the term, pin_yin, and english_def.
          split_line = l.split(" ")
          [term, pin_yin] = split_line[1].split("/")
          english_def = " ".join(split_line[2:])
          print("{};{}, {}".format(term, pin_yin, english_def.lower()))