I am using SequenceMatcher
to find a set of words within a group of texts. The problem I am having is that I need to record when it does not find a match, but one time per text. If I try an if statement, it gives me a result each time the comparison to another word fails.
names=[JOHN, LARRY, PETER, MARY]
files = [path or link]
for file in files:
for name in names:
if SequenceMatcher(None, name, file).ratio() > .9:
do something
else:
print name + 'not found'
I have also tried re.match
and re.find
and I encounter the same problem.
The code above is a simple version of what I am doing. I'm new to Python too.
Thank you very much!