bug in NHunspell spelling checker
I am using NHunspell for checking spelling.I added NHunspell.dll as a reference to my asp.net page.I added the namespace System.NHunspell. The problem i am facing is related to IDisposible. I put the downloaded code of NHunspell inside the button event.
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);
}
}
}
}
The * shown above is the line of error.The error is: " type used in a using statement must be implicitly convertible to 'System.IDisposable'".
Also there is a warning on that line :"'NHunspell.MyThes.MyThes(string, string)' is obsolete: 'idx File is not longer needed, MyThes works completely in memory'";
Can any one help me to correct this???
ok, I changed that line to MyThes thes = new MyThes("th_en_us_new.dat"); bug is gone.
But there is an e开发者_运维技巧xception "AFF File not found: E:\programfiles\visual studio\Common7\IDE\en_us.aff". what i should do??
Did you try changing the line to:
MyThes thes = new MyThes("th_en_us_new.dat");
Have you done a search for the en_us.aff file on your C:\ drive? In your original zipped download of NHunspell, you should find this file. It might just be enough for you to copy that file into the E:\programfiles\visual studio\Common7\IDE\ directory.
don't use using
then, if MyThes
doesn't support IDisposable
. For Obsolete
- press F12 on MyThes
and pick constructor without obsolete attribute
精彩评论