ceejaytheanalyst commited on
Commit
b513d7d
·
verified ·
1 Parent(s): c3c0205

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -17,13 +17,13 @@ def check_misspelled_words(user_input):
17
  # Tokenize the input into words
18
  words = user_input.split()
19
  # Get a list of misspelled words
20
- misspelled = spell.unknown(words)
21
  return misspelled
22
 
23
  # Define the function for mapping code
24
  def mapping_code(user_input):
25
- if len(user_input.split()) < 5: # Check if sentence has less than 5 words
26
- raise ValueError("Input sentence should be at least 5 words long.")
27
  emb1 = model.encode(user_input.lower())
28
  similarities = util.pytorch_cos_sim(emb1, stored_embeddings)[0]
29
  # Combine similarity scores with 'code' and 'description'
 
17
  # Tokenize the input into words
18
  words = user_input.split()
19
  # Get a list of misspelled words
20
+ misspelled = [word for word in words if word.isalpha() and not word.isdigit() and not spell.correction(word.lower()) == word.lower()]
21
  return misspelled
22
 
23
  # Define the function for mapping code
24
  def mapping_code(user_input):
25
+ if len(user_input.split()) <= 1: # Check if sentence has less than 5 words
26
+ raise ValueError("Input sentence should be more than 1 word long.Please provide the Full description")
27
  emb1 = model.encode(user_input.lower())
28
  similarities = util.pytorch_cos_sim(emb1, stored_embeddings)[0]
29
  # Combine similarity scores with 'code' and 'description'