Skip to content

Instantly share code, notes, and snippets.

Created August 23, 2016 13:22
Show Gist options
  • Save anonymous/e89cd0619dc7f61cbec8732c8ab6c990 to your computer and use it in GitHub Desktop.
Save anonymous/e89cd0619dc7f61cbec8732c8ab6c990 to your computer and use it in GitHub Desktop.
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