A pair of words are considered similar if they mean the same thing, or are used in the same context, for example teacher, students, classroom. Words are also similar if one is a type of another, for example terrier, dog, and mammal. Measuring similarities between words is needed in many text mining tasks.
Baseball and cricket are two games with lots of similarities. Both are bat and ball games; both games are scored in runs and judging is done by umpires. Given the similarities of baseball and cricket, I thought it would be interesting to measure the conceptual or semantic similarity between the words “baseball” and “cricket” using the normalized Google distance (NGD). The NGD measure of word similarity represents an interesting approach using Google search engine. The logic behind this approach is that if two words have similar meaning, or are used in a similar context, then the chances of both words occurring together on a large number of web pages are high. On the other hand, if a pair of words has nothing in common then there will be relatively fewer web pages having both words. This idea was proposed by Rudi L. Cilibrasi and Paul M.B. Vitanyi in a paper in 2007. The NGD between two words, x and y, is computed using the following formula:
The total number of web pages can be estimated using any common word, for example “the” present on every page. To calculate the NGD between a pair of words, all we have to do is use the Google search engine three times to get the respective number of pages. There is even a web based calculator that one can use for this.
To put the similarity between “baseball” and “cricket” in perspective, I decided to pick another eight words related to different sports. These are: “soccer”, “football”, “basketball”, “hockey”, “skiing”, “surfing”, and “swimming”. Using the web based NGD calculator, I ended up obtaining the following matrix representing NGD between different word pairs.
Using R, I decided to cluster these words using single link clustering. The resulting dendrogram is shown below.
Now this clustering result shows some interesting results; it doesn’t show baseball and cricket close to each other but rather baseball and basketball are shown to be most similar. It also shows hockey, football, and soccer to be close to each other. One explanation why baseball and basketball are deemed most similar on the basis of the NGD is that both these games are predominantly North American games and a very large number of websites in USA are devoted to sports as well as all newspapers carry stories about these sports. On the other hand, cricket playing countries, for example Australia, England, India, Pakistan, Sri Lanka, do not play baseball and thus websites from these countries are not likely to have mention of both baseball and cricket on the same page.
So what can we say about NGD from this simple exercise? Well! the NGD appears to have a hidden geographical component in it and there might be an application where this could be exploited.