A word cloud of Hacker News headlines
The front page of Hacker News, turned into a cloud of the words its titles keep repeating. Live, from a read-only mirror of the site.
Hacker News is a list of titles, most of the day. Putting all of them into one picture is a quick way to see what a day was about — which words came up over and over, and which only looked important.
To be fair to the format: a word cloud is not a good representation of occurrence. It has no axis, the areas are not proportional to anything, and "the biggest word" is a claim the picture cannot support precisely. It does look nice, and it does show you the shape of a day in one glance, which is what it is for.
Fetching…
Sizes are a word's share of the most frequent word, not its raw count — the numbers are in the line above. Tint is a band: the ten loudest words take the accent, the next fifteen the cool tint, the rest the faint one. Words are lowercased, stripped of punctuation and digits, single characters dropped, and filtered against the 2019 stop list.
The titles come from api.hnpwa.com, a read-only mirror of the Hacker News API, which answers with a permissive CORS header. The old version of this page asked that mirror for twenty pages of stories; this one asks for eight. It is someone else's service, and three hundred titles show the shape of a day about as well as six hundred do.
What changed in the port
Nothing about the counting: titles are lowercased, punctuation and digits are stripped, the 2019 stop-word list is applied, and the fifty most frequent words are laid out. What changed is what draws it.
The 2019 version loaded two libraries from two CDNs — all of d3 v3, and d3.layout.cloud — and drew with d3-selection, giving every word a colour from a twenty-colour palette. That is now one vendored file of 15 KB (the layout: placing words in a spiral against measured text boxes is not worth writing by hand) and plain SVG that takes the plate's own three tints. The layout waits for the webfont before measuring, or every word would be sized against the wrong metrics.
Bye.
Written in 2019, ported from the old Hugo site and lightly edited. The 2019 stop list, the fifty-word cut-off and the data source are unchanged; the drawing is now the site's own SVG instead of d3 and a CDN.
Comments
Discussion lives on GitHub — you'll need a GitHub account to post.