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

6

使用C# NHunspell,如何检查单词的拼写是否正确,如果不正确,则正确的拼写是什么?

我已将NHunspell.dll导入到项目中,并查看了文档

但由于我在阅读文档方面有些新手,很难知道从哪里开始。能否提供一个示例,演示如何检查单词的拼写是否正确?基本上,我需要一个NHunspell的Helloworld。


1
http://www.codeproject.com/Articles/33658/NHunspell-Hunspell-for-the-NET-platform - Katie Kilian
我最终使用了NetSpell,因为它更容易实现。不过还是谢谢你! - Howard
1个回答

9
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

本文介绍了一种用于 .NET 平台的拼写检查、断字和同义词功能。它基于 NHunspell 开源库开发,支持多语言和多个字典。此外,它还提供了一个灵活的接口,使得使用者可以轻松地将其集成到他们的应用程序中。

我们如何获取所有单词?我的意思是扫描字典文件中的每一行,并获取可以从该行生成的所有组合。我该怎么做?谢谢。 - Furkan Gözükara
https://www.codeproject.com/Articles/43495/Spell-Check-Hyphenation-and-Thesaurus-for-NET-with?msg=5368357#xx5368357xx - Furkan Gözükara
当我尝试实现这个时,我遇到了“AFF文件未找到”的错误。我在哪里可以找到或下载它以供hunspell使用? - Tech Learner
1
你可以从开放办公室获取它,那里有用于拼写检查的词典。使用7zip或其他存档查看器打开它并提取文件。 - Thomas Maierhofer
https://github.com/hunspell/hunspell/releases 上有一个PDF文件格式。 - Thomas Maierhofer
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接