Skip to content

Instantly share code, notes, and snippets.

@AKAMEDIASYSTEM
Created February 24, 2021 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AKAMEDIASYSTEM/682915f1453fc845027e6503ddc7be2f to your computer and use it in GitHub Desktop.
Save AKAMEDIASYSTEM/682915f1453fc845027e6503ddc7be2f to your computer and use it in GitHub Desktop.
# amulet_miner.py
"""Mine some poetry."""
import glob
import nltk
from hashlib import sha256
common = '8888'
uncommon = '88888'
rare = '888888'
epic = '8888888'
legendary = '88888888'
mythic = '888888888'
print(nltk.corpus.gutenberg.fileids())
# look at all *.txt in this directory
# txt_files = glob.glob('*.txt')
txt_files = nltk.corpus.gutenberg.fileids()
for tf in txt_files:
print('now reading %s' % tf)
# f = open(tf, 'rb')
f = nltk.corpus.gutenberg.sents(tf)
lines = [" ".join(j) for j in f]
# lines = f.readlines()
for l in lines:
hw = sha256(l.encode('utf-8').strip()).hexdigest()
if common in hw:
# print('%s is common' % l)
print(hw)
if uncommon in hw:
print('%s is uncommon' % l)
print(hw)
if rare in hw:
print('%s is rare' % l)
print(hw)
if epic in hw:
print('%s is epic' % l)
print(hw)
if mythic in hw:
print('%s is mythic' % l)
print(hw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment