Spaces:
Sleeping
Sleeping
File size: 2,488 Bytes
c3af845 ee3631e c3af845 ee3631e 34cd34c c3af845 |
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 |
import gradio as gr
from src.analyzer import EventAnalyzer
from ui.format import ResultFormatter
from ui.styles import css
# Initialize analyzer
analyzer = EventAnalyzer()
async def process_input(text: str) -> str:
"""Process input text and return formatted HTML results."""
result = await analyzer.analyze_event(text)
return ResultFormatter.format_results(result)
# Define example inputs
EXAMPLES = [
["John from Tech Corp. is attending the meeting in Washington, DC tomorrow at 14:30 #tech"],
["Sarah Johnson and Mike Smith from Defense Systems Inc. are conducting training in Norfolk, VA on June 15th #defense #training"],
["Team meeting at headquarters with @commander_smith at 0900 #briefing"],
["Prof. Maria Garcia from MIT will present her research at Stanford University on quantum computing next Thursday at 15:00 PST #science #quantum"],
["Annual cybersecurity conference by InfoSec Systems at Dubai World Trade Centre from May 5-7, featuring keynote speaker Dr. James Wilson #security"],
["Emergency response drill coordinated by FEMA and local authorities in Houston, TX on April 2nd at 0800 hours #emergency #preparedness"]
]
# Create custom theme with better alert colors
theme = gr.themes.Soft(
primary_hue="blue",
secondary_hue="neutral",
)
# Create Gradio interface with custom layout
with gr.Blocks(theme=theme, css=css, title="Event Analysis System") as demo:
gr.Markdown("# Event Analysis System")
gr.Markdown("Analyze text to extract entities, assess confidence, and identify key event information with relationship tracking.")
with gr.Row():
with gr.Column(scale=2):
input_box = gr.Textbox(
label="Event Text",
placeholder="Enter text to analyze (e.g., 'John from Tech Corp. is attending the meeting in Washington, DC tomorrow at 14:30 #tech')",
lines=3
)
gr.Examples(
examples=EXAMPLES,
inputs=[input_box],
label="Example Inputs",
examples_per_page=6
)
submit_btn = gr.Button("Submit", variant="primary")
with gr.Column(scale=3):
output = gr.HTML(label="Analysis Results")
# Event handlers
submit_btn.click(fn=process_input, inputs=input_box, outputs=output)
input_box.submit(fn=process_input, inputs=input_box, outputs=output)
if __name__ == "__main__":
demo.launch() |