You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
657 B
Python
25 lines
657 B
Python
5 years ago
|
import collections
|
||
|
|
||
|
file = open("results.txt") # open and read file
|
||
|
|
||
|
trump_list = []
|
||
|
|
||
|
trump = set(line.strip() for line in open('trump.txt')) # words that are inside sad.txt
|
||
|
|
||
|
# in the future I should split words from punctuation, so Trump's count as Trump
|
||
|
# for word in a.lower().split():
|
||
|
|
||
|
with open("results.txt") as f:
|
||
|
for line in f:
|
||
|
for word in line.split():
|
||
|
if word in trump:
|
||
|
#print(word + " this is sad")
|
||
|
trump_list.append(line + "<br>")
|
||
|
break
|
||
|
|
||
|
text_file = open("trump_news.htm", "w+")
|
||
|
text_file.write("".join(trump_list))
|
||
|
# print("".join(happy_list))
|
||
|
# Close the file
|
||
|
file.close()
|