Click here to Skip to main content
11,790,021 members (51,008 online)
Click here to Skip to main content spell checking parsing using C#

, 19 Jun 2002 132.4K 2.7K 54
Rate this:
Please Sign up or sign in to vote.
Online spell checking using C# and regular expressions.


SpellCheck.NET is free online spell checking site. Whenever I need to check my spelling I visit this site, so I decided to write a parser for this site. I wrote this parser with C# and wrapped it up in a DLL file and called it Word.dll. In this article I will show you how to parse a HTML page using regular expressions. I will not explain all the source code since it is available for download. My main purpose of this project is to demonstrate how to parse a HTML page using regular expressions. 

Before this project I have never worked with regular expressions seriously, so I decided to use regular expressions. In this project I have learned a lot about C# regular expressions and .NET framework. The difficult part was in this project writing regular expressions pattern. So I referred to different sites and books to get the right pattern.

Here are some useful sites to check out.

About Word.dll

Word.dll has one public class and two public methods

  1. Public Class SpellCheck

       Include "using Word.dll" at the top of file for the object reference.

       SpellCheck word = new SpellCheck();
  2. Public Method CheckSpelling

    This method will check the word and return true or false. If the word is correct then it will return true otherwise false.

       bool status = false;
       status = word.CheckSpelling("a word");
  3. Public Method GetSpellingSuggestions

    This method will return the collection of suggested words.

    foreach(string suggestion in word.GetSpellingSuggestions("a word"))
       System.Console.WriteLine( suggestion );

Parser Technique

  1. Connect to site and pass the word.
  2. Look for the word "correctly." in html file, if found return true
  3. else look for the word "misspelled.", if found return false.
    regular expression pattern @"(correctly.)|(misspelled.)"
  4. If the word misspelled found in html then look for the word "suggestions:"
    regular expression pattern  @"(suggestions:)"
  5. and parse the string between <blockquote>
    regular expression pattern  @"<blockquote>(?:\s*([^<]+) \s*)+ </blockquote>"
  6. and finally return the collection of suggested words.

C# code:

Source file is included in zip format for download.

Calling Word.dll wrapper class:

This is how you would call this wrapper class in your application.

using System;

using Word;

/// <summary>
/// Test Harness for SpellCheck Class
/// </summary>
class TestHarness
    /// <summary>
    /// testing Word Class
    /// </summary>
    static void Main(string[] args)
        SpellCheck word = new SpellCheck();

        bool status = false;
        string s = "youes";

        Console.WriteLine("Checking for word : " + s );
        // check to see if the word is not correct  
        // return the bool (true|false)
        status = word.CheckSpelling(s);

        if (status == false)
            Console.WriteLine("This word is misspelled : " + s);
            Console.WriteLine("Here are some suggestions");

            foreach( string suggestion in word.GetSpellingSuggestions(s) ) 
                System.Console.WriteLine( suggestion ); 
        else if (status == true)
            Console.WriteLine("This word is correct : " + s );



Run the "compile.bat" file at the DOS prompt, it will create necessary files.


This is how your screen would look like after you execute TestHarness.exe file.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Waheed Khan
Web Developer
United States United States
Currently working with C# and ASP.NET.

You may also be interested in...

Comments and Discussions

Generalresults are wrong Pin
Member 1148896210-May-15 10:15
memberMember 1148896210-May-15 10:15 
Questionproblem with Pin
Petr Semrád5-Jun-13 22:29
memberPetr Semrád5-Jun-13 22:29 
GeneralOpen Office Spellchecker for .NET + Hyphenation + Thesaurus Pin
Thomas Maierhofer16-Nov-09 6:22
memberThomas Maierhofer16-Nov-09 6:22 
GeneralRelated Dictionaries Pin
Vasudevan Deepak Kumar29-Jan-07 23:39
memberVasudevan Deepak Kumar29-Jan-07 23:39 
GeneralDictionaries Pin
Franck Quintana25-Oct-06 7:36
memberFranck Quintana25-Oct-06 7:36 
GeneralRe: Dictionaries Pin
Vasudevan Deepak Kumar19-Mar-07 6:15
memberVasudevan Deepak Kumar19-Mar-07 6:15 
GeneralRe: Dictionaries Pin
Franck Quintana19-Mar-07 6:37
memberFranck Quintana19-Mar-07 6:37 
QuestionCopyright? Pin
jmw17-Aug-06 8:33
memberjmw17-Aug-06 8:33 
AnswerRe: Copyright? Pin
Vasudevan Deepak Kumar19-Mar-07 6:15
memberVasudevan Deepak Kumar19-Mar-07 6:15 
GeneralDeveloping a spell checker Pin
mad_68421-Jan-05 19:41
membermad_68421-Jan-05 19:41 
GeneralRe: Developing a spell checker Pin
Vasudevan Deepak Kumar19-Mar-07 6:13
memberVasudevan Deepak Kumar19-Mar-07 6:13 
Generalcheck existance of word.dll Pin
bunny rabbit4-Feb-04 17:29
sussbunny rabbit4-Feb-04 17:29 
GeneralRe: check existance of word.dll Pin
Vasudevan Deepak Kumar19-Mar-07 6:13
memberVasudevan Deepak Kumar19-Mar-07 6:13 
GeneralWord.dll Pin
halegua9-Mar-03 19:58
memberhalegua9-Mar-03 19:58 
When can I get the "word.dll" , thanks.
GeneralRe: Word.dll Pin
Vasudevan Deepak Kumar19-Mar-07 6:14
memberVasudevan Deepak Kumar19-Mar-07 6:14 
GeneralThe Google Version Pin
Blake Coverett20-Jun-02 17:42
memberBlake Coverett20-Jun-02 17:42 
GeneralRe: The Google Version Pin
Nick Parker23-Jun-02 17:39
memberNick Parker23-Jun-02 17:39 
GeneralRe: The Google Version Pin
pareshgheewala29-Mar-05 23:06
memberpareshgheewala29-Mar-05 23:06 
GeneralRe: The Google Version Pin
Nick Parker30-Mar-05 1:52
protectorNick Parker30-Mar-05 1:52 
GeneralRe: The Google Version Pin
Vasudevan Deepak Kumar19-Mar-07 6:14
memberVasudevan Deepak Kumar19-Mar-07 6:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.1509028.1 | Last Updated 20 Jun 2002
Article Copyright 2002 by Waheed Khan
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid