OmPrakashSingh1704 commited on
Commit
55ae4ce
·
verified ·
1 Parent(s): 0d377dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -43,6 +43,12 @@ if 'selected_difficulty' not in st.session_state:
43
  if 'exclusions' not in st.session_state:
44
  st.session_state.exclusions = None
45
 
 
 
 
 
 
 
46
  def get_recommendations(user_description, count_vectorizer, count_matrix):
47
  user_description = preprocess_text(user_description)
48
  user_vector = count_vectorizer.transform([user_description])
 
43
  if 'exclusions' not in st.session_state:
44
  st.session_state.exclusions = None
45
 
46
+ def preprocess_text(text):
47
+ # Remove non-alphabet characters and extra spaces
48
+ text = re.sub(r'[^a-zA-Z\s]', '', text)
49
+ text = re.sub(r'\s+', ' ', text).strip()
50
+ return text.lower()
51
+
52
  def get_recommendations(user_description, count_vectorizer, count_matrix):
53
  user_description = preprocess_text(user_description)
54
  user_vector = count_vectorizer.transform([user_description])