2024-09-29 06:47:49 +00:00
|
|
|
stopwords = []
|
2024-09-29 07:05:14 +00:00
|
|
|
with open('nlp/stop_words.txt', 'r', encoding='utf-8') as file:
|
2024-09-29 07:13:08 +00:00
|
|
|
stopwords = file.readlines()
|
2024-09-29 06:47:49 +00:00
|
|
|
|
|
|
|
# Convert stopwords to a set for faster lookup
|
|
|
|
stopword_set = set(stopwords)
|
|
|
|
|
2024-09-29 07:08:25 +00:00
|
|
|
def check_stopwords(text):
|
2024-09-29 06:47:49 +00:00
|
|
|
"""
|
|
|
|
Check if any words from the stopwords list are present in the given text.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
text (str): The input text to check.
|
|
|
|
stopwords (list): A list of stopwords.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
bool: True if any stopword is found in the text, False otherwise.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Iterate through each word and check for stopwords
|
2024-09-29 07:21:23 +00:00
|
|
|
for word in stopword_set:
|
|
|
|
if word in text:
|
2024-09-29 06:47:49 +00:00
|
|
|
return True # Stop iteration and return True if a stopword is found
|
|
|
|
|
|
|
|
return False # Return False if no stopwords are found
|