So I have two txt files. one with a list of 2000 words and another with 1000 sentences. I also have a function that turns the list of words into a dictionary, with each word having a value of 0
So if the word list was : oranges bananas apples
The function returns:
{'oranges':0, 'bananas':0, 'apples':0}
I need to compare each sentence with this dictionary and increase the values for every word based on their frequency of the sentence.
So if the sentence was "I like apples, oranges, and bananas, but oranges are the best.", then the dictionary should contain:
{'oranges':2, 'bananas':1, 'apples':1}
To access the sentences from the file I used
file = open(sentences.txt)
lines = file.readlines()