Back to Devexpress

HunspellDictionary Class

corelibraries-devexpress-dot-xtraspellchecker-00289fce.md

latest4.3 KB
Original Source

HunspellDictionary Class

A dictionary for the Hunspell spell checking algorithm.

Namespace : DevExpress.XtraSpellChecker

Assembly : DevExpress.SpellChecker.v25.2.Core.dll

NuGet Package : DevExpress.SpellChecker.Core

Declaration

csharp
public class HunspellDictionary :
    DictionaryBase,
    ICloseWordsCalculatorFactory
vb
Public Class HunspellDictionary
    Inherits DictionaryBase
    Implements ICloseWordsCalculatorFactory

The following members return HunspellDictionary objects:

Remarks

A hunspell spell-checking dictionary instance is created by loading two files: a dictionary file and an affix file. The dictionary file, specified by the DictionaryBase.DictionaryPath property, contains only the root forms of words with information about morphological affix classes to combine with the roots. The affix file, specified by the HunspellDictionary.GrammarPath property, contains lists of affixes along with their context restrictions and effects. The affix file also serves as a settings file for the dictionary, containing all meta-data and settings.

The DictionaryBase.Load method is used to load Hunspell dictionary from files. You can load it from two streams containing dictionary and grammar data by using the HunspellDictionary.LoadFromStream method.

Note

We bear no responsibility for the content and availability of Hunspell dictionaries and affix files, since they are part of Hunspell project (for more information visit the Hunspell web site.

Example

The following code demonstrates how to create the HunspellDictionary dictionary at runtime.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spellchecker-enable-in-text-box

csharp
using DevExpress.XtraSpellChecker;
using System;
using System.Globalization;
            spellChecker1.Dictionaries.Clear();

            HunspellDictionary hunspellDictionaryEnglish = new HunspellDictionary();
            hunspellDictionaryEnglish.DictionaryPath = @"Dictionaries\Hunspell\en_US\en_US.dic";
            hunspellDictionaryEnglish.GrammarPath = @"Dictionaries\Hunspell\en_US\en_US.aff";
            hunspellDictionaryEnglish.Culture = new CultureInfo("en-US");
            hunspellDictionaryEnglish.Load();
            spellChecker1.Dictionaries.Add(hunspellDictionaryEnglish);
vb
Imports DevExpress.XtraSpellChecker
Imports System
Imports System.Globalization
            spellChecker1.Dictionaries.Clear()

            Dim hunspellDictionaryEnglish As New HunspellDictionary()
            hunspellDictionaryEnglish.DictionaryPath = "Dictionaries\Hunspell\en_US\en_US.dic"
            hunspellDictionaryEnglish.GrammarPath = "Dictionaries\Hunspell\en_US\en_US.aff"
            hunspellDictionaryEnglish.Culture = New CultureInfo("en-US")
            hunspellDictionaryEnglish.Load()
            spellChecker1.Dictionaries.Add(hunspellDictionaryEnglish)

Implements

ISpellCheckerDictionary

Inheritance

Object DictionaryBase HunspellDictionary

See Also

HunspellDictionary Members

DevExpress.XtraSpellChecker Namespace