Spaces:
Runtime error
Runtime error
create the search file
Browse files
search.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import arxiv
|
2 |
+
|
3 |
+
|
4 |
+
def search(query="", max_results=10, sort_by="Relevance", sort_order="Descending"):
|
5 |
+
|
6 |
+
sr_by_dict = {"Relevance": arxiv.SortCriterion.Relevance, "Last Updated Date":
|
7 |
+
arxiv.SortCriterion.LastUpdatedDate, "Submitted Date": arxiv.SortCriterion.SubmittedDate}
|
8 |
+
sr_or_dict = {"Descending": arxiv.SortOrder.Descending,
|
9 |
+
"Ascending": arxiv.SortOrder.Ascending}
|
10 |
+
|
11 |
+
search = arxiv.Search(
|
12 |
+
query=query,
|
13 |
+
max_results=max_results,
|
14 |
+
sort_by=sr_by_dict[sort_by],
|
15 |
+
sort_order=sr_or_dict[sort_order])
|
16 |
+
src_lst = []
|
17 |
+
for i in search.results():
|
18 |
+
id = i.entry_id.split("/")
|
19 |
+
src_lst.append(i.title+" - " + str(id[-1]))
|
20 |
+
|
21 |
+
return src_lst
|