-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEssayScanner.py
More file actions
39 lines (31 loc) · 860 Bytes
/
EssayScanner.py
File metadata and controls
39 lines (31 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
def main():
readfile()
def readfile():
file=sys.argv[1] #get the file from the argument
f=open(file,"r") #opens the file essay.txt
report=f.read()
checkfile(report)
f.close()
def checkfile(report):
a=0
endofsentence=0
count=len(report)
for a in range(0,count):
if report[a]=='.'or report[a]==','or report[a]=='!'or report[a]==';':
endofsentence+=1
words=report.split()
print(words)
validwords=0
testword=0
b=0
for a in words:
testword=words[b]
testword=len(testword)
if testword >=3:
validwords+=1
b+=1
numberwords=len(words)
print("The number of words is",len(words),"The total number of valid words is", validwords)
print("The average number of words per sentence is",validwords/endofsentence)
main()