OmPrakashSingh1704 commited on
Commit
4c5033c
1 Parent(s): fc17498

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -32,6 +32,12 @@ mode = st.toggle(label="MARTMAN")
32
  if 'ind' not in st.session_state:
33
  st.session_state.ind = []
34
 
 
 
 
 
 
 
35
  def get_recommendations(user_description, count_vectorizer, count_matrix):
36
  user_description = preprocess_text(user_description)
37
  user_vector = count_vectorizer.transform([user_description])
 
32
  if 'ind' not in st.session_state:
33
  st.session_state.ind = []
34
 
35
+ def preprocess_text(text):
36
+ # Remove non-alphabet characters and extra spaces
37
+ text = re.sub(r'[^a-zA-Z\s]', '', text)
38
+ text = re.sub(r'\s+', ' ', text).strip()
39
+ return text.lower()
40
+
41
  def get_recommendations(user_description, count_vectorizer, count_matrix):
42
  user_description = preprocess_text(user_description)
43
  user_vector = count_vectorizer.transform([user_description])