Skip to content

Instantly share code, notes, and snippets.

@natling
Created November 9, 2018 06:29
Show Gist options
  • Save natling/cefa21b114b13e4f6957449a2305008f to your computer and use it in GitHub Desktop.
Save natling/cefa21b114b13e4f6957449a2305008f to your computer and use it in GitHub Desktop.
# download corpus from https://www.ngrams.info
corpus = open('5-grams non case sensitive.txt')
corpus = [' '.join(line.split()[1:]) for line in corpus]
love = 'i love you'
lines = [line for line in corpus if line.find(love) >= 0]
lines = [line.rjust(len(line) - line.find(love) + max([line.find(love) for line in lines])) for line in lines]
lines = [line.replace(love, ' ' * len(love)) for line in lines]
poem = '\n'.join(lines)
print(poem)
# and and
# and for
# and so
# and very
# because so
# everybody says
# everyone says
# how much
# a lot
# all the
# and i
# and miss
# and you
# as a
# because you
# for it
# from the
# i love
# just like
# like a
# more than
# so much
# to death
# too much
# very much
# with all
# i say
# i think
# know that
# much as
# of course
# remember that
# tell you
# that and
# the way
# this because
# to say
# you and
# you because
# you know
# you that
# https://natalie.computer/love
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment