aaljabari commited on
Commit
13178bf
·
verified ·
1 Parent(s): a2b13e5

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +84 -0
static/script.js CHANGED
@@ -52,6 +52,90 @@ async function runNER() {
52
  }
53
  }
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  // ======================
57
  // Relation Extraction
 
52
  }
53
  }
54
 
55
+ async function runEAE() {
56
+ const text = document.getElementById("text").value;
57
+ const output = document.getElementById("output");
58
+
59
+ if (!text.trim()) {
60
+ output.textContent = "Please enter Arabic text.";
61
+ return;
62
+ }
63
+
64
+ output.textContent = "Processing event arguments...";
65
+
66
+ try {
67
+ const response = await fetch("/predict_eae", {
68
+ method: "POST",
69
+ headers: {
70
+ "Content-Type": "application/json"
71
+ },
72
+ body: JSON.stringify({ text: text })
73
+ });
74
+
75
+ const data = await response.json();
76
+ output.textContent = JSON.stringify(data, null, 2);
77
+ } catch (error) {
78
+ output.textContent = "Error extracting event arguments:\n" + error;
79
+ }
80
+ }
81
+
82
+ async function runAllRelations() {
83
+ const text = document.getElementById("text").value;
84
+ const output = document.getElementById("output");
85
+
86
+ if (!text.trim()) {
87
+ output.textContent = "Please enter Arabic text.";
88
+ return;
89
+ }
90
+
91
+ output.textContent = "Extracting relations and event arguments...";
92
+
93
+ try {
94
+ const [reResponse, eaeResponse] = await Promise.all([
95
+ fetch("/predict_re", {
96
+ method: "POST",
97
+ headers: {
98
+ "Content-Type": "application/json"
99
+ },
100
+ body: JSON.stringify({ text: text })
101
+ }),
102
+
103
+ fetch("/predict_eae", {
104
+ method: "POST",
105
+ headers: {
106
+ "Content-Type": "application/json"
107
+ },
108
+ body: JSON.stringify({ text: text })
109
+ })
110
+ ]);
111
+
112
+ const reData = await reResponse.json();
113
+ const eaeData = await eaeResponse.json();
114
+
115
+ const relationResults = reData.resp || [];
116
+ const eventResults = eaeData.resp || [];
117
+
118
+ const combinedResults = {
119
+ resp: [
120
+ ...relationResults.map(item => ({
121
+ ...item,
122
+ Task: "Relation Extraction"
123
+ })),
124
+ ...eventResults.map(item => ({
125
+ ...item,
126
+ Task: "Event Argument Extraction"
127
+ }))
128
+ ],
129
+ statusText: "OK",
130
+ statusCode: 0
131
+ };
132
+
133
+ output.textContent = JSON.stringify(combinedResults, null, 2);
134
+
135
+ } catch (error) {
136
+ output.textContent = "Error extracting all relations:\n" + error;
137
+ }
138
+ }
139
 
140
  // ======================
141
  // Relation Extraction