For each target word, I want to check whether the following words that appear before the next target word correspond to what I set in the document. If a match, I want it to be displayed in true and written to the txt file. If false, write false.
I use regex but the iteration method is great
import re re.findall("([a-zA-Z]+) " + tofind, txt)
Target and following words:
target word: document next words: set is complete
Doc example:
The document that I installed is complete. The document is excellent. Is a document a large set of documents completed. A full document document is good, but not complete.
The document appears 6 times in this passage, but I want it to come back and output below to the txt file
first document -> true second document -> false third document -> false fourth document -> true fifth document -> false sixth document -> false
source share