alaajabari commited on
Commit
4585cd9
·
verified ·
1 Parent(s): add7f19

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +17 -12
static/script.js CHANGED
@@ -85,19 +85,24 @@ async function runRE() {
85
  return;
86
  }
87
 
88
- // formatted output
89
- let formatted = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
- data.resp.forEach(r => {
92
- const subj = r[0];
93
- const rel = r[1];
94
- const obj = r[2];
95
- const conf = r[3];
96
-
97
- formatted += `${subj} → ${rel} → ${obj} (conf: ${conf.toFixed(2)})\n`;
98
- });
99
-
100
- document.getElementById("output").textContent = formatted;
101
 
102
  } catch (err) {
103
  document.getElementById("output").textContent =
 
85
  return;
86
  }
87
 
88
+ // =========================
89
+ // CLEAN JSON OUTPUT FORMAT
90
+ // =========================
91
+ const formattedList = data.resp.map(r => ({
92
+ Subject: {
93
+ Type: r.Subject.Type,
94
+ Label: r.Subject.Label
95
+ },
96
+ Relation: r.Relation,
97
+ Object: {
98
+ Type: r.Object.Type,
99
+ Label: r.Object.Label
100
+ },
101
+ Confidence: r.Confidence
102
+ }));
103
 
104
+ document.getElementById("output").textContent =
105
+ JSON.stringify(formattedList, null, 2);
 
 
 
 
 
 
 
 
106
 
107
  } catch (err) {
108
  document.getElementById("output").textContent =