Spellchecking

Superdesk can support several spellcheckers. They are implemented as backend plugin and used by the client.

Getting list of spellcheckers

To retrieve list of registered spellcheckers, a GET request must be done on spellcheckers_list endpoint.

Checking a text

A text can be checked using spellchecker endpoint.

class SpellcheckerService(datasource: str | None = None, backend=None)[source]

Service managing spellchecking and suggestions.

When doing a POST request on this service, the following keys can be used (keys with a * are required):

key

explanation

spellchecker *

name of the spellchecker

text *

text to check or word for suggestions

language

language to use (for spellcheckers handling several ones)

suggestions

false (default) to check a text, else will get suggestions

use_internal_dict

true (default) to remove spellings mistakes from words in personal dictionary

ignore

list of words to ignore (i.e. to remove from reported errors)

e.g. to check a French text while removing words from personal dictionary (grammar mistakes are here on purpose):

{
    "spellchecker": "grammalecte",
    "text": "Il nous reste à vérifié votre maquette."
}

Here is an example payload for suggestions:

{
    "spellchecker": "grammalecte",
    "suggestions": true,
    "text": "fote"
}

Getting suggestions

Getting suggestions for a word is done in a similar way as checking a text, on the same spellchecker endpoint, but with the additional "suggestions": true key.

Spellchecker plugin

So far, Superdesk supports the following spellcheckers:

class Grammalecte(*args, **kwargs)[source]

Grammelecte grammar/spelling/style checker integration

This class works with either the Grammalecte CLI or the Grammalecte server (both are downloadable at https://grammalecte.net). We use the CLI in priority because it handles spelling suggestions, which is not the case with the server.

The GRAMMELECTE_CLI setting (or environment variable) can be set to grammelecte-cli.py path.

The GRAMMALECTE_URL setting (or environment variable) can be set to the base URL of the server. e.g.: if you run Grammelect server with grammalecte-server.py -t -p 9999, you’ll have to put in the settings GRAMMALECTE_URL = http://localhost:9999 (or use the environment variable of the same name).

If GRAMMALECTE_CLI or GRAMMALECTE_URL are specified, they are used (if both are specified, only GRAMMALECTE_CLI will be used). If none is specified, the CLI is search in executables path, and if not found default URL (http://localhost:8080) will be used .

Grammelecte behaviour can be specified using GRAMMALECTE_CONFIG setting, which must be a dictionary mapping grammalecte option names to their boolean value. Check grammalecte-cli.py -lo to get option names.

In this dictionary, a special ignore_rules key can be set to a list of rules ids to ignore. Check grammalecte-cli.py -lr to get rules ids.

class LeuvenDutch(*args, **kwargs)[source]

University of Leuven Dutch grammar/spellchecker integration

The LEUVEN_DUTCH_API_KEY setting (or environment variable) must be set to the API key

class Languagetool(*args, **kwargs)[source]

Languagetool grammar/spellchecker integration

The LANGUAGETOOL_API_URL setting (or environment variable) must be set

class Default(*args, **kwargs)[source]

Default spellchecker of Superdesk

This spellchecker works with internal dictionaries, in any language.