RadDictionary
Provides word lookup backed by primary and alternate Metaphone indexes, with a hook for lazy loading.
Definition
Namespace:Telerik.WinForms.Documents.Proofing
Assembly:Telerik.WinControls.RichTextEditor.dll
Syntax:
public class RadDictionary : IWordDictionary
Inheritance: objectRadDictionary
Derived Classes:
Implements:
Constructors
Initializes an empty dictionary with default collection capacities.
public RadDictionary()
Initializes an empty dictionary sized for an estimated number of entries.
public RadDictionary(int expectedSize)
The estimated number of words used to size the dictionary's collections.
Fields
Maps each spelling to its primary and alternate Metaphone keys.
protected Dictionary<string, Tuple<string, string>> metaphoneByWord
Maps primary Metaphone keys to their indexed spellings.
protected Dictionary<string, List<string>> wordsByMetaphone
Maps alternate Metaphone keys to their indexed spellings.
protected Dictionary<string, List<string>> wordsByMetaphoneAlternate
Properties
Gets whether the initial dictionary load has completed; the base class sets this after the load hook returns.
protected bool DictionaryLoaded { get; }
Gets the spellings contained in the dictionary.
public IEnumerable<string> Words { get; }
Implements:
This property returns the currently indexed spellings without invoking the lazy-load hook.
Methods
Adds a spelling and its phonetic keys to the word and key indexes.
Ensures the derived dictionary data is initialized, invoking EnsureDictionaryLoadedOverride() only on the first call.
protected void EnsureDictionaryLoaded()
Provides the derived dictionary's one-time initialization logic for EnsureDictionaryLoaded().
protected virtual void EnsureDictionaryLoadedOverride()
Gets the primary Metaphone key recorded for a spelling.
Gets dictionary spellings that share a primary Metaphone key.
public IEnumerable<string> GetWordsByMetaphoneKey(string word)
The primary Metaphone key to look up, not the original spelling.
Returns:IEnumerable<string>
The matching spellings, or an empty sequence when the key is not present or the dictionary has no phonetic index.
Implements:
Creates the word list and the lookup indexes used by this dictionary.
protected void Init(int expectedSize)
The estimated number of words used to size the collections.
Loads serialized entries into the word list and both phonetic indexes.
protected void Load(IEnumerable<string> entries)
Entries in word:primaryKey:alternateKey form, as produced by the dictionary data format.
Loads dictionary entries from a stream. Blank lines are ignored; each other line must contain a spelling and its primary and alternate Metaphone keys separated by colons.
public void Load(Stream stream)
The stream containing serialized dictionary entries.
The reader created by this method is disposed when loading completes, which also closes
stream.
Raises the DataChanged event.
protected virtual void OnDataChanged()
Removes a spelling and its phonetic keys from the word and key indexes.
protected void RemoveWordFromMetaphoneDictionaries(string word, string metaphone, string metaphoneAlternate)
The spelling to remove.
metaphonestringThe primary Metaphone key previously associated with the spelling.
metaphoneAlternatestringThe alternate Metaphone key previously associated with the spelling.
Events
Occurs when a dictionary implementation signals that its contents have changed.
public event EventHandler DataChanged