Skip to content

holocronweaver/wanikani2anki

Repository files navigation

Export WaniKani data to an Anki deck using Python 3.

Uses WaniKani API v2.0 alpha (updated to spec as of 2017-08-04).

TODO: Give example images of WaniKani card on Anki desktop and AnkiDroid. TODO: Give example images of app.

Features

Export radicals, kanji, vocabulary

Each card has the following data (when relevant):

  • meanings
  • readings
  • user meanings
  • all user notes
  • SRS status (optional)^
  • vocabulary audio (optional)
  • example sentences (optional)
  • WaniKani level number

^ Anik deck retains WaniKani ordering. Cards are first ordered by ascending WaniKani level, then by radicals -> kanji -> vocabulary. If you don’t export the WaniKani SRS status, then by default you will learn cards in the deck order.

TODO: Update Anki Deck

Not yet implemented! See Issue #1.

After an initial export to Anki, the user may update their WaniKani collection and wish to update their Anki deck to keep it in sync.

TODO: Filters

Not yet implemented! See Issue #2.

Filter what content gets exported from WaniKani.

  • burned items
  • low success items

Multiple Ways to Use

Includes a app, Python library, and CLI.

Instructions

Installation

  1. Unzip the ZIP file to wherever you want to install the application.
  2. Go to the extracted wanikani2anki folder.
  3. Open w2a to start the app.

TODO: Create Anki Deck

TODO: Update Anki Deck

TODO: Change Card Type / Merge Into Existing Deck

If you have an existing Japanese Anki deck, you may have pre-existing card templates you wish to reuse. Alternatively, you may not like the provided card template and wish to create your own.

You can convert the exported WaniKani card type to any card type you want from within Anki. This requires mapping fields from one card type to another.

Another option is to edit the WaniKani card.

Note that the mapping will need to be repeated in the future if you re-export WaniKani to Anki to keep your deck synchronized with any changes.

Development

Here’s how to hack around in the source and/or create a distribution.

Prereqs

genanki dependencies

pip3 install cached-property frozendict pystache pyyaml --user

kivy and its dependencies

sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev xclip enchant

pip3 install kivy pygame --user

Run app from source directory

Simply run run.py.

Build a redistributable package

Make sure you can run the app using run.py first.

Now install PyInstaller: pip3 install pyinstaller

Run build.py, which will produce a redistributable folder and its ZIP compressed file in build/dist.

If you want to rebuild from scratch, first run clean.py.

WaniKani

Base Data

Non-user specific data rarely changes and is thus cached separate from user data. Typically this data should be updated periodically while the server is idle, say once a week. TODO: Provide example of updating base data.

User Data

User data is cached. This allows for only updated data to be retrieved from WaniKani, reducing data transfer costs.

Typically a server will remove old user caches over time, say after a few months.

SRS

Unlike WaniKani, Anki gives you control over the SRS algorithm parameters so you can customize it to fit your needs on a deck-by-deck basis. Want to make reviews occur more or less frequently? Want to limit the number of reviews you do a day? Want to add more learning stages or change their repetition intervals? Want to apply special rules to cards you frequently get wrong? Prefer to have ‘burned’ items given far future due dates rather than being permanently retired? Anki allows you to do all these things and more.

Future Plans

See TODO list.

Notes

Links

WaniKani SRS

WaniKani has 10 SRS stages: new, 4H, 8H, 24H, 3D, 1W, 2W (master), 1M (enlighten), 4M (burn), burned.

These map to Anki fairly well: new (new), 4H & 8H (learning), 24H to 4M (review). Burning doesn’t exist in Anki without addons, but intervals eventually become years and decades which may actually be better than never seeing the card again. Burning can be effectively mimicked by periodically setting all cards with intervals greater than 1 year to 100 years.

Anki SRS

Anki SRS has the following progression stages: new, learning, and review.

New

A card that has not been seen before. After its introduction, new cards transition to the learning stage.

Learning

A short stage that transitions new cards into your regular review queue. It does this by exposing you to the card for the first time, then repeating the card a number of times over relatively short, steadily increasing time intervals until all learning steps have been completed. Once all learning steps are complete, the card graduates to the review stage.

By default there are two learning steps, 1 minute and 10 minutes.

Review

Review involves several parameters. Some are deck-wide constants, others are per-card variables whose initial values are provided by deck settings.

Each card has an interval, the integer number of days between reviews.

After each review, the interval is updated based on the user rated difficulty:

  • Again: new interval = (new interval factor) * (old interval)
  • Hard: new interval = 1.2 * (interval modifier) * (fuzz) * (old interval)
  • Good: new interval = ease * (interval modifier) * (fuzz) * (old interval)
  • Easy: new interval = ease * (easy bonus) * (interval modifier) * (fuzz) * (old interval)

Note that ‘Again’ returns the card to the Learning stage. In that case the new interval is used once the card regraduates to Review.

Card defaults (variable): interval = 1, ease = 250%. Deck defaults (constant): easy bonus = 130%, interval modifier = 100%, new interval factor = 0%, max interval = 100 years These defaults can be user modified. The minimum interval is always 1.

A card’s ease may change depending on how a user rates a question:

  • Again: Ease is descreased by 20 percentage points.
  • Hard: Ease is decreasing by 15 percentage points, current interval multiplied by 1.2 instead of ease.
  • Good: Ease is unchanged.
  • Easy: Ease is increaded by 15 percentage points.

Ease can never be lower than 130%.

Easy bonus is only applied if user rates a question as ‘Easy’.

Interval modifier is purely for user customization and does nothing by default. It is not applied for ‘Again’. Anki doc suggests using this SuperMemo formula to calculate a desired modifier:

interval modifier = log(desired retention%) / log(current retention%) = log(desired retention% - current retention%)

Fuzz is a random modifier, presumably close to 1.0, which Anki applies to cards to prevent cards reviewed together and given the same rating from all appearing together in the next review. It cannot be user controlled.

Anki has more SRS algorithms than those described here, such as special handling of overdue and leech cards, but the above applies to common ‘regular’ reviews. For more detail, see the official Anki SRS algorithm documentation.

Alternatives

ProjectWaniKani API versionInterfaceLanguageDescription
wanikani2anki (this project)2scripts, libraryPythonSimple interfaces, lots of customization options. Library makes it easy to create highly customized decks.
wanikani-to-anki (website)1websiteRubyEasy to use. Creates raw CSV file for Anki, not a deck. User must make and style cards themselves (considerable work!). Limited export options.
wanikani2anki1Anki addonPythonSame name, but very different! Anki addon, uses Anki’s built-in Python interface.
WaniKani-Python1scriptsPythonIncludes Kanji stroke order. Script interface split between mobile and desktop. Simple, but not very flexible.

Legal Notices

The library, command-line interface and GUI application software are licensed under the Mozilla Public License 2.0 (MPL-2.0).

Card source code in the `cards` subfolder are licensed under the MIT License.

What is the MPL and how does it differ from the GPL? The MPL allows you to include this software in a project with any licensing scheme you wish. The main requirement is that you publicly share any changes you make to MPL-licensed files and leave their license intact. This is in contrast to the GPL which requires your whole project to have a GPL-compatible license.

The WanaKana script is licensed from the WaniKani Community Github under the MIT license.

The Noto CJK font is licensed from Google under the SIL Open Font License, Version 1.1. Its minified form is from this repository.

The author is in no way associated with the maintainers of Tofugu or WaniKani. Just a happy user who wants offline access, greater customizability, and more control over their data.

DO NOT PUBLICLY POST WANIKANI DECKS ON THE INTERNET. You do not have copyright ownership of any content on WaniKani you did not personally create (i.e., you only own your notes).

This software is meant to aid your studies. If you find WaniKani useful, support it by buying a subscription!

About

Convert your WaniKani data into an Anki deck.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published