def spam_detection(email):
with open('email.txt', 'r', errors='ignore') as f:
contents = f.read()
spam_keywords = ["account has been hacked", "urgent", "save on", "big deals","click this link","win","claim your prize"," !", " .", "lucky winner", "click here",]
if any(keyword in contents for keyword in spam_keywords):
return "spam"
return "ham"
result = spam_detection('email.txt')
print(result)
#this is my code
Я пытаюсь пометить все электронные письма с заданными ключевыми словами в содержании и темах любого данного электронного письма.
[code]def spam_detection(email): with open('email.txt', 'r', errors='ignore') as f: contents = f.read()
spam_keywords = ["account has been hacked", "urgent", "save on", "big deals","click this link","win","claim your prize"," !", " .", "lucky winner", "click here",]
if any(keyword in contents for keyword in spam_keywords): return "spam"
return "ham"
result = spam_detection('email.txt') print(result)
#this is my code [/code] Я пытаюсь пометить все электронные письма с заданными ключевыми словами в содержании и темах любого данного электронного письма.