Created
May 3, 2015 22:48
-
-
Save JonathanReeve/ac543e9541d1647c1c3b to your computer and use it in GitHub Desktop.
Export Brown Corpus categories to text files using NLTK.
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
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