grader - chars = 0 for line in file(t1 line =...

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

View Full Document Right Arrow Icon
#!/usr/bin/env python by Sara Kazemi ##Sorts texts by an estimated grade level with resepect to average sentence ##length and the simple to non-simple sentence ratio. import sys,re t1 = 'text0.txt' lines = 0 words = 0
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: chars = 0 for line in file(t1): line = re.sub(r'[^a-z ]',' ',line.lower()) lines = lines + 1 words = words + len(line.split()) chars = len(line) wpl = float(words)/float(lines) print lines, words, chars, wpl...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online