【问题标题】:bug in NHunspell spelling checkerNHunspell 拼写检查器中的错误
【发布时间】:2011-10-24 08:42:12
【问题描述】:

我正在使用 NHunspell 来检查拼写。我添加了 NHunspell.dll 作为对我的 asp.net 页面的引用。我添加了命名空间 System.NHunspell。 我面临的问题与 IDisposible 有关。 我把下载的NHunspell的代码放在按钮事件里面。

protected void Button1_Click(object sender, EventArgs e) {

        using (Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic"))
        {
            bool correct = hunspell.Spell("Recommendation");
            var suggestions = hunspell.Suggest("Recommendatio");
            foreach (string suggestion in suggestions)
            {
                Console.WriteLine("Suggestion is: " + suggestion);
            }
        }

        // Hyphen
        using (Hyphen hyphen = new Hyphen("hyph_en_us.dic"))
        {
            var hyphenated = hyphen.Hyphenate("Recommendation");
        }


*  using (MyThes thes = new MyThes("th_en_us_new.idx", "th_en_us_new.dat"))
        {
            using (Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic"))
            {
                ThesResult tr = thes.Lookup("cars", hunspell);
                foreach (ThesMeaning meaning in tr.Meanings)
                {
                    Console.WriteLine("  Meaning: " + meaning.Description);
                    foreach (string synonym in meaning.Synonyms)
                    {
                        Console.WriteLine("    Synonym: " + synonym);

                    }
                }
            }


        }

上面显示的*是错误行。错误是: " 在 using 语句中使用的类型必须隐式转换为 'System.IDisposable'"。

该行还有一条警告:“'NHunspell.MyThes.MyThes(string, string)' 已过时:'idx 文件不再需要,MyThes 完全在内存中工作'”;

谁能帮我改正这个???

好的,我将该行更改为 MyThes thes = new MyThes("th_en_us_new.dat");错误消失了。

但是有一个异常“AFF File not found: E:\programfiles\visual studio\Common7\IDE\en_us.aff”。我该怎么办??

【问题讨论】:

    标签: c#


    【解决方案1】:

    您是否尝试将行更改为:

    MyThes thes = new MyThes("th_en_us_new.dat");
    

    您是否在 C:\ 驱动器上搜索过 en_us.aff 文件?在您原始的 NHunspell 压缩下载中,您应该可以找到该文件。您只需将该文件复制到 E:\programfiles\visual studio\Common7\IDE\ 目录中就足够了。

    【讨论】:

    • 下载的 NHunspell 仅包含 NHunspell.dll、NHunspellx64.dll、NHunspellx86.dll。
    • 如果您是 CodeProject 的成员,请从codeproject.com/KB/recipes/hunspell-for-net.aspx 下载 zip 文件
    • 现在又多了一个例外:“未找到 Hunspell Intel 32Bit DLL:C:\Documents and Settings\Nikhil K\My Documents\Visual Studio 2008\Projects\splee\splee\Hunspellx86.dll”。行:“使用(Hunspell hunspell = new Hunspell(“en_us.aff”,“en_us.dic”))”。请帮帮我..
    • Rason:我已将 MyThes 从包装器更改为完全托管的版本。所以不再需要 IDisposable 的东西了
    • 有什么比 HUNSPELL 更好的吗?
    【解决方案2】:

    如果MyThes 不支持IDisposable,则不要使用using。对于Obsolete - 在MyThes 上按 F12 并选择没有过时属性的构造函数

    【讨论】:

    • 还有什么比 hunspell 更好的吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-06
    • 1970-01-01
    • 2012-03-04
    • 2012-12-05
    相关资源
    最近更新 更多