Adapting commited on
Commit
9420338
1 Parent(s): 1a4ba8e
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from pprint import pprint
3
+ from widgets import *
4
+
5
+ # [![github](https://img.kookapp.cn/assets/2022-09/1w4G0FIWGK00w00w.png)](https://github.com/Mondkuchen/idp_LiteratureResearch_Tool)
6
+
7
+ # sidebar content
8
+ platforms, number_papers = render_sidebar()
9
+
10
+ # body
11
+ render_body(platforms,number_papers,5)
12
+
13
+
14
+
15
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ numpy==1.23.3
2
+ pandas==1.4.4
3
+ streamlit==1.12.2
4
+ requests-toolkit-stable
widgets/__init__.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ from .body import render_body
2
+ from .sidebar import render_sidebar
widgets/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (245 Bytes). View file
 
widgets/__pycache__/_sidebar.cpython-39.pyc ADDED
Binary file (1.06 kB). View file
 
widgets/__pycache__/body.cpython-39.pyc ADDED
Binary file (2.03 kB). View file
 
widgets/__pycache__/sidebar.cpython-39.pyc ADDED
Binary file (1.36 kB). View file
 
widgets/__pycache__/utils.cpython-39.pyc ADDED
Binary file (252 Bytes). View file
 
widgets/body.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from api_ import ArxivQuery, IEEEQuery, PaperWithCodeQuery
3
+ import random
4
+
5
+ def render_body(platforms, num_papers, num_papers_preview):
6
+ query_input = st.text_input('Enter your keyphrases', placeholder='''e.g. "Machine learning"''')
7
+ tmp = st.empty()
8
+ paperInGeneral = st.empty() # paper的大概
9
+ random_ids = random.sample([i for i in range(num_papers)],num_papers_preview)
10
+
11
+ if query_input != '':
12
+ with st.spinner('Searching...'):
13
+ tmp.markdown(f'You entered query: `{query_input}`')
14
+ paperInGeneral_md = '''# Query Results Preview
15
+ We have found following papers for you! (displaying 5 papers for each literature platforms)
16
+ '''
17
+ if 'IEEE' in platforms:
18
+ paperInGeneral_md += '''## IEEE
19
+ | ID| Paper Title | Publication Year |
20
+ | -------- | -------- | -------- |
21
+ '''
22
+ IEEEQuery.__setup_api_key__('vpd9yy325enruv27zj2d353e')
23
+ ieee = IEEEQuery.query(query_input)
24
+ for i in range(num_papers_preview):
25
+ id = random_ids[i]
26
+ title = str(ieee[id]['title']).replace('\n', ' ')
27
+ publication_year = str(ieee[id]['publication_year']).replace('\n', ' ')
28
+ paperInGeneral_md += f'''|{i + 1}|{title}|{publication_year}|\n'''
29
+ if 'Arxiv' in platforms:
30
+ paperInGeneral_md += '''
31
+ ## Arxiv
32
+ | ID| Paper Title | Publication Year |
33
+ | -------- | -------- | -------- |
34
+ '''
35
+ arxiv = ArxivQuery.query(query_input, max_results=num_papers)
36
+ for i in range(num_papers_preview):
37
+ id = random_ids[i]
38
+ title = str(arxiv[id]['title']).replace('\n', ' ')
39
+ publication_year = str(arxiv[id]['published']).replace('\n', ' ')
40
+ paperInGeneral_md += f'''|{i + 1}|{title}|{publication_year}|\n'''
41
+ if 'PaperWithCode' in platforms:
42
+ paperInGeneral_md += '''
43
+ ## Paper with Code
44
+ | ID| Paper Title | Publication Year |
45
+ | -------- | -------- | -------- |
46
+ '''
47
+ pwc = PaperWithCodeQuery.query(query_input, items_per_page=num_papers)
48
+ for i in range(num_papers_preview):
49
+ id = random_ids[i]
50
+ title = str(pwc[id]['title']).replace('\n', ' ')
51
+ publication_year = str(pwc[id]['published']).replace('\n', ' ')
52
+ paperInGeneral_md += f'''|{i + 1}|{title}|{publication_year}|\n'''
53
+
54
+ paperInGeneral.markdown(paperInGeneral_md)
widgets/sidebar.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from .utils import PACKAGE_ROOT
3
+
4
+ def render_sidebar():
5
+ path = f'{PACKAGE_ROOT}/static/tum.png'
6
+ print(path)
7
+ sidebar_markdown = f'''
8
+
9
+ <center>
10
+ <img src="https://raw.githubusercontent.com/leoxiang66/streamlit-tutorial/IDP/widgets/static/tum.png" alt="TUM" width="150"/>
11
+
12
+ <h1>
13
+ Literature Research Tool
14
+ </h1>
15
+
16
+
17
+ <code>
18
+ v1.0.0
19
+ </code>
20
+
21
+
22
+ </center>
23
+
24
+
25
+ <center>
26
+ <a href="https://github.com/Mondkuchen/idp_LiteratureResearch_Tool"><img src = "https://cdn-icons-png.flaticon.com/512/733/733609.png" width="23"></img></a> <a href="mailto:xiang.tao@outlook.de"><img src="https://cdn-icons-png.flaticon.com/512/646/646094.png" alt="email" width = "27" ></a>
27
+ </center>
28
+
29
+ ---
30
+
31
+ ## Choose the Paper Search Platforms'''
32
+ st.sidebar.markdown(sidebar_markdown,unsafe_allow_html=True)
33
+ # elvsier = st.sidebar.checkbox('Elvsier',value=True)
34
+ # IEEE = st.sidebar.checkbox('IEEE',value=False)
35
+ # google = st.sidebar.checkbox('Google Scholar')
36
+ platforms = st.sidebar.multiselect('Platforms',options=
37
+ [
38
+ # 'Elvsier',
39
+ 'IEEE',
40
+ # 'Google Scholar',
41
+ 'Arxiv',
42
+ 'PaperWithCode'
43
+ ], default=[
44
+ # 'Elvsier',
45
+ 'IEEE',
46
+ # 'Google Scholar',
47
+ 'Arxiv',
48
+ 'PaperWithCode'
49
+ ])
50
+
51
+
52
+
53
+ st.sidebar.markdown('## Choose the number of papers to display')
54
+ number_papers=st.sidebar.slider('number', 0, 500, 25, 10)
55
+
56
+ return platforms, number_papers
widgets/static/tum.png ADDED
widgets/utils.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ from pathlib import Path
2
+ PACKAGE_ROOT = str(Path(__package__).absolute())