In python I am trying to take in a file of text. And searching through each character, when I find a capital, I want to keep track of the number of characters after until I find a '?', '!', or '.' Basically, I am reading in large files of text and trying to calculate how many sentences there are and the total characters to find average sentence length. (I know there will be some bugs with things such as Mr. or E.g., but I can live with the bugs. The data set is so large that the error will be negligible.)
char = ''
for line in sys.stdin:
words = line
for char in words:
if char.isupper():
# read each char until you see a ?,!, or . and keep track
# of the number of characters in the sentence.