WaniKani to Anki 2 plugin

Should there be a duplicate of each card?

1 Like

I got it to work! Fantastic job dude thank you.  I was about to undertake setting it all up one by one >.<

One thing though - do you think it is possible to include mnemonics too or is that too much?

Also, I would kind of like it if it mirrored the ‘test’ scenario where it asks for eg: the MEANING, or the READING, or something along those lines so you can better   get a feel as though it were wanikani test rather than just another card deck?

@luluhouse7: There ought not be strictly speaking duplicates of each card: out of the box, the intent was to have a card for the WaniKani front-back, and then a second card for the same item that is back-front.
However: we do know that the strategy I chose to get that effect isn’t exactly portable (see earlier posts in this thread about “MODEL_NAME” and “basic”).  If what I chose to do by default is getting you duplicate cards, you might throw the deck away, and try the steps listed in /t/WaniKani-to-Anki-2-plugin/1303/4  Let us know how this works out.

Exactly how different people want to have the cards created seems to vary quite a bit, and I don’t have yet any reasonable ideas about how to provide for customization without too much fuss.

@Jatacid: about including mnemonics: that I can see, the API responses don’t include the mnemonics (see all about that at http://www.wanikani.com/api).  Anything that is in the API responses for Kanji and Vocab you can make use of.

Your second question, similarly to what I just wrote to luluhouse7, this area of what does the card say, what’s on the front, what’s on the back, there seem to be many different preferences, and I’m open to ideas about how to permit customization.  Those who are feelin’ frisky and are willing to try to customize the plugin script itself may discover interesting ways to slice and dice this i haven’t thought of yet.  Pastebin’s and github pulls welcome, to be sure!

Ok, I give up! 

Somebody, talk to me like I am a grandma who doesn’t ‘do computers’ and help me figure out how to join the WK Anki crew! I struggled with it alone (because I don’t like asking for help - an issue in itself that I am dealing with), thus I have upgraded my Anki, I downloaded Python, I copied the script for naigeru’s WK plugin, edited it in Python to insert my API key, changed the model to ‘basic’ and saved it in the Anki addons folder. When I opened Anki I got an error message (once before I remembered to change the model, and the same one again after).

Remember, I’m a frail, elderly old lady! Explain it to me please! TIA.

Is there a way so it only makes vocab or kanji decks?  it would be awesome to have it make 2 decks, one with only kanji and one with only vocab, its confusing seeing for example 人 and not knowing if i should be thinking on the reading  ひと or じん にん

Edit: figured it out myself,  just had to put the commentary mark on a lot of lines  to disable all classes n functions with vocab, so it made only a kanji one, if somebody is interested let me know and ill post the lines.

@EskimoJo: Sorry to hear you’re having a hard time with the plugin and Anki and all.  
Can you send along one way or another the error message you are getting?
Can you also send along details like what kind of computer you’ve got, what kind of Anki exactly?

@Apraxas: not out of the box right now, making two decks.
I did include styles in the cards such that vocab and kanji could be styled differently if you wanted, though I didn’t explain it very well, and it’s kind of hard to get to the place where you’d add the styles in Anki.

It seems like the different axes of choice are:

- choice of WaniKani card direction, reverse direction, or both
- choice of kanji or vocab, or both
- choice of one deck or two, for kanji and vocab
- choice of what exactly is put on the sides of the cards

(and make it easier to get started…).

Any other choices people have wanted to make?

The best for my own study style would be to have 2 separate decks, one only for kanji so i focus on their own name and meanings, and other for only vocabulary, so i focus on the words and their meanings without mixing kanji names in there.

What i did was copy paste the plugin you made so i could have 2 of the same, then disable the “vocab” lines and added it and renamed the stuff to wanikani deck to wanikanji.

Later ill make another copy and disable the other way around, making a wanivocab deck and should be good to go, thank you :slight_smile:

basically i have 2 copies of your plugin installed atm XD

naigeru said... @EskimoJo: Sorry to hear you're having a hard time with the plugin and Anki and all.  
Can you send along one way or another the error message you are getting?
Can you also send along details like what kind of computer you've got, what kind of Anki exactly?


Error message says this:

An error occurred in an add-on. Please contact the add-on author.

Traceback (most recent call last):

File "C:\cygwin\home\dae\win\build\pyi.win32\anki\outPYZ1.pyz/aqt.addons", line 38, in loadAddons

File "c:\pyi\iu.py", line 436, in importHook

File "c:\pyi\iu.py", line 505, in doimport

File "c:\pyi\iu.py", line 297, in getmod

File "c:\pyi\iu.py", line 123, in getmod

File "C:\Users\Jo Somebody\Documents\Anki\addons\wanikani.py", line 1

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32

^

SyntaxError: invalid syntax

I have a PC laptop, Windows 7, and Anki 2.0.7. (remember, I'm your elderly neighbour that will bring you cakes if you help her!)

 Just got this error. Let me know if you have any ideas please @naigeru

An error occurred in an add-on. Please contact the add-on author.
Traceback (most recent call last):
File “aqt/addons.pyc”, line 38, in loadAddons

File "/Users/Steve/Documents/Anki/addons/wanikani2anki.py", line 1
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340
SyntaxError: unexpected character after line continuation character
The character it indicates is "f" in "cocoartf1187"

Thanks!

@naigeru (and everybody else interested):
I tweaked your plugin quite a bit - mainly in order to import kanji and vocabulary into separate decks and do so by level (if configured).
Currently this is quite specific to my card layout but I’d be willing to provide a generalized version if anybody is interested.

Yep, got it to make an unlocked kanji and unlocked vocab decks separated, studying has never been better.

@aina, @apraxas, maybe put your texts in a pastebin? there are enough good ideas that I’d like to try to congeal them together and put a preference pane atop them to make this all easier.  ideally, not requiring editing the .py file at all.

@EskimoJo and @stevowilco :

From what we’ve got here, both of you are showing symptoms of some editing of the wanikani.py file having not gone well. Rather than try to recover, I’m going to suggest that we start over, I don’t believe finding exactly where we edited awry (and it is easy to do here…) isn’t worth the time and frustration.

So:

1. Open Anki, then choose from the menus Tools > Add-ons > Open Add-ons folder … This should push you back out to the Finder or Explorer and open the add-ons folder Anki uses (C:\Users\Jo Somebody\Documents\Anki\addons\ for instance).  

2. You ought to see at least a wanikani.py and a wanikani.pyo file there, possibly other things named wanikani.  Delete or throw all these into the trash, or however things work on your computer.  Leave this folder open, so you can get back to it.

3. Close Anki now.  Open it again, and verify that nothing about wanikani shows in the Tools menu anymore.  If something still does show, we have to try step #2 again, something is still hanging out there.  Otherwise, close Anki again and move on.

4. Visit this page in a web browser: https://raw.github.com/nigelkerr/wanikani2anki/master/wanikani.py  This is the raw wanikani.py file itself.  Save-as this to the same folder we deleted things from in step #2 above (the addons folder).

5. Now let’s make sure this much worked.  Open Anki.  There ought to now be one new thing in the Tools menu, “Show WaniKani API Key”.  Choosing that ought to show a dialog saying “WaniKani API Key not defined!”  So far so good.  Close Anki again.

6. Now set the API Key in the plugin.  Copy your API key from it’s official home at http://www.wanikani.com/account and open the wanikani.py file we’ve saved into the addons folder with a text editor.  

Here, @EskimoJo, I’m a little uncertain what is best on Windows: plain old Notepad may not be good enough.  Notepad++ I hear good things about (http://notepad-plus-plus.org/download/v6.3.html).  Word might do it, but make sure to save as plain text.  

7. Find the WANIKANI_API_KEY line, which I show as being line 44.  You want to change it from

WANIKANI_API_KEY = ‘YOUR_API_KEY_HERE’

to

WANIKANI_API_KEY = ‘b874681538943667g874681538943667’

The single quotes should stay, and all 32 letters of the key need to be in between them.  This string above isn’t a real key, it is a demo.
Save that, and close the text editor.

8. Start Anki again, now you ought to see two WaniKani items in the Tools menu.  Start with “Show WaniKani API Key” first.  This ought to show a little dialog about “WaniKani API Key: b874681538943667g874681538943667”.  If it doesn’t, we’ve had a mishap in step #7 above.  

9. If it showed the key, now we can try “Update WaniKani Deck”.  This will take a few seconds of spinning, and we ought to be rewarded with a new “WaniKani” deck.

Give these instructions a try, and then let me know what success you each have.

cheers!


@naigeru

http://pastebin.com/kPtYpYxs

New features:
+ separate decks for kanji and vocab
+ creates card models for kanji and vocab resp. and does not rely on existing models anymore (layout is quite pretty too, I think, PLUS: links to Tangorin)
(I dropped the level feature, as it was hard coded rather than configurable via the GUI and I should try to get some sleep now.)

Card layouts:
Kanji: one for reading, one for meaning, reading lists important reading plus on’yomi and kun’yomi
Vocab: both regular and reversed

Tested on Gentoo Linux, Anki 2.0.7, Python 3.2.3. 
Let me now if you have troubles with the patch!


@aina suspect the patch is truncated, probably by pastebin.  urgh.
may ask you to hold off a bit til the next version here, your formats and fields work sounds interesting, but first get an easier-to-use version out, then make splendider.

@naigeru Worked great! Thanks!

@naigeru:
aaaah, just saw that indeed it is truncated.
I could send it to you by email? Or make a pull request at github?

@naigeru:

ok, found the culprit - it was me, not pastebin.

once again, this time hopefully complete:
http://pastebin.com/znbGHSVR

@aina i see you’ve sent along a patch that’s looking completer; i’m not going to get anywheres with it today.  thanks!