Skip to content

symspellpy ¤

Backend for the symspellpy library.

Classes:

Name Description
SymspellpyBackend

Backend for the symspellpy library.

SymspellpyBackend(config: dict[str, Any], known_words: set[str] | None = None) ¤

Bases: Backend

Backend for the symspellpy library.

This backend needs to load dictionaries provided by symspellpy itself.

Parameters:

Name Type Description Default
config dict[str, Any]

User configuration from mkdocs.yml.

required
known_words set[str] | None

Globally known words.

None
Source code in src/mkdocs_spellcheck/backends/symspellpy.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def __init__(self, config: dict[str, Any], known_words: set[str] | None = None) -> None:  # noqa: ARG002
    """Initialize the `symspellpy` backend.

    This backend needs to load dictionaries provided
    by `symspellpy` itself.

    Parameters:
        config: User configuration from `mkdocs.yml`.
        known_words: Globally known words.
    """
    self.spell = SymSpell()
    dictionary_res = resources.files("symspellpy").joinpath("frequency_dictionary_en_82_765.txt")
    with resources.as_file(dictionary_res) as dictionary_path:
        self.spell.load_dictionary(dictionary_path, 0, 1)