Functions¶
The top-level entry points. Everything here is importable directly from denckring;
the README's "What is stable" says which are under its promise and which are published
but not yet promised.
denckring.check ¶
check(
procedure_id: str,
text: str,
*,
lang: Lang = "en",
**params: Any,
) -> Report
Check a text against a procedure by id.
denckring.produce ¶
produce(
procedure_id: str,
text: str,
*,
lang: Lang = "en",
**params: Any,
) -> Production
Generate with a procedure by id, returning every result it found.
denckring.apply ¶
apply(
procedure_id: str,
text: str,
*,
lang: Lang = "en",
**params: Any,
) -> str
Generate one text with a procedure by id — the best result it found.
denckring.get ¶
get(procedure_id: str) -> BaseProcedure[Any]
One registered procedure, or UnknownProcedure.
denckring.describe ¶
describe(
procedure_id: str,
*,
lang: Lang = "en",
scholarly: bool = False,
) -> Description
One procedure, in full. Raises UnknownProcedure for an unknown id.
denckring.prompt_hint ¶
prompt_hint(
procedure_id: str, *, lang: Lang = "en", **params: Any
) -> str
The row's prompt hint in lang, stating every parameter given (ADR 0050).
params are validated as check validates them, so defaults fill in and a
bad value raises InvalidParams exactly as it would there. Values render by
one rule: a list or tuple joins its items with ", ", anything else is str().
A letter set is quoted letter by letter in the language's own marks, and under
fold_diacritics a letter is shown folded, as the checker compares it
(core.hints.as_compared).
A parameter the template has no placeholder for, set to anything but its
default, follows the hint on a line of its own, - name = value: and the
field's description (English in every language), in field order
(core.hints.settings): a switch or threshold such as eodermdrome's
min_letters changes what the checker judges, so the prompt says so. With
every such parameter at its default, nothing is appended.
Raises NoPromptHint when the row has no hint in lang — no fallback to
English, which describe does and discloses in untranslated, but a bare
string cannot — and UnsetHintParameter when the hint states a parameter
whose value is None ("inferred" to a checker, nothing to a sentence).
A composite (multiple_constraint) is followed by one line per named
constraint, - and that constraint's own hint rendered from its entry's
params by this same function, in constraints order, any
lines of its own indented under it. So each sub-hint validates and refuses as
it would if asked for directly, and the error names the sub-constraint.
denckring.render_hint ¶
render_hint(
procedure_id: str,
template: str,
*,
lang: Lang = "en",
**params: Any,
) -> str
Render a template the caller owns by the rule prompt_hint uses.
For a caller writing its own prompt for a row rather than using the catalogue's.
params are validated as check validates them, so defaults fill in and a bad
value raises InvalidParams; lang must name a language a pack is installed
for, as it must for check. Values render as in prompt_hint: a list joins with
", ", a field declaring x-denckring-show: letters quotes each letter ("e",
"t", or „e“, „t“ and « e », « t » in German and French), anything else is
str(). Under fold_diacritics a letter is shown folded, as the checker compares
it. A placeholder naming no parameter of the row
raises InvalidParams; one whose value is None raises UnsetHintParameter.
A parameter the template has no placeholder for, set off its default, is
appended on its own line as prompt_hint appends it, so a template written
without a threshold cannot drop one a caller sets. A composite is followed by
one line per constraint, as in prompt_hint, each that constraint's catalogue
hint rendered from its entry's params: the caller's template states the
composite, and the entries' parameters are stated whether it names them or not
(ADR 0059).
denckring.checker_history ¶
checker_history(procedure_id: str) -> list[CheckerChange]
Every checker_version a row has had, oldest first, with the release and why.
The last entry's version is describe(procedure_id).checker_version. Compare it
with report.provenance.checkers to learn whether a result predates a change that
could have moved the row's verdicts (ADR 0061). Raises UnknownProcedure for an
id that is not registered.
denckring.rules ¶
rules(procedure_id: str) -> tuple[str, ...]
Every violation.rule the row's checker can emit, sorted.
The vocabulary each row declares (BaseProcedure.rules), so a caller can map
rules to its own classes without reading checker source. multiple_constraint
passes its constraints' violations through unchanged, and any registered row
can be one of them, so it answers with every other row's vocabulary.
Under the README's stability promise since 0.4.0 (ADR 0059): a published rule keeps its name and meaning, a row may add rules, and removing or renaming one is a breaking change the changelog names.
denckring.rule_categories ¶
rule_categories(procedure_id: str) -> dict[str, str]
Each rule rules(procedure_id) returns, mapped to the kind of failure it names.
The categories are a closed set, defined in failure_categories(): a forbidden
letter is excluded_letter, a missing line count, a broken rhyme sound. A rule
string has the same category on every row that emits it, but two:
slenderizing's wrong_letter is transcription, where the spine rows'
is position, and missing_letter is transcription on the rows that align
a text's letters with its source's (slenderizing, homoconsonantism,
homovocalism), where the inventory rows' is inventory. So a caller counting
failures across rows counts by kind without a map of its own (audit C3),
provided it asks each row rather than keying by the rule alone.
multiple_constraint answers with each rule's usual category.
Published with the rules themselves, and under the same terms: a rule's category
may move in a minor release, and the changelog will say so.
denckring.failure_categories ¶
failure_categories() -> dict[str, str]
Every failure category rule_categories uses, mapped to what it means.
denckring.scope ¶
scope(
procedure_id: str, *, lang: Lang = "en", **params: Any
) -> str
The smallest unit the row judges alone under these parameters (audit C2).
One of scopes(): word, line, sentence, or text for no promise. A
word-scoped row passes a text of words if and only if it passes each word
alone, so a caller composing rows can build a passing text from passing
words. The parameters matter: tautogram is word-scoped only with initial
stated, since unset it reads the initial off the text's first word. Validated
as check validates them. lang is taken as admits and check take it, so
one set of keyword arguments serves all three, and must name a language a pack
is installed for; the scope is a property of the rule and is the same in every
language.
denckring.scopes ¶
scopes() -> dict[str, str]
Every scope scope returns, mapped to what it promises.
denckring.admits ¶
admits(
procedure_id: str,
word: str,
/,
*,
lang: Lang = "en",
**params: Any,
) -> bool
Whether a word-scoped row passes word alone, and so in any text of such words.
Raises NotWordLocal when scope(procedure_id, **params) is not word: a
word alone has no verdict of its own there. Equal to
check(procedure_id, word, ...).satisfied; the scope is what makes that
answer hold in every text the word is joined into.
denckring.witness ¶
witness(
procedure_id: str,
vocabulary: Iterable[str],
/,
*,
lang: Lang = "en",
size: int = 12,
**params: Any,
) -> str
A text the row passes, built from vocabulary: proof the parameters can be met.
Golden cases prove a row satisfiable at its defaults; this proves it at any
parameters a word-scoped row is given (audit C6). It joins, by spaces and in
vocabulary order, the first size entries that are each one word as the
pack splits them and that the row admits. Raises NotWordLocal as admits
does, InvalidParams for a size under 1, and NoCandidateWord when no
entry is admitted, which is the vocabulary's answer, not the row's.
denckring.words ¶
words(
lang: Lang = "en",
*,
max_band: int | None = None,
letters_only: bool = True,
order: WordOrder = "band",
) -> tuple[str, ...]
The language's graded words up to max_band, commonest band first (audit D1).
The words a caller drawing everyday vocabulary wants: the pack's
graded_words() kept to bands up to max_band (SCOWL's size classes in
English, where 10 is the commonest), to words of letters alone when
letters_only, and without the entries a pack excludes as no everyday word
(payed, numbest; ADR 0051). Sorted by band, then alphabetically; with
order="frequency", by how often each occurs in the pack's corpus, commonest
first (ADR 0052; English only so far). No checker reads this view, so it moves
no verdict. Raises MissingCapability when the pack grades no words, or has no
corpus counts for order="frequency", and ValueError for any other order.
denckring.nouns ¶
nouns(
lang: Lang = "en", *, max_band: int | None = None
) -> tuple[str, ...]
The nouns N+7 counts through, in its order, optionally only everyday ones (D5).
With max_band unset, exactly the dictionary n_plus_7 and s_plus_7 read
when no dictionary is passed, which a prompt asking for N+7 must print,
since the answer is in it. With max_band, only the nouns that words(lang,
max_band=max_band, letters_only=False) also lists, still in dictionary order,
so a caller can build a source whose every noun a reader can be shown.
denckring.golden_cases ¶
golden_cases(
lang: Lang | None = None, *, runnable: bool = True
) -> list[GoldenCase]
The shipped golden examples, each a text with the verdict its row must give.
Every case names its row (procedure), its lang, the text and the params
to check it with, and the recorded verdict (satisfied, with min_score or
max_score where the score is pinned too). provenance says where the text
came from: external (a published work), constructed (written for the suite)
or self-generated (the row's own apply). Only external is evidence about
the reading rather than the code. requires lists capabilities the case needs
beyond its row's.
lang keeps one language's cases. runnable, the default, keeps the cases this
install can run: the language's pack declares every capability the row and the
case require. A case it drops would end in MissingCapability, or would give an
answer about the installed data rather than the text, which is why the scoreboard
blocks it rather than scoring it. Pass runnable=False for the whole corpus.
denckring.pack_provenance ¶
pack_provenance(lang: Lang = 'en') -> PackProvenance
Which pack answers for lang on this install, and which data it reads.
The same record every Report.provenance.pack carries, without checking a text
first: the pack's class, and each data distribution it reads mapped to its
installed version (empty for a built-in default). Unlike a report's copy it also
carries digests, content hashes of the pack's surfaces (ADR 0060 D4).
A caller recording a run, or choosing what to draw from, reads it here rather
than getattring the pack's data_distributions, which is not part of the
LanguagePack protocol.
denckring.summaries ¶
summaries(
*,
query: str | None = None,
family: str | None = None,
runnable_only: bool = False,
lang: Lang = "en",
) -> list[Summary]
The implemented procedures, filtered. query subsumes search.
Only implemented rows appear: the other 66 catalogued forms have no checker, so offering them would be offering something that cannot run.
denckring.all_procedures ¶
all_procedures() -> dict[str, BaseProcedure[Any]]
Every registered procedure, by id.
denckring.unmet_requirements ¶
unmet_requirements(
case: GoldenCase, pack: LanguagePack
) -> list[str]
Which of the case's own capability requirements this pack cannot meet.
denckring.PARAMETER_ROLES
module-attribute
¶
PARAMETER_ROLES: Mapping[str, str] = MappingProxyType(
_ROLES
)
Each x-denckring-role value a parameter schema can carry, and what it tells a
caller writing a prompt.
Read-only: a role may be added, never removed or renamed without a Breaking: changelog entry (ADR 0060).