Spaces:
Sleeping
Sleeping
Nick Sorros
commited on
Commit
·
28fedac
1
Parent(s):
b493a01
Limit results and add download button
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from collections import Counter
|
2 |
import streamlit as st
|
|
|
3 |
import srsly
|
4 |
|
5 |
|
@@ -17,9 +18,11 @@ st.sidebar.write(
|
|
17 |
"A complete list of MeSH tags can be found here https://meshb.nlm.nih.gov/treeView"
|
18 |
)
|
19 |
st.sidebar.write("The grants data can be found https://www.threesixtygiving.org/")
|
|
|
20 |
st.sidebar.write(
|
21 |
"The model used to tag grants is https://huggingface.co/Wellcome/WellcomeBertMesh"
|
22 |
)
|
|
|
23 |
|
24 |
if "grants" not in st.session_state:
|
25 |
st.session_state["grants"] = list(srsly.read_jsonl("tagged_grants.jsonl"))
|
@@ -43,4 +46,7 @@ if "results" in st.session_state:
|
|
43 |
if tag_i < len(most_common_tags):
|
44 |
tag = most_common_tags[tag_i]
|
45 |
st.button(tag, on_click=search, kwargs={"query": tag})
|
46 |
-
st.
|
|
|
|
|
|
|
|
1 |
from collections import Counter
|
2 |
import streamlit as st
|
3 |
+
import pandas as pd
|
4 |
import srsly
|
5 |
|
6 |
|
|
|
18 |
"A complete list of MeSH tags can be found here https://meshb.nlm.nih.gov/treeView"
|
19 |
)
|
20 |
st.sidebar.write("The grants data can be found https://www.threesixtygiving.org/")
|
21 |
+
st.sidebar.header("Parameters")
|
22 |
st.sidebar.write(
|
23 |
"The model used to tag grants is https://huggingface.co/Wellcome/WellcomeBertMesh"
|
24 |
)
|
25 |
+
nb_results = st.sidebar.slider("Number of results to display", value=20, min_value=1, max_value=100)
|
26 |
|
27 |
if "grants" not in st.session_state:
|
28 |
st.session_state["grants"] = list(srsly.read_jsonl("tagged_grants.jsonl"))
|
|
|
46 |
if tag_i < len(most_common_tags):
|
47 |
tag = most_common_tags[tag_i]
|
48 |
st.button(tag, on_click=search, kwargs={"query": tag})
|
49 |
+
results = st.session_state["results"]
|
50 |
+
st.caption(f"Found {len(results)}. Displaying {nb_results}")
|
51 |
+
st.download_button("Download results", data=pd.DataFrame(results).to_csv(), file_name="results.csv", mime="text/csv")
|
52 |
+
st.table(results[:nb_results])
|