I recently found [Browser Extension] WaniKani Kanji Highlighter 2021
I like the feeling of having the WK entry for a kanji popping up on mouseover.
But I imagine more is possible: A WK highlighter! Not only simple kanji.
For kanji pairs it should be easy peasy to check whether they are in the WK vocabulary and then do a popup like for the kanji.
But now to the challenge: Verbs!
Let’s take a simple example: 上げる and 上がる.
Normally verbs won’t appear in a text in dictionary form. So what if I find one or more kanji followed by kana and not a particle. Would it work to add randomly す, る and む with a good chance to get the correct dictionary entry from WK? Or would more intelligence be necessary?
Adjectives would be another topic but I will let them out for now.
I have actually found a JavaScript library that groups Japanese words, which will allow me to highlight words instead of just kanji, in the future. I just need to find the time to implement it hahaha
As I already said before. I’m ready to give you a helping hand beginning of June when I’m on vacation.
A pointer to the JavaScript library? Does it help with verbs?
I’m so interested in this topic because I imagine (Until the reality test) that it can help me tremendously in reading Japanese stuff (Lightnovels )
My code is a mess hahaha but sure we can talk about it then, in June.
The lib: Tiny Segmenter
Why not just install a good dictionary/browser extension? No need to reinvent the wheel. Plus a dictionary will have more words than WK.
The world has more than one type of wheel But earnestly …
You mean e.g. Yomichan?
- If I can read some stuff: OK.
- elIf I remember my WK story: OK.
- else I want fast access to WK. And I consider mouseover as fast.
Obviously for words missing in WK I can use Jisho oder Google translate.
Let’s go to work. We have Ascension now. I’m on vacation until Whit Monday. This should give a friend and me some time to give it a shot.
First step is segmenting Japanese sentences by particles and then trying to get stems for adjectives and verbs. The Cure Dolly way looks promising to us. On Sunday I expect first results showing whether it’s feasable.
Programming language Python. Why? We both like it more than Javascript and for the final step to the browser AFAIK Python2JS translators exist.
Anyway Highlighter and e.g. Yomichan can be combined. HIghlighter works on mouse over and Yomichan reacts to the shift key.
Still you can say: Why reinvent the wheel. Isn’t what’s there good enough? What I’m coding for my job isn’t much fun. So let’s just do this. With a programming language I like and a result which hopefully helps me reading LNs.
Hello Diogo, work started.
Any hints where in you code you parse the contents of the website for Japanese content and where you inject your highlighting stuff?
Some tips are better than me looking through your code myself
P.S: I didn’t find an email address on github, so …
Hi, so the main file for the highlighting is this one https://github.com/digas99/wanikani-kanji-highlighter/blob/master/scripts/highlighter/highlight.js.
I basically get all html tags in the page, filter those that can harbor text and then when I find one that has text in it, I check if it has any kanji from any list I want. If it does, then I create SPAN tags with those kanji, give it a class with the styling and replace the old text with the same text but with those SPANs in the place of the kanji.
So, this HTML:
<div>Kanji: 勉強する</div>
becomes this:
<div>Kanji: <span class="...">勉</span><span class="...">強<span>する</div>
I see that’s the < span class=“wkhighlighter_highlighted wkhighlighter_clickable wkhighlighter_hoverable”>小</ span> stuff.
Thanks. I guess this helps.
Proof of concept!
A vocabulary popup! The basic step from a kanji highlighter to a vocabulary highlighter.
Vacation is over. But …
I can find dictionary verbs.
Python to Javascript translation isn’t as good as I thought and I hate Javascript
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.