ceejaytheanalyst commited on
Commit
56fcccb
·
verified ·
1 Parent(s): 90da2fd

Update app.py

Browse files

Added a slider

Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -26,8 +26,8 @@ def check_misspelled_words(user_input):
26
 
27
  # Define the function for mapping code
28
  # Define the function for mapping code
29
- def mapping_code(user_input):
30
- if len(user_input.split()) < 5: # Check if sentence has less than 5 words
31
  raise ValueError("Input sentence should be at least 5 words long.")
32
  emb1 = model.encode(user_input.lower())
33
  similarities = []
@@ -36,7 +36,7 @@ def mapping_code(user_input):
36
  similarities.append(similarity)
37
 
38
  # Filter results with similarity scores above 0.70
39
- result = [(code, desc, sim) for (code, desc, sim) in zip(stored_data["SBS_code"], stored_data["Description"], similarities) if sim > 0.70]
40
 
41
  # Sort results by similarity scores
42
  result.sort(key=lambda x: x[2], reverse=True)
@@ -60,6 +60,8 @@ def main():
60
 
61
  st.markdown("**Note:** Similarity scores are not absolute and should be further confirmed manually for accuracy.")
62
 
 
 
63
  # Input text box for user input
64
  user_input = st.text_input("Enter CPT description:", placeholder="Please enter a full description for better search results.")
65
  # Button to trigger mapping
 
26
 
27
  # Define the function for mapping code
28
  # Define the function for mapping code
29
+ def mapping_code(user_input,user_slider_input_number):
30
+ if len(user_input.split()) < 1: # Check if sentence has less than 5 words
31
  raise ValueError("Input sentence should be at least 5 words long.")
32
  emb1 = model.encode(user_input.lower())
33
  similarities = []
 
36
  similarities.append(similarity)
37
 
38
  # Filter results with similarity scores above 0.70
39
+ result = [(code, desc, sim) for (code, desc, sim) in zip(stored_data["SBS_code"], stored_data["Description"], similarities) if sim > user_slider_input_number]
40
 
41
  # Sort results by similarity scores
42
  result.sort(key=lambda x: x[2], reverse=True)
 
60
 
61
  st.markdown("**Note:** Similarity scores are not absolute and should be further confirmed manually for accuracy.")
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
  # Button to trigger mapping