-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
73 lines (61 loc) · 2.26 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Import relevant libraries
import streamlit as st
from helper_functions import Helper_Functions
# Header
st.set_page_config(page_title='Med Router', page_icon = '💊')
# Intiating the app
st.header("Med Router 💊")
hf = Helper_Functions()
# Side Bar
with st.sidebar:
# Init
st.header("Customize Your Options")
# Website Checkbox
st.write("Website")
mayo = st.checkbox('Mayo Clinic', value = True)
webmd = st.checkbox("Webmd", value = True)
# Type Checkbox
st.write("Type")
disease = st.checkbox('Diseases', value = True)
drug = st.checkbox('Drugs', value = True)
supplement = st.checkbox('Supplements', value = True)
symptom = st.checkbox('Symptoms', value = True)
# Number of ouputs
number = st.number_input('No Of Results', step = 1, min_value= 5, max_value= 50)
# Button
submit_state = st.button("Submit")
if submit_state:
hf.customize_refresh()
hf.customize_mayo(mayo)
hf.customize_webmd(webmd)
hf.customize_disease(disease)
hf.customize_drugs(drug)
hf.customize_supplements(supplement)
hf.customize_symptoms(symptom)
hf.customize_number(number)
# Main Content - Input
var = st.text_input("Input Your Query Here", placeholder="Abdominal aortic aneurysm")
state, results = hf.cosine_similarity_check(var)
# Main Content - Output
if state:
for ind in results.index:
name = results['name'][ind]
url = results['url'][ind]
type = results['type'][ind]
website = results['website'][ind]
score = results['Cosine Similarity'][ind]
with st.expander(name, expanded=False):
col1, col2 = st.columns([1, 3])
with col1:
st.write("**Website :**", website)
st.write("**Score :**", round(score,3))
with col2:
st.write("**Type :**", type.capitalize())
st.write("**URL :**", url)
else:
with st.expander("No Matches", expanded=False):
st.write("There are no results found. This could be because of the input or the options. Please try something else! ")
st.write("------------------")
st.subheader("✨ By Grace Hephzibah✨")
st.write("https://github.com/Grace-Hephzibah")
st.write("------------------")