jgyasu commited on
Commit
3b4471f
1 Parent(s): 13a6069

Update lcs.py

Browse files
Files changed (1) hide show
  1. lcs.py +3 -1
lcs.py CHANGED
@@ -8,7 +8,8 @@ def find_common_subsequences(sentence, str_list):
8
  str_list = [s.lower() for s in str_list]
9
 
10
  def is_present(subseq, str_list):
11
- return all(subseq in s for s in str_list)
 
12
 
13
  def remove_stop_words_and_special_chars(sentence):
14
  sentence = re.sub(r'[^\w\s]', '', sentence)
@@ -33,3 +34,4 @@ def find_common_subsequences(sentence, str_list):
33
  index += 1
34
 
35
  return common_grams
 
 
8
  str_list = [s.lower() for s in str_list]
9
 
10
  def is_present(subseq, str_list):
11
+ subseq_regex = re.compile(r'\b' + re.escape(subseq) + r'\b')
12
+ return all(subseq_regex.search(s) for s in str_list)
13
 
14
  def remove_stop_words_and_special_chars(sentence):
15
  sentence = re.sub(r'[^\w\s]', '', sentence)
 
34
  index += 1
35
 
36
  return common_grams
37
+