Spaces:
Sleeping
Sleeping
Create TLDR.py
Browse files
TLDR.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import panel as pn
|
| 2 |
+
import pytz
|
| 3 |
+
from datetime import date
|
| 4 |
+
from datetime import datetime
|
| 5 |
+
from dateutil.relativedelta import relativedelta, MO
|
| 6 |
+
import param
|
| 7 |
+
import json
|
| 8 |
+
|
| 9 |
+
from functools import partial
|
| 10 |
+
from src.search import Search_Papers
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def load_categories():
|
| 17 |
+
# f = open("categories_general.txt", "r")
|
| 18 |
+
# list_categories = f.read().splitlines()
|
| 19 |
+
|
| 20 |
+
# reading the data from the file
|
| 21 |
+
with open('categories_arxiv.txt') as f:
|
| 22 |
+
data = f.read()
|
| 23 |
+
# reconstructing the data as a dictionary
|
| 24 |
+
category_dict = json.loads(data)
|
| 25 |
+
list_categories_tags = list(category_dict.keys())
|
| 26 |
+
list_categories_names = list(category_dict.values())
|
| 27 |
+
|
| 28 |
+
return [list_categories_tags, list_categories_names]
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def run_code(event):
|
| 32 |
+
categories = buttons_to_add
|
| 33 |
+
timeframe_today = (datetime.combine(date.today(), datetime.min.time())).replace(tzinfo = pytz.utc)
|
| 34 |
+
timeframe_week = timeframe_today + relativedelta(weekday=MO(-1))
|
| 35 |
+
|
| 36 |
+
timeframe_day = (datetime.combine(datetime(2023, 7, 16), datetime.min.time())).replace(tzinfo = pytz.utc)
|
| 37 |
+
|
| 38 |
+
search_mode = "Timeframe" #Accepted values: 'NumberResults' and 'Timeframe
|
| 39 |
+
sort_by = "PublishDate" #Accepted values: 'PublishDate', 'LastUpdatedDate' and 'Relevance'
|
| 40 |
+
sort_order = "Descending" #Accepted values: 'Ascending' and 'Descending'
|
| 41 |
+
|
| 42 |
+
for category in arxiv_tags:
|
| 43 |
+
|
| 44 |
+
print("Inside function:", buttons_to_add, category, flush = True)
|
| 45 |
+
query = category
|
| 46 |
+
search = Search_Papers(query, search_mode, timeframe_week, sort_by, sort_order)
|
| 47 |
+
result_arxiv = search.search_arxiv()
|
| 48 |
+
# result_general = search.search_general()
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
# for test in result_general:
|
| 52 |
+
# try:
|
| 53 |
+
# print(test['title'], flush = True)
|
| 54 |
+
# print(test['subject'], flush = True)
|
| 55 |
+
# print(test, flush = True)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
# except:
|
| 59 |
+
# print(test['abstract'], flush = True)
|
| 60 |
+
|
| 61 |
+
#return result_general
|
| 62 |
+
return result_arxiv
|