NHunspell Spell Checker Error

I use NHunspell for spell checking. I added NHunspell.dll as a link to my asp.net page. I added the System.NHunspell namespace. The problem I am facing is related to IDisposible. I put the loaded NHunspell code 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);

                    }
                }
            }


        }

Shown above * is an error line. Error: "used in the using statement must be implicitly converted to" System.IDisposable ".

There is also a warning in this line: "NHunspell.MyThes.MyThes (line, line)" is deprecated: "idx File is no longer needed, MyThes works completely in memory";

Can someone help me fix this?

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

"AFF : E:\programfiles\visual studio\Common7\IDE\en_us.aff". ?

+3
2

:

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

en_us.aff C: \? Zune NHunspell . E:\programfiles\visual studio\Common7\IDE \.

+1

using, , MyThes IDisposable. Obsolete - F12 MyThes

0
source

Source: https://habr.com/ru/post/1742307/


All Articles