[Userscript] Open Framework: Visually Similar Kanji Filter

:warning: This is a third-party script/app and is not created by the WaniKani team. By using this, you understand that it can stop working at any time or be discontinued indefinitely.

as requested by @jprspereira

For users of the self study script

This script adds a filter that lets you study a kanji’s visually similar kanji. It uses Lars Yenken’s PHD thesis data hosted on @acm2010’s github page to find a given kanji’s companions.

Before you can study a kanji’s similar kanji, you first have to create a list of kanji that you are having trouble with. You can do this by going to the script’s settings and typing some kanji into the input box at the top. The kanji you input will appear in the list below.

These are also the kanji which will appear in the self study quiz. You choose kanji from these to study by selecting them.
image

For developers

You can use the visually_similar_kanji filter as any other ItemData filter. The filter takes key/value pairs, where the key is the kanji and the value is set to true.

Example
wkof.ItemData.get_items({wk_items: {filters: {visually_similar_kanji: {剤: true}}}}).then((data)=>{
    console.log(data);
})

// Expected output
[0: {id: 897, object: "kanji", url: "https://api.wanikani.com/v2/subjects/897", data_updated_at: "2019-02-07T00:28:35.020617Z", data: {…}, …}
1: {id: 977, object: "kanji", url: "https://api.wanikani.com/v2/subjects/977", data_updated_at: "2019-02-07T00:28:35.020617Z", data: {…}, …}
2: {id: 1191, object: "kanji", url: "https://api.wanikani.com/v2/subjects/1191", data_updated_at: "2019-02-07T00:28:35.216565Z", data: {…}, …}
3: {id: 1348, object: "kanji", url: "https://api.wanikani.com/v2/subjects/1348", data_updated_at: "2019-02-07T00:28:35.216565Z", data: {…}, …}
4: {id: 1577, object: "kanji", url: "https://api.wanikani.com/v2/subjects/1577", data_updated_at: "2019-02-07T00:28:35.216565Z", data: {…}, …}
5: {id: 1668, object: "kanji", url: "https://api.wanikani.com/v2/subjects/1668", data_updated_at: "2019-02-07T00:28:35.216565Z", data: {…}, …}
6: {id: 1862, object: "kanji", url: "https://api.wanikani.com/v2/subjects/1862", data_updated_at: "2019-02-07T00:28:35.216565Z", data: {…}, …}
7: {id: 2135, object: "kanji", url: "https://api.wanikani.com/v2/subjects/2135", data_updated_at: "2019-02-07T00:28:35.326609Z", data: {…}, …}
8: {id: 2438, object: "kanji", url: "https://api.wanikani.com/v2/subjects/2438", data_updated_at: "2019-02-07T00:28:35.326609Z", data: {…}, …}
9: {id: 2445, object: "kanji", url: "https://api.wanikani.com/v2/subjects/2445", data_updated_at: "2019-02-07T00:28:35.326609Z", data: {…}, …}]

There is also a include_visually_similar_kanji filter, which adds the similar kanji and their relative similarity info to any kanji in your request.

Example
wkof.ItemData.get_items({wk_items: {filters: {item_type: 'kan', include_visually_similar_kanji: true}}}).then((data)=>{
    console.log(data[0].visually_similar_kanji);  // The requested character is 一
})

// Expected output
[0: {kan: "十", score: 0.5}
1: {kan: "二", score: 0.5}
2: {kan: "七", score: 0.5}
3: {kan: "丁", score: 0.5}
4: {kan: "己", score: 0.333333}
5: {kan: "与", score: 0.333333}
6: {kan: "子", score: 0.333333}
7: {kan: "下", score: 0.333333}
8: {kan: "土", score: 0.333333}
9: {kan: "上", score: 0.333333}]

Available at

this place

19 Likes

Image of @Kumirei creating tons of userscripts without sleep to win the APIv2 competition

17 Likes

Yep, full respect.
Don’t know about the competition, but Kumi already won our hearts.

Where can I start to learn to do this kind of stuff?

5 Likes

Right here

8 Likes

Very excited to try this. Thanks for yet another awesome script! :purple_heart:

1 Like

2 Likes

But Kumi was going script crazy before the competition.

chiyaunsure

4 Likes

It’s the viking DNA

5 Likes

I see it coming

Yet I thought, “nah it can’t be”

And while clicking I was losing hope… And there it was

2 Likes

Honest answer: I just learned by trying to do stuff while looking at other scripts and googling

3 Likes

That’s great. You sure have learned a lot, I remember you started with way more simple scripts like the Kanna one.

I might be looking at your code if you don’t mind

1 Like

Woah Burns (the kanna one) was actually pretty recent. I made that one in June 2018, while I started learning in October 2017. The oldest script that I still have listed is Spongebob Time Cards from November 2017, then there’s Rainbow Flairs from December 2017, and then a few more before my first notable script, the like counter, in January 2018. In total I have 51 scripts published, but only 7 with more than 100 installs, if you don’t count the pure CSS ones.

1 Like

Nice work! There are several files with similar kanji using different criteria there, why did you choose the “stroke edit distance” specifically? In the Niai script I use several sources because each criterion misses some kanji that are definitely very similar.

I remember that the stroke edit distance had some issues because it occasionally includes 「一」 with a very good score, and it lists exactly 10 items, even though there are more (or some items are not similar at all).

I chose that one because because it had ten similar kanji for all kanji, making it predictable, and when studying similar kanji I feel like it won’t be as effective if you study only the similar ones right after each other, so some less similar kanji help with interleaving.

Also it seemed a lot of work to use them all, unless I compiled them into one source.

I was going to ask why the script didn’t work for me. But I guess the answer was just having a list of kanji wasn’t enough. I had to select them and also click the option to “include this source” for them to appear on the quiz. Did I get it?

Anyway, assuming that’s it, thanks very much for making this. It looks like something that will be very helpful to me.

1 Like

Ah, yes. I did it this way so you can keep a list of kanji that have been problematic in the past, in case you want to study them again sometime, and not have to enter it into an input box every time (can be hard if you’re already having trouble remembering the kanji).

Yep. That’s a quirk of the self study quiz, though.

That should do it!

1 Like

I mean, I was suspicious and suspected it a teeny bit, but still glad I can be surprise rickrolled. Successfully baited :smile:

1 Like

Wanted to ask the exact same thing lol

@Kumirei thank you for this script, I’ll definitely use it to prepare for the jlpt because the visually similar kanji are killing me.

2 Likes

Although this answer discouraged me lol

2 Likes

I have a few questions about Visually Similar.

  • Is there any reason the github file is not cached? I see network delays at startup.

  • I there a way to populate all the items with visually similar data as opposed to just those that are configured in the settings? I would then be able to populate the Item Inspector popups with the relevant visually similar kanji icons.

  • Are you open to make a search filter that uses a list of kanjis separated by commas like I did in the search filters I just posted? This would let people search for any list of kanji they please in a manner that is consistent with the other search filters.