Spaces:
Running
Running
1.2.0
Browse files- app.py +2 -2
- setup.py +2 -1
- widgets/body.py +5 -5
- widgets/sidebar.py +12 -5
app.py
CHANGED
@@ -5,7 +5,7 @@ from widgets import *
|
|
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,start_year,end_year,
|
9 |
|
10 |
# body head
|
11 |
with st.form("my_form",clear_on_submit=False):
|
@@ -25,7 +25,7 @@ with st.form("my_form",clear_on_submit=False):
|
|
25 |
|
26 |
if submitted:
|
27 |
# body
|
28 |
-
render_body(platforms, number_papers, 5, query_input, show_preview,start_year,end_year,
|
29 |
# '''
|
30 |
# bar = (
|
31 |
# Bar()
|
|
|
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, start_year, end_year, hyperparams = render_sidebar()
|
9 |
|
10 |
# body head
|
11 |
with st.form("my_form",clear_on_submit=False):
|
|
|
25 |
|
26 |
if submitted:
|
27 |
# body
|
28 |
+
render_body(platforms, number_papers, 5, query_input, show_preview, start_year, end_year, hyperparams)
|
29 |
# '''
|
30 |
# bar = (
|
31 |
# Bar()
|
setup.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from setuptools import setup, find_packages
|
|
|
2 |
|
3 |
with open("README.md", "r") as readme_file:
|
4 |
readme = readme_file.read()
|
@@ -21,7 +22,7 @@ requirements = [
|
|
21 |
|
22 |
setup(
|
23 |
name="LiteratureResearchTool",
|
24 |
-
version=
|
25 |
author="Tao Xiang",
|
26 |
author_email="tao.xiang@tum.de",
|
27 |
description="A tool for literature research and analysis",
|
|
|
1 |
from setuptools import setup, find_packages
|
2 |
+
from widgets.sidebar import APP_VERSION
|
3 |
|
4 |
with open("README.md", "r") as readme_file:
|
5 |
readme = readme_file.read()
|
|
|
22 |
|
23 |
setup(
|
24 |
name="LiteratureResearchTool",
|
25 |
+
version=f'{APP_VERSION[1:]}',
|
26 |
author="Tao Xiang",
|
27 |
author_email="tao.xiang@tum.de",
|
28 |
description="A tool for literature research and analysis",
|
widgets/body.py
CHANGED
@@ -55,7 +55,7 @@ We have found following papers for you! (displaying 5 papers for each literature
|
|
55 |
|
56 |
paperInGeneral.markdown(paperInGeneral_md)
|
57 |
|
58 |
-
def render_body(platforms, num_papers, num_papers_preview, query_input, show_preview:bool,start_year,end_year,
|
59 |
|
60 |
tmp = st.empty()
|
61 |
if query_input != '':
|
@@ -68,18 +68,18 @@ def render_body(platforms, num_papers, num_papers_preview, query_input, show_pre
|
|
68 |
|
69 |
# lrt results
|
70 |
## baseline
|
71 |
-
if
|
72 |
model = baseline_lrt
|
73 |
else:
|
74 |
config = Configuration(
|
75 |
plm= '''all-mpnet-base-v2''',
|
76 |
-
dimension_reduction=
|
77 |
clustering= 'kmeans-euclidean',
|
78 |
-
keywords_extraction='
|
79 |
)
|
80 |
model = LiteratureResearchTool(config)
|
81 |
|
82 |
-
generator = model(query_input,num_papers,start_year,end_year,max_k=
|
83 |
for i,plat in enumerate(platforms):
|
84 |
clusters, articles = next(generator)
|
85 |
st.markdown(f'''# {i+1} {plat} Results''')
|
|
|
55 |
|
56 |
paperInGeneral.markdown(paperInGeneral_md)
|
57 |
|
58 |
+
def render_body(platforms, num_papers, num_papers_preview, query_input, show_preview:bool, start_year, end_year, hyperparams: dict):
|
59 |
|
60 |
tmp = st.empty()
|
61 |
if query_input != '':
|
|
|
68 |
|
69 |
# lrt results
|
70 |
## baseline
|
71 |
+
if hyperparams['dimension_reduction'] == 'none' and hyperparams['model_cpt'] == 'keyphrase-transformer':
|
72 |
model = baseline_lrt
|
73 |
else:
|
74 |
config = Configuration(
|
75 |
plm= '''all-mpnet-base-v2''',
|
76 |
+
dimension_reduction= hyperparams['dimension_reduction'],
|
77 |
clustering= 'kmeans-euclidean',
|
78 |
+
keywords_extraction=hyperparams['model_cpt']
|
79 |
)
|
80 |
model = LiteratureResearchTool(config)
|
81 |
|
82 |
+
generator = model(query_input, num_papers, start_year, end_year, max_k=hyperparams['max_k'], platforms=platforms)
|
83 |
for i,plat in enumerate(platforms):
|
84 |
clusters, articles = next(generator)
|
85 |
st.markdown(f'''# {i+1} {plat} Results''')
|
widgets/sidebar.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
import streamlit as st
|
2 |
import datetime
|
3 |
# from .utils import PACKAGE_ROOT
|
|
|
|
|
|
|
4 |
|
5 |
def render_sidebar():
|
6 |
icons = f'''
|
@@ -20,7 +23,7 @@ def render_sidebar():
|
|
20 |
|
21 |
|
22 |
<code>
|
23 |
-
|
24 |
</code>
|
25 |
|
26 |
|
@@ -65,21 +68,25 @@ def render_sidebar():
|
|
65 |
|
66 |
|
67 |
with st.sidebar:
|
68 |
-
st.markdown('## Adjust
|
69 |
-
with st.expander('Clustering
|
70 |
dr = st.selectbox('1) Dimension Reduction', options=['none', 'pca'], index=0)
|
71 |
tmp = min(number_papers,15)
|
72 |
max_k = st.slider('2) Max number of clusters', 2,tmp , tmp//2)
|
73 |
|
|
|
|
|
|
|
74 |
|
75 |
st.markdown('---')
|
76 |
st.markdown(icons,unsafe_allow_html=True)
|
77 |
-
st.markdown('''<center>
|
78 |
|
79 |
# st.sidebar.markdown('## Choose the number of clusters')
|
80 |
# k = st.sidebar.slider('number',1,10,3)
|
81 |
|
82 |
return platforms, number_papers, start_year, end_year, dict(
|
83 |
dimension_reduction= dr,
|
84 |
-
max_k = max_k
|
|
|
85 |
)
|
|
|
1 |
import streamlit as st
|
2 |
import datetime
|
3 |
# from .utils import PACKAGE_ROOT
|
4 |
+
from lrt.utils.functions import template
|
5 |
+
|
6 |
+
APP_VERSION = 'v1.2.0'
|
7 |
|
8 |
def render_sidebar():
|
9 |
icons = f'''
|
|
|
23 |
|
24 |
|
25 |
<code>
|
26 |
+
{APP_VERSION}
|
27 |
</code>
|
28 |
|
29 |
|
|
|
68 |
|
69 |
|
70 |
with st.sidebar:
|
71 |
+
st.markdown('## Adjust hyperparameters')
|
72 |
+
with st.expander('Clustering Options'):
|
73 |
dr = st.selectbox('1) Dimension Reduction', options=['none', 'pca'], index=0)
|
74 |
tmp = min(number_papers,15)
|
75 |
max_k = st.slider('2) Max number of clusters', 2,tmp , tmp//2)
|
76 |
|
77 |
+
with st.expander('Keyphrases Generation Options'):
|
78 |
+
model_cpt = st.selectbox(label='Model checkpoint', options=template.keywords_extraction.keys(),index=0)
|
79 |
+
|
80 |
|
81 |
st.markdown('---')
|
82 |
st.markdown(icons,unsafe_allow_html=True)
|
83 |
+
st.markdown('''<center>Copyright © 2022 by Tao Xiang</center>''',unsafe_allow_html=True)
|
84 |
|
85 |
# st.sidebar.markdown('## Choose the number of clusters')
|
86 |
# k = st.sidebar.slider('number',1,10,3)
|
87 |
|
88 |
return platforms, number_papers, start_year, end_year, dict(
|
89 |
dimension_reduction= dr,
|
90 |
+
max_k = max_k,
|
91 |
+
model_cpt = model_cpt
|
92 |
)
|