Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,31 +23,28 @@ def scrape_website(url):
|
|
| 23 |
|
| 24 |
def summarize_website(url):
|
| 25 |
"""Handles the full summarization pipeline"""
|
| 26 |
-
try:
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
if "Error" in extracted_text:
|
| 33 |
-
return f"β {extracted_text}"
|
| 34 |
-
|
| 35 |
-
if len(extracted_text.split()) < 50:
|
| 36 |
-
return "β οΈ Error: Insufficient content for summarization (minimum 50 words required)"
|
| 37 |
-
|
| 38 |
-
max_input_length = 1000
|
| 39 |
-
truncated_text = extracted_text[:max_input_length]
|
| 40 |
-
|
| 41 |
-
summary = summarizer(
|
| 42 |
-
truncated_text,
|
| 43 |
-
max_length=200,
|
| 44 |
-
min_length=50,
|
| 45 |
-
do_sample=False,
|
| 46 |
-
truncation=True
|
| 47 |
-
)
|
| 48 |
|
| 49 |
-
|
|
|
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
except Exception as e:
|
| 52 |
return f"β Summarization Error: {str(e)}"
|
| 53 |
|
|
@@ -94,9 +91,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css, title="Website Summarizer") as a
|
|
| 94 |
examples_per_page=2
|
| 95 |
)
|
| 96 |
|
| 97 |
-
# Progress indicator
|
| 98 |
-
progress = gr.Textbox(visible=False)
|
| 99 |
-
|
| 100 |
# Event handlers
|
| 101 |
submit_btn.click(
|
| 102 |
fn=summarize_website,
|
|
|
|
| 23 |
|
| 24 |
def summarize_website(url):
|
| 25 |
"""Handles the full summarization pipeline"""
|
| 26 |
+
try:
|
| 27 |
+
extracted_text = scrape_website(url)
|
| 28 |
+
|
| 29 |
+
if "Error" in extracted_text:
|
| 30 |
+
return f"β {extracted_text}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
if len(extracted_text.split()) < 50:
|
| 33 |
+
return "β οΈ Error: Insufficient content for summarization (minimum 50 words required)"
|
| 34 |
|
| 35 |
+
max_input_length = 1000
|
| 36 |
+
truncated_text = extracted_text[:max_input_length]
|
| 37 |
+
|
| 38 |
+
summary = summarizer(
|
| 39 |
+
truncated_text,
|
| 40 |
+
max_length=200,
|
| 41 |
+
min_length=50,
|
| 42 |
+
do_sample=False,
|
| 43 |
+
truncation=True
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
return f"## π Summary\n\n{summary[0]['summary_text']}"
|
| 47 |
+
|
| 48 |
except Exception as e:
|
| 49 |
return f"β Summarization Error: {str(e)}"
|
| 50 |
|
|
|
|
| 91 |
examples_per_page=2
|
| 92 |
)
|
| 93 |
|
|
|
|
|
|
|
|
|
|
| 94 |
# Event handlers
|
| 95 |
submit_btn.click(
|
| 96 |
fn=summarize_website,
|