waf / anki-thai

Build an Thai Vocab Anki deck from a JSON file
MIT License
10 stars 1 forks source link
anki python thai

This repository builds a thai.apkg file (for importing into Anki/AnkiDroid) from the JSON file resources/cards.sealang.json. It's built around thai/english language flashcards, but it shouldn't be too hard to repurpose it for other JSON files.

Download

If you just want the Thai flashcards generated by this library, download dist/thai.apkg.

Installation

If you want to generate your own Anki flash card deck (.apkg), clone this repo and modify the python script as required.

Modification

Modify the json-to-anki.py script. The script reads a json file that contains an array of the objects:

{
    "rank":"1",
    "source":"AUA Reader AUA Chapter 01",
    "thai": "ดี",
    "english":"good"
}

If you import this file, it would not have any nested decks in the resulting Anki deck (because it's a flat array of cards). If you want categories (in this case, a category for each chapter), you would design a source map like this:

{
    "AUA Reader AUA Chapter 01": {
        "source": "AUA Lessons::Chapter 01"
    },
    "AUA Reader AUA Chapter 02": {
        "source": "AUA Lessons::Chapter 02"
    }
}

json-to-anki.py

Converts a json file to an APKG file, with support for nested decks.

# generate cards from a source json file
$ ./json-to-anki.py

split-json

A helper script for splitting large JSON files into smaller JSON files.

# list all sources
$ ./split-json.py list

# split source
$ ./split-json.py split $source $outfile

# example
$ ./split-json.py split SEAlang SEAlang.json

SEALang deck

The SEALang deck generated from the cards.sealang.json file contains the following categories ("nested decks"):