File size: 1,153 Bytes
1d9f73b
 
 
 
7139637
 
 
1d9f73b
7139637
 
 
 
1d9f73b
7139637
 
 
 
 
 
 
 
 
a5eafbd
7139637
 
 
 
 
 
 
 
 
 
 
 
 
 
1d9f73b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
async function runNER() {
    const text = document.getElementById("text").value;
    const mode = document.getElementById("mode").value;

    const status = document.getElementById("status");
    const button = document.getElementById("extractBtn");
    const output = document.getElementById("output");

    // Show processing message
    status.textContent = "⏳ Extracting entities...";
    status.style.color = "blue";
    button.disabled = true;

    try {
        const response = await fetch("/predict", {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify({ text, mode })
        });

        const data = await response.json();

        output.textContent = JSON.stringify(data, null, 2);

        // Finished successfully
        status.textContent = "✅ Extraction completed.";
        status.style.color = "green";
    } catch (error) {
        output.textContent = error;

        status.textContent = "❌ An error occurred during extraction.";
        status.style.color = "red";
    } finally {
        button.disabled = false;
    }
}