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

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

Definition

Namespace:Telerik.WinForms.Documents.Proofing

Assembly:Telerik.WinControls.RichTextEditor.dll

Syntax:

C#
public class DocumentSpellChecker : ISpellChecker

Inheritance: objectDocumentSpellChecker

Implements: ISpellChecker

Constructors

Initializes the checker without a custom dictionary. The WinForms build also registers the built-in en-US dictionary.

C#
public DocumentSpellChecker()

Initializes the checker with an optional custom dictionary, which is used as the invariant-culture fallback.

C#
public DocumentSpellChecker(ICustomWordDictionary customDictionary)
Parameters:customDictionaryICustomWordDictionary

The custom dictionary to use as a fallback, or null when none is supplied.

Fields

Multiplier applied to candidate edit distances when computing suggestion rank.

C#
public static readonly int EditDistanceCoefficient

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 added for a mismatch in the first or last character.

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 a value indicating whether MEF should be used to load default dictionaries.

C#
public bool AutomaticallyLoadDefaultDictionaries { get; set; }
Property Value:

true if default dictionaries should be loaded automatically; otherwise, false.

Gets or sets the options used by document proofing when deciding which words to check.

C#
public SpellCheckerSettings Settings { get; set; }

Implements: ISpellChecker.Settings

Gets or sets the culture used by operations that do not specify a culture.

C#
public CultureInfo SpellCheckingCulture { get; set; }
Property Value:

The active culture, or null to use CurrentCulture.

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 resolved for the specified culture, falling back to the invariant-culture dictionary.

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 culture or the invariant culture.

Implements: ISpellChecker.AddWord(string, CultureInfo)

Adds a spelling to the custom dictionary resolved for the active culture, falling back to the invariant-culture dictionary.

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

The spelling to add.

Exceptions: InvalidOperationException

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

Implements: ISpellChecker.AddWord(string)

Determines whether a custom dictionary resolves for the active culture, including the invariant-culture fallback.

C#
public bool CanAddWord()
Returns:

bool

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

Implements: ISpellChecker.CanAddWord()

Determines whether a custom dictionary resolves for the specified culture, including the invariant-culture 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)

Determines whether a word is recognized using the specified culture and its available dictionaries.

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

The spelling to check.

cultureCultureInfo

The culture whose dictionaries are used.

Returns:

bool

true when the spelling is recognized; otherwise, false.

Implements: ISpellChecker.CheckWordIsCorrect(string, CultureInfo)

Determines whether a word is recognized using the active culture and its available dictionaries.

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

The spelling to check.

Returns:

bool

true when the spelling is recognized; otherwise, false.

Implements: ISpellChecker.CheckWordIsCorrect(string)

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

C#
public ICustomWordDictionary GetCustomDictionary()
Returns:

ICustomWordDictionary

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

Implements: ISpellChecker.GetCustomDictionary()

Gets the custom dictionary for the specified 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 available.

Implements: ISpellChecker.GetCustomDictionary(CultureInfo)

Gets the word dictionary for the active culture, falling back to the invariant-culture dictionary.

C#
public IWordDictionary GetDictionary()
Returns:

IWordDictionary

The matching dictionary, or null when neither dictionary is available.

Implements: ISpellChecker.GetDictionary()

Gets the word dictionary for the specified culture, falling back to the invariant-culture dictionary.

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

The culture whose dictionary is requested.

Returns:

IWordDictionary

The matching dictionary, or null when neither dictionary is available.

Implements: ISpellChecker.GetDictionary(CultureInfo)

Gets ranked spelling candidates using the specified culture.

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

The spelling for which to find candidates.

cultureCultureInfo

The culture whose dictionaries are used.

Returns:

ICollection<string>

Candidate replacement spellings; the collection can be empty when no candidates are found.

Implements: ISpellChecker.GetSuggestions(string, CultureInfo)

Gets ranked spelling candidates using the active culture.

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

The spelling for which to find candidates.

Returns:

ICollection<string>

Candidate replacement spellings; the collection can be empty when no candidates are found.

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 resolved for the specified culture, falling back to the invariant-culture dictionary.

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 culture or the invariant culture.

Implements: ISpellChecker.RemoveWord(string, CultureInfo)

Removes a spelling from the custom dictionary resolved for the active culture, falling back to the invariant-culture dictionary.

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

The spelling to remove.

Exceptions: InvalidOperationException

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

Implements: ISpellChecker.RemoveWord(string)

Events

Occurs when dictionary data or the active spelling culture changes.

C#
public event EventHandler DataChanged

Implements: ISpellChecker.DataChanged