Topic Sentiment Analyzer

Topic Sentiment Analyzer

Analyze text to understand underlying sentiment and extract key topics.

Analyze New Text

No Analysis Performed

Go to the 'Input & Analysis' tab to start.

For Topic: ${topic}

Sentiment Summary

Overall Sentiment
${overallSentiment}
Breakdown

Keyword Analysis

${keywordListsHtml}
`; const pdfTemplate = document.getElementById('pdf-template'); pdfTemplate.innerHTML = reportHtml; pdfTemplate.style.position = 'absolute'; pdfTemplate.style.left = '-9999px'; pdfTemplate.classList.remove('invisible'); try { const { jsPDF } = window.jspdf; const canvas = await html2canvas(pdfTemplate.querySelector('.pdf-report-container'), { scale: 3, useCORS: true }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save(`Sentiment_Report_${topic.replace(/\s+/g, '_')}.pdf`); } catch(e) { console.error('PDF Generation Error:', e); alert('Failed to generate PDF. See console for details.'); } finally { button.disabled = false; button.textContent = originalText; pdfTemplate.innerHTML = ''; pdfTemplate.classList.add('invisible'); } } // --- EVENT LISTENERS --- analyzeBtn.addEventListener('click', performAnalysis); document.getElementById('dashboard-results').addEventListener('click', (e) => { if (e.target && e.target.id === 'download-pdf-btn') { generatePdfReport(); } }); // --- INITIALIZATION --- switchTab(0); // Start on input tab renderDashboard(); });
Scroll to Top