Articles → .NET → Spell Checker Using Hunspell C#
Spell Checker Using Hunspell C#
Getting Components
- Add the reference of all the DLLs (that is specified in preceding table)
- Copy en_us.aff and en_us.dic at C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0
Hunspell Methods
- Spell – This method checks the spelling of input string (English). If the spelling is correct then the method returns true else false.
- 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
Click to Enlarge