开发者

Check if word in english dictionary programmatically in c#

开发者 https://www.devze.com 2023-03-05 18:00 出处:网络
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:

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...
    } 
} 
0

精彩评论

暂无评论...
验证码 换一张
取 消