Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +17 -12
static/script.js
CHANGED
|
@@ -85,19 +85,24 @@ async function runRE() {
|
|
| 85 |
return;
|
| 86 |
}
|
| 87 |
|
| 88 |
-
//
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 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 =
|