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.

Revisions

  1. @invalid-email-address Anonymous created this gist Aug 23, 2016.
    20 changes: 20 additions & 0 deletions anna.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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))