Created
September 28, 2011 18:01
-
-
Save netdesign/1248689 to your computer and use it in GitHub Desktop.
text stats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| text = TokenizedText | |
| def textStats(text): | |
| length = 0 | |
| punctuation = 0 | |
| smallWordsCount = 0 | |
| for word in text: | |
| if(word == "," or word == "." or word == ";" or word == ":"): | |
| punctuation += 1 | |
| else: | |
| wordLength = len(word) | |
| length += wordLength | |
| if(wordLength <= 3): | |
| smallWordsCount += 1 | |
| return {'avgWordLength':length/(len(text)-punctuation),'numWords':len(text), 'punctNum':punctuation, 'smallWordCound':smallWordsCount, 'phraseAvgSize':(len(text)/punctuation)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment