import { useState } from 'react'; import { evalParsing } from '../api/client'; export default function ParsingEval({ file, accessToken, onClose }) { const [loading, setLoading] = useState(false); const [result, setResult] = useState(null); const [error, setError] = useState(null); const runEval = async () => { setLoading(true); setError(null); setResult(null); try { const data = await evalParsing(file.path_lower, accessToken); if (data.error) { setError(data.error); } else { setResult(data); } } catch (err) { setError(err.message); } setLoading(false); }; // Format number with commas const formatNumber = (num) => { return num?.toLocaleString() || '0'; }; return (
{/* Header */}

Docling Parsing Evaluation

{file.name}

{/* Content */}
{!result && !loading && !error && (

Test Docling's document parsing

This will download the file and analyze how Docling extracts structure

)} {loading && (

Parsing document with Docling...

This may take a moment for large files

)} {error && (

Parsing failed

{error}

)} {result && (
{/* Status Badge */}
{result.status === 'OK' ? ( Parsing Successful ) : ( {result.status} )} {result.format?.toUpperCase()}
{/* Stats Grid */}

{formatNumber(result.total_elements)}

Elements

{formatNumber(result.total_chars)}

Characters

{formatNumber(result.total_words)}

Words

{result.page_count || '-'}

Pages

{/* Element Types */} {result.element_types && Object.keys(result.element_types).length > 0 && (

Element Types

{Object.entries(result.element_types) .sort((a, b) => b[1] - a[1]) .map(([type, count]) => (
{type.replace('_', ' ')} {count}
))}
)} {/* Sample Elements */} {result.sample_elements && result.sample_elements.length > 0 && (

Sample Elements (first 10)

{result.sample_elements.map((el, idx) => (
{el.type} {el.level && ( Level {el.level} )}

{el.text || '(empty)'}

))}
)}
)}
{/* Footer */} {result && (
)}
); }