Spaces:
Running
Running
Update app2.py
Browse files
app2.py
CHANGED
|
@@ -19,108 +19,6 @@ main_body_instance = MainBody()
|
|
| 19 |
paper_list = [] # Add this line to initialize paper_list as an empty list
|
| 20 |
|
| 21 |
|
| 22 |
-
|
| 23 |
-
def load_categories():
|
| 24 |
-
# f = open("categories_general.txt", "r")
|
| 25 |
-
# list_categories = f.read().splitlines()
|
| 26 |
-
|
| 27 |
-
# reading the data from the file
|
| 28 |
-
with open('categories_arxiv.txt') as f:
|
| 29 |
-
data = f.read()
|
| 30 |
-
# reconstructing the data as a dictionary
|
| 31 |
-
category_dict = json.loads(data)
|
| 32 |
-
list_categories_tags = list(category_dict.keys())
|
| 33 |
-
list_categories_names = list(category_dict.values())
|
| 34 |
-
|
| 35 |
-
return [list_categories_tags, list_categories_names]
|
| 36 |
-
|
| 37 |
-
def run_code(event):
|
| 38 |
-
categories = buttons_to_add
|
| 39 |
-
timeframe_today = (datetime.combine(date.today(), datetime.min.time())).replace(tzinfo = pytz.utc)
|
| 40 |
-
timeframe_week = timeframe_today + relativedelta(weekday=MO(-1))
|
| 41 |
-
|
| 42 |
-
timeframe_day = (datetime.combine(datetime(2023, 7, 16), datetime.min.time())).replace(tzinfo = pytz.utc)
|
| 43 |
-
|
| 44 |
-
search_mode = "Timeframe" #Accepted values: 'NumberResults' and 'Timeframe
|
| 45 |
-
sort_by = "PublishDate" #Accepted values: 'PublishDate', 'LastUpdatedDate' and 'Relevance'
|
| 46 |
-
sort_order = "Descending" #Accepted values: 'Ascending' and 'Descending'
|
| 47 |
-
|
| 48 |
-
for category in arxiv_tags:
|
| 49 |
-
|
| 50 |
-
print("Inside function:", buttons_to_add, category, flush = True)
|
| 51 |
-
query = category
|
| 52 |
-
search = Search_Papers(query, search_mode, timeframe_week, sort_by, sort_order)
|
| 53 |
-
result_arxiv = search.search_arxiv()
|
| 54 |
-
# result_general = search.search_general()
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
# for test in result_general:
|
| 58 |
-
# try:
|
| 59 |
-
# print(test['title'], flush = True)
|
| 60 |
-
# print(test['subject'], flush = True)
|
| 61 |
-
# print(test, flush = True)
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
# except:
|
| 65 |
-
# print(test['abstract'], flush = True)
|
| 66 |
-
|
| 67 |
-
#return result_general
|
| 68 |
-
return result_arxiv
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
def update_mainTLDR():
|
| 74 |
-
global paper_list # Declare 'paper_list' as a global variable to store the search results
|
| 75 |
-
|
| 76 |
-
# Create a list to store the contents for the selected categories
|
| 77 |
-
content_list = []
|
| 78 |
-
|
| 79 |
-
# Check if any categories are selected
|
| 80 |
-
if buttons_to_add:
|
| 81 |
-
for category in buttons_to_add:
|
| 82 |
-
print("Used categories:", buttons_to_add, flush=True)
|
| 83 |
-
|
| 84 |
-
# Generate a Markdown object for each selected category
|
| 85 |
-
markdown = pn.pane.Markdown(f"# {category}")
|
| 86 |
-
first_flag = 1
|
| 87 |
-
for paper in paper_list:
|
| 88 |
-
# paper_title = "## " + paper['title'][0]
|
| 89 |
-
# paper_tldr = "### " + paper['abstract'][0]
|
| 90 |
-
# paper_date = "### " + paper['created'][0]
|
| 91 |
-
|
| 92 |
-
paper_title = "## " + paper.title
|
| 93 |
-
paper_tldr = paper.summary
|
| 94 |
-
paper_date = "### " + (paper.published).strftime("%d/%m/%Y %H:%M:%S")
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
if first_flag:
|
| 98 |
-
content = pn.Row(
|
| 99 |
-
markdown,
|
| 100 |
-
pn.Column(paper_title,
|
| 101 |
-
paper_tldr,
|
| 102 |
-
paper_date),
|
| 103 |
-
sizing_mode='stretch_width',
|
| 104 |
-
)
|
| 105 |
-
first_flag = 0
|
| 106 |
-
else:
|
| 107 |
-
content = pn.Row(
|
| 108 |
-
pn.Column(
|
| 109 |
-
paper_title,
|
| 110 |
-
paper_tldr,
|
| 111 |
-
paper_date),
|
| 112 |
-
sizing_mode='stretch_width',
|
| 113 |
-
)
|
| 114 |
-
|
| 115 |
-
content_list.append(content)
|
| 116 |
-
#content_list.append(content)
|
| 117 |
-
else:
|
| 118 |
-
# If no categories are selected, display the default message
|
| 119 |
-
content_list.append(pn.pane.Markdown("# Please select some tags!"))
|
| 120 |
-
|
| 121 |
-
return content_list
|
| 122 |
-
|
| 123 |
-
|
| 124 |
main_body = [pn.Row(pn.pane.Markdown("# Please select some tags!"),
|
| 125 |
# pn.Column(text, text2, sizing_mode='stretch_width'),
|
| 126 |
# pn.Column(text2, text, sizing_mode='stretch_width'),
|
|
|
|
| 19 |
paper_list = [] # Add this line to initialize paper_list as an empty list
|
| 20 |
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
main_body = [pn.Row(pn.pane.Markdown("# Please select some tags!"),
|
| 23 |
# pn.Column(text, text2, sizing_mode='stretch_width'),
|
| 24 |
# pn.Column(text2, text, sizing_mode='stretch_width'),
|