Skip to main content

Generate Anki .apkg decks from JSON (MCQ) or TSV (basic) card data.

Project description

kunyi

Generate Anki .apkg decks from JSON (MCQ) or TSV (basic) card data.

Part of the Seya study ecosystem.


Installation

pip install kunyi

Or for local development:

git clone https://github.com/LingT03/Kunyi.git
cd Kunyi
pip install -e .

CLI usage

# JSON — multiple-choice question cards
kunyi "Cloud Computing" cards.json

# TSV — basic front/back cards
kunyi "Calc 2 Formulas" formulas.tsv

# Explicit output path (recommended for subprocess callers)
kunyi "Cloud Computing" cards.json --output /path/to/deck.apkg

# Override format detection
kunyi "My Deck" cards.data --format tsv

On success the resolved .apkg path is printed to stdout (exit 0).
On failure a human-readable message is printed to stderr (exit 1).


Input formats

JSON — MCQ cards

{
  "cards": [
    {
      "question": "What does CPU stand for?",
      "choices": ["Central Processing Unit", "Core Power Unit", "Control Processing Unit"],
      "correct_answer": "Central Processing Unit",
      "explanation": "CPU stands for Central Processing Unit.",
      "tags": ["chapter-1"]
    }
  ]
}

correct_answer must be an element of choices — validated on parse.
tags is optional.

TSV — basic cards

Tab-delimited UTF-8. Optional header row (front\tback) is auto-detected and skipped.

front	back
What is spaced repetition?	A technique that spaces reviews over time.
What is active recall?	Actively retrieving information from memory.

Library usage

from pathlib import Path
from kunyi import AnkiCardDeck, MCQCard, BasicCard

deck = AnkiCardDeck(deck_name="My Deck")

deck.add_card(MCQCard(
    question="What does RAM stand for?",
    choices=["Random Access Memory", "Read Access Module"],
    correct_answer="Random Access Memory",
    explanation="RAM is the primary short-term memory of a computer.",
    tags=["hardware"],
))

deck.add_card(BasicCard(
    front="What is a CPU?",
    back="The central processing unit — the brain of a computer.",
))

deck.save_deck(Path("output/my_deck.apkg"))

Running tests

pip install pytest
pytest tests/

What is Anki?

Anki is a free flashcard program that uses spaced repetition and active recall to maximise long-term retention. kunyi generates .apkg files that can be imported directly into Anki.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kunyi-0.1.0.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kunyi-0.1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file kunyi-0.1.0.tar.gz.

File metadata

  • Download URL: kunyi-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for kunyi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0a512c03eba4da364407e41a9925a454f2ff9f45694f36172c80ebc6f68e477f
MD5 48a6014025a7084d5e37ad56f67c11a8
BLAKE2b-256 f83878e928f65656a9c2ae75ee5bdd0a8e7cd749c4f3d0008577ae9448def47f

See more details on using hashes here.

File details

Details for the file kunyi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kunyi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for kunyi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d414866fdc70092d147e1e0d11631de4360f6252d6c877c63ee074660280c3e0
MD5 272e61db6114a63adee4bedfb8251eca
BLAKE2b-256 7833df2efbfd77f78d1365675bdc28542ce00289b5a5093bd10031797b398379

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page