Sumayyea commited on
Commit
026eac1
·
verified ·
1 Parent(s): b61cfc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -4
app.py CHANGED
@@ -7,7 +7,7 @@ import re
7
  from collections import Counter
8
 
9
  def clean_text(text):
10
- text = text.replace('"', '\\"') # Escape double quotes
11
  text = text.replace('\n', ' ') # Replace newlines with space
12
  text = unicodedata.normalize("NFKD", text) # Normalize Unicode characters
13
  text = re.sub(r'\s+', ' ', text).strip() # Remove extra whitespace
@@ -19,7 +19,7 @@ def fetch_arxiv_data(search_term, max_results=50):
19
  response.raise_for_status()
20
  root = ET.fromstring(response.content)
21
 
22
- columns = ["ID", "Title", "Authors", "Summary", "Published Date", "Categories", "DOI", "Journal Reference", "Primary Category", "Link"]
23
  df = pd.DataFrame(columns=columns)
24
 
25
  for entry in root.findall("{http://www.w3.org/2005/Atom}entry"):
@@ -47,6 +47,19 @@ def fetch_arxiv_data(search_term, max_results=50):
47
 
48
  link = entry.find("{http://www.w3.org/2005/Atom}link").attrib.get("href", "N/A")
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  new_row = {
51
  "ID": arxiv_id,
52
  "Title": title,
@@ -57,10 +70,18 @@ def fetch_arxiv_data(search_term, max_results=50):
57
  "DOI": doi,
58
  "Journal Reference": journal_ref_text,
59
  "Primary Category": primary_category,
60
- "Link": link
 
 
 
 
61
  }
62
  df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
63
 
 
 
 
 
64
  return df
65
 
66
  # Streamlit UI
@@ -89,4 +110,4 @@ if st.button("Fetch Papers"):
89
  mime='text/csv',
90
  )
91
  except Exception as e:
92
- st.error(f"An error occurred: {e}")
 
7
  from collections import Counter
8
 
9
  def clean_text(text):
10
+ text = text.replace('"', '\"') # Escape double quotes
11
  text = text.replace('\n', ' ') # Replace newlines with space
12
  text = unicodedata.normalize("NFKD", text) # Normalize Unicode characters
13
  text = re.sub(r'\s+', ' ', text).strip() # Remove extra whitespace
 
19
  response.raise_for_status()
20
  root = ET.fromstring(response.content)
21
 
22
+ columns = ["ID", "Title", "Authors", "Summary", "Published Date", "Categories", "DOI", "Journal Reference", "Primary Category", "Link", "Comments", "Subjects", "Version", "PDF Link"]
23
  df = pd.DataFrame(columns=columns)
24
 
25
  for entry in root.findall("{http://www.w3.org/2005/Atom}entry"):
 
47
 
48
  link = entry.find("{http://www.w3.org/2005/Atom}link").attrib.get("href", "N/A")
49
 
50
+ # Extract comments if available
51
+ comments = entry.find("{http://arxiv.org/schemas/atom}comment")
52
+ comments_text = clean_text(comments.text) if comments is not None else "N/A"
53
+
54
+ # Extract subjects if available
55
+ subjects = categories_list
56
+
57
+ # Extract submission history to get the current version
58
+ version = "v1" # Default version
59
+ for link in entry.findall("{http://www.w3.org/2005/Atom}link"):
60
+ if link.attrib.get("title") == "pdf":
61
+ pdf_link = link.attrib.get("href")
62
+
63
  new_row = {
64
  "ID": arxiv_id,
65
  "Title": title,
 
70
  "DOI": doi,
71
  "Journal Reference": journal_ref_text,
72
  "Primary Category": primary_category,
73
+ "Link": link,
74
+ "Comments": comments_text,
75
+ "Subjects": subjects,
76
+ "Version": version,
77
+ "PDF Link": pdf_link
78
  }
79
  df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
80
 
81
+ # Sort the DataFrame by Published Date with latest on top
82
+ df["Published Date"] = pd.to_datetime(df["Published Date"])
83
+ df = df.sort_values(by="Published Date", ascending=False).reset_index(drop=True)
84
+
85
  return df
86
 
87
  # Streamlit UI
 
110
  mime='text/csv',
111
  )
112
  except Exception as e:
113
+ st.error(f"An error occurred: {e}")