YouTube imported lesson Quality-of-Life improvements

Hello, after importing a few more advanced YT videos during my Italian learning I’ve stumbled on two recurring issues:

  1. When selecting across lines in the text, a space isn’t appended between text and it looks strange in google translate, in fact the built-in LingQ translate is never able to handle the translation so I always need to use google translate in this context.
  2. when I advance the text to the next page without clicking on every “new” word, they are all marked as known! This is super bad, because often I’ll legitimately not know them and then marking them as level 1 will net me negative coins and just lead to a frustrating learning experience

images of feedback #1:

Thanks in advanced :slight_smile:

At least for #2 you can turn it off by unchecking the option at settings>app settings>Reader>Paging moves to known.

Keep in mind they will still move to known if you complete the lesson. They want you to lingq any you don’t know.

1 Like

As @hiptothehop mentioned, you can disable the Paging moves to Known under Settings > Reader on the site or app.

Regarding #1, this unfortunately depends on the subtitle file format, so there is no much we can do on our end.

1 Like

ah ok I was wondering how much processing goes on when the script gets ingested, maybe replacing all of the newline characters with space + \n could do it? That might be too much of a blanket assumption, though

super helpful thanks! Yeah it’s totally fine to mark them as known upon lesson completion

Since you made some suggestions in the original post -

We are getting close to launching a major new feature - Lynx, an AI chat companion. LingQ users will be able to talk with Lynx and get practice their conversational skills. You’ll be able to talk about lessons you’d completed to practice your vocabulary, get feedback on what you’re saying in the convo, and even export the conversation as a LingQ lesson.

If you want to join the list of beta testers for Android or Web, let me know. We’re always happy to have more feedback from users who like to suggest improvements! The beta starts Monday.

2 Likes

as a heavy web user I’m definitely interested. I’ve been using various LLMs to help break down particular grammatical constructions I don’t recognize and to practice basic phrases and conversation (mostly to force myself to speak a little). For what it’s worth, I do still think it would be useful to fix the newline import issue I mentioned in #1 of the post, but excited to see what new things the LingQ team is cooking up, also!

I’ll add you to the list and reach out to you when the beta is starting :slight_smile:

Hi everyone,

regarding issue #1, I think OP was not talking about the handling of the subtitles per se, but rather about what happens when the user selects words across lines/paragraphs. While normally, LingQ is able to suggest translations for parts of phrases, in such cases, an error message is displayed instead, without any space across the lines.

1 Like

you’re right! I realize that I was only able to include a single screenshot as a new poster so it may not have come across perfectly, thanks for including better screenshots :slight_smile:

Tell the LingQ’s dev team to use this code to change the select event listener to get the characters like ,, ., ? properly with new line tags \n.

They are probably using DOM.textContent to get the text.

Original Text

Getted Text

Budget airlines don't save you as much as you thinkIn fact, many of them are becoming an outright scamThese companies have admitted to secretly paying their gate agents a bribe to claim passengers' bags are too big, even when they're not, forcing people to pay a ridiculously overpriced baggage feeDo you pay your employees a feeDo you incentivize them to go pick out bags from people getting on planes and kick them off the flightJust yes or no

Text got from my code

Budget airlines don't save you you think.
In fact, many of them are becoming an outright scam.
These companies have admitted to secretly paying their gate agents a bribe to claim passengers ' bags are too big, even when they're not, forcing people to pay a ridiculously overpriced baggage fee.
Do you pay your employees a fee?
Do you incentivize them to go pick out bags from people getting on planes and kick them off the flight?
Just yes or no?
function getAllLeafNodes(root) {
    const leaves = [];
    function traverse(node) {
        if (node.nodeType === Node.TEXT_NODE) {
            if (node.textContent.trim() !== "") leaves.push(node);
            return;
        }
        if (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
            if (node.childNodes.length === 0) {
                leaves.push(node);
                return;
            }
            for (const child of node.childNodes) {
                traverse(child);
            }
        }
    }
    traverse(root);
    return leaves;
}

function extractTextFromDOM(domElement) {
    const textParts = [];
    let sentenceElements = domElement.querySelectorAll('.sentence');
    sentenceElements = sentenceElements.length ? sentenceElements : [domElement];
    if (domElement.childNodes.length === 0) return null;

    sentenceElements.forEach(sentenceElement => {
        for (const childNode of getAllLeafNodes(sentenceElement)) {
            const text = childNode.textContent.trim();
            if (text) textParts.push(text);

            const parentNodeType = childNode.parentNode.nodeType;
            if (parentNodeType === Node.ELEMENT_NODE && childNode.parentNode.matches('.has-end-punctuation-question')) textParts.push('?');
            if (parentNodeType === Node.ELEMENT_NODE && childNode.parentNode.matches('.has-end-punctuation-period')) textParts.push('.');
        }
        textParts.push('\n');
    });

    return textParts.slice(0, -1).join(' ')
        .replace(/[^\S\n]?(\?|\.|\n)[^\S\n]?/g, '$1')
        .replace(/[^\S\n]?(,)/g, '$1');
}

@ecalzolaio I fixed the problem in my script. @zoran see the before/after of the script.

1 Like

Me Also. I want to see that.

1 Like

@vet8t6z79pc4 Thanks!