It certainly does depend on the sample. I've used a different script I just wrote which is much more efficient to calculate my averages. The source is at the bottom. I have quite a few ebooks myself, including American Gods.
I've removed the table of contents from each book where necessary.
American Gods: 4.195
Anansi Boys: 4.199
Pride & Prejudice: 4.444
However, running it over more scientific works:
The Origin of Species: 4.883
Principia: 4.948
Various collection of biology papers I had on my computer: 5.337
I think you'll get more accurate results with this script, and it runs very quickly.
import re
with open('/path/to/file') as words:
wordlist = [re.sub(r'[^A-Za-z_]+', '', x) for x in words.read().split()]
wordcount = len(wordlist)
wordlist = map(lambda x: len(x), wordlist)
wordlist = reduce(lambda x,y: x+y, wordlist)
print (wordlist/float(wordcount))
View all comments
Show parent comment
1
u/AnkhMorporkian Sep 23 '13
It certainly does depend on the sample. I've used a different script I just wrote which is much more efficient to calculate my averages. The source is at the bottom. I have quite a few ebooks myself, including American Gods.
I've removed the table of contents from each book where necessary.
However, running it over more scientific works:
I think you'll get more accurate results with this script, and it runs very quickly.