Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,9 +15,10 @@ import textwrap
|
|
| 15 |
from reportlab.lib.pagesizes import letter
|
| 16 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
| 17 |
from reportlab.lib.styles import getSampleStyleSheet
|
|
|
|
| 18 |
|
| 19 |
-
# Set up logging
|
| 20 |
-
logging.basicConfig(level=logging.INFO)
|
| 21 |
logger = logging.getLogger(__name__)
|
| 22 |
|
| 23 |
# Custom CSS for styling with dark mode compatibility
|
|
@@ -397,6 +398,9 @@ def generate_sentiment_pdf(sentiment_score: float) -> BytesIO:
|
|
| 397 |
story.append(Spacer(1, 12))
|
| 398 |
interpretation = "Positive" if sentiment_score > 0.6 else "Negative" if sentiment_score < 0.4 else "Neutral"
|
| 399 |
story.append(Paragraph(f"Interpretation: {interpretation}", styles['Normal']))
|
|
|
|
|
|
|
|
|
|
| 400 |
|
| 401 |
doc.build(story)
|
| 402 |
buffer.seek(0)
|
|
@@ -695,7 +699,7 @@ def analyze_pdf(file_obj) -> tuple:
|
|
| 695 |
|
| 696 |
# Generate PDF for download
|
| 697 |
pdf_buffer = generate_sentiment_pdf(sentiment_score)
|
| 698 |
-
pdf_file = (f"Sentiment_Analysis_{record_id}.pdf", pdf_buffer.
|
| 699 |
|
| 700 |
risk_summary_output = f"""
|
| 701 |
<div class='result-box'>
|
|
|
|
| 15 |
from reportlab.lib.pagesizes import letter
|
| 16 |
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
| 17 |
from reportlab.lib.styles import getSampleStyleSheet
|
| 18 |
+
from datetime import datetime
|
| 19 |
|
| 20 |
+
# Set up logging with timestamp
|
| 21 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 22 |
logger = logging.getLogger(__name__)
|
| 23 |
|
| 24 |
# Custom CSS for styling with dark mode compatibility
|
|
|
|
| 398 |
story.append(Spacer(1, 12))
|
| 399 |
interpretation = "Positive" if sentiment_score > 0.6 else "Negative" if sentiment_score < 0.4 else "Neutral"
|
| 400 |
story.append(Paragraph(f"Interpretation: {interpretation}", styles['Normal']))
|
| 401 |
+
current_time = datetime.now().strftime("%I:%M %p IST, %B %d, %Y")
|
| 402 |
+
story.append(Spacer(1, 12))
|
| 403 |
+
story.append(Paragraph(f"Generated on: {current_time}", styles['Normal']))
|
| 404 |
|
| 405 |
doc.build(story)
|
| 406 |
buffer.seek(0)
|
|
|
|
| 699 |
|
| 700 |
# Generate PDF for download
|
| 701 |
pdf_buffer = generate_sentiment_pdf(sentiment_score)
|
| 702 |
+
pdf_file = (f"Sentiment_Analysis_{record_id}.pdf", pdf_buffer.getvalue(), "application/pdf")
|
| 703 |
|
| 704 |
risk_summary_output = f"""
|
| 705 |
<div class='result-box'>
|