Resolved Which Spell Checker to Use

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
141
Programming Experience
10+
I'm presently using a reference to Microsoft.Office.Interop.Word to effect spell checking.

I figured I like to divorce from Word so I'm trying to find out the best way to go.

NHunspell seemed at first attractive because it's for .NET, then I believe, I if my checking is correct, it's unchanged since 2015 and its users are unknown to me.

So, I downloaded "Hunspell richedit_sample" from Source Force which seems to have well known user, but it's CPP and when I compiled the example, I got missing file errors.

Then I used Visual Studio's "Manage Nuget Packages" in VS2022 and searched for Hunspell and it shows both NHunspell and Hunspell.Native with NHunSpell having many more downloads.

So, my question is:

Do you have a recommendation what spell checker to use with a VB.NET VS202 application?

I'm not asking for help implementing it, yet. Only what to study and maybe the best way to add it to my application.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,717
Location
Sydney, Australia
Programming Experience
10+
The Hunspell.Native NuGet package says this:
NHunspell Spell Checker native DLLs.
The NHunspell NuGet package says this:
It is an alternative to NetSpell, GNU Aspell, ISpell, PSpell and Enchant. It wraps the native libraries for Hunspell and Hyphen and contains a fully managed version of MyThes.
It appears that the latter uses the former, although not as an explicit dependency.

It's also worth noting that there is a NHunspell.Patched package as well, with a different owner and updated in 2020. I assume that someone has addressed an issue with the original package. The only difference in the readme is that the patched version says this:
This version of the nuget package automatically copies the native binaries to the output directory.
That seems to suggest that the original version would require you to do that yourself, maybe by installing the native package as well.
 

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
141
Programming Experience
10+
I found the NHunspell.Patched package and installed it. It ended up in my Profile folder.

I think I would have preferred it in my solution folder but that's not a big problem.

I used the Manage Packages for Solution to install it in the project that needs it.

And I see it under Dependencies

But I cannot find a way to reference it so I can use it.

1) How is that done?

2) I'm using Any CPU so do I need to reference both the 32 and the 64 dll?
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,603
Location
Norway
Programming Experience
10+
WPF textboxes has spellchecking integrated, these threads also explain hosting that in winforms using ElementHost:
 

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
141
Programming Experience
10+
JohnH:

I'm not looking for a textbox with spell check.

Just, how to spell check a String.

What I need to find out is, in general, how to include a package n a VB project.

Even if I did not need the spell check, now that I realize how little I know about packages, I'd like to earn about them

Thanks
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,717
Location
Sydney, Australia
Programming Experience
10+
But I cannot find a way to reference it so I can use it.

1) How is that done?
It's already done. Installing the package references the included DLL(s). You now just use the types contained therein like you would any other types. If you don't want to have to qualify the type names in your code, add an appropriate using statement at the top of the file to import the appropriate namespace. If you want to see what libraries, namespaces and types your project has access to, open the Object Browser.
2) I'm using Any CPU so do I need to reference both the 32 and the 64 dll?
The NuGet package should handle that automatically.
 

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
141
Programming Experience
10+
I did as you suggest but
Imports NHunspell.Patched
gives BC40056 error.

Also, using it in code does not work.

So, I tried it with System.Management just to see if I was doing it right.

The vbproj file now has:
<ItemGroup>
<PackageReference Include="NHunspell.Patched" Version="1.2.5554" />
<PackageReference Include="System.Management" Version="7.0.0-preview.1.22076.8" />
</ItemGroup>

Imports System.Management
Reports no error and the code works ok.

Could NHunspell.Patched by incompatible with NET6?

I tried different imports like:
Imports NHunspell
Imports Hunspell
In desperation, but nothing I tried works.

NHunSpell shows in Object Browser

Got any magic you can share?
 
Last edited:

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,603
Location
Norway
Programming Experience
10+
Solution

aaaron123@roadrunner.com

Well-known member
Joined
Jan 23, 2011
Messages
141
Programming Experience
10+
WeCantSpell.Hunspell seems to work well for Net6 and has many downloads.

I presume these people learned how to use it.

I don't know how, I looked and looked.

I found a few things I can get it to do but can't find sufficient documentation or samples to do a good job using it.

Can you help?


UPDATE:

I downloaded the WeCantSpell.Hunspell source code an opened it in VS2022.

Hoping I could find the Public Functions that I know work and then learn some others but it's just too big (or my weak C#)

Anyway, I'll look some more but it doesn't look like I'll be able to use WeCantSpell.Hunspell

I did find WordList.Suggest which take a word, not a string of words like MSWord takes.

Too bad, I liked the Word approach,

But I can't seem to find anything I did not already know.
 
Last edited:

Latest posts

Top Bottom