-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyWordDetector.py
More file actions
19 lines (16 loc) · 830 Bytes
/
PyWordDetector.py
File metadata and controls
19 lines (16 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os
while True:
with open('keywords.txt', 'r', encoding='utf-8') as keywords:
keywords = keywords.read().lower().split(",")
txtContents = input('Provide path to file or paste text: ')
if os.path.exists(txtContents):
with open(txtContents, 'r', encoding='utf-8') as txtContents:
txtContents = " " + txtContents.read().replace('\n', ' ').lower()
result = [i for i in keywords if(i in txtContents)]
print('Does the text contain words from the keywords list: ' + str(bool(result)))
continue
else:
txtContents = " " + txtContents.lower()
result = [i for i in keywords if(i in txtContents)]
print('Does the text contain words from the keywords list: ' + str(bool(result)))
continue