Spaces:
Sleeping
Sleeping
Update utils/summarizer.py
Browse files- utils/summarizer.py +12 -5
utils/summarizer.py
CHANGED
|
@@ -27,16 +27,23 @@ def split_text(text, max_chunk_len=800):
|
|
| 27 |
|
| 28 |
def summarize_text(text):
|
| 29 |
"""
|
| 30 |
-
Generate
|
| 31 |
"""
|
| 32 |
if not text.strip():
|
| 33 |
return "No input provided."
|
| 34 |
|
|
|
|
| 35 |
chunks = split_text(text)
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
for chunk in chunks:
|
| 39 |
result = summarizer(chunk, max_length=130, min_length=30, do_sample=False)
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
def summarize_text(text):
|
| 29 |
"""
|
| 30 |
+
Generate a readable executive summary using bullet points.
|
| 31 |
"""
|
| 32 |
if not text.strip():
|
| 33 |
return "No input provided."
|
| 34 |
|
| 35 |
+
text = text.replace("\n", " ").replace(" ", " ").strip()
|
| 36 |
chunks = split_text(text)
|
| 37 |
+
|
| 38 |
+
bullet_points = []
|
| 39 |
|
| 40 |
for chunk in chunks:
|
| 41 |
result = summarizer(chunk, max_length=130, min_length=30, do_sample=False)
|
| 42 |
+
summary = result[0]["summary_text"].strip()
|
| 43 |
+
summary_lines = summary.split('. ')
|
| 44 |
+
for line in summary_lines:
|
| 45 |
+
clean = line.strip().rstrip('.')
|
| 46 |
+
if clean:
|
| 47 |
+
bullet_points.append(f"• {clean}.")
|
| 48 |
+
|
| 49 |
+
return "📄 Executive Summary:\n" + "\n".join(bullet_points)
|