Spaces:
Sleeping
Sleeping
File size: 3,293 Bytes
6944052 4a86a4b 6944052 73ff4b5 6944052 73ff4b5 6944052 73ff4b5 6944052 73ff4b5 6944052 9053ece 73ff4b5 9053ece 6944052 73ff4b5 9053ece 73ff4b5 9053ece 73ff4b5 9053ece 73ff4b5 9053ece 73ff4b5 9053ece 73ff4b5 9053ece 73ff4b5 9053ece 73ff4b5 6944052 9053ece |
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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
import gradio as gr
from modules.summarizer import summarize_text
from modules.classifier import classify_text
from modules.event_detector import detect_events
def process_summarization(input_text):
summary = summarize_text(input_text)
return summary
def process_classification(input_text):
classification = classify_text(input_text)
return classification
def process_event_detection(input_text):
events = detect_events(input_text)
events_formatted = ', '.join(events) if isinstance(events, list) else events
return events_formatted
with gr.Blocks() as demo:
gr.Markdown(
"""
# NLP Assistant
A simple app for:
- Summarization
- News Classification
- Event Detection
"""
)
with gr.Tabs():
with gr.Tab("Summarization"):
gr.Markdown(
"""
## Summarization
Enter your text below and get a summarized version.
**Note:**
- This task can take **~800–1000 seconds (~13–16 minutes)** for about **700–800 words**.
- Longer articles will take **even more time**.
- Please be patient!
"""
)
input_text_sum = gr.Textbox(
label="Input Text for Summarization",
placeholder="Paste your article, document, or paragraph here...",
lines=10
)
summarize_btn = gr.Button("Summarize")
summary_output = gr.Textbox(label="Summary", lines=8)
summarize_btn.click(
fn=process_summarization,
inputs=[input_text_sum],
outputs=[summary_output]
)
with gr.Tab("Classification"):
gr.Markdown(
"""
## News/Text Classification
Enter your text below to detect its category.
"""
)
input_text_classify = gr.Textbox(
label="Input Text for Classification",
placeholder="Paste your article or paragraph here...",
lines=10
)
classify_btn = gr.Button("Classify")
classification_output = gr.Textbox(label="Classification Result", lines=2)
classify_btn.click(
fn=process_classification,
inputs=[input_text_classify],
outputs=[classification_output]
)
with gr.Tab("Event Detection"):
gr.Markdown(
"""
## Event Detection
Extract keywords and named entities from your text.
"""
)
input_text_events = gr.Textbox(
label="Input Text for Event Detection",
placeholder="Paste your article, news, or report here...",
lines=10
)
detect_btn = gr.Button("Detect Events")
events_output = gr.Textbox(label="Detected Events", lines=8)
detect_btn.click(
fn=process_event_detection,
inputs=[input_text_events],
outputs=[events_output]
)
if __name__ == "__main__":
demo.launch() |