【问题标题】:Using the C# NHunspell how do I check words?使用 C# NHunspell 如何检查单词?
【发布时间】:2013-02-21 13:17:27
【问题描述】:

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

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

但是在阅读文档方面有点新手,很难知道从哪里开始。有人可以举例说明如何检查单词是否拼写正确吗?基本上我需要一个用于 NHunspell 的 Helloworld。

【问题讨论】:

标签: c# spell-checking hunspell nhunspell


【解决方案1】:
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

【讨论】:

  • 如何获取所有单词?我的意思是扫描 dic 文件的每一行并获取可以从该行生成的所有组合。我怎样才能做到这一点? ty
  • 当我尝试实现这一点时,我收到错误“找不到 AFF 文件”。在哪里可以找到或下载 hunspell。
  • 您可以从开放式办公室获取,有用于拼写检查的词典。使用 7zip 或其他存档查看器打开它并解压缩文件。
  • @ThomasMaierhofer - 您能否分享任何参考链接以了解 AFF 和 .DIC 文件的用途。
猜你喜欢
  • 1970-01-01
  • 2017-06-22
  • 2014-08-03
  • 1970-01-01
  • 2016-03-01
  • 1970-01-01
  • 2013-05-27
  • 2016-05-29
  • 1970-01-01
相关资源
最近更新 更多