首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用C# NHunspell如何检查单词?

使用C# NHunspell如何检查单词?
EN

Stack Overflow用户
提问于 2013-03-07 00:19:55
回答 1查看 8.5K关注 0票数 6

如何使用C# NHunspell检查单词的拼写是否正确,如果拼写不正确,应如何进行拼写检查?

我已经将NHunspell.dll导入到项目中。并查看了the documentation

但是,作为阅读文档的新手,很难知道从哪里开始。有人能提供一个如何检查单词拼写是否正确的例子吗?基本上,我需要一个用于NHunspell的Helloworld。

EN

回答 1

Stack Overflow用户

发布于 2013-04-01 01:56:39

代码语言:javascript
复制
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

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15252596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档