Make blacklist and whitelist cleaner

This commit is contained in:
2023-01-10 17:29:00 +01:00
parent b0e9e80b14
commit 25c95366ad
2 changed files with 2 additions and 4 deletions

View File

@ -19,8 +19,7 @@ def is_word_in_text(words: str, text: str) -> bool:
for word in word_list: for word in word_list:
look_for: str = rf"(^|[^\w]){word}([^\w]|$)" look_for: str = rf"(^|[^\w]){word}([^\w]|$)"
pattern: re.Pattern[str] = re.compile(look_for, re.IGNORECASE) pattern: re.Pattern[str] = re.compile(look_for, re.IGNORECASE)
matches: re.Match[str] | None = re.search(pattern, text) if re.search(pattern, text):
if matches:
return True return True
return False return False

View File

@ -19,8 +19,7 @@ def is_word_in_text(words: str, text: str) -> bool:
for word in word_list: for word in word_list:
look_for: str = rf"(^|[^\w]){word}([^\w]|$)" look_for: str = rf"(^|[^\w]){word}([^\w]|$)"
pattern: re.Pattern[str] = re.compile(look_for, re.IGNORECASE) pattern: re.Pattern[str] = re.compile(look_for, re.IGNORECASE)
matches: re.Match[str] | None = re.search(pattern, text) if re.search(pattern, text):
if matches:
return True return True
return False return False