gpt4 book ai didi

c# - NHunspell 拼写检查器中的错误

转载 作者:行者123 更新时间:2023-11-30 18:09:06 48 4
gpt4 key购买 nike

我正在使用 NHunspell 检查拼写。我添加了 NHunspell.dll 作为对我的 asp.net 页面的引用。我添加了 namespace 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)' is obsolete: 'idx File is not longer needed, MyThes works completely in memory'”;

谁能帮我改正这个问题???

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

但出现异常“找不到AFF文件:E:\programfiles\visual studio\Common7\IDE\en_us.aff”。我该怎么办??

最佳答案

您是否尝试将行更改为:

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

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

关于c# - NHunspell 拼写检查器中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2692372/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com