[Userscript] WaniKani Pitch Info

I probably won’t do that for now. When somebody posts on the forums asking about a bug in a script, I often only post a fix if I have already written one for myself, rather than creating a fix in response to the post. I think by posting the code on the forums instead, it’s maybe easier for people to understand that if the script breaks in the future, somebody else might need to fix it, and that even if I do eventually fix it, it will only be when it annoys me enough which might be a long time.

There are also some other things like I don’t know how much script development I will continue to do after I reach level 60, and don’t want to contribute to the problem of more abandoned scripts on Greaseyfork.

4 Likes

Since the upcoming changes to the WK lesson screen will break this script, I have looked into fixing it by letting it use my newly developed WK Item Info Injector library script. But while I was adapting the code, I also noticed that the weblio queries don’t seem to work anymore? Does anyone know where to find the pitch info now? Or was it removed from weblio entirely?

1 Like

I believe it was removed from Weblio entirely. There’s an open source pitch accent list that Yomichan and the Midori iPhone app use. I can grab a link for you later.

1 Like

Here’s the GitHub file. Most of the time the data is easy to parse, but be careful of words where the pitch accent differs depending on part of speech, like 結構.

4 Likes

Thank you! And thanks for the heads-up about the part-of-speech special cases. Luckily, this currently affects only 19 WK vocabulary items. Unluckily, already the first of these seems to pose a problem: WK teaches 多分 as adverb and noun, and the accents.txt file says: (名;形動)0,(副)1. So for nouns it’s [0], and for adverbs it’s [1]. My first idea to address this was to color each word type in the respective color:

Screenshot

but for items like 大事, this won’t work, because they have multiple possible pitch accents per word type: (名)1,3,(形動)0,3. Only relying on colors is probably not the best idea anyway for accessibility reasons. Maybe appending the corresponding numbers behind each word type is better? :thinking:
image
Or would that make the interface too cluttered? It seems a bit redundant to have the pitch accent numbers listed below the reading and also in “Word Type” under meaning. And during lessons, the word types are not on the screen at the same time as the pitch accent graph. Although it wouldn’t be hard to also display the “Word Type” in the reading tab.


Aside from that problem, 392 WK vocabulary items are not in accents.txt. I’m wondering if there is an easy way to reduce this number, or if these items should just be left at 不詳 [-1]. Some examples: 〜円 (suffixes marked with 〜), 二万 (numerals), 仕方がない (expressions), 工学者 (compounds), 決定する (する verbs where WK included the する). For the する verbs, would it be correct to look up the word without the する and use that pitch accent?


The script currently inserts links to weblio, but they are not helpful in regards to pitch accent anymore. Should they link somewhere else, like OJAD, which I’ve seen mentioned in this thread? Or should the links be removed?

Originally, I just wanted to modify this script so that it works with the changes to the lessons, but in the end it turned into a complete rewrite of this script. I don’t know what I should do with it now? Is it considered rude to make a pull request that basically replaces the entire code? Should I instead publish it as a new script? But that seems bad because the current script users won’t get the update automatically.

For now, my version can be installed from here.

This version only uses the github file suggested by @seanblue. A few hundred WK vocabulary items are missing from this file (see previous post). For する verbs, my script currently looks up the word without the する and use that pitch accent. I’m a bit worried that this might not always be correct.

Screenshots of the new script version

I have added some “settings” to the script (a few variables at the top of the script code, no fancy UI). The radius of the dots and the line thickness can be changed. Digraphs are now not squashed by default, as can be seen in the screenshot for きゅう (but this can also be changed with a setting):

image

The description below the reading now shows which pitch accent belongs to which word type:

image

4 Likes

I don’t see why that would be a problem. It’s not actually a single word anyway.

I have just noticed that in the github file, the entry for 対 is

対	たい	1

but for 対する, the entry is

対する	たいする	3

I don’t know if this is an exception/considered a different word, or if this might also happen for other words where the entry with appended する is actually missing from the github file.

1 Like

For some words, the する version is read differently altogether, e.g. 達する (たっする) or 接する (せっする). So you can probably not avoid having a separate treatment at least for those special cases…

達する and 接する are both in the github file, so at least those two are no problem.

Unless there are some rules that can be implemented, the only “separate treatment” that I can think of is to not display anything at all if the full word including the する is not in the file.

1 Like

I think if they are in the file you can consider them separate words from a dictionary perspective. I just meant that I think it’s a reasonable assumption that if the する version isn’t in the file that you can just grab the non-する version. If you’re really concerned, add a small disclaimer on the page in those cases.

1 Like

I’ve noticed a bug whenever I do more than 5 lessons. For the first set of 5 lessons, the script works fine, but when the next set of 5 loads, the script causes my entire WaniKani tab to freeze once I try to see the reading of the first word. This happens every time for me, so I end up having to close the tab and reopen WaniKani each time I want to do 5 more lessons.

I realise the script creator hasn’t been online in a year or two, so I doubt it’ll be fixed. Is anyone else experiencing this problem? It may just be a problem with my set-up so I thought I should ask :sweat_smile:

1 Like

That happens to me too, but I think I get two or three sets before it breaks. Also, I didn’t know which script it was, so thanks for confirming that for me.

2 Likes

I think I have found the bug that you described in my “WaniKani Item Info Injector” library script that “WaniKani Pitch Info” uses. I have fixed it and will create a pull request for “WaniKani Pitch Info” to update to the newest version of “WaniKani Item Info Injector”.

You can either wait until the script author accepts my pull request, or you can install “WaniKani Item Info Injector” directly to immediately use the newest version.

Also, if it still does not work after the update, let me know and I will look into it.

EDIT: I had forgotten that the script author of this userscript has already given me write access to the repository. Version 0.56 of “WaniKani Pitch Info” is up and contains the fix.

3 Likes

Thank you so much!

1 Like

Thank you! I won’t be able to test it until I actually get enough new lessons, but I’m sure it has fixed the problem :grin: :grin:

1 Like

Encountering an error that I’m not sure is on my end or not. It affects 3 scripts so I’m posting it on each of their pages in the hopes that someone will be able to fix it for me.

Pitch Info, Cherry Picker, and Hide Context Sentences all fail to load/work correctly when I load up a vocabulary page. Here’s the console errors:

Sometimes I look at Tampermonkey and see that they’re not even showing up in the list of scripts on the page, othertimes they show up but seem to do nothing. Any ideas?

3 Likes

I will fix it when I’m home from work (in about 9 hours).

Update: Should be fixed now in version 0.61.

4 Likes

Just came here to thank you for your amazing work.

4 Likes

It seems to me that the only time I really get to see the pitch pattern info is during the lessons.
However, that definitely isn’t enough for me to remember properly.
Is there a way to show it later as well in some way?
This addon is generally helpful though!
(Sorry if this was answered before. You can post a link to another answer if you like. Thanks.)