Ajatt-Tools / Japanese

🍚 Automatically generate furigana and other data on Anki cards.
https://ankiweb.net/shared/info/1344485230
GNU Affero General Public License v3.0
34 stars 7 forks source link

Is there a proper way to generate Vocab Color Codes? #17

Closed EliCodesForFun closed 1 month ago

EliCodesForFun commented 1 month ago

Hello,

I wanted to generate color codes onto the Vocab card format that goes along with this add-on. In order to get any color coding, I had to generate it into the VocabFurigana field, and enable the Morpheme Parser, which is normally used for sentences. I had reservations about doing it this way, because there might be words I saved from a vocab list that get improperly parsed as 2 words in a sentence (?) Not quite sure if there's supposed to be a better way to generate this, as I also have the VocabPitchNum (which I couldn't generate into that field) but that num doesn't trigger a color change in my card format.

I was referencing this guide, but it didn't have much info on tweaking the Vocab card format: https://tatsumoto.neocities.org/blog/anki-japanese-support#color-coding

Screenshot (not exact but I edited it in Orange to show): image Basically under the "Add furigana for word" setting, I checked the split morphemes, added color code pitch Attributes, Underline, (and Color) and then regenerated everything.

It ends up looking like this: image

Windows 11 Anki Version ⁨24.06.3 (d678e393)⁩ Python 3.9.18 Qt 6.6.2 PyQt 6.6.1

tatsumoto-ren commented 1 month ago

Hello. The color-coding feature was designed with sentences in mind, similarly to how the MIA Japanese add-on did it in the past. So I'm afraid there might be some hiccups when trying to color-code isolated vocab. However, this new use case is definitely something we should invest in and make sure it works as expected.

EliCodesForFun commented 1 month ago

Hello. The color-coding feature was designed with sentences in mind, similarly to how the MIA Japanese add-on did it in the past. So I'm afraid there might be some hiccups when trying to color-code isolated vocab. However, this new use case is definitely something we should invest in and make sure it works as expected.

That would be awesome. For my particular case, I'm doing vocab cards and I was interested in the color coding. I thought there would be a quick way to hack it up using the PitchAccentNum but I don't know a JavaScript hack for it right now.

tatsumoto-ren commented 1 month ago

I'm going to investigate this problem and see why it doesn't work for vocab cards.

I thought there would be a quick way to hack it up using the PitchAccentNum but I don't know a JavaScript hack for it right now.

Take a look at this note type. It has built-in JS that changes the color of the bolded word if the VocabPitchNum field contains a number.

EliCodesForFun commented 1 month ago

I'm going to investigate this problem and see why it doesn't work for vocab cards.

I thought there would be a quick way to hack it up using the PitchAccentNum but I don't know a JavaScript hack for it right now.

Take a look at this note type. It has built-in JS that changes the color of the bolded word if the VocabPitchNum field contains a number.

I was able to hack it a bit. I had to use the Sentence card format. One issue is that we're essentially getting sentence readings on vocab, so it ends up kinda funny looking sometimes, and can misparse:

image

And this is an example on the old Anki 2.1 furigana support, but the same concept here - we get multiple readings. image

I'm kind of fine with it this way, anyway, though some words starting with hiragana can look a little funny.

It'll take some careful thought and maybe some settings for implementing this for vocab words, I suppose. I haven't tried these cases without the sentence parsing to compare.

tatsumoto-ren commented 1 month ago

I tried applying the settings from the first comment (don't split morphemes + enable coloring) but couldn't reproduce the issue. I got the color-coding for the individual word correctly.

The way ほほ笑む is handled is a bug that hasn't been discovered until now. I'll upload a fix soon. btw it makes more sense to learn 微笑む which is the correct form.

tatsumoto-ren commented 1 month ago

Is this issue resolved now?

EliCodesForFun commented 1 month ago

Is this issue resolved now?

I was able to generate the pitch accent while not having the word parser enabled this time, so I think we're good to go, and I figured out where can add the numbers. I ended up just utilizing the html/css styled pitch accent rather than relying on JavaScript to change it dynamically using the number.

Thank you!