How can I find out how many keywords from a file are also in another file? I have a file containing a list of words, and I'm trying to figure out if those words are in another file.
I have a file (keywords.txt) containing key words, and I'm trying to find out if another file contains (tweets.txt) which contains sentences, contains any of the keywords
def main() :
done = False
while not done:
try:
keywords = input("Enter the filename titled keywords: ")
with open(keywords, "r") as words:
done = True
except IOError:
print("Error: file not found.")
total = 0
try:
tweets = input("Enter the file Name titled tweets: ")
with open(tweets, 'r') as tweets:
except IOError:
print("Error: file not found.")
def sentiment_of_msg(msg_words_counter):
summary = 0
for line in tweets:
if happy_dict in line:
summary += 10 * **The number of keywords in the sentence of the file**
elif veryUnhappy_dict in line:
summary += 1 * quantity
elif neutral_dict in line:
summary += 5 * quantity
return summary