Skip to content

Instantly share code, notes, and snippets.

@acrymble
Created July 6, 2011 09:23
Show Gist options
  • Select an option

  • Save acrymble/1066900 to your computer and use it in GitHub Desktop.

Select an option

Save acrymble/1066900 to your computer and use it in GitHub Desktop.
Python HTML to Pretty Print
# html-to-pretty-print.py
import obo
# create dictionary of n-grams
n = 7
url = 'http://www.oldbaileyonline.org/print.jsp?div=t17800628-33'
text = obo.webPageToText(url)
fullwordlist = obo.stripNonAlphaNum(text)
ngrams = obo.getNGrams(fullwordlist, n)
worddict = obo.nGramsToKWICDict(ngrams)
print worddict["black"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment