Spaces:
Sleeping
Sleeping
Update frontend/src/pages/Home.jsx
Browse files- frontend/src/pages/Home.jsx +92 -21
frontend/src/pages/Home.jsx
CHANGED
|
@@ -177,7 +177,7 @@ export default function Home() {
|
|
| 177 |
/>
|
| 178 |
|
| 179 |
</div>
|
| 180 |
-
|
| 181 |
<AnimatePresence>
|
| 182 |
{correctionResult && (
|
| 183 |
<motion.div
|
|
@@ -197,21 +197,25 @@ export default function Home() {
|
|
| 197 |
|
| 198 |
{/* Data Calculation (Handled inline for the UI) */}
|
| 199 |
{(() => {
|
| 200 |
-
const
|
|
|
|
|
|
|
|
|
|
| 201 |
const words = correctionResult.original ? correctionResult.original.trim().split(/\s+/).length : 1;
|
|
|
|
| 202 |
|
| 203 |
-
//
|
| 204 |
-
const qualityScore = Math.round((words
|
| 205 |
-
|
| 206 |
return (
|
| 207 |
-
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(
|
| 208 |
|
| 209 |
{/* Panel 1: User Text Quality Score */}
|
| 210 |
-
<div style={{ padding: '24px', background: 'var(--surface-alt)', borderRadius: '12px', border: '1px solid var(--border)' }}>
|
| 211 |
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
|
| 212 |
<div>
|
| 213 |
-
<span style={{ fontSize: '14px', fontWeight: 600, color: 'var(--text-2)' }}>
|
| 214 |
-
<p style={{ fontSize: '12px', color: 'var(--muted)', marginTop: '4px' }}>
|
| 215 |
</div>
|
| 216 |
<div style={{ display: 'flex', alignItems: 'baseline', gap: '2px' }}>
|
| 217 |
<span style={{ fontSize: '42px', fontWeight: 700, color: qualityScore > 80 ? 'var(--green)' : qualityScore > 50 ? 'var(--amber)' : 'var(--red)' }}>
|
|
@@ -224,32 +228,99 @@ const burdenScore = Math.round((words -errors) / words)*100;
|
|
| 224 |
{/* Formula Display */}
|
| 225 |
<div style={{ marginTop: '20px', padding: '12px', background: 'var(--bg)', borderRadius: '8px', border: '1px dashed var(--border2)', fontFamily: "'JetBrains Mono', monospace", fontSize: '12px', color: 'var(--muted)' }}>
|
| 226 |
<div style={{ marginBottom: '6px', color: 'var(--text-2)', fontWeight: 500 }}>Applied Formula:</div>
|
| 227 |
-
<div>Score = (
|
| 228 |
-
<div style={{ marginTop: '6px', color: 'var(--accent)' }}>Calculation: ({words}
|
| 229 |
</div>
|
| 230 |
</div>
|
| 231 |
|
| 232 |
-
{/* Panel 2:
|
| 233 |
-
{
|
| 234 |
-
<div style={{ padding: '24px', background: 'var(--surface-alt)', borderRadius: '12px', border: '1px solid var(--border)' }}>
|
| 235 |
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
|
| 236 |
<div>
|
| 237 |
-
<span style={{ fontSize: '14px', fontWeight: 600, color: 'var(--text-2)' }}>
|
| 238 |
-
<p style={{ fontSize: '12px', color: 'var(--muted)', marginTop: '4px' }}>
|
| 239 |
</div>
|
| 240 |
<div style={{ display: 'flex', alignItems: 'baseline', gap: '2px' }}>
|
| 241 |
<span style={{ fontSize: '42px', fontWeight: 700, color: 'var(--accent)' }}>
|
| 242 |
-
{
|
| 243 |
</span>
|
| 244 |
-
<span style={{ fontSize: '14px', fontWeight: 600, color: 'var(--muted)', marginLeft: '4px' }}>errors</span>
|
| 245 |
</div>
|
| 246 |
</div>
|
| 247 |
|
| 248 |
{/* Formula Display */}
|
| 249 |
<div style={{ marginTop: '20px', padding: '12px', background: 'var(--bg)', borderRadius: '8px', border: '1px dashed var(--border2)', fontFamily: "'JetBrains Mono', monospace", fontSize: '12px', color: 'var(--muted)' }}>
|
| 250 |
-
<div style={{ marginBottom: '6px', color: 'var(--text-2)', fontWeight: 500 }}>
|
| 251 |
-
<div>
|
| 252 |
-
<div style={{ marginTop: '6px', color: 'var(--accent)' }}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
</div>
|
| 254 |
</div>
|
| 255 |
|
|
|
|
| 177 |
/>
|
| 178 |
|
| 179 |
</div>
|
| 180 |
+
{/* ββββββββββ ACADEMIC EVALUATION METRICS DASHBOARD ββββββββββ */}
|
| 181 |
<AnimatePresence>
|
| 182 |
{correctionResult && (
|
| 183 |
<motion.div
|
|
|
|
| 197 |
|
| 198 |
{/* Data Calculation (Handled inline for the UI) */}
|
| 199 |
{(() => {
|
| 200 |
+
const spell = correctionResult.spell_fixed || 0;
|
| 201 |
+
const grammar = correctionResult.grammar_fixed || 0;
|
| 202 |
+
const homophone = correctionResult.homophone_fixed || 0;
|
| 203 |
+
const totalErrors = spell + grammar + homophone;
|
| 204 |
const words = correctionResult.original ? correctionResult.original.trim().split(/\s+/).length : 1;
|
| 205 |
+
const confidence = correctionResult.confidence ?? 1;
|
| 206 |
|
| 207 |
+
// Accurate quality score based on percentage of correct words
|
| 208 |
+
const qualityScore = Math.max(0, Math.round(((words - totalErrors) / words) * 100));
|
| 209 |
+
|
| 210 |
return (
|
| 211 |
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(280px, 1fr))', gap: '24px' }}>
|
| 212 |
|
| 213 |
{/* Panel 1: User Text Quality Score */}
|
| 214 |
+
<div style={{ padding: '24px', background: 'var(--surface-alt)', borderRadius: '12px', border: '1px solid var(--border)', display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
|
| 215 |
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
|
| 216 |
<div>
|
| 217 |
+
<span style={{ fontSize: '14px', fontWeight: 600, color: 'var(--text-2)' }}>Text Quality Score</span>
|
| 218 |
+
<p style={{ fontSize: '12px', color: 'var(--muted)', marginTop: '4px' }}>Accuracy based on initial input.</p>
|
| 219 |
</div>
|
| 220 |
<div style={{ display: 'flex', alignItems: 'baseline', gap: '2px' }}>
|
| 221 |
<span style={{ fontSize: '42px', fontWeight: 700, color: qualityScore > 80 ? 'var(--green)' : qualityScore > 50 ? 'var(--amber)' : 'var(--red)' }}>
|
|
|
|
| 228 |
{/* Formula Display */}
|
| 229 |
<div style={{ marginTop: '20px', padding: '12px', background: 'var(--bg)', borderRadius: '8px', border: '1px dashed var(--border2)', fontFamily: "'JetBrains Mono', monospace", fontSize: '12px', color: 'var(--muted)' }}>
|
| 230 |
<div style={{ marginBottom: '6px', color: 'var(--text-2)', fontWeight: 500 }}>Applied Formula:</div>
|
| 231 |
+
<div>Score = ((Words - Errors) / Words) Γ 100</div>
|
| 232 |
+
<div style={{ marginTop: '6px', color: 'var(--accent)' }}>Calculation: (({words} - {totalErrors}) / {words}) Γ 100</div>
|
| 233 |
</div>
|
| 234 |
</div>
|
| 235 |
|
| 236 |
+
{/* Panel 2: Overall Confidence */}
|
| 237 |
+
<div style={{ padding: '24px', background: 'var(--surface-alt)', borderRadius: '12px', border: '1px solid var(--border)', display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
|
|
|
|
| 238 |
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
|
| 239 |
<div>
|
| 240 |
+
<span style={{ fontSize: '14px', fontWeight: 600, color: 'var(--text-2)' }}>Overall Confidence</span>
|
| 241 |
+
<p style={{ fontSize: '12px', color: 'var(--muted)', marginTop: '4px' }}>Model certainty in applied corrections.</p>
|
| 242 |
</div>
|
| 243 |
<div style={{ display: 'flex', alignItems: 'baseline', gap: '2px' }}>
|
| 244 |
<span style={{ fontSize: '42px', fontWeight: 700, color: 'var(--accent)' }}>
|
| 245 |
+
{Math.round(confidence * 100)}%
|
| 246 |
</span>
|
|
|
|
| 247 |
</div>
|
| 248 |
</div>
|
| 249 |
|
| 250 |
{/* Formula Display */}
|
| 251 |
<div style={{ marginTop: '20px', padding: '12px', background: 'var(--bg)', borderRadius: '8px', border: '1px dashed var(--border2)', fontFamily: "'JetBrains Mono', monospace", fontSize: '12px', color: 'var(--muted)' }}>
|
| 252 |
+
<div style={{ marginBottom: '6px', color: 'var(--text-2)', fontWeight: 500 }}>Metric:</div>
|
| 253 |
+
<div>System generated confidence</div>
|
| 254 |
+
<div style={{ marginTop: '6px', color: 'var(--accent)' }}>Raw Value: {confidence}</div>
|
| 255 |
+
</div>
|
| 256 |
+
</div>
|
| 257 |
+
|
| 258 |
+
{/* Panel 3: Total Corrections */}
|
| 259 |
+
<div style={{ padding: '24px', background: 'var(--surface-alt)', borderRadius: '12px', border: '1px solid var(--border)', display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
|
| 260 |
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
|
| 261 |
+
<div>
|
| 262 |
+
<span style={{ fontSize: '14px', fontWeight: 600, color: 'var(--text-2)' }}>Total Corrections</span>
|
| 263 |
+
<p style={{ fontSize: '12px', color: 'var(--muted)', marginTop: '4px' }}>Total distinct fixes applied to text.</p>
|
| 264 |
+
</div>
|
| 265 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: '2px' }}>
|
| 266 |
+
<span style={{ fontSize: '42px', fontWeight: 700, color: 'var(--accent)' }}>
|
| 267 |
+
{totalErrors}
|
| 268 |
+
</span>
|
| 269 |
+
</div>
|
| 270 |
+
</div>
|
| 271 |
+
|
| 272 |
+
{/* Breakdown Display */}
|
| 273 |
+
<div style={{ marginTop: '20px', padding: '12px', background: 'var(--bg)', borderRadius: '8px', border: '1px dashed var(--border2)', fontFamily: "'JetBrains Mono', monospace", fontSize: '12px', color: 'var(--muted)' }}>
|
| 274 |
+
<div style={{ marginBottom: '6px', color: 'var(--text-2)', fontWeight: 500 }}>Error Breakdown:</div>
|
| 275 |
+
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
| 276 |
+
<span>Spelling: {spell}</span>
|
| 277 |
+
<span>Grammar: {grammar}</span>
|
| 278 |
+
</div>
|
| 279 |
+
<div style={{ marginTop: '6px' }}>
|
| 280 |
+
<span>Homophones: {homophone}</span>
|
| 281 |
+
</div>
|
| 282 |
+
</div>
|
| 283 |
+
</div>
|
| 284 |
+
|
| 285 |
+
{/* Panel 4: Grammar Fixes */}
|
| 286 |
+
<div style={{ padding: '24px', background: 'var(--surface-alt)', borderRadius: '12px', border: '1px solid var(--border)', display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
|
| 287 |
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
|
| 288 |
+
<div>
|
| 289 |
+
<span style={{ fontSize: '14px', fontWeight: 600, color: 'var(--text-2)' }}>Grammar Fixes</span>
|
| 290 |
+
<p style={{ fontSize: '12px', color: 'var(--muted)', marginTop: '4px' }}>Syntax and structural adjustments.</p>
|
| 291 |
+
</div>
|
| 292 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: '2px' }}>
|
| 293 |
+
<span style={{ fontSize: '42px', fontWeight: 700, color: 'var(--accent)' }}>
|
| 294 |
+
{grammar}
|
| 295 |
+
</span>
|
| 296 |
+
</div>
|
| 297 |
+
</div>
|
| 298 |
+
|
| 299 |
+
{/* Engine Display */}
|
| 300 |
+
<div style={{ marginTop: '20px', padding: '12px', background: 'var(--bg)', borderRadius: '8px', border: '1px dashed var(--border2)', fontFamily: "'JetBrains Mono', monospace", fontSize: '12px', color: 'var(--muted)' }}>
|
| 301 |
+
<div style={{ marginBottom: '6px', color: 'var(--text-2)', fontWeight: 500 }}>Processing Engine:</div>
|
| 302 |
+
<div style={{ color: 'var(--accent)' }}>T5 Transformer Model</div>
|
| 303 |
+
</div>
|
| 304 |
+
</div>
|
| 305 |
+
|
| 306 |
+
{/* Panel 5: Spelling Fixes */}
|
| 307 |
+
<div style={{ padding: '24px', background: 'var(--surface-alt)', borderRadius: '12px', border: '1px solid var(--border)', display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
|
| 308 |
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
|
| 309 |
+
<div>
|
| 310 |
+
<span style={{ fontSize: '14px', fontWeight: 600, color: 'var(--text-2)' }}>Spelling Fixes</span>
|
| 311 |
+
<p style={{ fontSize: '12px', color: 'var(--muted)', marginTop: '4px' }}>Typographical and orthographic corrections.</p>
|
| 312 |
+
</div>
|
| 313 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: '2px' }}>
|
| 314 |
+
<span style={{ fontSize: '42px', fontWeight: 700, color: 'var(--accent)' }}>
|
| 315 |
+
{spell}
|
| 316 |
+
</span>
|
| 317 |
+
</div>
|
| 318 |
+
</div>
|
| 319 |
+
|
| 320 |
+
{/* Engine Display */}
|
| 321 |
+
<div style={{ marginTop: '20px', padding: '12px', background: 'var(--bg)', borderRadius: '8px', border: '1px dashed var(--border2)', fontFamily: "'JetBrains Mono', monospace", fontSize: '12px', color: 'var(--muted)' }}>
|
| 322 |
+
<div style={{ marginBottom: '6px', color: 'var(--text-2)', fontWeight: 500 }}>Processing Engine:</div>
|
| 323 |
+
<div style={{ color: 'var(--accent)' }}>SymSpell Dictionary</div>
|
| 324 |
</div>
|
| 325 |
</div>
|
| 326 |
|