Using the C# NHunspell how do I check words?
Asked Answered
P

1

6

Using the C# NHunspell, how do I check if a word is spelled correctly and if not what the correct spelling is?

I've imported the NHunspell.dll into the project. And have looked at the documentation.

But being a bit new at reading documentation it's hard to know where to start. Can someone provide an example on how to check if a word is spelled correctly? Basically I need a Helloworld for NHunspell.

Pederasty answered 6/3, 2013 at 16:19 Comment(3)
codeproject.com/Articles/33658/…Glisten
Also, browse the unit tests: nhunspell.svn.sourceforge.net/viewvc/nhunspell/trunk/UnitTests/…Glisten
I actually ended up using NetSpell because it was easier to implement. Thank you though!Pederasty
S
9
using (Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic"))
{
    Console.WriteLine("Hunspell - Spell Checking Functions");
    Console.WriteLine("¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯");

    Console.WriteLine("Check if the word 'Recommendation' is spelled correct"); 
    bool correct = hunspell.Spell("Recommendation");
    Console.WriteLine("Recommendation is spelled " + 
       (correct ? "correct":"not correct"));

    Console.WriteLine("");
    Console.WriteLine("Make suggestions for the word 'Recommendatio'");
    List<string> suggestions = hunspell.Suggest("Recommendatio");
    Console.WriteLine("There are " + 
       suggestions.Count.ToString() + " suggestions" );
    foreach (string suggestion in suggestions)
    {
        Console.WriteLine("Suggestion is: " + suggestion );
    }
}

From the Article http://www.codeproject.com/Articles/43495/Spell-Check-Hyphenation-and-Thesaurus-for-NET-with

Sound answered 31/3, 2013 at 17:56 Comment(7)
how can we get all words? I mean scan each line of the dic file and get all combinations that can be produced from that line. how can i do that? tyPooler
codeproject.com/Articles/43495/…Pooler
When I try to implement this, I am getting error "AFF File not found". Where I can find or download it for hunspell.Isopropyl
You can get it from open office, there are dictioniaries for spell checking. Open it with 7zip or some other archive viewer and extract the files.Sound
@ThomasMaierhofer - Can you please share any reference link to understand the purpose of AFF and .DIC file.Isopropyl
github.com/hunspell/hunspell/releases There is a file format PDFSound
@ThomasMaierhofer - I want to use MPL v1.1 in my .net project. Can you please share me the external or NuGet link to download this specific version for .Net.Isopropyl

© 2022 - 2024 — McMap. All rights reserved.