Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -60,11 +60,15 @@ async def summarize_news(query, num_results=3):
|
|
60 |
chunk_size = 500 # Adjust chunk size as needed
|
61 |
chunks = [sentences[i:i + chunk_size] for i in range(0, len(sentences), chunk_size)]
|
62 |
|
63 |
-
# Summarize
|
64 |
-
summaries =
|
|
|
|
|
|
|
|
|
65 |
|
66 |
# Combine all summaries
|
67 |
-
final_summary = ' '.join(
|
68 |
|
69 |
logging.debug(f"Final summarized text: {final_summary}")
|
70 |
return final_summary
|
|
|
60 |
chunk_size = 500 # Adjust chunk size as needed
|
61 |
chunks = [sentences[i:i + chunk_size] for i in range(0, len(sentences), chunk_size)]
|
62 |
|
63 |
+
# Summarize each chunk separately
|
64 |
+
summaries = []
|
65 |
+
for chunk in chunks:
|
66 |
+
chunk_text = ' '.join(chunk)
|
67 |
+
summary = summarizer(chunk_text, max_length=120, min_length=30, do_sample=False)
|
68 |
+
summaries.append(summary[0]['summary_text'])
|
69 |
|
70 |
# Combine all summaries
|
71 |
+
final_summary = ' '.join(summaries)
|
72 |
|
73 |
logging.debug(f"Final summarized text: {final_summary}")
|
74 |
return final_summary
|