Skip to main content

Dictionary Class

A simple dictionary.

Namespace: DevExpress.Blazor.RichEdit.SpellCheck

Assembly: DevExpress.Blazor.RichEdit.v23.2.dll

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public class Dictionary :
    DictionaryBase

Remarks

A simple dictionary consists of a dictionary and an alphabet file: the dictionary file lists all the words of a particular language, and the alphabet file is an optional file that contains a string with all the capital letters of a language. The Rich Text Editor uses these letters to speed up the construction of spelling suggestions.

Note

Assign a file provider to the FileProvider property so that the service can access dictionary files. The FileNotFoundException error occurs if you do not set the file provider, but add a dictionary.

A dictionary’s Culture property defines the dictionary’s culture. The Rich Text Editor checks spelling against all dictionaries when the component’s DocumentCulture property corresponds to an invariant culture. Otherwise, the Rich Text Editor uses only the dictionaries whose culture is invariant or matches the document’s culture.

You can use the AddToDictionaryAction property to allow users to add words to a dictionary. The example below demonstrates how to add a simple dictionary and use it as a storage for new words:

public void ConfigureServices(IServiceCollection services) {
    services.AddDevExpressBlazor().AddSpellCheck(opts => {
        opts.FileProvider = new PhysicalFileProvider(
            Path.Combine(Directory.GetCurrentDirectory(), "Data", "Dictionaries")
        );
        opts.MaxSuggestionCount = 7;
        opts.Dictionaries.Add(new Dictionary {
            DictionaryPath = "CustomEnglish.dic",
            AlphabetPath = "EnglishAlphabet.txt",
            Culture = "en-US"
        });
        opts.AddToDictionaryAction = (word, culture) => {
            switch (culture.Name) {
                case "en-US":
                    string path = opts.FileProvider.GetFileInfo("CustomEnglish.dic").PhysicalPath;
                    File.AppendAllText(path, word);
                    break;
                default:
                    break;
            };
        };
    });
}

Refer to the following topic for more information: Spell Check.

Inheritance

See Also