alaajabari commited on
Commit
2bd700a
·
verified ·
1 Parent(s): ad240b0

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +28 -5
static/script.js CHANGED
@@ -1,17 +1,40 @@
1
  async function runNER() {
2
  const text = document.getElementById("text").value;
3
- const mode = document.getElementById("mode").value;
4
 
5
  const response = await fetch("/predict", {
6
  method: "POST",
7
- headers: {
8
- "Content-Type": "application/json"
9
- },
10
- body: JSON.stringify({ text, mode })
11
  });
12
 
13
  const data = await response.json();
14
 
15
  document.getElementById("output").textContent =
16
  JSON.stringify(data, null, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
 
1
  async function runNER() {
2
  const text = document.getElementById("text").value;
 
3
 
4
  const response = await fetch("/predict", {
5
  method: "POST",
6
+ headers: { "Content-Type": "application/json" },
7
+ body: JSON.stringify({ text, mode: "1" })
 
 
8
  });
9
 
10
  const data = await response.json();
11
 
12
  document.getElementById("output").textContent =
13
  JSON.stringify(data, null, 2);
14
+ }
15
+
16
+
17
+ async function runRE() {
18
+ const text = document.getElementById("text").value;
19
+
20
+ const response = await fetch("/predict_re", {
21
+ method: "POST",
22
+ headers: { "Content-Type": "application/json" },
23
+ body: JSON.stringify({ text })
24
+ });
25
+
26
+ const data = await response.json();
27
+
28
+ // nicer formatting for relations
29
+ let formatted = "";
30
+
31
+ if (data.resp.length === 0) {
32
+ formatted = "No relations found.";
33
+ } else {
34
+ data.resp.forEach(r => {
35
+ formatted += `${r[0]} → ${r[1]} → ${r[2]} (conf: ${r[3].toFixed(2)})\n`;
36
+ });
37
+ }
38
+
39
+ document.getElementById("output").textContent = formatted;
40
  }