Articles → .NET → Spell Checker Using Hunspell C#

Spell Checker Using Hunspell C#






Getting Components




ComponentURL
Hunspell DLLs (Hunspellx64.dll, Hunspellx86.dll and Hunspell.dll)http://download.crawler-lib.net/
en_US.affhttp://sourceforge.net/p/nhunspell/code/ci/default/tree/NHunspellSamples/CSharpConsoleSamples/en_US.aff
en_US.dichttp://sourceforge.net/p/nhunspell/code/ci/default/tree/NHunspellSamples/CSharpConsoleSamples/en_US.dic




  1. Add the reference of all the DLLs (that is specified in preceding table)
  2. Copy en_us.aff and en_us.dic at C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0

Hunspell Methods




  1. Spell – This method checks the spelling of input string (English). If the spelling is correct then the method returns true else false.
  2. Suggest – In this method we will pass a string and this method will return the suggestions.

Sample Application




using System;
using System.Collections.Generic;
using NHunspell;

public partial class _Default: System.Web.UI.Page {
  protected void Page_Load(object sender, EventArgs e) {
    using(Hunspell hunspell = new Hunspell("en_us.aff", "en_US.dic")) {
      bool result = hunspell.Spell("table");

      List < string > suggestions = hunspell.Suggest("intance");
    }
  }
}





Output


Picture showing the output of Spell checker using Hunspell C#
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, June 1, 2015

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250