Spaces:
Sleeping
Sleeping
File size: 668 Bytes
6e4a2f6 79d4400 6e4a2f6 79d4400 6e4a2f6 79d4400 6e4a2f6 79d4400 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
const textSpacyForm = document.querySelector('.text-spacy-form');
const translateText = async (text) => {
const inferResponse = await fetch(`score_text?text_input=${text}`);
const inferJson = await inferResponse.json();
var jsonStr = JSON.stringify(inferJson);
return jsonStr;
};
textSpacyForm.addEventListener('submit', async (event) => {
event.preventDefault();
const textSpacyInput = document.getElementById('text-spacy-input');
const textSpacyParagraph = document.querySelector('.text-spacy-output');
try {
textSpacyParagraph.textContent = await translateText(textSpacyInput.value);
} catch (err) {
console.error(err);
}
}); |