Spaces:
Running
Running
Johnyquest7
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -42,19 +42,19 @@ def pubmed_search(mesh_terms, email, start_date, end_date):
|
|
42 |
if not mesh_terms or not email:
|
43 |
return "Please provide MeSH terms and email.", None, None
|
44 |
|
45 |
-
# Convert
|
46 |
start_date_str = start_date.strftime("%Y-%m-%d")
|
47 |
end_date_str = end_date.strftime("%Y-%m-%d")
|
48 |
|
49 |
# Join MeSH terms for query
|
50 |
-
query = " AND ".join([f'"{term}"[MeSH Terms]' for term in mesh_terms])
|
51 |
|
52 |
# Fetch PubMed IDs
|
53 |
pubmed_ids = fetch_pubmed(query, email, start_date_str, end_date_str)
|
54 |
if not pubmed_ids:
|
55 |
return "No articles found for the given search terms and date range.", None, None
|
56 |
|
57 |
-
|
58 |
|
59 |
# Gradio interface components
|
60 |
with gr.Blocks() as app:
|
@@ -65,8 +65,8 @@ with gr.Blocks() as app:
|
|
65 |
add_button = gr.Button("Add MeSH Term")
|
66 |
mesh_terms_box = gr.Textbox(label="Added MeSH Terms", interactive=False, lines=2)
|
67 |
|
68 |
-
start_date = gr.
|
69 |
-
end_date = gr.
|
70 |
email_input = gr.Textbox(label="Email", placeholder="Your email (required by PubMed API)", interactive=True)
|
71 |
|
72 |
search_button = gr.Button("Search PubMed")
|
|
|
42 |
if not mesh_terms or not email:
|
43 |
return "Please provide MeSH terms and email.", None, None
|
44 |
|
45 |
+
# Convert date objects to string format
|
46 |
start_date_str = start_date.strftime("%Y-%m-%d")
|
47 |
end_date_str = end_date.strftime("%Y-%m-%d")
|
48 |
|
49 |
# Join MeSH terms for query
|
50 |
+
query = " AND ".join([f'"{term}"[MeSH Terms]' for term in mesh_terms.split(",")])
|
51 |
|
52 |
# Fetch PubMed IDs
|
53 |
pubmed_ids = fetch_pubmed(query, email, start_date_str, end_date_str)
|
54 |
if not pubmed_ids:
|
55 |
return "No articles found for the given search terms and date range.", None, None
|
56 |
|
57 |
+
# (Keep the rest of the function unchanged)
|
58 |
|
59 |
# Gradio interface components
|
60 |
with gr.Blocks() as app:
|
|
|
65 |
add_button = gr.Button("Add MeSH Term")
|
66 |
mesh_terms_box = gr.Textbox(label="Added MeSH Terms", interactive=False, lines=2)
|
67 |
|
68 |
+
start_date = gr.Date(label="Start Date", value="2025-01-01")
|
69 |
+
end_date = gr.Date(label="End Date", value="2025-01-07")
|
70 |
email_input = gr.Textbox(label="Email", placeholder="Your email (required by PubMed API)", interactive=True)
|
71 |
|
72 |
search_button = gr.Button("Search PubMed")
|