Delete pages/upload_file.py
Browse files- pages/upload_file.py +0 -86
pages/upload_file.py
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pandas as pd
|
3 |
-
from io import StringIO
|
4 |
-
import json
|
5 |
-
from transformers import pipeline # AutoTokenizer, AutoModelForTokenClassification
|
6 |
-
|
7 |
-
#for k, v in st.session_state.items():
|
8 |
-
# st.session_state[k] = v
|
9 |
-
|
10 |
-
def on_click():
|
11 |
-
st.session_state.user_input = ""
|
12 |
-
|
13 |
-
#@st.cache
|
14 |
-
def convert_df(df:pd.DataFrame):
|
15 |
-
return df.to_csv(index=False).encode('utf-8')
|
16 |
-
|
17 |
-
#@st.cache
|
18 |
-
def convert_json(df:pd.DataFrame):
|
19 |
-
result = df.to_json(orient="index")
|
20 |
-
parsed = json.loads(result)
|
21 |
-
json_string = json.dumps(parsed)
|
22 |
-
#st.json(json_string, expanded=True)
|
23 |
-
return json_string
|
24 |
-
|
25 |
-
st.header("Work in Progress")
|
26 |
-
|
27 |
-
uploaded_file = st.file_uploader(label = "Upload single csv file")
|
28 |
-
if uploaded_file is not None:
|
29 |
-
stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
30 |
-
string_data = stringio.read()
|
31 |
-
st.success('Your file input is: '+ string_data, icon="β
")
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
#df_topics = filter_chapters_env(df_topics, "chapter_name")
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
#my_model_results = pipeline("ner", model= "checkpoint-92")
|
40 |
-
#HuggingFace_model_results = pipeline("ner", model = "blaze999/Medical-NER")
|
41 |
-
|
42 |
-
|
43 |
-
createNER_button = st.button("Map to SBS codes")
|
44 |
-
|
45 |
-
#col1, col2, col3 = st.columns([1,1,2.5])
|
46 |
-
#col1.subheader("Score")
|
47 |
-
#col2.subheader("SBS code")
|
48 |
-
#col3.subheader("SBS description V2.0")
|
49 |
-
|
50 |
-
dictA = {"Score": [], "SBS Code": [], "SBS Description V2.0": []}
|
51 |
-
|
52 |
-
|
53 |
-
#if uploaded_file is not None and createNER_button == True:
|
54 |
-
# dict1 = {"word": [], "entity": []}
|
55 |
-
# dict2 = {"word": [], "entity": []}
|
56 |
-
# #stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
57 |
-
# #string_data = stringio.read()
|
58 |
-
# #st.write("Your input is: ", string_data)
|
59 |
-
# #with col1:
|
60 |
-
# # #st.write(my_model_results(string_data))
|
61 |
-
# # #col1.subheader("myDemo Model")
|
62 |
-
# # #for result in my_model_results(string_data):
|
63 |
-
# # # st.write(result['word'], result['entity'])
|
64 |
-
# # # dict1["word"].append(result['word']), dict1["entity"].append(result['entity'])
|
65 |
-
# # #df1 = pd.DataFrame.from_dict(dict1)
|
66 |
-
# # #st.write(df1)
|
67 |
-
# with col2:
|
68 |
-
# #st.write(HuggingFace_model_results(string_data))
|
69 |
-
# #col2.subheader("Hugging Face Model")
|
70 |
-
# for result in HuggingFace_model_results(string_data):
|
71 |
-
# st.write(result['word'], result['entity'])
|
72 |
-
# dict2["word"].append(result['word']), dict2["entity"].append(result['entity'])
|
73 |
-
# df2 = pd.DataFrame.from_dict(dict2)
|
74 |
-
# #st.write(df2)
|
75 |
-
|
76 |
-
|
77 |
-
# cs, c1, c2, c3, cLast = st.columns([0.75, 1.5, 1.5, 1.5, 0.75])
|
78 |
-
# with c1:
|
79 |
-
# #csvbutton = download_button(results, "results.csv", "π₯ Download .csv")
|
80 |
-
# csvbutton = st.download_button(label="π₯ Download .csv", data=convert_df(df1), file_name= "results.csv", mime='text/csv', key='csv')
|
81 |
-
# with c2:
|
82 |
-
# #textbutton = download_button(results, "results.txt", "π₯ Download .txt")
|
83 |
-
# textbutton = st.download_button(label="π₯ Download .txt", data=convert_df(df1), file_name= "results.text", mime='text/plain', key='text')
|
84 |
-
# with c3:
|
85 |
-
# #jsonbutton = download_button(results, "results.json", "π₯ Download .json")
|
86 |
-
# jsonbutton = st.download_button(label="π₯ Download .json", data=convert_json(df1), file_name= "results.json", mime='application/json', key='json')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|