Package: autoanki
❗️Pull requests welcome! If you think you can improve AA in any way, you are welcome to send me a message!autoankiAuto-Generate Anki Flashcards from a text file.Converts Chinese books from text files to Anki decks.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.UsageAutoAnki is both a library and a terminal tool.
To get started, runpip install autoankiThis should install all the requirements. Then, in a Python file dofrom autoanki import AutoAnkiTo get started, first, create a database for AutoAnki to usedb_path = "AutoAnki.db"
if not AutoAnki.is_database(db_path):
    AutoAnki.create_autoanki_db(db_path)Then create an instance of AutoAnki using the databaseaa = AutoAnki(db_path)Add whatever books you want in your deck. These can be text files, or a folder full of text filesbookpath = '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:When getting definitions for words, it uses selenium to scrape definitions
from a dictionary websiteCheck 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/downloadsTerminalIf you would like to run AutoAnki from the terminal, run AutoAnki/terminal.pyThis will run a terminal interface where you will be able to runHow it worksAutoAnki interfaces has 4 components on the back end:BookCleaner: Cleans the input coming in from files that the user suppliesDatabaseManager: Takes the cleaned input and puts it into the databaseDictionary: Finds definitions for words in the databaseDeckManager: takes information from the user and database, and makes an Anki deck
out of itDatabase:There are 3 different types of tables in the DB,dictionary, which holds all the definitions and other informationbook_list, which holds the titles of the books in the databasebook, based off of the name of the book, and holds the words in the book to find in the dictionarydictionary:word_idwordword_traditionalword_type (noun, verb, etc.)pinyinpinyin_numbersnumber_of_strokessub_componentsfrequencyhsk_leveltop_levelaudio_pathimage_pathdefinitionDictionary tablebook_list:book_namebook_table_namelanguageBook list tablebook_examplebook_table_word_iddictionary_word_idnumber_of_appearancesBook tablePlanned featuresCurrently, 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 findMore customization for how the cards in the deck look, and what they have on themThe 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