Google Toolbar Spell Check API

I saw in this post that the Google toolbar could be extracted and looked at. So, I spend an afternoon reverse engineering the spell checker api. The api ends up to be very easy to use. Checking is done with an HTTP post to https://www.google.com/tbproxy/spell?lang=en&hl=en.

The xml structure looks like this…

<?xml version="1.0" encoding="utf-8" ?>  
<spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1">  
    <text>Ths is a tst</text>  
</spellrequest>  

The response look like …

<?xml version="1.0" encoding="UTF-8"?>  
<spellresult error="0" clipped="0" charschecked="12">  
    <c o="0" l="3" s="1">This Th's Thus Th HS</c>  
    <c o="9" l="3" s="1">test tat ST St st</c>  
</spellresult>  
Tag Description
o The offset from the start of the text of the word
l Length of misspelled word
s Confidence of the suggestion
text Tab delimited list of suggestions

I created a complete C# GoogleSpell library as a demo. The library can be download at http://www.loresoft.com/files/uploads/GoogleSpell.zip

Here is an example on how to use GoogleSpell …

string text = "ths is a tst";  
SpellRequest request = new SpellRequest(text);  
  
SpellResult result = SpellCheck.Check(request);  
  
foreach (SpellCorrection correction in result.Corrections)  
{  
    Console.WriteLine("Misspelled: {0} ({1}:{2})",   
        text.Substring(correction.Offset, correction.Length),   
        correction.Offset, correction.Length);  
  
    foreach(string suggestion in correction.Suggestions)  
    {  
        Console.WriteLine("    {0}", suggestion);  
    }  
}  

I plan to develop an ajax web client for the google spell api. This will be really sweet as it won’t require anything to be installed on the sever other then a js file. I’ll post again when I have the web client complete.



comments powered by Disqus