killergerbah / asbplayer

Browser-based media player and Chrome extension for subtitle sentence mining
MIT License
536 stars 69 forks source link

Yomitan not picking up the full sentence with a normal "add". Related to: {cloze-prefix} {cloze-suffix} #459

Closed Viterkim closed 3 months ago

Viterkim commented 4 months ago

I like having a setup in yomitan with (anki connect)

{cloze-prefix} ({cloze-body}) {cloze-suffix}

when i mine stuff i have the full sentence and the word in (). However with asbplayer, when there's "2 lines of subtitles" only the line with the actual word in will get mined, this means that the audio will have the full sentence but the sentence is only "half".

Using the asbplayer anki settings doesn't help as i like modifying the content and not just pop in the entire sentence.

Would it be possible to make both sentence lines the same HTML part or something like that? Or is there a way i can make yomitan pickup both sentences?

Thanks!

edit: this used to work fine in https://github.com/animebook/animebook.github.io :D also would it be possible to disable double click to full screen, or click to play/pause?

edit 2: disabling double click can be done with a simple violent monkey / tamper monkey script:

// ==UserScript==
// @name        Disable oduble click for fullscreen for killergerbah.github.io
// @namespace   Violentmonkey Scripts
// @match       https://killergerbah.github.io/asbplayer/*
// @grant       none
// @version     8.5
// @author      Good old chat gippity
// @description 7/6/2024, 1:33:00 PM
// ==/UserScript==

(function() {
    'use strict';

    document.addEventListener('dblclick', function(event) {
        if (event.target.tagName.toLowerCase() === 'video') {
            event.stopPropagation();
        }
    }, true);
})();
killergerbah commented 3 months ago

@Viterkim If you

  1. Configure both Yomitan and asbplayer to supply the sentence.
  2. And use the "create card with Yomitan, then update with asbplayer" flow.

Then, the asbplayer-supplied sentence should override the Yomitan one, BUT also inherit any HTML markup in the Yomitan sentence. If that's not what is happening then there might be a bug, and it would be helpful to have an example of the Yomitan template actually being used, since I might be misunderstanding the problem.

Viterkim commented 3 months ago

Anki setup: image

Asbplayer setup: image

Sentence: image

Added from anki: image

Updated with asbplayer (no () now): image

so if you can see the example word is 服 which i had marked (服) but the () dissapears since it's not in the original subtitle. it's because I'm using

{cloze-prefix} ({cloze-body}) {cloze-suffix}

to mark the {cloze-body} in ().

With animebook it just copied the entire sentence in (both top and bottom), even in a nice oneliner example: image

Or maybe I'm doing something wrong?

Viterkim commented 3 months ago

Here's a subtitle file Non Non Biyori-S3 E12-Episode 12_ja.zip

killergerbah commented 3 months ago

@Viterkim Got it, I think I understand the problem a bit better now. Yomitan picks up the entire sentence on animebook, I believe due to a combination of how animebook renders the subtitle and how Yomitan detects boundaries between sentences. I can suggest two possible workarounds:

Unfortunately I am hesitant to make any subtitle rendering changes just to fix this issue so it would be great if one of the options above work for you.

Viterkim commented 3 months ago

image image

There's no \n line terminator when parsing sentences.

I'm not really sure how doing anything with {cloze-body} would help? My card format are vocab cards, with the sentence on the back where i have the () for convenience, for glancing at the word location.

asbplayer: image i can see that there's just a newline in the content

animebook: image Here there's the <p> tags?

Maybe this helps?

Also appreciate you spending your time on answering!

killergerbah commented 3 months ago

I'm not really sure how doing anything with {cloze-body} would help? My card format are vocab cards, with the sentence on the back where i have the () for convenience, for glancing at the word location.

What I mean is to highlight {cloze-body} using HTML formatting instead of parentheses. So something like <b>{cloze-body}</b> would do it, but you would be highlighting the word in bold instead of using parentheses.

If you do this then asbplayer will properly retain the highlighting when it updates the sentence.

Viterkim commented 3 months ago

like this? image

image

image

image

no doesn't work

Viterkim commented 3 months ago

Okay it seems to work with the image and not the subtitle track 1 field (didn't see the top one). But man i just don't like the bold stuff :D

killergerbah commented 3 months ago

l see, the HTML markup being retained for the individual subtitle tracks should probably be considered a bug.

About the bolding, you could still use HTML to get parentheses instead if you use the solution in this StackOverflow post: https://stackoverflow.com/questions/60178429/add-parentheses-before-and-after-paragraph-in-html-css

I would try something like this:

<span>{cloze-body}</span>

And then CSS in your Anki note type like this:

span::before {
  content: "("
}

span::after {
  content: ")"
}
Viterkim commented 3 months ago

It's actually a really good solution, and would also have something unique to wrap the word in!

BUT it unfortunately doesn't work. Setup: image image

Before: image image

After: image image

killergerbah commented 3 months ago

Hmm not sure what to tell you - maybe it is not possible to achieve the parentheses with HTML.

For asbplayer, I am reluctant to make changes to support this very specific use case, and you might have better luck submitting an issue to Yomitan regarding its sentence boundary detection when it comes to text separated by newlines.

Viterkim commented 3 months ago

Hmm not sure what to tell you - maybe it is not possible to achieve the parentheses with HTML.

For asbplayer, I am reluctant to make changes to support this very specific use case, and you might have better luck submitting an issue to Yomitan regarding its sentence boundary detection when it comes to text separated by newlines.

I think there might be a bug, as it worked with the bold html tag, but not with the stuff you suggested! @killergerbah