简体   繁体   English

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

[英]Using the C# NHunspell how do I check words?

Using the C# NHunspell, how do I check if a word is spelled correctly and if not what the correct spelling is? 使用C#NHunspell,如何检查单词是否拼写正确,如果不正确拼写是什么?

I've imported the NHunspell.dll into the project. 我已将NHunspell.dll导入到项目中。 And have looked at the documentation . 并查看了文档

But being a bit new at reading documentation it's hard to know where to start. 但是在阅读文档方面有点新意,很难知道从哪里开始。 Can someone provide an example on how to check if a word is spelled correctly? 有人可以举例说明如何拼写单词拼写正确吗? Basically I need a Helloworld for NHunspell. 基本上我需要一个NHunspell的Helloworld。

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 );
    }
}

From the Article http://www.codeproject.com/Articles/43495/Spell-Check-Hyphenation-and-Thesaurus-for-NET-with 来自文章http://www.codeproject.com/Articles/43495/Spell-Check-Hyphenation-and-Thesaurus-for-NET-with

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM