check_spell(lang=None,
encoding=' UTF-8 ' ,
variety=None,
extopts={ } ,
envs=None,
suponly=False,
maxsugg=5)
|
|
Check spelling using Aspell [hook factory].
Aspell language is selected by the lang parameter, which
should be a language code of one of the installed spelling dictionaries.
Text encoding used by the dictionary is provided by the
encoding parameter. If the dictionary comes in several
varieties, a non-default one is selected using the variety
parameter. Any additional options from the set of Aspell configuration
fields can be passed in as (name, value) dictionary by the
extopts parameter.
Pology may contain internal supplemental dictionaries for selected
language in lang/<lang>/spell/ directory, and these
are automatically picked up. Any subdirectories in
lang/<lang>/spell/ are considered as to contain
supplemental dictionaries in special "environments" (e.g.
jargon, certain projects, etc.), and are not included by default. Such
environments can be included by the envs parameter, which is
a list of relative paths added to lang/<lang>/spell/
directory. All supplemental dictionaries from such paths are included, as
well as from all their parent directories up to
lang/<lang>/spell/ (this makes supplemental
dictionaries hierarchical, e.g. environment foo/bar is a
child of foo , and thus when foo/bar is
requested, both its and supplements of foo are used).
If lang is None , then automatic detection of
the language based on the catalog of the message is attempted (see
catalog language() method). Similar is attempted for
environments if env is None (see catalog environment() method).
Aspell's system dictionary can be completely excluded from the check
by the suponly parameter, when the check will use only
internal supplemental dictionaries.
Misspelled words are reported to stdout, with suggestions if
available. Maximum number of suggestions to display is selected by the
maxsugg parameter; if negative, all suggestions are
shown.
Spell checking is performed by internally splitting text into words,
and querying Aspell word by word. Spliting is performed in a simple
fashion; it is assumed that text has been appropriately filtered down to
plain text, e.g. that any XML-like markup and other literals have been
removed (see pology.remove for filtering possibilities).
Spell checking can be skipped entirely on a message by issuing the
no-check-spell sieve
flag. Alternatively, only certain words may be declared well spelled
by adding a manual comment starting with well-spelled: and
followed by comma-separated list of words. Example:
# |, no-check-spell
msgid "Aaaargh, gahhh, khh..."
msgstr ""
# well-spelled: Aaaargh, kh
msgid "Aaaargh, kh, kh... I have been defeated...!"
msgstr ""
- Parameters:
lang (string) - language of spelling dictionary
encoding (string) - encoding used by the dictionary
variety (string) - variety of dictionary
extopts (dict) - additional options to send to Aspell
envs (list of strings) - environments for supplemental dictionaries
suponly (bool) - whether to use only supplemental dictionaries
maxsugg (int) - maximum number of suggestions to show for misspelled word
- Returns:
(text, msg, cat) -> numerr
- type S3A hook
|