Posted by Paul Welter on Tuesday, July 19 2005 at 12:29 AM

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.

~ Paul

File: GoogleSpell.zip Size: 18,865 kB

4 Comments Posted in: Projects / NetSpell    Tagged as: , ,

Similar Posts

  1. The NetSpell project
  2. How to integrate NetSpell with FreeTextBox
  3. How to create a custom dictionary

Comments

Show/Hide Trackbacks
#1 Comment by xiaohui on 7/06/2009 at 3:18 AM
Gravatar for xiaohui

ffsdfsd

#2 Comment by Stuart Duncan on 1/07/2010 at 10:36 AM
Gravatar for Stuart Duncan

Any luck with the AJAX library for this spellchecker?

#3 Comment by Richard Garicia on 1/08/2010 at 12:57 AM
Gravatar for Richard Garicia

the code doesn't work

Leave a Comment