lern – The Bash Flash Card Script
Martin Döring, September 18th of 2021
I wanted to learn a new language, but I did not find a satisfying solution for that. Anki drove me crazy in it's complexity and handling. So today I wrote my own intentionally minimalistic 80 lines flash cards script in bash. I named it »lern« which is German for »learn«, as you may have assumed. ;-)
For now it is a very simple learning algorithm. The code could be enhanced to save the progress in an extra file. Also for now there is no way to learn a subset, say just 30 records from 300. Best for now would be to structure you flash card files in a way, that every file is just about 30 records long.
How it works
The script works like this:
- It shows the question,
- you hit <enter> and
- you see the correct answer
- you hit <y>, if you did recall it correctly
- you hit <x> or <q> to quit
- every other input counts as »no«
The running script looks like this:
CSV File Format
The file format for the vocabulary is simple: The CSV file has two columns with words or phrases to learn. Column »A« is the question asked and column »B« is the answer. Although, you can change this with the -r option and learn the other way round.
The first line of the file contains the languages to learn in column »A« and »B«. The csv file needs to be saved with embracing double quotes for every cell. The whole file looks like this, as an example:
Prerequisites
- Runs in every terminal session with a bash shell.
- One or more csv files with double quotes »"« around the single cell's text for vocabulary to learn
Features
- Reads flash card records from a normal two column csv file you can create, and maintain simply with LibreOffice Calc or Excel.
- Language pair information is read in from line one of the csv file.
- Algorithm: You need to learn as long as you got every pair right for three times.
- You can make use of as much commas or semicolons as you like
- The columns can be seperated by »;« or »,«
- You can invert the learning order with the »-r« option.
Shortcomings
- No saved state of learning progress
- No double quotes in records, use » and « for this, if needed
- Better to learn with not so long files, say 30 records
lern — The Bash Flash Card Script
If you have any suggestions, how to make the script even smaller or faster, just write me:
——