help - # word total count words += len(line.split())...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import sys,re # set all the counters to zero lines = sentences = words = 0 file1= 'text1.txt' for line in open(file1, 'r'): lines += 1 if line.startswith('\n'): blanklines += 1 else: # assumes certain stop punctuation and counts to calculate sentences. sentences += line.count('.') + line.count('!') + line.count('?')
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: # word total count words += len(line.split()) filename = sys.argv[1] ratio = float(words)/float(sentences) print "test:", words, lines, sentences print " Average Words per Line:" print "Text 1 ", ratio print filename...
View Full Document

This note was uploaded on 09/06/2009 for the course LING 571 taught by Professor Staff during the Fall '08 term at San Diego State.

Ask a homework question - tutors are online