Created
July 5, 2011 19:51
-
-
Save acrymble/1065739 to your computer and use it in GitHub Desktop.
Python HTML to Frequency Pairs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # html-to-freq-3.py | |
| import obo | |
| # create sorted dictionary of word-frequency pairs | |
| url = 'http://www.oldbaileyonline.org/print.jsp?div=t17800628-33' | |
| text = obo.webPageToText(url) | |
| fullwordlist = obo.stripNonAlphaNum(text) | |
| wordlist = obo.removeStopwords(fullwordlist, obo.stopwords) | |
| dictionary = obo.wordListToFreqDict(wordlist) | |
| sorteddict = obo.sortFreqDict(dictionary) | |
| # compile dictionary into string and wrap with HTML | |
| outstring = "" | |
| for s in sorteddict: | |
| outstring += str(s) | |
| outstring += "<br />" | |
| obo.wrapStringInHTML("html-to-freq-3", url, outstring) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment