Update app.py
Browse files
app.py
CHANGED
@@ -52,35 +52,37 @@ def mapping_code(user_input,user_slider_input_number):
|
|
52 |
return top_5_results
|
53 |
|
54 |
# Streamlit frontend interface
|
|
|
|
|
55 |
def main():
|
56 |
st.title("CPT Description Mapping")
|
57 |
st.markdown("<font color='red'>**⚠️ Please ensure the accuracy of your input spellings.**</font>", unsafe_allow_html=True)
|
58 |
|
59 |
-
st.markdown("<font color='blue'>**💡 Note:** Please note that the similarity scores provided are not indicative of accuracy
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
if
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
st.error(str(e))
|
84 |
|
85 |
if __name__ == "__main__":
|
86 |
main()
|
|
|
|
52 |
return top_5_results
|
53 |
|
54 |
# Streamlit frontend interface
|
55 |
+
import streamlit as st
|
56 |
+
|
57 |
def main():
|
58 |
st.title("CPT Description Mapping")
|
59 |
st.markdown("<font color='red'>**⚠️ Please ensure the accuracy of your input spellings.**</font>", unsafe_allow_html=True)
|
60 |
|
61 |
+
st.markdown("<font color='blue'>**💡 Note:** Please note that the similarity scores provided are not indicative of accuracy. Top 5 code descriptions provided should be verified with CPT descriptions by the user.</font>", unsafe_allow_html=True)
|
62 |
+
|
63 |
+
# user_slider_input_number = st.sidebar.slider('Select similarity threshold', 0.0, 1.0, 0.7, 0.01, key='slider1', help='Adjust the similarity threshold')
|
64 |
+
|
65 |
+
# Input text box for user input
|
66 |
+
user_input = st.text_input("Enter CPT description:", placeholder="Please enter a full description for better search results.")
|
67 |
+
|
68 |
+
# Button to trigger mapping
|
69 |
+
if st.button("Map"):
|
70 |
+
if not user_input.strip(): # Check if input is empty or contains only whitespace
|
71 |
+
st.error("Input box cannot be empty.")
|
72 |
+
elif validate_input(user_input):
|
73 |
+
st.warning("Please input correct description containing only letters and numbers, or letters only.")
|
74 |
+
else:
|
75 |
+
st.write("Please wait for a moment .... ")
|
76 |
+
# Call backend function to get mapping results
|
77 |
+
try:
|
78 |
+
mapping_results = mapping_code(user_input) # user_slider_input_number
|
79 |
+
# Display top 5 similar sentences
|
80 |
+
st.write("Top 5 similar sentences:")
|
81 |
+
for i, result in enumerate(mapping_results, 1):
|
82 |
+
st.write(f"{i}. Code: {result['Code']}, Description: {result['Description']}, Similarity Score: {float(result['Similarity Score']):.4f}")
|
83 |
+
except ValueError as e:
|
84 |
+
st.error(str(e))
|
|
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
main()
|
88 |
+
|