Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,62 +1,16 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import xml.etree.ElementTree as ET
|
3 |
import re
|
4 |
import urllib
|
5 |
-
import torch
|
6 |
-
|
7 |
-
|
8 |
-
from transformers import pipeline
|
9 |
-
|
10 |
-
classifier = pipeline(model="Yozhikoff/arxiv-topics-distilbert-base-cased")
|
11 |
-
|
12 |
-
|
13 |
-
import re
|
14 |
import urllib.request
|
15 |
import xml.etree.ElementTree as ET
|
16 |
|
17 |
-
def get_arxiv_title_and_abstract(link):
|
18 |
-
try:
|
19 |
-
# Validate the arxiv link
|
20 |
-
pattern = r'^https?://arxiv.org/(abs|pdf)/(\d{4}\.\d{4,5})(\.pdf)?$'
|
21 |
-
match = re.match(pattern, link)
|
22 |
-
if not match:
|
23 |
-
raise ValueError('Invalid arxiv link')
|
24 |
-
|
25 |
-
# Construct the arxiv API URL
|
26 |
-
arxiv_id = match.group(2)
|
27 |
-
api_url = f'http://export.arxiv.org/api/query?id_list={arxiv_id}'
|
28 |
-
|
29 |
-
# Send a request to the arxiv API
|
30 |
-
response = urllib.request.urlopen(api_url)
|
31 |
-
xml_data = response.read()
|
32 |
-
|
33 |
-
# Parse the XML data
|
34 |
-
root = ET.fromstring(xml_data)
|
35 |
-
entry = root.find('{http://www.w3.org/2005/Atom}entry')
|
36 |
-
title = entry.find('{http://www.w3.org/2005/Atom}title').text
|
37 |
-
summary = entry.find('{http://www.w3.org/2005/Atom}summary').text
|
38 |
-
|
39 |
-
return title, summary
|
40 |
-
except:
|
41 |
-
raise gr.Error('Invalid arXiv URL!')
|
42 |
-
|
43 |
-
|
44 |
import gradio as gr
|
45 |
-
import xml.etree.ElementTree as ET
|
46 |
-
import re
|
47 |
-
import urllib
|
48 |
import torch
|
49 |
|
50 |
-
|
51 |
from transformers import pipeline
|
52 |
|
53 |
classifier = pipeline(model="Yozhikoff/arxiv-topics-distilbert-base-cased")
|
54 |
|
55 |
|
56 |
-
import re
|
57 |
-
import urllib.request
|
58 |
-
import xml.etree.ElementTree as ET
|
59 |
-
|
60 |
def get_arxiv_title_and_abstract(link):
|
61 |
try:
|
62 |
# Validate the arxiv link
|
|
|
|
|
|
|
1 |
import re
|
2 |
import urllib
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import urllib.request
|
4 |
import xml.etree.ElementTree as ET
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
import gradio as gr
|
|
|
|
|
|
|
7 |
import torch
|
8 |
|
|
|
9 |
from transformers import pipeline
|
10 |
|
11 |
classifier = pipeline(model="Yozhikoff/arxiv-topics-distilbert-base-cased")
|
12 |
|
13 |
|
|
|
|
|
|
|
|
|
14 |
def get_arxiv_title_and_abstract(link):
|
15 |
try:
|
16 |
# Validate the arxiv link
|