Created
July 16, 2016 10:43
-
-
Save janprill/5bafc6ea22f6566f8154af6ae7064316 to your computer and use it in GitHub Desktop.
This file contains 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
# Export wordlists of differently tagged word types from brown corpus | |
# using the natural language toolkit. | |
import io | |
import nltk | |
brown_tagged = nltk.corpus.brown.tagged_words(tagset='universal') | |
word_tag_fd = nltk.FreqDist(brown_tagged) | |
types = ['NOUN', 'VERB', 'DET', 'ADJ', 'ADP', 'CONJ', 'ADV', 'PRT'] | |
for t in types: | |
words = [wt[0] for (wt, _) in word_tag_fd.most_common() if wt[1] == t] | |
with io.open("{0}.txt".format(t), 'w', encoding='utf8') as out: | |
out.write('\n'.join(words)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment