Jun-27-2018, 03:33 PM
You loop over the list Words. But in that loop, you have a map statement that uses the whole list, not the individual word for that iteration of the loop. (Note that s is a bad variable name, and since it's not clear what s is, it's not clear that it's what should be in the map statement.) So you are processing all of the words once for each word. If you look at your output file, I bet it has sentences with cherry in it.
So get rid of the map statement, and replace it with a simple if statement for s being in the sentence.
Note that you are looping through the whole file once for each word. It would probably be more efficient to loop through the file once, store sentences in a dictionary based on words they match, and then after that loop go through the stored sentences and write them to the files.
So get rid of the map statement, and replace it with a simple if statement for s being in the sentence.
Note that you are looping through the whole file once for each word. It would probably be more efficient to loop through the file once, store sentences in a dictionary based on words they match, and then after that loop go through the stored sentences and write them to the files.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures