Google's Ngram Viewer Goes Wild

With the addition of wildcard search-term capabilities, Google's fabulous language-analysis tool gets even more powerful.

It's been nearly three years since Google rolled out its Ngram Viewer, allowing armchair historians to plot the trajectories of words and phrases over time based on an enormous corpus of data extracted from the Google Books digitization project. Since then, there have been numerous studies seeking to glean some cultural significance from the graphs of falling and rising word usage. And the graphs themselves have inspired imitators: Recently, the engineering team behind Rap Genius introduced Ngram-style graphing of historical word frequency in rap lyrics, and, more bizarrely, New York Times wedding announcements. (You can even compare the hiphop and matrimonial datasets.)

As the Ngram model extends its influence, Google continues to tinker, making improvements to the Ngram Viewer's already slick interface. Last year saw a major upgrade, with a sizable increase in the underlying data spanning English and seven other languages, as well as the introduction of part-of-speech tagging and mathematical operators that allowed for more sophisticated searches. Today, meet Ngram Viewer 3.0. While the corpus itself hasn't expanded in this version, the search features have become even more useful, especially now that wildcards are in the mix.

Anyone who has spent time delving into databases knows how much flexibility you can get with wildcards: use an asterisk to stand in for any word, and suddenly your search horizons have expanded. In the new Ngram Viewer, using the asterisk as a wildcard will display the top ten most frequently appearing words that fill the slot over the range of time you have selected. The asterisk can be combined with parts of speech, too, so "*_NOUN" will find only the nouns that could appear in the sequence of words you're searching on.

Now if you type "*_NOUN 's theorem" into the Ngram Viewer, you will see a graph with the ten most common names (which count as nouns) that have spawned eponymous theorems — names like Godel, Bayes, and Euler. (Right-clicking will toggle back and forth between a view tracking the different variants and one showing a single line encompassing all the variants.)

When the Google project team (Jon Orwant, Slav Petrov, and Dipanjan Das) gave me a sneak peek at the new version of the Ngram Viewer, I had no shortage of wildcard searches to test out. On Twitter, I've fielded questions like "Besides media moguls, what other moguls are there?" and "What can be ragtag other than a bunch?" It's possible to answer these questions using the publicly available corpora compiled by Mark Davies at Brigham Young University, but the peculiar interface can be off-putting to casual users. With the Ngram Viewer, you just need to enter a search like "*_NOUN mogul" or "ragtag *_NOUN" and select a year range. It turns out that in 20th-century sources, media moguls are joined by movie moguls, real estate moguls, and Hollywood moguls, while the most likely things to be ragtag are armies, groups, and bands.

You can also compare different slices of the overall dataset. Let's say you want to know the most typical prepositions that precede the street in American and British varieties of English. (Any American who has puzzled over Madness singing "Our house, in the middle of the street" will know that prepositions work a bit differently on the other side of the pond.) It turns out that in the street is the most frequent prepositional phrase in British English, while on the street currently leads the pack in American English.

All of this wildcard goodness isn't restricted to the English section of the corpus, either. In English, you can discover that the nouns that most often serve as the object of the verb drink include waterwinecoffeebeer, and tea. But you can do the same search on the German verb trinken to find a different ranking of beverages: Kaffee (coffee) and Bier (beer) are on top, followed by Wein (wine), Wasser (water), and Tee (tea).

I expect that one salutary effect of the new wildcard searches will be to encourage more nuanced searching, instead of simply running the numbers on individual words and phrases devoid of context. Some of the scholarly work in the burgeoning field of "culturomics" has relied on Ngram data without bothering to dig much deeper than relative frequencies of single words. For instance, an article appearing earlier this year in the journal Psychological Science purported to demonstrate that "individualistic and materialistic values" are on the rise simply by looking at the changing fortunes of word pairs like give vs. get.

While get has become more frequent relative to give, does that mean we're becoming more selfish? As Mark Liberman suggested on Language Log, the rise in get usage could be due to phrasal patterns that have nothing to do with acquiring material possessions, since get can be used with adjectives (get sick) or passive verbs (get acquainted). And sure enough, with wildcard searching we can quickly see increases in "get + adjective" (like get betterget ready, and get drunk) and "get + verb" (like get marriedget involved, and get started).

In addition to wildcards, the new Ngram Viewer introduces a couple of other welcome changes: variation in capitalization and inflection can be accounted for. The previous version was always case-sensitive, but now you can check a "case-insensitive" box if you want to look at forms with varying capitalization all at once. Right-clicking on the line will then display the most common case variants, each on its own line in the graph. So, for instance, a case-insensitive search on aids will expand to show the rapid rise of AIDS (as opposed to aids or Aids) since 1980.

Similarly, different inflections, such as variants of a verb with -s-ed-ing, or no ending, can be split out into different lines or summed together, all with a right-click. For the interactivity of the graphs, we can thank one of the three college interns that Google hired to work on the project this summer. Jason Mann of Columbia, David Zhang of USC, and Lu Yang of Cornell all worked on the Ngram Viewer, and Mann came up with the idea of using interactive charts to break out and merge lines for different variants.

While the Ngram Viewer remains one of Google's "20 percent time" projects, meaning that it isn't a high priority for the engineers working on it, it is heartening to see continued improvements to satisfy all of us Ngram-heads. It's also notable that Google's dictionary, which pops up in search results when you're looking to define a word (like, say, literally), now includes a graph of relevant Ngram results. Clicking on the graph in the dictionary entry takes the user to the Ngram Viewer, which should guarantee a steady stream of new devotees to the addictive world of Ngrams. Now more than ever, it's a glorious time suck for professional and amateur researchers alike.