Hello, after importing a few more advanced YT videos during my Italian learning I’ve stumbled on two recurring issues:
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.
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
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
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.
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!
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.
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
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.