Automated Flashcard Making with Mnemosyne and Python

As a student, I need to memorize a bunch of random stuff. Flashcards are a good way of doing so, and my all-time favorite flashcard program is Mnemosyne. It’s lightweight, simple, powerful, and has this nifty algorithm for determining what card to show you next based on memory studies (by real psychologists(!)).

My current batch of flashcards deal with American history, and they happen to be pretty extensive–instead of

Quakers : Followers of a simple religion popular in Pennsylvania.

It’s:

Quakers:

  • Quakers believed human religious institutions were, for the most part, unnecessary
  • They believed they could receive revelation directly from God and placed little importance on the Bible
  • They were pacifists and declined to show customary deference to their alleged social superiors
  • Their aggressiveness in denouncing established institutions brought them trouble in both Britain and America
  • They opposed slavery and favored decent treatment of Native Americans
  • Elements of this culture would play a role in shaping the characterization of a United States that valued independence and social equality

Impressive, no? Luckily, Mnemosyne supports formatting with HTML, so I could achieve that effect with some <ul> and <li> tags. But if you consider how many tags went into that one card, and that there’s 500 cards in the deck, you’d get might tired of <ul> and <li>.

Luckily, Mnemosyne supports importing decks in a number of formats. The simplest is tab-delimited text files. Start a line with a question, then put in a tab and the answer. One line per card. Simple enough.

And any Linux programmer knows how to play with text files…So behold, Timmy’s Awesome Automated Bullet Maker!

filename = raw_input("Filename: ")
f = file(filename, "w")
while True:
    user_input_q = raw_input("Q: ")
    if user_input_q == "q":
        break
    answer = "<ul>"
    while True:
        user_input_a = raw_input("A: ")
        if user_input_a == "q":
            break
        answer += "<li>" + user_input_a + "</li>"
    answer += "</ul>\n"
    f.write(user_input_q + "\t" + answer)
f.close()

To use it, save it as a .py file and launch it with Python (on Linux, that would be python mnemosyne.py at the terminal). When prompted, put in the filename you want to save to, then the question, then the first bullet point of your answer. Put a new bullet point at each “A: ” prompt. When you’re out of points, input “q”. When you’re done, input “q” at the question prompt. Feel free to post any questions, comments or concerns below.

Enjoy!

Share/Save/Bookmark

2 Responses to “Automated Flashcard Making with Mnemosyne and Python”

  1. Edwin says:

    awesome!

    how does a green windows guy import plain text files to mnemosyne?

    please email me!

  2. Timmy says:

    File->Import->Follow directions.

Leave a Reply