Aug-31-2018, 01:23 PM
Hi Python/NLTK mentors,
Here is the task that I'm trying to implement in Jupyter Notebook:
Compare the lexical diversity scores for all 15 text categories in the Brown Corpus.
Which genre is more lexically diverse?
Please check my code below if this is how to calculate lexical diversity scores? Thank you in advance.
Here is the task that I'm trying to implement in Jupyter Notebook:
Compare the lexical diversity scores for all 15 text categories in the Brown Corpus.
Which genre is more lexically diverse?
Please check my code below if this is how to calculate lexical diversity scores? Thank you in advance.
import nltk import nltk.corpus from nltk.book import * from nltk.corpus import brown
print ("Genre Lexical diversity") for cat in nltk.corpus.brown.categories(): words_in_cat = nltk.corpus.brown.words(categories=cat) print (cat, "{:3g}".format( float(len(words_in_cat)) / len(set(words_in_cat)) )) print (" ")[Image: 02_zpsxawm7nuk.png]
Blockchain Visionary & Aspiring Encipher/Software Developer
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube