First I started with SourceForge NetSpell project.
But it has so many limitations.They are maintaining a dictionary in the application.
It is not having all the words.
 
Then I tried with yahoo , google apis which are having licensing problems and right now Google is not issuing keys for their APIs.
 
Then I went this final approach "Screen Scrapping"
 
I used google spell check .
If you type anything wrong in google search box it will give a suggestion " Did you mean?: [the suggested text]"
 
I am parsing that text "Did you mean" and I am catching that suggested text for my application
 
And the code is below:
 
By using HttpWebRequest and HttpWebResponse I am reading and getting the content (Screen Scrapping) and storing the text in
and at this place (  "spell=1\" class=p>";  ) Google is giving the suggested text . I am parsing between "did you mean and the suggested text".

string lcUrl = "http://www.google.co.in/search?hl=en&q=" + txtbox.Text;

// *** Establish the request

HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create(lcUrl);

// *** Set properties

loHttp.Timeout = 10000;

// 10 secs

loHttp.UserAgent = "Code Sample Web Client";

// *** Retrieve request info headers

HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();

Encoding enc = Encoding.GetEncoding(1252); // Windows default Code Page

StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc);

string lcHtml = loResponseStream.ReadToEnd();

loWebResponse.Close();

loResponseStream.Close();

string result;

int start, end;

string searchTerm = "spell=1\" class=p>";

string endTerm = "</a>";

start = lcHtml.IndexOf(searchTerm);

if (start == -1)

{

}

else

{

end = lcHtml.IndexOf(endTerm, start);

result = lcHtml.Substring(start + searchTerm.Length, end – (start + searchTerm.Length));

result = result.Replace(

"<b>", string.Empty);

result = result.Replace(

"</b>", string.Empty);

result = result.Replace(

"<i>", string.Empty);

result = result.Replace(

"</i>", string.Empty);

}

Advertisements

About ambatisreedhar

Developer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s