如何使用C# NHunspell检查单词的拼写是否正确,如果拼写不正确,应如何进行拼写检查?
我已经将NHunspell.dll导入到项目中。并查看了the documentation。
但是,作为阅读文档的新手,很难知道从哪里开始。有人能提供一个如何检查单词拼写是否正确的例子吗?基本上,我需要一个用于NHunspell的Helloworld。
发布于 2013-04-01 01:56:39
using (Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic"))
{
Console.WriteLine("Hunspell - Spell Checking Functions");
Console.WriteLine("¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯");
Console.WriteLine("Check if the word 'Recommendation' is spelled correct");
bool correct = hunspell.Spell("Recommendation");
Console.WriteLine("Recommendation is spelled " +
(correct ? "correct":"not correct"));
Console.WriteLine("");
Console.WriteLine("Make suggestions for the word 'Recommendatio'");
List<string> suggestions = hunspell.Suggest("Recommendatio");
Console.WriteLine("There are " +
suggestions.Count.ToString() + " suggestions" );
foreach (string suggestion in suggestions)
{
Console.WriteLine("Suggestion is: " + suggestion );
}
}来自文章http://www.codeproject.com/Articles/43495/Spell-Check-Hyphenation-and-Thesaurus-for-NET-with
https://stackoverflow.com/questions/15252596
复制相似问题