Spaces:
Sleeping
Sleeping
update
Browse files- static/index.html +246 -28
static/index.html
CHANGED
@@ -1,3 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<body>
|
2 |
<div class="container">
|
3 |
<h1>TexClarity</h1>
|
@@ -85,18 +281,16 @@
|
|
85 |
}
|
86 |
|
87 |
const rawResults = await response.json();
|
88 |
-
console.log("Raw response:", rawResults);
|
89 |
|
90 |
// Handle both array and object responses
|
91 |
let results;
|
92 |
if (Array.isArray(rawResults)) {
|
93 |
-
// If the response is an array, take the first element
|
94 |
results = rawResults[0];
|
95 |
} else {
|
96 |
-
// If the response is already an object, use it directly
|
97 |
results = rawResults;
|
98 |
}
|
99 |
-
console.log("Processed results:", results);
|
100 |
|
101 |
if (results.error) {
|
102 |
throw new Error(results.error);
|
@@ -118,37 +312,60 @@
|
|
118 |
}
|
119 |
|
120 |
function updateTable(results) {
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
function updateChart(results) {
|
143 |
const ctx = document.getElementById('resultsChart').getContext('2d');
|
144 |
if (chartInstance) chartInstance.destroy();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
chartInstance = new Chart(ctx, {
|
146 |
type: 'bar',
|
147 |
data: {
|
148 |
-
labels:
|
149 |
datasets: [{
|
150 |
label: 'Scores',
|
151 |
-
data:
|
152 |
backgroundColor: '#4e79e6',
|
153 |
borderColor: '#6a8de9',
|
154 |
borderWidth: 1
|
@@ -161,4 +378,5 @@
|
|
161 |
});
|
162 |
}
|
163 |
</script>
|
164 |
-
</body>
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>TexClarity</title>
|
7 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
8 |
+
<link href="https://fonts.googleapis.com/css2?family=Griffy&display=swap" rel="stylesheet">
|
9 |
+
<style>
|
10 |
+
body {
|
11 |
+
font-family: Arial, sans-serif;
|
12 |
+
background: linear-gradient(135deg, #000, #1a1a2e);
|
13 |
+
color: #fff;
|
14 |
+
margin: 0;
|
15 |
+
padding: 20px;
|
16 |
+
display: flex;
|
17 |
+
justify-content: center;
|
18 |
+
min-height: 100vh;
|
19 |
+
}
|
20 |
+
.container {
|
21 |
+
max-width: 1000px;
|
22 |
+
width: 100%;
|
23 |
+
}
|
24 |
+
h1 {
|
25 |
+
font-family: 'Griffy', cursive;
|
26 |
+
font-size: 2em;
|
27 |
+
margin-bottom: 0;
|
28 |
+
margin-top: 10px;
|
29 |
+
position: absolute;
|
30 |
+
top: 20px;
|
31 |
+
left: 20px;
|
32 |
+
color: #fff;
|
33 |
+
text-align: left;
|
34 |
+
box-shadow: 0 0 5px rgba(78, 121, 230, 0.2);
|
35 |
+
padding: 5px 10px;
|
36 |
+
border-radius: 5px;
|
37 |
+
animation: glow 2s infinite;
|
38 |
+
}
|
39 |
+
@keyframes glow {
|
40 |
+
0% { box-shadow: 0 0 5px rgba(78, 121, 230, 0.2); }
|
41 |
+
50% { box-shadow: 0 0 8px rgba(78, 121, 230, 0.4); }
|
42 |
+
100% { box-shadow: 0 0 5px rgba(78, 121, 230, 0.2); }
|
43 |
+
}
|
44 |
+
h2 {
|
45 |
+
font-family: 'Verdana', sans-serif;
|
46 |
+
font-size: 1.8em;
|
47 |
+
font-weight: normal;
|
48 |
+
margin-top: 30px;
|
49 |
+
}
|
50 |
+
h1, h2 {
|
51 |
+
color: #fff;
|
52 |
+
text-align: left;
|
53 |
+
}
|
54 |
+
.input-section {
|
55 |
+
margin-top: 60px;
|
56 |
+
margin-bottom: 20px;
|
57 |
+
}
|
58 |
+
textarea {
|
59 |
+
width: 100%;
|
60 |
+
height: 250px;
|
61 |
+
padding: 15px;
|
62 |
+
margin-bottom: 10px;
|
63 |
+
border: none;
|
64 |
+
border-radius: 8px;
|
65 |
+
background: #e0e0e0;
|
66 |
+
color: #333;
|
67 |
+
font-size: 1.2em;
|
68 |
+
box-sizing: border-box;
|
69 |
+
box-shadow: 0 0 10px rgba(78, 121, 230, 0.3);
|
70 |
+
transition: box-shadow 0.3s;
|
71 |
+
}
|
72 |
+
textarea:focus {
|
73 |
+
box-shadow: 0 0 15px rgba(78, 121, 230, 0.6);
|
74 |
+
}
|
75 |
+
.labels-section {
|
76 |
+
display: flex;
|
77 |
+
align-items: center;
|
78 |
+
gap: 10px;
|
79 |
+
margin-bottom: 10px;
|
80 |
+
}
|
81 |
+
.labels-section label {
|
82 |
+
font-size: 1.2em;
|
83 |
+
}
|
84 |
+
input {
|
85 |
+
flex: 2;
|
86 |
+
padding: 15px;
|
87 |
+
border: 2px solid #4e79e6;
|
88 |
+
border-radius: 8px;
|
89 |
+
background: #e0e0e0;
|
90 |
+
color: #333;
|
91 |
+
font-size: 1.2em;
|
92 |
+
box-shadow: 0 0 8px rgba(78, 121, 230, 0.3);
|
93 |
+
transition: box-shadow 0.3s;
|
94 |
+
}
|
95 |
+
input:focus {
|
96 |
+
box-shadow: 0 0 8px rgba(78, 121, 230, 0.5);
|
97 |
+
}
|
98 |
+
button {
|
99 |
+
background: linear-gradient(135deg, #2c5aa0, #4e79e6);
|
100 |
+
color: #fff;
|
101 |
+
padding: 10px 20px;
|
102 |
+
border: none;
|
103 |
+
border-radius: 8px;
|
104 |
+
cursor: pointer;
|
105 |
+
font-size: 1.1em;
|
106 |
+
box-shadow: 0 0 15px rgba(78, 121, 230, 0.5);
|
107 |
+
animation: pulse 2s infinite;
|
108 |
+
transition: transform 0.2s;
|
109 |
+
}
|
110 |
+
button:hover {
|
111 |
+
transform: scale(1.05);
|
112 |
+
box-shadow: 0 0 20px rgba(78, 121, 230, 0.8);
|
113 |
+
}
|
114 |
+
@keyframes pulse {
|
115 |
+
0% { box-shadow: 0 0 15px rgba(78, 121, 230, 0.5); }
|
116 |
+
50% { box-shadow: 0 0 25px rgba(78, 121, 230, 0.8); }
|
117 |
+
100% { box-shadow: 0 0 15px rgba(78, 121, 230, 0.5); }
|
118 |
+
}
|
119 |
+
.results {
|
120 |
+
display: flex;
|
121 |
+
flex-direction: column;
|
122 |
+
gap: 20px;
|
123 |
+
}
|
124 |
+
table {
|
125 |
+
width: 100%;
|
126 |
+
border-collapse: collapse;
|
127 |
+
background: linear-gradient(135deg, #000, #1a1a2e);
|
128 |
+
border-radius: 8px;
|
129 |
+
overflow: hidden;
|
130 |
+
}
|
131 |
+
th, td {
|
132 |
+
padding: 12px;
|
133 |
+
text-align: left;
|
134 |
+
color: #fff;
|
135 |
+
}
|
136 |
+
th {
|
137 |
+
font-weight: bold;
|
138 |
+
}
|
139 |
+
.chart-container {
|
140 |
+
display: none;
|
141 |
+
position: relative;
|
142 |
+
height: 300px;
|
143 |
+
background: linear-gradient(135deg, #000, #1a1a2e);
|
144 |
+
border-radius: 8px;
|
145 |
+
padding: 10px;
|
146 |
+
}
|
147 |
+
.loading {
|
148 |
+
position: fixed;
|
149 |
+
top: 50%;
|
150 |
+
left: 50%;
|
151 |
+
transform: translate(-50%, -50%);
|
152 |
+
color: #4e79e6;
|
153 |
+
font-size: 3.5em;
|
154 |
+
display: none;
|
155 |
+
}
|
156 |
+
.loading::after {
|
157 |
+
content: '...';
|
158 |
+
animation: dots 1.5s infinite;
|
159 |
+
}
|
160 |
+
@keyframes dots {
|
161 |
+
0% { content: '.'; }
|
162 |
+
33% { content: '..'; }
|
163 |
+
66% { content: '...'; }
|
164 |
+
}
|
165 |
+
@media (max-width: 768px) {
|
166 |
+
.container {
|
167 |
+
padding: 10px;
|
168 |
+
}
|
169 |
+
textarea, input, button {
|
170 |
+
font-size: 1em;
|
171 |
+
}
|
172 |
+
.labels-section {
|
173 |
+
flex-direction: column;
|
174 |
+
align-items: flex-start;
|
175 |
+
}
|
176 |
+
button {
|
177 |
+
width: 100%;
|
178 |
+
}
|
179 |
+
h1 {
|
180 |
+
font-size: 1.5em;
|
181 |
+
top: 10px;
|
182 |
+
left: 10px;
|
183 |
+
}
|
184 |
+
h2 {
|
185 |
+
margin-top: 20px;
|
186 |
+
font-size: 1.4em;
|
187 |
+
}
|
188 |
+
.input-section {
|
189 |
+
margin-top: 40px;
|
190 |
+
}
|
191 |
+
.loading {
|
192 |
+
font-size: 2.5em;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
</style>
|
196 |
+
</head>
|
197 |
<body>
|
198 |
<div class="container">
|
199 |
<h1>TexClarity</h1>
|
|
|
281 |
}
|
282 |
|
283 |
const rawResults = await response.json();
|
284 |
+
console.log("Raw response:", JSON.stringify(rawResults, null, 2)); // Formatted JSON
|
285 |
|
286 |
// Handle both array and object responses
|
287 |
let results;
|
288 |
if (Array.isArray(rawResults)) {
|
|
|
289 |
results = rawResults[0];
|
290 |
} else {
|
|
|
291 |
results = rawResults;
|
292 |
}
|
293 |
+
console.log("Processed results:", JSON.stringify(results, null, 2)); // Formatted JSON
|
294 |
|
295 |
if (results.error) {
|
296 |
throw new Error(results.error);
|
|
|
312 |
}
|
313 |
|
314 |
function updateTable(results) {
|
315 |
+
const tbody = document.querySelector('#results-table tbody');
|
316 |
+
tbody.innerHTML = '';
|
317 |
+
|
318 |
+
// If labels is a single string, split it manually based on the input
|
319 |
+
let labelsArray = [];
|
320 |
+
if (typeof results.labels === 'string') {
|
321 |
+
labelsArray = results.labels.split(',').map(label => label.trim());
|
322 |
+
} else if (Array.isArray(results.labels)) {
|
323 |
+
labelsArray = results.labels; // Use the original array if it's already split
|
324 |
+
} else {
|
325 |
+
console.warn("Unexpected labels format:", results.labels);
|
326 |
+
labelsArray = [results.labels.toString()]; // Fallback
|
327 |
+
}
|
328 |
+
|
329 |
+
// Use the first score (since the model might return one score for all labels)
|
330 |
+
const score = results.scores.length > 0 ? results.scores[0].toFixed(3) : '0.000';
|
331 |
+
|
332 |
+
// Create a row for each label with the same score
|
333 |
+
if (labelsArray.length === 0) {
|
334 |
+
console.warn("No labels to display");
|
335 |
+
return;
|
336 |
+
}
|
337 |
+
labelsArray.forEach((label) => {
|
338 |
+
const row = document.createElement('tr');
|
339 |
+
row.innerHTML = `<td>${label}</td><td>${score}</td>`;
|
340 |
+
tbody.appendChild(row);
|
341 |
+
});
|
342 |
+
}
|
343 |
+
|
344 |
function updateChart(results) {
|
345 |
const ctx = document.getElementById('resultsChart').getContext('2d');
|
346 |
if (chartInstance) chartInstance.destroy();
|
347 |
+
|
348 |
+
// If labels is a single string, split it manually for the chart
|
349 |
+
let labelsArray = [];
|
350 |
+
if (typeof results.labels === 'string') {
|
351 |
+
labelsArray = results.labels.split(',').map(label => label.trim());
|
352 |
+
} else if (Array.isArray(results.labels)) {
|
353 |
+
labelsArray = results.labels;
|
354 |
+
} else {
|
355 |
+
labelsArray = [results.labels.toString()];
|
356 |
+
}
|
357 |
+
|
358 |
+
// Create scores array with the same length as labelsArray
|
359 |
+
const score = results.scores.length > 0 ? results.scores[0] : 0;
|
360 |
+
const scoresArray = Array(labelsArray.length).fill(score);
|
361 |
+
|
362 |
chartInstance = new Chart(ctx, {
|
363 |
type: 'bar',
|
364 |
data: {
|
365 |
+
labels: labelsArray,
|
366 |
datasets: [{
|
367 |
label: 'Scores',
|
368 |
+
data: scoresArray,
|
369 |
backgroundColor: '#4e79e6',
|
370 |
borderColor: '#6a8de9',
|
371 |
borderWidth: 1
|
|
|
378 |
});
|
379 |
}
|
380 |
</script>
|
381 |
+
</body>
|
382 |
+
</html>
|