Automated Regulatory Document Classification Tool

Automated Regulatory Document Classification Tool

Simulate AI-powered classification of legal and regulatory text.

${analysisResult.primary.name}

Confidence Score: ${analysisResult.primary.score}%

Key Terms Identified in Top Category

${analysisResult.keywords[analysisResult.primary.name]?.map(k => `${k}`).join('') || '

No specific keywords found.

'}

Confidence Score Breakdown

${Object.entries(analysisResult.scores).map(([category, score]) => `
${category}
${score}%
`).join('')}
`; }; const renderInput = () => { const textArea = document.getElementById('document-text-input'); if (!textArea.value) { // Don't overwrite if user is typing textArea.value = analysisResult?.text || sampleText; } }; const renderDetailedAnalysis = () => { const container = document.getElementById('detailed-analysis-content'); if (!analysisResult) { container.innerHTML = `

No document has been analyzed yet. Please run an analysis first.

`; return; } container.innerHTML = `

Keyword Matches by Category

${Object.entries(analysisResult.keywords).map(([category, keywords]) => `

${category}

${keywords.length > 0 ? `

Found ${keywords.length} keyword(s): ${keywords.join(', ')}

` : `

No relevant keywords were identified for this category.

` }
`).join('')}
`; }; const renderAll = () => { renderDashboard(); renderInput(); renderDetailedAnalysis(); }; // --- TAB NAVIGATION --- window.changeTab = (tabIndex) => { currentTab = tabIndex; renderAll(); // Always refresh data on tab change const tabs = document.querySelectorAll('.tab'); const tabContents = document.querySelectorAll('.tab-content'); tabs.forEach((tab, i) => { tab.classList.toggle('tab-active', i === tabIndex); tab.classList.toggle('tab-inactive', i !== tabIndex); }); tabContents.forEach((content, i) => { content.style.display = i === tabIndex ? 'block' : 'none'; }); }; window.navigateTab = (direction) => { const numTabs = document.querySelectorAll('.tab').length; let newTab = currentTab + direction; if (newTab < 0) newTab = 0; if (newTab >= numTabs) newTab = numTabs - 1; changeTab(newTab); }; // --- PDF DOWNLOAD FUNCTIONALITY --- window.downloadPDF = () => { if (!analysisResult) return; const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); // Header doc.setFontSize(18); doc.setFont(undefined, 'bold'); doc.text('Regulatory Document Classification Report', 105, 22, { align: 'center' }); // Summary Table doc.autoTable({ startY: 30, body: [ ['Primary Classification', analysisResult.primary.name], ['Confidence Score', `${analysisResult.primary.score}%`], ], theme: 'plain', styles: { fontSize: 11, cellPadding: 2 }, columnStyles: { 0: { fontStyle: 'bold' } } }); // Breakdown Table doc.setFontSize(14); doc.setFont(undefined, 'bold'); doc.text('Confidence Score Breakdown', 14, doc.autoTable.previous.finalY + 15); const breakdownBody = Object.entries(analysisResult.scores).map(([category, score]) => [category, `${score}%`]); doc.autoTable({ startY: doc.autoTable.previous.finalY + 18, head: [['Category', 'Confidence']], body: breakdownBody, theme: 'striped', headStyles: { fillColor: [29, 78, 216] } // blue-700 }); // Keywords Table doc.setFontSize(14); doc.setFont(undefined, 'bold'); doc.text('Identified Keywords', 14, doc.autoTable.previous.finalY + 15); const keywordsBody = Object.entries(analysisResult.keywords).map(([category, keywords]) => [ category, keywords.join(', ') || 'N/A' ]); doc.autoTable({ startY: doc.autoTable.previous.finalY + 18, head: [['Category', 'Keywords Found']], body: keywordsBody, theme: 'grid', headStyles: { fillColor: [100, 116, 139] } // slate-500 }); doc.save('Classification_Report.pdf'); }; // --- INITIAL RENDER --- renderAll(); changeTab(0); });
Scroll to Top