-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreporting.py
More file actions
58 lines (48 loc) · 1.42 KB
/
reporting.py
File metadata and controls
58 lines (48 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas
from datetime import datetime
def generate_pdf_report(
filename,
overall_sentiment,
lda_topics,
extractive_summary,
abstractive_summary
):
c = canvas.Canvas(filename, pagesize=A4)
width, height = A4
y = height - 40
c.setFont("Helvetica-Bold", 16)
c.drawString(40, y, "NarrativeNexus - Analysis Report")
y -= 30
c.setFont("Helvetica", 10)
c.drawString(40, y, f"Generated on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
y -= 40
c.setFont("Helvetica-Bold", 12)
c.drawString(40, y, "Overall Sentiment:")
y -= 20
c.setFont("Helvetica", 11)
c.drawString(60, y, overall_sentiment)
y -= 40
c.setFont("Helvetica-Bold", 12)
c.drawString(40, y, "Topic Modeling Results:")
y -= 20
c.setFont("Helvetica", 10)
for topic in lda_topics:
c.drawString(60, y, f"{topic['topic']}: {topic['words']}")
y -= 15
if y < 80:
c.showPage()
y = height - 40
y -= 20
c.setFont("Helvetica-Bold", 12)
c.drawString(40, y, "Extractive Summary:")
y -= 20
c.setFont("Helvetica", 10)
c.drawString(60, y, extractive_summary[:500])
y -= 60
c.setFont("Helvetica-Bold", 12)
c.drawString(40, y, "Abstractive Summary:")
y -= 20
c.setFont("Helvetica", 10)
c.drawString(60, y, abstractive_summary[:500])
c.save()