Check if word in english dictionary programmatically in c#
I want to check if a word is in English dictionary and make it a tag. All i know is that NetSpell has a dll but i don't know h开发者_如何学JAVAow to check it.
This is the solution:
NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();
oDict.DictionaryFile = "en-US.dic";
//load and initialize the dictionary
oDict.Initialize();
string txtWords = Company;
NetSpell.SpellChecker.Spelling oSpell = new NetSpell.SpellChecker.Spelling();
oSpell.Dictionary = oDict;
char []chDelims = {' ','\n', '\t', '\r'};
foreach (string s in txtWords.Split(chDelims))
{
if (s.Length > 0 && oSpell.TestWord(s))
{
//Do something here...
}
}
精彩评论