Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,12 +67,9 @@ def fetch_and_display_content(url):
|
|
67 |
metadata, cleaned_text = extract_and_clean_text(text)
|
68 |
detected_lang = detect_language(cleaned_text)
|
69 |
|
70 |
-
# Generate Summary Automatically
|
71 |
-
summary_text = hierarchical_summarization(cleaned_text)
|
72 |
-
|
73 |
# Add detected language to metadata
|
74 |
metadata["Detected Language"] = detected_lang.upper()
|
75 |
-
return cleaned_text, metadata, detected_lang,
|
76 |
|
77 |
### 2️⃣ Cleaning Function
|
78 |
def extract_and_clean_text(data):
|
@@ -313,7 +310,7 @@ with gr.Blocks() as demo:
|
|
313 |
with gr.Row():
|
314 |
extracted_text = gr.Textbox(label="Extracted Content", visible=False, interactive=False, lines=15)
|
315 |
metadata_output = gr.JSON(label="Article Metadata", visible=False) # Displays metadata
|
316 |
-
wordcloud_output = gr.Image(label="Word Cloud", visible=
|
317 |
|
318 |
|
319 |
detected_lang = gr.Textbox(label="Detected Language", visible=False)
|
@@ -322,7 +319,7 @@ with gr.Blocks() as demo:
|
|
322 |
ner_output = gr.Textbox(label="Extracted Entities", visible=True, interactive=False)
|
323 |
|
324 |
|
325 |
-
|
326 |
default_entity_types = gr.Textbox(label="Default Entity Types", value="PERSON, Organization, location, Date, PRODUCT, EVENT", interactive=True)
|
327 |
custom_entity_types = gr.Textbox(label="Custom Entity Types", placeholder="Enter additional entity types (comma-separated)", interactive=True)
|
328 |
|
@@ -331,7 +328,7 @@ with gr.Blocks() as demo:
|
|
331 |
fetch_and_display_content,
|
332 |
inputs=[url_input],
|
333 |
|
334 |
-
outputs=[extracted_text, metadata_output, detected_lang,
|
335 |
)
|
336 |
|
337 |
# Automatically generate word cloud when extracted_text changes
|
@@ -341,6 +338,13 @@ with gr.Blocks() as demo:
|
|
341 |
outputs=[wordcloud_output],
|
342 |
show_progress=True
|
343 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
|
345 |
#process_summary_button.click(hierarchical_summarization, inputs=[extracted_text], outputs=[summary_output])
|
346 |
|
|
|
67 |
metadata, cleaned_text = extract_and_clean_text(text)
|
68 |
detected_lang = detect_language(cleaned_text)
|
69 |
|
|
|
|
|
|
|
70 |
# Add detected language to metadata
|
71 |
metadata["Detected Language"] = detected_lang.upper()
|
72 |
+
return cleaned_text, metadata, detected_lang, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
73 |
|
74 |
### 2️⃣ Cleaning Function
|
75 |
def extract_and_clean_text(data):
|
|
|
310 |
with gr.Row():
|
311 |
extracted_text = gr.Textbox(label="Extracted Content", visible=False, interactive=False, lines=15)
|
312 |
metadata_output = gr.JSON(label="Article Metadata", visible=False) # Displays metadata
|
313 |
+
wordcloud_output = gr.Image(label="Word Cloud", visible=False)
|
314 |
|
315 |
|
316 |
detected_lang = gr.Textbox(label="Detected Language", visible=False)
|
|
|
319 |
ner_output = gr.Textbox(label="Extracted Entities", visible=True, interactive=False)
|
320 |
|
321 |
|
322 |
+
|
323 |
default_entity_types = gr.Textbox(label="Default Entity Types", value="PERSON, Organization, location, Date, PRODUCT, EVENT", interactive=True)
|
324 |
custom_entity_types = gr.Textbox(label="Custom Entity Types", placeholder="Enter additional entity types (comma-separated)", interactive=True)
|
325 |
|
|
|
328 |
fetch_and_display_content,
|
329 |
inputs=[url_input],
|
330 |
|
331 |
+
outputs=[extracted_text, metadata_output, detected_lang, wordcloud_output, process_audio_button,process_ner_button, extracted_text, metadata_output]
|
332 |
)
|
333 |
|
334 |
# Automatically generate word cloud when extracted_text changes
|
|
|
338 |
outputs=[wordcloud_output],
|
339 |
show_progress=True
|
340 |
)
|
341 |
+
|
342 |
+
extracted_text.change(
|
343 |
+
hierarchical_summarization,
|
344 |
+
inputs=[extracted_text],
|
345 |
+
outputs=[summary_output],
|
346 |
+
show_progress=True
|
347 |
+
)
|
348 |
|
349 |
#process_summary_button.click(hierarchical_summarization, inputs=[extracted_text], outputs=[summary_output])
|
350 |
|