Spaces:
Running
Running
charlieoneill
commited on
Commit
•
41fb331
1
Parent(s):
4c2dac4
Update app.py
Browse files
app.py
CHANGED
@@ -373,14 +373,45 @@ def create_interface():
|
|
373 |
for doc_id in topk_doc_ids:
|
374 |
metadata = df_metadata[df_metadata['arxiv_id'] == doc_id].iloc[0]
|
375 |
title = metadata['title'].replace('[', '').replace(']', '')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
search_results.append([
|
377 |
-
|
378 |
int(metadata['citation_count']),
|
379 |
int(metadata['year'])
|
380 |
])
|
381 |
|
382 |
return search_results, all_values, all_indices
|
383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
@gr.render(inputs=[input_text, search_results_state, feature_values_state, feature_indices_state, manually_added_features_state, subject])
|
385 |
def show_components(text, search_results, feature_values, feature_indices, manually_added_features, current_subject):
|
386 |
if len(text) == 0:
|
@@ -402,10 +433,17 @@ def create_interface():
|
|
402 |
|
403 |
with gr.Row():
|
404 |
with gr.Column(scale=2):
|
|
|
|
|
|
|
|
|
|
|
405 |
df = gr.Dataframe(
|
406 |
headers=["Title", "Citation Count", "Year"],
|
407 |
value=search_results,
|
408 |
-
label="Top 10 Search Results"
|
|
|
|
|
409 |
)
|
410 |
|
411 |
feature_search = gr.Textbox(label="Search Feature Labels")
|
|
|
373 |
for doc_id in topk_doc_ids:
|
374 |
metadata = df_metadata[df_metadata['arxiv_id'] == doc_id].iloc[0]
|
375 |
title = metadata['title'].replace('[', '').replace(']', '')
|
376 |
+
# Remove single quotes from title
|
377 |
+
title = title.replace("'", "")
|
378 |
+
|
379 |
+
url_id = doc_id.replace('_arXiv.txt', '')
|
380 |
+
if 'astro-ph' in url_id:
|
381 |
+
url_id = url_id.split('astro-ph')[1]
|
382 |
+
url = f"https://arxiv.org/abs/astro-ph/{url_id}"
|
383 |
+
else:
|
384 |
+
# Create the clickable link based on the doc_id
|
385 |
+
if '.' in doc_id:
|
386 |
+
url = f"https://arxiv.org/abs/{doc_id.replace('_arXiv.txt', '')}"
|
387 |
+
else:
|
388 |
+
url = f"https://arxiv.org/abs/hep-ph/{doc_id.replace('_arXiv.txt', '')}"
|
389 |
+
|
390 |
+
linked_title = f"[{title}]({url})"
|
391 |
+
|
392 |
search_results.append([
|
393 |
+
linked_title,
|
394 |
int(metadata['citation_count']),
|
395 |
int(metadata['year'])
|
396 |
])
|
397 |
|
398 |
return search_results, all_values, all_indices
|
399 |
|
400 |
+
|
401 |
+
|
402 |
+
# # Prepare search results
|
403 |
+
# search_results = []
|
404 |
+
# for doc_id in topk_doc_ids:
|
405 |
+
# metadata = df_metadata[df_metadata['arxiv_id'] == doc_id].iloc[0]
|
406 |
+
# title = metadata['title'].replace('[', '').replace(']', '')
|
407 |
+
# search_results.append([
|
408 |
+
# title,
|
409 |
+
# int(metadata['citation_count']),
|
410 |
+
# int(metadata['year'])
|
411 |
+
# ])
|
412 |
+
|
413 |
+
# return search_results, all_values, all_indices
|
414 |
+
|
415 |
@gr.render(inputs=[input_text, search_results_state, feature_values_state, feature_indices_state, manually_added_features_state, subject])
|
416 |
def show_components(text, search_results, feature_values, feature_indices, manually_added_features, current_subject):
|
417 |
if len(text) == 0:
|
|
|
433 |
|
434 |
with gr.Row():
|
435 |
with gr.Column(scale=2):
|
436 |
+
# df = gr.Dataframe(
|
437 |
+
# headers=["Title", "Citation Count", "Year"],
|
438 |
+
# value=search_results,
|
439 |
+
# label="Top 10 Search Results"
|
440 |
+
# )
|
441 |
df = gr.Dataframe(
|
442 |
headers=["Title", "Citation Count", "Year"],
|
443 |
value=search_results,
|
444 |
+
label="Top 10 Search Results",
|
445 |
+
datatype=["markdown", "number", "number"], # Add this line
|
446 |
+
wrap=True # Add this line to ensure long titles don't get cut off
|
447 |
)
|
448 |
|
449 |
feature_search = gr.Textbox(label="Search Feature Labels")
|