Skip to content

Instantly share code, notes, and snippets.

@ekinhbayar
Forked from ulgens/brown-taggedwords.py
Created October 16, 2016 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekinhbayar/b85864bca0fa28cfaaa6c9d0df224eb2 to your computer and use it in GitHub Desktop.
Save ekinhbayar/b85864bca0fa28cfaaa6c9d0df224eb2 to your computer and use it in GitHub Desktop.
Export Brown Corpus tagged words by categories using NLTK. Based on: https://gist.github.com/JonathanReeve/ac543e9541d1647c1c3b
from nltk.corpus import brown
for category in brown.categories():
words = brown.tagged_words(categories=category)
text = '\n '.join('%s, %s' % word for word in words)
filename = category + '.txt'
with open(filename, 'w') as outfile:
outfile.write(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment