AI-Powered Market Sentiment Analysis
Sentiment Analysis Report
Please enter text in the 'Input Text' tab and click 'Analyze Sentiment' to see the report.
Original Text (Snippet):
${text.length > 300 ? text.substring(0, 297) + "..." : text}
Overall Sentiment Score: ${sentimentScoreNormalized.toFixed(2)} (Range: -1.00 Negative to +1.00 Positive)
Sentiment Category: ${sentimentCategory}
Analysis Summary: Found ${positiveCount} positive indicator(s) and ${negativeCount} negative indicator(s) out of ${words.length} words analyzed.
Note: This is a basic keyword-based analysis and may not capture complex nuances. For critical decisions, use advanced AI sentiment analysis services.
`; pdfButton.style.display = 'inline-block'; sentimentSwitchTab(null, 'sentimentResultTab'); } function sentimentGoToPreviousTab() { if (currentSentimentTab === 'sentimentResultTab') { sentimentSwitchTab(null, 'sentimentInputTab'); } // Add more conditions if more tabs are present } function downloadSentimentReportPDF() { const { jsPDF } = window.jspdf; if (!jsPDF) { alert("PDF generation library (jsPDF) is not loaded. Please check your internet connection or contact support."); return; } const resultOutput = document.getElementById('sentimentResultOutput'); const textInput = document.getElementById('sentimentTextInput'); if (!resultOutput || !textInput) { alert("Could not find content to generate PDF. Please analyze text first."); return; } const originalText = textInput.value; const analysisData = { score: resultOutput.querySelector("p:nth-of-type(2) > span") ? resultOutput.querySelector("p:nth-of-type(2) > span").textContent : "N/A", category: resultOutput.querySelector("p:nth-of-type(3) > span") ? resultOutput.querySelector("p:nth-of-type(3) > span").textContent : "N/A", summary: resultOutput.querySelector("p:nth-of-type(4)") ? resultOutput.querySelector("p:nth-of-type(4)").textContent : "N/A" }; const doc = new jsPDF(); doc.setFontSize(18); doc.setTextColor(parseInt(getComputedStyle(document.documentElement).getPropertyValue('--tool-primary-color').substring(1), 16)); // Primary color for title doc.text("Market Sentiment Analysis Report", 105, 20, null, null, "center"); doc.setFontSize(10); doc.setTextColor(100); // Gray const generationDate = new Date().toLocaleString(); doc.text(`Report Generated: ${generationDate}`, 105, 28, null, null, "center"); doc.setFontSize(12); doc.setTextColor(parseInt(getComputedStyle(document.documentElement).getPropertyValue('--tool-text-color').substring(1), 16)); // Default text color let yPos = 40; const pageHeight = doc.internal.pageSize.height; const margin = 15; const usableWidth = doc.internal.pageSize.width - 2 * margin; function addSection(title, content) { if (yPos + 15 > pageHeight - margin) { // Check if new page needed doc.addPage(); yPos = 20; } doc.setFontSize(14); doc.setFont(undefined, 'bold'); doc.text(title, margin, yPos); yPos += 7; doc.setFontSize(11); doc.setFont(undefined, 'normal'); const lines = doc.splitTextToSize(content, usableWidth); lines.forEach(line => { if (yPos + 5 > pageHeight - margin) { doc.addPage(); yPos = 20; } doc.text(line, margin, yPos); yPos += 6; // Line height }); yPos += 5; // Spacing after section } addSection("Original Text:", originalText); doc.setLineWidth(0.2); doc.line(margin, yPos-2, doc.internal.pageSize.width - margin, yPos-2); addSection("Overall Sentiment Score:", analysisData.score); addSection("Sentiment Category:", analysisData.category); addSection("Analysis Summary:", analysisData.summary); doc.setFontSize(9); doc.setTextColor(150); const disclaimer = "Note: This is a basic keyword-based analysis. For critical decisions, consult advanced AI sentiment analysis services. Currency: USD ($) is the default where applicable (not directly used in this sentiment tool)."; const disclaimerLines = doc.splitTextToSize(disclaimer, usableWidth); disclaimerLines.forEach(line => { if (yPos + 5 > pageHeight - margin) { doc.addPage(); yPos = 20; } doc.text(line, margin, yPos); yPos += 5; }); doc.save("Market-Sentiment-Analysis-Report.pdf"); } // Ensure functions are globally accessible for inline event handlers window.sentimentSwitchTab = sentimentSwitchTab; window.analyzeSentimentAndSwitchTab = analyzeSentimentAndSwitchTab; window.sentimentGoToPreviousTab = sentimentGoToPreviousTab; window.downloadSentimentReportPDF = downloadSentimentReportPDF;