Socket
Book a DemoInstallSign in
Socket

SpellCheck.Simple

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

SpellCheck.Simple

Offline spell-checking of words within texts, including Markdown tags. This library enables accurate detection of spelling errors while considering the presence of Markdown formatting. The library utilizes OpenOffice's *.dic and *.aff files to support spell-checking in over 80 languages from around the world. See also: SpellCheck.Dictionaries nuget package which comes with built-in support for languages such as de-DE, en-GB, en-US, es-ES, fr-FR, it-IT, pl-PL, and pt-PT for your convenience. This feature enhances the library's spell-checking capabilities by providing preloaded dictionaries, thereby streamlining the process of verifying text accuracy across multiple languages.

1.2.0
Source
nugetNuGet
Version published
Maintainers
1
Created
Source

SpellCheck Offline Library

Offline spell-checking of words within texts, including Markdown tags. This library enables accurate detection of spelling errors while considering the presence of Markdown formatting.

The library utilizes OpenOffice's *.dic and *.aff files to support spell-checking in over 80 languages from around the world.

The library comes with built-in support for languages such as de-DE, en-GB, en-US, es-ES, fr-FR, it-IT, pl-PL, and pt-PT for your convenience. It enhances the spell-checking capability by providing preloaded dictionaries, thus streamlining the process of checking text for accuracy across different languages.

NOTE: Feel free to make a pull request.

SpellCheck.Simple nuget package

The SpellCheck.Simple library can be used to perform various spell-checking tasks. Here's an example of how to get started:

Install the SpellCheck.Simple nuget package from the package manager console:

dotnet add package SpellCheck.Simple

Just create an instance of the SpellCheck class and use it.

using SpellCheck;

// Create a SpellCheck instance
var spellChecker = await SpellChecker.CreateFromFiles("en_US.dic", "en_US.aff");
spellChecker.SetIgnoredWords("bulba", "kotek");

// Perform spell-checking on a word
Console.WriteLine(spellChecker.IsWordCorrect("hello")); // true
Console.WriteLine(spellChecker.IsWordCorrect("kotek")); // true
Console.WriteLine(spellChecker.IsWordCorrect("adsasd")); // false

// Perform spell-checking on a text
Console.WriteLine(spellChecker.IsTextCorrect("This is an example text.")); // true
Console.WriteLine(spellChecker.IsTextCorrect("This is an ixample text.")); // false

// Get suggestions for an incorrect word
var suggestions = spellChecker.SuggestWord("worl"); 
Console.WriteLine(string.Join(", ", suggestions)); // work, world

// More advanced usage is possible as well

Use this class in the way above if you want to use your own dictionaries and don't want to use built-in dictionaries.

SpellCheck.Dictionaries nuget package

A much simpler way to use the SpellCheck class is to use the built-in dictionaries.

Install the SpellCheck.Dictionaries nuget package from the package manager console:

dotnet add package SpellCheck.Dictionaries

Just create an instance of the SpellChecker class and use it.

using SpellCheck.Dictionaries;

var factory = new SpellCheckFactory();
// Create a SpellCheck instance
var arSpellChecker = await factory.CreateSpellChecker("ar_SR");
var enSpellChecker = await factory.CreateSpellChecker("en_US");

Console.WriteLine(enSpellChecker.IsTextCorrect("hello world")); // true
Console.WriteLine(arSpellChecker.IsTextCorrect("متنوعة")); // true

There are some built in dictionaries for the following languages:

LanguageCultureDictionaryAffix file
Deutschde-DEde_DE.dicde_DE.aff
English (US)en-USen_US.dicen_US.aff
English (GB)en-GBen_GB.dicen_GB.aff
Españoles-ESes_ES.dices_ES.aff
Françaisfr-FRfr_FR.dicfr_FR.aff
Italianoit-ITit_IT.dicit_IT.aff
Polishpl-PLpl_PL.dicpl_PL.aff
Portuguêspt-PTpt_PT.dicpt_PT.aff

Custom dictionaries

using SpellCheck.Dictionaries;

var factory = new SpellCheckFactory("C:\Dictionaries");

// Create a SpellCheck instance from files ar-SR.dic and ar-SR.aff
// in the C:\Dictionaries directory
var spellChecker = factory.CreateSpellCheck("ar-SR");

If the directory is not specified, the current directory is used.

SpellCheck works with dictionaries and affix files coming from Open Office Hunspell format. If you need more languages, you can download them from this GitHub repository and put them into destination directory to work with. These files are in UTF-8 format.

Another way is to go to the website softmaker.com and download dictionary you wish. A total of 85 language dictionaries are available. After downloading, change the file name extension .sox to .zip and open the file. You should see some files inside. Unpack *.dic and *.aff files to the destination directory, an that's all. You can use these files by SpellCheck and SpellCheckFactory classes.

If you're using the SpellCheck class alone, the *.dic and *.aff files should be in UTF-8 format. If they're not, you can convert them using the
iconv tool or include the following code before the first use of the SpellCheck class:

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

This step is unnecessary if you're using SpellCheckFactory class.

Class dependency diagram

Class diagram

Keywords

"spell-checking

FAQs

Package last updated on 02 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.