Skip to content

Instantly share code, notes, and snippets.

@dbasch
Created December 9, 2013 22: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 dbasch/99451ac5646e9cf0e2a7 to your computer and use it in GitHub Desktop.
Save dbasch/99451ac5646e9cf0e2a7 to your computer and use it in GitHub Desktop.
#Generate map in the form word1 -> word2 -> occurences of word2 after word1
for title in titles[:-1]:
title = title.split()
if len(title) > lookback:
for i in xrange(len(title)+1):
markov_map[' '.join(title[max(0,i-lookback):i])][' '.join(title[i:i+1])] += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment