Created
December 29, 2016 00:10
-
-
Save CrazyPython/e324a3ecc310e5e68c23632149cece75 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| emma_sents = [] | |
| f = open('train.txt', 'w') | |
| for fileid in ['shakespeare-caesar.txt', 'shakespeare-hamlet.txt','shakespeare-macbeth.txt']: | |
| emma_sents.extend(nltk.corpus.gutenberg.sents(fileid)) | |
| def join(array): | |
| result = '' | |
| for i in array: | |
| if i not in ', .,"/[]\+-)(*&^%$#@!~`<>:;{}|-_?' + "'": | |
| result += ' '+i | |
| else: | |
| result += i | |
| result = result.strip() | |
| return result | |
| for i in emma_sents: | |
| f.write(join(i) + '\n\n') | |
| f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment