Code for Spell Check
can i get a c# code for spell check..? source should be from a text file..which is a notepad(user defined words)
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gaurav BariPosted Feb 20, 2015, 5:35 AM
Hanuma YPosted Jul 22, 2013, 12:40 AM
Hemant SrivastavaPosted Jul 19, 2013, 9:57 AM
If you don't want to use any DLL and like to use your own logic, then basically you pretty much need to build your own dictionary with correct words... (or use some existing dictionary if avaiable). Store that dictionary in a .Net Dictionary or .Net HashTable collection (both have KeyValuePair) instead of using any .Net List. Array etc. so that your search won't take much time. These collection are pretty fast in searching.
Whenever you read any word from textfile, seacrh that word in this collection (e.g. using ContainKey()) method. If word is in, signal 'Correct Word' otherwise 'Wrong Word or not found in dictionary'.
Hanuma YPosted Jul 19, 2013, 12:46 AM
Hanuma YPosted Jul 19, 2013, 12:46 AM
Hemant SrivastavaPosted Jul 18, 2013, 2:23 PM
Then try this method:
//This methods reads words from a text file and check spelling
// FilePath = "C:\\Test\\WordsList.txt";
public void SpellCheck(String FilePath)
{
//FilePath = "C:\\Test\\WordsList.txt";
Boolean IsWordCorrect;
String sResult;
Object filler = null;
Microsoft.Office.Interop.Word.Application appWord = null;
try
{
appWord = new Microsoft.Office.Interop.Word.Application();
string word = string.Empty;
using (StreamReader sr = new StreamReader(FilePath))
{
while ((word = sr.ReadLine()) != null)
{
Console.Write("Word: " + word);
IsWordCorrect = appWord.CheckSpelling(word, ref filler, ref filler, ref filler, ref filler, ref filler, ref filler, ref filler, ref filler, ref filler, ref filler, ref filler, ref filler);
if (IsWordCorrect)
{
Console.WriteLine("\t\tCorrect Spelling");
}
else
{
Console.WriteLine("\t\tWrong Spelling");
}
}
}
}
catch (Exception Ex)
{
sResult = "Exception occurred:" + Ex.Message;
}
finally
{
if (appWord != null)
{
appWord.Quit(ref filler, ref filler, ref filler);
}
}
}
Hope it will help.
Sanjeeb LenkaPosted Jul 18, 2013, 12:21 PM
http://www.codeproject.com/Articles/19435/An-ASP-NET-Spell-Checker-for-a-Textbox
http://www.codeproject.com/Articles/7594/Spell-check-text-area
Iftikar HussainPosted Jul 18, 2013, 11:59 AM
Please refer the below link
http://www.codeproject.com/Articles/7594/Spell-check-text-area
http://www.codeproject.com/Articles/2469/SpellCheck-net-spell-checking-parsing-using-C
Regards,
Iftikar