<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks


Find meanings of a bunch of words at once with Google Spreadsheet

A relative recently asked me if there was a quick way to find the meanings of a list of words all at once. I use & recommend WordWeb to look up difficult words but it takes one word/phrase a time.

I knew about the nifty GoogleLookup function in Google Spreadsheet that fetches "straightforward facts about specific things", but it does not fetch definitions from Google Dictionary as I had imagined. So, I turned to the ImportXML function to scrape the meaning of each word from Google Dictionary.


ImportXML() takes two input parameters URL & queryURL is the URL of the XML or HTML file from which information will be fetched while query represents the XPath query to run on the data given at the URL.


If you were manually looking for the meaning of pipsqueak on Google Dictionary, this is how the URL in your browser address-bar would look when you submit the request -
http://www.google.com/dictionary?q=pipsqueak&hl=en&langpair=en|en&spell=1&oi=spell


You'll notice that the word we submitted goes into a querystring value (q=pipsqueak). To automatically fetch definitions of multiple words at once, I placed the list of words in column A with the first one going into cell A2. In cell B2, I typed this formula -
=ImportXML("http://www.google.com/dictionary?aq=f&langpair=en|en&q="&A2&"&hl=en","//ul[@id='pr-root']")

If you look closely at that formula, you'll see that I inserted the cell number (A2) into the first argument of the function. Now, as we are interested in only the portion of the Google Dictionary page that shows the meaning of the word, we will grab only that content using a XPath query. The definition of the word is rendered in the HTML source code of the Google Dictionary page within an ordered list which has the value 'pr-root' for its ID attribute.
(click on image to enlarge)

After you finish typing the formula, press the Enter key & within a few seconds, the meaning of the word will get populated in the cell B2.

While the focus is on the cell B2, you can copy the formula to the rest of cells for which you want the definitions in column B by dragging at the edge of tiny blue box that appears at the bottom right corner of cell B2. This process will dynamically change the column A cell numbers in the formula & bingo......the meanings of the remaining words in column A will get populated in the column B.

(click on image to enlarge)

Labels:

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

Posted by Anonymous Anonymous | 1/09/2012 08:00:00 AM

doesn't work! :(    



Posted by Anonymous Anonymous | 2/08/2012 08:31:00 PM

This trick depends on Google Dictionary. The Google Dictionary website was terminated on August 5, 2011http://en.wikipedia.org/wiki/Google_Dictionary

This trick can be adapted to work with other online dictionaries like thefreedictionary.com    



Posted by Anonymous Anonymous | 6/12/2012 03:33:00 AM

Thanks for the tip. I managed to workout using Thesaurus.com by using the formula:

=index(importhtml("http://thesaurus.com/browse/"&B7&"?s=t";"table",1),3,2)

Cheers    



Posted by Blogger Oliver Rose | 5/01/2013 08:37:00 AM

I would love to be able to use this - can I get a little more instruction on how to do it?
Thanks in advance,
Oliver    



»

Post a Comment