“iPhone 3D” In Stock At Amazon!
Amazon has replaced the Pre-order button for my book with Add to Cart. To celebrate, I created a word cloud of the entire book using wordle.net and a python script. Here’s the word cloud:
I love that “API” got nestled into “ES”. To create the word cloud, I first ran a little python script against the book’s DocBook source. The script simply extracts content from para elements. If I don’t do this, the word cloud contains all the sample code and represents words like const in huge, overwhelming text. (I tried it, trust me.) Anyway here’s the script:
from xml.dom.minidom import parse import codecs def getText(nodelist): rc = "" for node in nodelist: if node.nodeType == node.TEXT_NODE: rc = rc + node.data return rc f = codecs.open( "wordle.txt", "w", "utf-8" ) for i in xrange(0, 10): filename = "ch%02d.xml" % i tree = parse(filename) paras = tree.getElementsByTagName("para") for para in paras: f.write(getText(para.childNodes)) print "wordle.txt has been dumped"
After running the script, I simply pasted the resulting text file into wordle.net.