Nahrát soubory do „scripts“

v tejto zmene je pridana lematizacia do kodu treba nahradit vlozeny api kluc s priradenym
This commit is contained in:
Patrik Rigan 2024-12-16 20:16:04 +00:00
parent 25e0b9a0c8
commit 667ea9324e

View File

@ -22,6 +22,28 @@ let autoPlayEnabled = true;
let currentTranslationMode = 'letters'; // Default mode
translateBtn.disabled = true;
// Function to lemmatize text via NLP4SK API
async function lemmatizeText(text) {
try {
const response = await fetch('http://arl6.library.sk/nlp4sk/api/lematizacia', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text }),
});
if (!response.ok) {
throw new Error('Chyba pri volaní lematizačného API');
}
const data = await response.json();
return data.result || text; // Return lemmatized text or original if no result
} catch (error) {
console.error('Chyba pri lematizácii:', error);
statusText.innerText = 'Chyba pri lematizácii, použije sa pôvodný text.';
return text; // Fallback to original text on error
}
}
// Function to check if video exists (for local testing)
async function videoExists(src) {
return new Promise(resolve => {
@ -143,6 +165,10 @@ if (currentTranslationMode === 'letters') {
translateBtn.addEventListener('click', async () => {
autoPlayEnabled = true;
// Lematizácia vstupu
const lemmatizedText = await lemmatizeText(inputText.value);
inputText.value = lemmatizedText; // Update input field with lemmatized text
// Load the video sequence based on the current translation mode
if (currentTranslationMode === 'words') {
await loadVideoSequenceByWords();