-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFogCalc.py
22 lines (15 loc) · 898 Bytes
/
FogCalc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from WSCount import wordcount, sentencecount, counting
def main():
try:
fog_index_calculated = ((wordcount()/sentencecount()) + counting())*0.4
gunning_fog_index = ((wordcount()/sentencecount()) + 100*(counting()/wordcount()))*0.4
except ZeroDivisionError:
fog_index_calculated = gunning_fog_index = 0
with open("FogIndex.txt", "w+") as new_file:
new_file.write("The Fog Index of the given text document is " + str(fog_index_calculated) + "\n")
new_file.write("The Gunning Fog Index of the given document is " + str(gunning_fog_index)+"\n")
new_file.write("Total number of sentences = " + str(sentencecount())+"\n")
new_file.write("Total number of words = " + str(wordcount()) + "\n")
new_file.write("Total number of words with 3 or more syllables = " + str(counting()) + "\n")
if __name__ == '__main__':
main()