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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 18, 2013, 7:59 AM EDT
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
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 18, 2013, 8:21 AM EDT
http://www.codeproject.com/Articles/19435/An-ASP-NET-Spell-Checker-for-a-Textbox
http://www.codeproject.com/Articles/7594/Spell-check-text-area
Hemant SrivastavaRank #581 · 4.2K reputationPosted Jul 18, 2013, 10:23 AM EDT
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.
Hanuma Y7 reputationPosted Jul 18, 2013, 8:46 PM EDT
Hanuma Y7 reputationPosted Jul 18, 2013, 8:46 PM EDT
Hemant SrivastavaRank #581 · 4.2K reputationPosted Jul 19, 2013, 5:57 AM EDT
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 Y7 reputationPosted Jul 21, 2013, 8:40 PM EDT
Gaurav Bari5 reputationPosted Feb 20, 2015, 12:35 AM EST