首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NHunspell拼写检查器中的错误

NHunspell拼写检查器中的错误
EN

Stack Overflow用户
提问于 2010-04-22 23:54:16
回答 2查看 2.1K关注 0票数 3

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

受保护的无效发送者(object Button1_Click,EventArgs e) {

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

                    }
                }
            }


        }

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

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

有人能帮我改正这个错误吗?

好了,我把这一行改为新的thes = MyThes MyThes("th_en_us_new.dat");bug已经消失了。

但有一个异常“未找到AFF文件: E:\programfiles\visual studio\Common7\IDE\en_us.aff”。我该怎么做??

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-04-23 00:00:26

您是否尝试将行更改为:

代码语言:javascript
复制
MyThes thes = new MyThes("th_en_us_new.dat");

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

票数 1
EN

Stack Overflow用户

发布于 2010-04-23 00:01:04

如果MyThes不支持IDisposable,那么就不要使用using。对于Obsolete -在MyThes上按F12键并拾取不带过时属性的构造函数

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

https://stackoverflow.com/questions/2692372

复制
相关文章

相似问题

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