Update lcs.py
Browse files
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 |
-
|
|
|
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 |
+
|