[Userscript] ConfusionGuesser

In version 1.13 I have added the option “Minimized if all ratings < X” so that the guess list does not pop up if the guesses are probably not that relevant. Maybe that would help?

The problem is that I use the rateSimilarity() function for both English vocabulary and Japanese vocabulary, and in the case of Japanese vocabulary, having the longer string not contain the other single character should not immediately result in 0 similarity (because in Japanese, it should also consider the visual similarity of the kanji). It would definitely be more efficient to split up the function into rateEnglishSimilarity() and rateJapaneseSimilarity() and optimize the English version, but I think I would prefer to leave the function as is and instead prevent the 800 guesses from happening.

1 Like

Version 1.14 patch-notes:

Performance improvement for one-letter answers with fuzzy search disabled

With fuzzy search disabled, I just searched for all meanings that start with the given string. This led to a huge number of results when searching for very short strings (e.g. ~800 results for “a”). As a result, you would get hundreds of worthless guesses after entering “a” as an answer to a meaning question. Such a high number of guesses also leads to noticeable lag.

To prevent this, I switch to only considering exact matches if the previous method returns more than 16 results.

Small performance improvements for "Levenshtein distance" function

When writing the ConfusionGuesser script I tried to avoid using for-loops and instead used forEach(), map(), filter(), reduce(), …
Sadly, my “Levenshtein distance” function was extremely slow compared to a version using for-loops (tested on Chromium), so I’m now using for-loops in that function.

An interesting discovery I made in my experiments:

Array initialization
console.time("new Array => fill => map");
for (let i = 0; i < 1000; i++) {
	let d = new Array(1000).fill(null).map((a, j) => j);
}
console.timeEnd("new Array => fill => map");

console.time("Array.from");
for (let i = 0; i < 1000; i++) {
	let d = Array.from({length: 1000}, (a, j) => j);
}
console.timeEnd("Array.from");

console.time("for-loop");
for (let i = 0; i < 1000; i++) {
	let d = [];
	for (let j = 0; j < 1000; j++) d[j] = j;
}
console.timeEnd("for-loop");

Result in Microsoft Edge (Chromium):

new Array => fill => map: 16.60595703125 ms
Array.from: 75.56396484375 ms
for-loop: 7.5732421875 ms

Result in Firefox:

new Array => fill => map: 29ms
Array.from: 16ms
for-loop: 22ms

Chromium is awful at Array.from()! :open_mouth: Until now I had used Array.from() in my “Levenshtein distance” function, but now I’m just using a for-loop.

Please let me know if something doesn’t work.
Link to previous script version for downgrading in case version 1.14 doesn’t work for you

3 Likes

I just learned about this script and it’s awesome. I always went looking for the confusing kanji by myself which interrupted the review process. Having this script makes the experience much smoother.

Thank you!

2 Likes

been using this for a few weeks and I just want to say this is so useful, it should be part of WaniKani itself,. Loove it.

2 Likes

Hello,
Just now I was migrating my WK scripts to new PC and when I imported target ZIP with bunch of Tapermonkey scripts, somehow among other I discovered this one

i.e., “WaniKani item info injector”. I double-checked if it was in original bunch and it wasn’t. I failed to find it’s script page on forums, but it states inside of it to be made by @Sinyaven . So I just come here out of curiosity to ask what this script do and is it even possible for other scripts to auto-install their dependencies without my permission?

This script is a library script, which means that it is intended to be used by other scripts (similar to WaniKani Open Framework). It simplifies the addition of information to WaniKani items for userscripts like Keisei or Niai. I have created it because the recent change of the lesson page was breaking several userscripts (two of my own and several of other script authors), and instead of fixing them one by one, I wrote this library script and fixed all userscripts by letting them use WaniKani Item Info Injector instead of their previous injection method that was not working anymore.

That said, I don’t know why this script landed in your list of installed userscripts. It can be installed, but the only place where I linked to the Greasy Fork page was in the WaniKani Lesson Filter thread, and you would have had to manually install it. For now, all scripts just include it using the @require tag.

I have not created a thread for this library script yet, because there are still some things I want to change about it before I “advertise” it.


Anyway, you can uninstall the script, but you can also keep it. If it is installed like this, every other script uses this one (instead of their own @required one), so this setup makes sure that you always use the newest version with the latest bugfixes.

1 Like

Oh, I see. I do actually use Keisei script and seems like somehow Tapermonkey pulled all of it’s requirements as well. Thing made me curious most, was your script imported without proper link to it’s Greasy Fork page, so it took a bit to investigate it’s origin.

Anyways, thank you for your great job! I’ve updated it in my library to be always up to date.

1 Like

script seems to have stopped working since the latest wk update… ??

It still works for me both with and without script compatibility mode. Can you give an example of a situation where it does not work? I have noticed that you reported a problem with a different script as well – have you made sure that your script manager (Tampermonkey, …) is running?

in that case I’ll have to play around on this end and see if its just something wierd…it happened after the wk update and one of the other scripts had been fixed … so was assuming it was something similar. If it’s something else then will need to try to troubleshoot on this end

edit—hadn’t even restarted… started working again as mysteriously as it quit… glad it’s working again :slight_smile: :smiley:

Great Scott! You’ve been so helpful to me with my own scripts. How am I just discovering this now?!

I’m very much looking forward to my reviews tomorrow.

1 Like

I hope ConfusionGuesser will be useful for you :slight_smile:

Thanks, but don’t expect too high quality from this script in particular. It was my first userscript, and it’s not really optimized. Usually it takes under 10ms to compute the guesses, but sometimes it takes over 100ms :sweat_smile:

I have also started to question some design decisions like having the useful settings “Include user synonyms” and “Use IDS” disabled by default. I usually don’t like programs that do stuff “behind the user’s back” (like downloading and locally storing the third-party IDS file), so I wanted to make “Use IDS” opt-in, but since then I often had to delete my IndexedDB where the settings are stored, and it gets really annoying having to manually change them back every time (I always disable “Use WK radicals” and “Use WK visually similar list” and instead enable “Use IDS”).

2 Likes

Geez. Remember when you were first learning to drive and you unconsciously assumed everyone else on the road around you was an expert that had been driving forever? First @Kumirei and now you are telling me you also created your first userscripts here (still hard for me to fathom!).

In my case, I’d never even written a line of javascript before my first Wanikani script. I’m not sure if I’ve learned more kanji or more front-end coding stuff since then!

Another thing I’ve learned is that I’m not just slow in days-per-level, I’m also slow in seconds-per-question. I average around 6 spq while it seems many of my script’s users average around half that. It takes me longer than 100ms to slurp a sip of coffee, so there’s little chance I’ll notice!

Tell me about it! It took me about 4 months to develop the current production version of the GanbarOmeter after publishing the first alpha version. It took approximately 100ms after pushing the latest build to realize that my default of only quizzing on new-kanji (vs. radicals, kanji, and vocabulary) made no sense at all.

I totally get (and appreciate) not doing stuff behind the user’s back. As a product manager, I learned to appreciate “on first run” sections of single-use code. As you’re pointing out, that’s definitely the best place to put all sorts of opt-in/opt-out stuff like downloads, registration, telemetry creation, support site login creation, etc.

3 Likes

Nope. Not helpful at all:

:wink:

(I’d swear when this happens that the radical morphed under my very eyes! I’d have realized after a bit once I pressed “f” but it’s very cool and quick to see it pop up immediately like that. Love it!)

2 Likes

First time it’s popped up and I already love it :ok_hand:

2 Likes

same, I just installed it and :o I really enjoy it

2 Likes

v1.15 feature request (beyond making “use IDS” the default :slight_smile: )

I’ve been using the Niai 似合い Visually Similar Kanji script that for quite a while now. I’m definitely planning to continue to use both.

One feature I particularly appreciate with the Niai script is the ability to add my own characters.

For example, I frequently mix up (こう) and (こう), so I added the latter to the “visually similar” list. Whenever you add your own visually similar character, the script adds it to the beginning of the list it displays (which is quite helpful). I’ve used this whenever I regularly mix up characters for any reason (not just visual similarities, but similar readings or mnemonics, etc.).

The Niai script is only for kanji, though.

I’d love the ability to add vocabulary I frequently confuse to the confusion guesser. In other words, for the occasional instance where I know exactly which item I’m confusing something with, I’d like the ability to add it to the Confusion Guesser and have it display it preferentially over the default.

Ideally (while I’m wishing :slight_smile: ), I’d like the option when to make additions bidirectionally. In the example above, for example, I added 効 to the entry for 功 but didn’t take the time to open another browser tab for 功 and add 効 to it. It would be nice if the script took care of adding it in both directions.

Finally, in version 2, I’d really appreciate it if the script magically prevented me from moving on too quickly to the next review because I was so confident in my answer that I didn’t see the red until too late. So annoying.

Hmm. That last was a joke, but now that I’ve written it, I think I may put in an RFE to the WK team. It might be a good idea to stop listening for the return key for a few hundred ms after an incorrect answer.

The Double Check script already provides this functionality (“mistake delay” – the second tab in the settings menu).

Regarding the other requests, I will have to think about it for a while. I consider ConfusionGuesser to be mostly feature complete, and I don’t know yet if I want to implement such extensive additions. Also I’m not sure about the added value of having this feature in ConfusionGuesser over just taking notes about these confusions with the note fields provided by vanilla WK.

In case anyone else stumbles upon this post and also wants this feature, here is a poll so I can gauge the interest:

  • I would like a feature to manually add confusion guesses to the list
  • I have no interest in such a feature

0 voters

2 Likes

Version 1.15:

  • Now also works on extra study page

Please let me know if something doesn’t work.
Link to previous script version for downgrading in case version 1.15 doesn’t work for you

3 Likes

Man. Just wanted to share my love for this script.

To be honest, I almost always ignore what it shows, just quickly typing “f” when I get something wrong to see the correct answer. Most of the time I know exactly why I got it wrong.

Sometimes, though, this thing is astonishingly helpful.

Example 1: 排水(はいすい) vs. 漏水(ろうすい)

This was seriously great. I kinda have a “hash collision” in my brain for the English words “drainage” and “leakage” even though they clearly have different meanings. It’s actually even clearer in Japanese and having the ConfusionGuesser just put it right there was simply awesome. Really made my day.

Example 2: 受託(じゅたく) vs. 受諾(じゅだく)

Doubtless, I’m not the only one that confuses these two, but it made my day today when this finally solved a nagging leech that I kept meaning to look into after my review session (but always forgot).

This one was neat because I was missing both reading (濁点(だくてん) or no) and meaning (“be entrusted with” vs. “acceptance”) randomly. I knew there was another vocabulary term I was confusing it with but could never remember to look it up (a recurring theme).

Seriously: this script is gold. Thank you!

6 Likes