I have code which reads a text file and outputs the amount of TLA's in the text as a percentage out of how many lines contain text.
import re
total_lines = 0
matched_lines = 0
for line in open("sentences.txt"):
total_lines += 1
matched_lines += bool(re.search(r"\b[A-Z]{3}\b", line))
matched_lines += bool(re.search(r"\b[A-Z]\\.[A-Z]\\.[A-Z]\b", line)) # DOES NOT WORK
print('{}% of sentences contain a TLA'.format(round(float(matched_lines) / total_lines * 100, 1)))
What i'm trying to do is count TLA's with full stops between them. So like now it counts WWW but i want it to count W.W.W as well.