Thursday, July 21, 2005

Spell Checking With Google: The Web Service

Remember that old book called a dictionary? Once upon a time, this is what we had to use to check the spelling of a word. Now instead, we can use the spell checker that comes with the free Google Toolbar for Firefox and IE. After you install the toolbar, click on the Check button of the newly added toolbar: the content of every text field and text area on your page will be checked, and spelling errors will be highlighted. Click on a highlighted word and a drop down with appear with a number of suggestions.

This is nice tool per se. But if you are looking at the requests made by your browser while you are using the toolbar, which is extremely easy on Firefox using the LiveHTTPHeaders plugin, you will notice something even more interesting: the web service behind the toolbar. How does it work? The toolbar posts on an XML document that contains the text to check on http://www.google.com//tbproxy/spell?lang=en&hl=en. The document looks like:

    <spellrequest textalreadyclipped="0" ignoredups="1"
            ignoredigits="1" ignoreallcaps="0">
        <text>what is the speling of exemple?</text>
    </spellrequest>

To this request, Google responds with this XML document:

    <spellresult error="0" clipped="0" charschecked="30">
        <c o="12" l="7" s="1">spelling spieling sapling spilling spoiling</c>
        <c o="23" l="7" s="1">example exemplar exampled examples exempt</c>
    </spellresult>

Simon Willison noticed this a few days ago and wrote an entry about it in his blog. This opens the door to a number of interesting hacks. Do you feel inspired? (Calling this service directly from your code might violate the Google EULA, so you might want to check it out to see how you feel about it.)

1 comment:

  1. If Google follows what they normally do, if enough people start using it, they'll probably just open up the API anyway.

    Thanks for this tip, I can allready see a few uses for this.

    ReplyDelete