Created
August 23, 2016 13:22
-
-
Save anonymous/e89cd0619dc7f61cbec8732c8ab6c990 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 re | |
| import random | |
| arq = open ("pt.txt", 'r').read() | |
| (type(arq)) | |
| #print (len(arq)) | |
| def tokens(arq): | |
| return re.findall ('[a-z]+', arq.lower()) | |
| words = tokens(arq) | |
| len (words) | |
| """ print (words[:10])""" #print the words from 10 to 10 | |
| def sample(bag, n=10): | |
| return ' '.join(random.choice(bag) for _ in range (n)) | |
| print (sample (words)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment