Skip to main content

Automatically make Anki Decks for Chinese text

Project description

❗️
Pull requests welcome! If you think you can improve AA in any way, you are welcome to send me a message!

autoanki

Auto-Generate Anki Flashcards from a text file.

Converts Chinese books from text files to Anki decks.

Text to Anki

AutoAnki was created to help Chinese learners get into more advanced texts. It can be hard transitioning from graded readers to full books, and this tool was designed to help ease that process.

Usage

AutoAnki is both a library and a terminal tool. To get started, run pip install autoanki This should install all the requirements. Then, in a Python file dofrom AutoAnki import AutoAnki, cli

To get started, first, create a database for AutoAnki to use

db_path = "AutoAnki.db"
if not AutoAnki.is_database(db_path):
    AutoAnki.create_autoanki_db(db_path)

Then create an instance of AutoAnki using the database

aa = AutoAnki(db_path)

Add whatever books you want in your deck. These can be text files, or a folder full of text files

bookpath = 'short-story.txt'
aa.add_book(bookpath, 'My first book😆')

Once all of your books are added, the definitions need to be found, and then you can create a deck!

aa.complete_unfinished_definitions()
aa.create_deck("AutoAnki Deck", "output")

This will automatically have the .apkg extension, which Anki uses. Go into Anki, and import this file. You should see your deck in the list:

Anki deck view

When getting definitions for words, it uses selenium to scrape definitions from a dictionary website

Check your version of Chrome, and put the same version driver in the same directory as main. Drivers can be found here ---> https://chromedriver.chromium.org/downloads

Terminal

If you would like to run AutoAnki from the terminal, run AutoAnki/terminal.py
This will run a terminal interface where you will be able to run

How it works

AutoAnki interfaces has 4 components on the back end:

  1. BookCleaner: Cleans the input coming in from files that the user supplies
  2. DatabaseManager: Takes the cleaned input and puts it into the database
  3. Dictionary: Finds definitions for words in the database
  4. DeckManager: takes information from the user and database, and makes an Anki deck out of it

Database:

There are 3 different types of tables in the DB,

  1. dictionary, which holds all the definitions and other information
  2. book_list, which holds the titles of the books in the database
  3. book, based off of the name of the book, and holds the words in the book to find in the dictionary

dictionary:

  • word_id
  • word
  • word_traditional
  • word_type (noun, verb, etc.)
  • pinyin
  • pinyin_numbers
  • number_of_strokes
  • sub_components
  • frequency
  • hsk_level
  • top_level
  • audio_path
  • image_path
  • definition

Dictionary table Dictionary table

book_list:

  • book_name
  • book_table_name
  • language

Book list table Book list table

book_example

  • book_table_word_id
  • dictionary_word_id
  • number_of_appearances

Book table Book table

Planned features

  • Currently, all definitions are collected from the internet. This is really slow, so using a dictionary from a file would greatly improve performance. It could fall back on the web dictionary for words it can't find
  • More customization for how the cards in the deck look, and what they have on them
  • The ability to hear what a word sounds like. The database supports this, I just need combine the sounds, and upload the sounds with the cards.
  • There are a few TODOs in the code that I would like to fix

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

autoanki-1.0.5.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

autoanki-1.0.5-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file autoanki-1.0.5.tar.gz.

File metadata

  • Download URL: autoanki-1.0.5.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for autoanki-1.0.5.tar.gz
Algorithm Hash digest
SHA256 5607dbfd160dd9ca348c5514b4e03da6a50284cef1dea1e4d10c4c46b804aefa
MD5 7f4007c990b7e7f739dcbccee8e5ea98
BLAKE2b-256 b530003083bbec94ed7f255b855cbb675aa0e39dbf68fcc3d840dfe0e55e72cd

See more details on using hashes here.

File details

Details for the file autoanki-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: autoanki-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for autoanki-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3de3d7ecf550d54f4bfb19cf3ee8a1cb160491ef35749e2ae3a566f3f927a6fe
MD5 a6c1d4035d70b23bf81d04b7b22e3dc2
BLAKE2b-256 9fdf247d06ef31b4648ec25a13e337c6c934bf720e1eb71776d772bbaed7c71d

See more details on using hashes here.

Supported by

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