Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from model import search_articles, extract_entities, find_full_names
|
3 |
+
|
4 |
+
def process_name(name: str):
|
5 |
+
"""Process name through search and entity extraction pipeline"""
|
6 |
+
if not name.strip():
|
7 |
+
return "", "", ""
|
8 |
+
|
9 |
+
# Search for articles
|
10 |
+
search_results = search_articles(name.strip())
|
11 |
+
|
12 |
+
# Extract entities from search results
|
13 |
+
entities = extract_entities(search_results)
|
14 |
+
|
15 |
+
# Find full names of entities
|
16 |
+
full_names = find_full_names(search_results, entities)
|
17 |
+
|
18 |
+
return search_results, entities, full_names
|
19 |
+
|
20 |
+
# Create Gradio interface
|
21 |
+
with gr.Blocks(title="Name Research Tool") as demo:
|
22 |
+
gr.Markdown("# Name Research Tool")
|
23 |
+
gr.Markdown("Enter a business or project name to search for related articles and extract key entities.")
|
24 |
+
|
25 |
+
with gr.Row():
|
26 |
+
name_input = gr.Textbox(label="Name", placeholder="Enter business or project name")
|
27 |
+
search_btn = gr.Button("Search", variant="primary")
|
28 |
+
|
29 |
+
with gr.Column():
|
30 |
+
output1 = gr.Textbox(label="Search Results", lines=10, max_lines=20)
|
31 |
+
output2 = gr.Textbox(label="Extracted Entities", lines=5, max_lines=10)
|
32 |
+
output3 = gr.Textbox(label="Full Names", lines=5, max_lines=10)
|
33 |
+
|
34 |
+
search_btn.click(
|
35 |
+
fn=process_name,
|
36 |
+
inputs=[name_input],
|
37 |
+
outputs=[output1, output2, output3]
|
38 |
+
)
|
39 |
+
|
40 |
+
# TODO: Add CSV upload functionality here
|
41 |
+
|
42 |
+
if __name__ == "__main__":
|
43 |
+
demo.launch()
|