Spaces:
Running
Running
Update static/script.js
Browse files- static/script.js +18 -9
static/script.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
| 1 |
async function runNER() {
|
| 2 |
-
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
|
|
|
|
| 1 |
async function runNER() {
|
| 2 |
+
try {
|
| 3 |
+
const text = document.getElementById("text").value;
|
| 4 |
|
| 5 |
+
const response = await fetch("/predict", {
|
| 6 |
+
method: "POST",
|
| 7 |
+
headers: { "Content-Type": "application/json" },
|
| 8 |
+
body: JSON.stringify({ text, mode: "1" })
|
| 9 |
+
});
|
| 10 |
|
| 11 |
+
const raw = await response.text(); // 👈 IMPORTANT
|
| 12 |
+
console.log("RAW RESPONSE:", raw);
|
| 13 |
+
|
| 14 |
+
const data = JSON.parse(raw);
|
| 15 |
|
| 16 |
+
document.getElementById("output").textContent =
|
| 17 |
+
JSON.stringify(data, null, 2);
|
| 18 |
+
|
| 19 |
+
} catch (err) {
|
| 20 |
+
document.getElementById("output").textContent =
|
| 21 |
+
"NER Error: " + err.message;
|
| 22 |
+
}
|
| 23 |
}
|
| 24 |
|
| 25 |
|