2011-05-14 70 views
5

我想检查一个单词是否在英文字典中,并将其作为标签。我所知道的是,NetSpell有一个DLL,但我不知道如何检查它。检查是否以英文字典编程方式在C#

+0

字典是不会赶上错误。 – 2011-05-14 18:25:30

+1

如果你想检查对第三方DLL的东西,你需要API文档。 – ZoolWay 2011-05-14 18:30:50

+2

我解决了它..人们应该停止降低我的声望。 – 2011-05-14 18:56:26

回答

7

这是解决方案:

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... 
    } 
} 
相关问题