Skip to content

Instantly share code, notes, and snippets.

@JonathanReeve
Created May 3, 2015 22:48
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonathanReeve/ac543e9541d1647c1c3b to your computer and use it in GitHub Desktop.
Save JonathanReeve/ac543e9541d1647c1c3b to your computer and use it in GitHub Desktop.
Export Brown Corpus categories to text files using NLTK.
import nltk
from nltk.corpus import brown
for category in brown.categories():
words = brown.words(categories=category)
text = " ".join(words)
filename = category + '.txt'
outfile = open(filename, 'w')
outfile.write(text)
outfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment