WeCantSpell.Hunspell
2.1.0
See the version list below for details.
dotnet add package WeCantSpell.Hunspell --version 2.1.0
NuGet\Install-Package WeCantSpell.Hunspell -Version 2.1.0
<PackageReference Include="WeCantSpell.Hunspell" Version="2.1.0" />
paket add WeCantSpell.Hunspell --version 2.1.0
#r "nuget: WeCantSpell.Hunspell, 2.1.0"
// Install WeCantSpell.Hunspell as a Cake Addin #addin nuget:?package=WeCantSpell.Hunspell&version=2.1.0 // Install WeCantSpell.Hunspell as a Cake Tool #tool nuget:?package=WeCantSpell.Hunspell&version=2.1.0
WeCantSpell: Hunspell
A port of Hunspell v1 for .NET, .NET Standard, and .NET Core.
Download and install with NuGet: WeCantSpell.Hunspell
Features
- Reads Hunspell DIC and AFF file formats
- Supports checking and suggesting words
- Ported to fully managed C#
- Can be queried concurrently
- Confusing LGPL, GPL, MPL tri-license
- Compatible with .NET Core and .NET Standard
- Compatible with multiple .NET framework versions
- Uses .NET to handle cultures and encodings
License
"It's complicated"
Read the license: LICENSE
This library was ported from the original Hunspell source and as a result is licensed under an MPL, LGPL, and GPL tri-license. Read the LICENSE file to be sure you can use this library.
Quick Start Example
using WeCantSpell.Hunspell;
public class Program
{
static void Main(string[] args)
{
var dictionary = WordList.CreateFromFiles(@"English (British).dic");
bool notOk = dictionary.Check("teh");
var suggestions = dictionary.Suggest("teh");
bool ok = dictionary.Check("the");
}
}
Upstream
To know how up to date this port is, check the hunspell-origin submodule.
Performance
"Good enough I guess"
The performance of this port while not fantastic relative to the original binaries and NHunspell is definitely acceptable. If you need better performance you should check out NHunspell.
Benchmark | WeCantSpell.Hunspell | NHunspell |
---|---|---|
Dictionary Loads /s | 🐌 3.08 | 🐇 13.62 |
Words Checked /s | 🐢 724,855 | 🐇 986,026 |
Note: Measurements taken on a Intel 6700K with a 850 PRO 256GB.
Specialized Examples
Construct from a list:
static void Main(string[] args)
{
var words = "The quick brown fox jumps over the lazy dog".Split(' ');
var dictionary = WordList.CreateFromWords(words);
bool notOk = dictionary.Check("teh");
}
Construct from streams:
static void Main(string[] args)
{
using(var dictionaryStream = File.OpenRead(@"English (British).dic"))
using(var affixStream = File.OpenRead(@"English (British).aff"))
{
var dictionary = WordList.CreateFromStreams(dictionaryStream, affixStream);
bool notOk = dictionary.Check("teh");
}
}
Encoding Issues
The .NET Framework contains many encodings that can be handy when opening some dictionary or affix files that do not use a UTF8 encoding or were incorrectly given a UTF BOM. On a full framework platform this works out great but when using .NET Core or .NET Standard those encodings may be missing. If you suspect that there is an issue when loading dictionary and affix files you can check the dictionary.Affix.Warnings
collection to see if there was a failure when parsing the encoding specified in the file, such as "Failed to get encoding: ISO-8859-15"
or "Failed to parse line: SET ISO-8859-15"
. To enable these encodings, reference the System.Text.Encoding.CodePages
package and then use Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)
to register them before loading files.
using System.Text;
using WeCantSpell.Hunspell;
class Program
{
static Program() => Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
static void Main(string[] args)
{
var dictionary = WordList.CreateFromFiles(@"encoding.dic");
bool notOk = dictionary.Check("teh");
var warnings = dictionary.Affix.Warnings;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net35 is compatible. net40 was computed. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
NuGet packages (13)
Showing the top 5 NuGet packages that depend on WeCantSpell.Hunspell:
Package | Downloads |
---|---|
Dynamicweb.Admin
Package Description |
|
Dynamicweb.WeightedSearch
Weighted Search |
|
HIC.RDMP.Plugin.UI
UI package for plugin development |
|
VPKSoft.ScintillaSpellCheck
A spell checking library for the ScintillaNET. |
|
Skybrud.TextAnalysis
Hunspell text analysis package for .NET. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on WeCantSpell.Hunspell:
Repository | Stars |
---|---|
LayTec-AG/Plotly.Blazor
This library packages the well-known charting library plotly.js into a razor component that can be used in a Blazor project.
|
|
nightroman/FarNet
Far Manager framework for .NET modules and scripts in PowerShell, F#, JavaScript.
|
Version | Downloads | Last updated |
---|---|---|
5.2.1 | 6,473 | 11/13/2024 |
5.2.0 | 237 | 11/12/2024 |
5.1.0 | 8,766 | 10/23/2024 |
5.0.1 | 3,608 | 10/23/2024 |
5.0.0 | 292,829 | 12/3/2023 |
4.1.0 | 8,318 | 11/20/2023 |
4.0.0 | 284,036 | 5/15/2022 |
3.1.2 | 143,859 | 3/24/2022 |
3.1.1 | 6,335 | 2/21/2022 |
3.1.0 | 2,020 | 2/21/2022 |
3.0.1 | 874,356 | 9/6/2018 |
2.1.0 | 4,097 | 8/23/2018 |
2.0.1 | 5,569 | 7/23/2018 |
2.0.0 | 10,641 | 7/1/2017 |
1.1.0 | 1,746 | 6/20/2017 |
1.0.0 | 6,906 | 5/30/2017 |
Changelog can be found at https://github.com/aarondandy/WeCantSpell.Hunspell/blob/master/changelog.md