Compare commits
No commits in common. "pr351jz-Lematizácia_vstupu_používateľa_#37" and "main" have entirely different histories.
pr351jz-Le
...
main
@ -22,28 +22,6 @@ let autoPlayEnabled = true;
|
|||||||
let currentTranslationMode = 'letters'; // Default mode
|
let currentTranslationMode = 'letters'; // Default mode
|
||||||
translateBtn.disabled = true;
|
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)
|
// Function to check if video exists (for local testing)
|
||||||
async function videoExists(src) {
|
async function videoExists(src) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@ -165,10 +143,6 @@ if (currentTranslationMode === 'letters') {
|
|||||||
translateBtn.addEventListener('click', async () => {
|
translateBtn.addEventListener('click', async () => {
|
||||||
autoPlayEnabled = true;
|
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
|
// Load the video sequence based on the current translation mode
|
||||||
if (currentTranslationMode === 'words') {
|
if (currentTranslationMode === 'words') {
|
||||||
await loadVideoSequenceByWords();
|
await loadVideoSequenceByWords();
|
||||||
|
Loading…
Reference in New Issue
Block a user