New to Telerik UI for WinForms? Start a free 30-day trial

Checks words against culture-specific dictionaries and custom words, and ranks spelling suggestions.

Definition

Namespace:Telerik.WinControls.SpellChecker.Proofing

Assembly:Telerik.WinControls.SpellChecker.dll

Syntax:

C#
public class DocumentSpellChecker : ISpellChecker, IDisposable

Inheritance: objectDocumentSpellChecker

Implements: IDisposableISpellChecker

Constructors

Creates a checker with the built-in English dictionary and no custom dictionary.

C#
public DocumentSpellChecker()

Creates a checker with an optional custom dictionary and registers the built-in English dictionary. The supplied custom dictionary is used as the invariant-culture fallback.

C#
public DocumentSpellChecker(ICustomWordDictionary customDictionary)
Parameters:customDictionaryICustomWordDictionary

The custom dictionary used when no culture-specific custom dictionary is registered.

Fields

Multiplier applied to candidate edit distances when computing suggestion rank.

C#
public static readonly int EditDistanceCoeficient

Exclusive upper bound for the Damerau-Levenshtein distance of a returned suggestion.

C#
public static readonly int EditDistanceLimit

Rank reduction applied to candidates with a Damerau-Levenshtein distance of one.

C#
public static readonly int EditDistanceOneBoost

Maximum Sift3 distance accepted during candidate scanning; it also defines the scanned word-length window.

C#
public static readonly int EditDistanceScanLimit

Penalty weight used by the suggestion comparator for first- or last-character differences.

C#
public static readonly int EndsDifferencePenalty

Maximum number of ranked candidates considered before the final edit-distance filter.

C#
public static readonly int MaxNumberOfSuggestions

Rank reduction applied when a candidate's primary Metaphone key matches the queried word.

C#
public static readonly int MetaphoneEqualBoost

Properties

Gets or sets the culture used by operations without an explicit culture. A null value uses CurrentCulture; changing this property raises DataChanged.

C#
public CultureInfo SpellCheckingCulture { get; set; }

Implements: ISpellChecker.SpellCheckingCulture

Methods

Adds a custom dictionary with the specified culture to the spell checker. If a dictionary with this culture already exists, it is overwritten.

C#
public void AddCustomDictionary(ICustomWordDictionary customDictionary, CultureInfo culture)
Parameters:customDictionaryICustomWordDictionarycultureCultureInfo

Adds a dictionary with the specified culture to the spell checker. If a dictionary with this culture already exists, it is overwritten.

C#
public void AddDictionary(IWordDictionary dictionary, CultureInfo culture)
Parameters:dictionaryIWordDictionarycultureCultureInfo

Adds a lazily initialized dictionary with the specified culture to the spell checker. If a dictionary with this culture already exists, it is overwritten.

C#
public void AddDictionary(Lazy<IWordDictionary> lazyDictionary, CultureInfo culture)
Parameters:lazyDictionaryLazy<IWordDictionary>cultureCultureInfo

Adds a spelling to the custom dictionary for the specified culture or its invariant fallback.

C#
public void AddWord(string word, CultureInfo culture)
Parameters:wordstring

The spelling to add.

cultureCultureInfo

The culture whose custom dictionary receives the spelling.

Exceptions: InvalidOperationException

No custom dictionary is registered for the specified culture or its invariant fallback.

Implements: ISpellChecker.AddWord(string, CultureInfo)

Adds a spelling to the custom dictionary for SpellCheckingCulture or the current culture.

C#
public void AddWord(string word)
Parameters:wordstring

The spelling to add.

Exceptions: InvalidOperationException

No custom dictionary is registered for the active culture or its invariant fallback.

Implements: ISpellChecker.AddWord(string)

Determines whether a custom dictionary is available for SpellCheckingCulture or the current culture.

C#
public bool CanAddWord()
Returns:

bool

true when a custom dictionary is available; otherwise, false.

Implements: ISpellChecker.CanAddWord()

Determines whether a custom dictionary is available for the specified culture or its invariant fallback.

C#
public bool CanAddWord(CultureInfo culture)
Parameters:cultureCultureInfo

The culture whose custom dictionary is checked.

Returns:

bool

true when a custom dictionary is available; otherwise, false.

Implements: ISpellChecker.CanAddWord(CultureInfo)

Checks whether all word parts are recognized by dictionaries for the specified culture. Language-specific proofing may split a compound spelling before dictionary lookup.

C#
public bool CheckWordIsCorrect(string word, CultureInfo culture)
Parameters:wordstring

The spelling to check.

cultureCultureInfo

The culture used for word splitting and dictionary lookup.

Returns:

bool

true when all word parts are recognized; otherwise, false.

Implements: ISpellChecker.CheckWordIsCorrect(string, CultureInfo)

Checks whether a spelling is recognized using SpellCheckingCulture or the current culture.

C#
public bool CheckWordIsCorrect(string word)
Parameters:wordstring

The spelling to check.

Returns:

bool

true when all language-specific word parts are found in a dictionary; otherwise, false.

Implements: ISpellChecker.CheckWordIsCorrect(string)

Clears the checker's dictionary registries and metadata references without disposing the dictionary instances.

C#
public void Dispose()

Implements: IDisposable.Dispose()

Gets the custom dictionary for a culture, falling back to the invariant-culture custom dictionary.

C#
public ICustomWordDictionary GetCustomDictionary(CultureInfo culture)
Parameters:cultureCultureInfo

The culture whose custom dictionary is requested.

Returns:

ICustomWordDictionary

The matching custom dictionary, or null when none is registered.

Gets the dictionary for a culture, falling back to the invariant-culture dictionary and instantiating it if needed.

C#
public IWordDictionary GetDictionary(CultureInfo culture)
Parameters:cultureCultureInfo

The culture whose dictionary is requested.

Returns:

IWordDictionary

The matching dictionary, or null when neither that culture nor the invariant culture is registered.

Gets ranked spelling suggestions from the dictionaries for the specified culture.

C#
public ICollection<string> GetSuggestions(string word, CultureInfo culture)
Parameters:wordstring

The spelling for which to find suggestions.

cultureCultureInfo

The culture whose word and custom dictionaries are used.

Returns:

ICollection<string>

Up to MaxNumberOfSuggestions candidates; an empty collection for a null or empty input.

Implements: ISpellChecker.GetSuggestions(string, CultureInfo)

Gets ranked spelling suggestions using SpellCheckingCulture or the current culture.

C#
public ICollection<string> GetSuggestions(string word)
Parameters:wordstring

The spelling for which to find suggestions.

Returns:

ICollection<string>

Up to MaxNumberOfSuggestions candidates; an empty collection for a null or empty input.

Implements: ISpellChecker.GetSuggestions(string)

Removes the custom dictionary with the specified culture from the spell checker. This method returns false if no such dictionary is found.

C#
public bool RemoveCustomDictionary(CultureInfo culture)
Parameters:cultureCultureInfoReturns:

bool

Removes the dictionary with the specified culture from the spell checker. This method returns false if no such dictionary is found.

C#
public bool RemoveDictionary(CultureInfo culture)
Parameters:cultureCultureInfoReturns:

bool

Removes a spelling from the custom dictionary for the specified culture or its invariant fallback.

C#
public void RemoveWord(string word, CultureInfo culture)
Parameters:wordstring

The spelling to remove.

cultureCultureInfo

The culture whose custom dictionary is searched.

Exceptions: InvalidOperationException

No custom dictionary is registered for the specified culture or its invariant fallback.

Implements: ISpellChecker.RemoveWord(string, CultureInfo)

Removes a spelling from the custom dictionary for SpellCheckingCulture or the current culture.

C#
public void RemoveWord(string word)
Parameters:wordstring

The spelling to remove.

Exceptions: InvalidOperationException

No custom dictionary is registered for the active culture or its invariant fallback.

Implements: ISpellChecker.RemoveWord(string)

Events

Occurs when the checker culture, registered dictionaries, or observed custom-dictionary data changes.

C#
public event EventHandler DataChanged

Implements: ISpellChecker.DataChanged